--***********************************************************
--**                    THE INDIE STONE                    **
--***********************************************************

require "TimedActions/ISBaseTimedAction"

ISLockDoors = ISBaseTimedAction:derive("ISOpenCloseVehicleWindow")

function ISLockDoors:isValid()
	return true;
end

function ISLockDoors:update()
	
end

function ISLockDoors:start()
end

function ISLockDoors:stop()
	ISBaseTimedAction.stop(self)
end

function ISLockDoors:perform()
	for seat=1,self.vehicle:getMaxPassengers() do
		local part = self.vehicle:getPassengerDoor(seat-1)
		if part then
			if isClient() then
				local args = { vehicle = self.vehicle:getId(), part = part:getId(), locked = self.open }
				sendClientCommand(self.character, 'vehicle', 'setDoorLocked', args)
			else
				part:getDoor():setLocked(self.open);
			end
		end
	end
	-- needed to remove from queue / start next.
	ISBaseTimedAction.perform(self)
end

function ISLockDoors:new(character, vehicle, open, time)
	local o = {}
	setmetatable(o, self)
	self.__index = self
	o.character = character
	o.vehicle = vehicle
	o.open = open
	o.maxTime = time
	return o
end

