-- by modelleicher
-- www.schwabenmodding.bplaced.net
-- lässt die Plane beim Streuen langsam nach hinten wandern..
-- Achtung, die Transform des planeMoveIndex muss in Grundstellung immer trans 0 0 0 haben sonst funktionierts nicht..

unloadingPlane = {};

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

function unloadingPlane:load(xmlFile)

    self.planeMoveIndex = Utils.indexToObject(self.components, getXMLString(xmlFile, "vehicle.unloadingPlane#planeMoveIndex"));
	self.planeMoveEnd = Utils.getNoNil(getXMLFloat(xmlFile, "vehicle.unloadingPlane#planeMoveEnd"));
	
	self.checkFillLevel = self.fillLevel
end;

function unloadingPlane:delete()
end;
function unloadingPlane:readStream(streamId, connection)
end;
function unloadingPlane:writeStream(streamId, connection)
end;
function unloadingPlane:mouseEvent(posX, posY, isDown, isUp, button)
end;
function unloadingPlane:keyEvent(unicode, sym, modifier, isDown)
end;

function unloadingPlane:update(dt)	
end;

function unloadingPlane:updateTick(dt)
	if self:getIsActive() then
		if self.isTurnedOn == true then
		    self.checkFillLevel = self.fillLevel
			local rw = self.fillLevel / self.capacity
			local prozentwert = rw * 100
			
			local rfin = math.abs(self.planeMoveEnd);
	        local rw2 = rfin * prozentwert
			local rw3 = rw2 / 100
			translationWert =  rfin - rw3
			setTranslation(self.planeMoveIndex, 0, 0, -translationWert);
		end;
	end;
	if self.isTurnedOn == false then
			if self.fillLevel > self.checkFillLevel or self.fillLevel == 0 then
				setTranslation(self.planeMoveIndex, 0, 0, 0);			
			end;
    end;	
end;
function unloadingPlane:draw()
end;


