--
-- Autor: Hewaaa
-- Date: 31.12.2012
-- publisher: www.ls2013.org
-- Hinweis: das kopieren von Sourcecode ist strafbar nach UrhG §2.1
-- 
ImbissWagen = {};

function ImbissWagen.prerequisitesPresent(specializations)
    return true; 
end;

function ImbissWagen:load(xmlFile)

	self.Trigger1 = ImbissWagen.Trigger1;
	self.TriggerIndex1 = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.Trigger1#index"));
	addTrigger(self.TriggerIndex1, "Trigger1", self);
	self.enteredTrigger1 = false;
	
end;

function ImbissWagen:Trigger1(triggerId, otherId, onEnter, onLeave, onStay, otherShapeId)
	if (g_currentMission.controlledVehicle and otherId == g_currentMission.controlledVehicle.components[1].node) or (g_currentMission.player and otherId == g_currentMission.player.rootNode) then
		if onEnter then
			self.enteredTrigger1 = true;
		end;
	if onLeave then 
		self.enteredTrigger1 = false;
		end;
	end;
end;


function ImbissWagen:readStream(streamId, connection)	
end;

function ImbissWagen:writeStream(streamId, connection)		
end;

function ImbissWagen:delete()
end;

function ImbissWagen:mouseEvent(posX, posY, isDown, isUp, button)
end;

function ImbissWagen:keyEvent(unicode, sym, modifier, isDown)
end;

function ImbissWagen:update(dt)
	
	if self.enteredTrigger1 then
		if InputBinding.isPressed(InputBinding.ImbissWagen_1) then
			self:setAnimationTime(1, self.animationParts[1].currentPosition+(self.animationParts[1].offSet*(dt/10)));
		end;
		if InputBinding.isPressed(InputBinding.ImbissWagen_2) then
			self:setAnimationTime(1, self.animationParts[1].currentPosition-(self.animationParts[1].offSet*(dt/10)));
		end;
				if self.animationParts[1].clipEndTime then
					g_currentMission:addHelpButtonText(string.format(g_i18n:getText("ImbissWagen_2")), InputBinding.ImbissWagen_2);
				else
					g_currentMission:addHelpButtonText(string.format(g_i18n:getText("ImbissWagen_1")), InputBinding.ImbissWagen_1);
				end;
	end;

end;

function ImbissWagen:triggerCallback(triggerId,otherId,onEnter,onLeave,onStay)
    if (triggerId == self.stateChange) then
        if (onEnter and g_currentMission.controlPlayer and g_currentMission.player ~= nil and otherId == g_currentMission.player.rootNode) then
            self.changeAllowed = true;
        elseif (onLeave) then
            self.changeAllowed = false;
        end;
    end;
end;

function ImbissWagen:updateTick(dt)
end;

function ImbissWagen:draw()
end;

function ImbissWagen:onLeave()	
end;