--***********************************************************
--**                    ROBERT JOHNSON                     **
--***********************************************************

require "TimedActions/ISBaseTimedAction"

ISRemoveCampfireAction = ISBaseTimedAction:derive("ISRemoveCampfireAction");

function ISRemoveCampfireAction:isValid()
	camping.updateClientCampfire(self.campfire)
	return self.campfire:getObject() ~= nil
end

function ISRemoveCampfireAction:update()
end

function ISRemoveCampfireAction:start()
end

function ISRemoveCampfireAction:stop()
    ISBaseTimedAction.stop(self);
end

function ISRemoveCampfireAction:perform()
	if isClient() then
		local cf = self.campfire
		local args = { x = cf.x, y = cf.y, z = cf.z }
		sendClientCommand(self.character, 'camping', 'removeCampfire', args)
	else
		camping.removeCampfire(self.campfire);
		self.character:getInventory():AddItem("camping.CampfireKit")
	end
	-- needed to remove from queue / start next.
	ISBaseTimedAction.perform(self);
end

function ISRemoveCampfireAction:new (character, campfire, time)
	local o = {}
	setmetatable(o, self)
	self.__index = self
	o.character = character;
	o.stopOnWalk = true;
	o.stopOnRun = true;
	o.maxTime = time;
	-- custom fields
	o.campfire = campfire
	return o
end
