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

require "TimedActions/ISBaseTimedAction"

ISCheckTrapAction = ISBaseTimedAction:derive("ISCheckTrapAction");

function ISCheckTrapAction:isValid()
	return self.trap:getTrapObject() ~= nil and self.trap.animal.type ~= nil;
end

function ISCheckTrapAction:update()
end

function ISCheckTrapAction:start()
end

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

function ISCheckTrapAction:perform()
	if isClient() then
		local sq = self.trap:getSquare()
		local args = { x = sq:getX(), y = sq:getY(), z = sq:getZ() }
		sendClientCommand(self.character, 'trapping', 'removeAnimal', args)
	else
		self.trap:removeAnimal(self.character)
	end
	ISBaseTimedAction.perform(self);
end

function ISCheckTrapAction:new(character, trap, time)
	local o = {}
	setmetatable(o, self)
	self.__index = self
	o.character = character;
	o.trap = trap;
    o.maxTime = time;
	return o;
end
