-- GreenStarCombine.lua
--
-- @author  MRA-Modding(Alex2009)
-- @website www.alex2009.de, www.mra-modding.de
-- @date    15.06.2011
--
--Modifikation erst nach rücksprache mit dem Autor(Alex2009) erlaubt.
--Modification allowed only after consultation with the author(Alex2009).

GreenStarCombine = {};

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

function GreenStarCombine:load(xmlFile)
    self.GSLlights = nil;
	self.GSRlights = nil;
	self.GreenStarLightsLeft = {};
    local i = 1;
	while true do
	    local zindex = i - 1;
	    self.GreenStarLightsLeft[i] = Utils.indexToObject(self.components, getXMLString(xmlFile,"vehicle.GreenStar#indexRedLeft") .. "|" .. zindex);
	    if i == 11 then
		    break;
		end;
		if self.GreenStarLightsLeft[i] == nil then
		    print("GreenStar Error: Canīt load Lights!");
		    break;
		end;
	    i=i + 1;
	end;
    self.GreenStarLightsMiddle = {};
    local i = 1;
	while true do
	    local zindex = i - 1;
	    self.GreenStarLightsMiddle[i] = Utils.indexToObject(self.components, getXMLString(xmlFile,"vehicle.GreenStar#indexGreenMiddle") .. "|" .. zindex);
	    if i == 3 then
		    break;
		end;
		if self.GreenStarLightsMiddle[i] == nil then
		    print("GreenStar Error: Canīt load Lights!");
		    break;
		end;
	    i=i + 1;
	end;
	self.GreenStarLightsRight = {};
    local i = 1;
	while true do
	    local zindex = i - 1;
	    self.GreenStarLightsRight[i] = Utils.indexToObject(self.components, getXMLString(xmlFile,"vehicle.GreenStar#indexRedRight") .. "|" .. zindex);
	    if i == 11 then
		    break;
		end;
		if self.GreenStarLightsRight[i] == nil then
		    print("GreenStar Error: Canīt load Lights!");
			break;
		end;
	    i=i + 1;
	end;
end;

function GreenStarCombine:delete()
end;

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

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

function GreenStarCombine:update(dt)
	if self:getIsActive() or (self.passengerName == g_settingsNickname) or (self.HoldAtVehiclePlayerName == g_settingsNickname) then
		if self.GSLlights ~= nil and self.GSRlights ~= nil then
		    setVisibility(self.GreenStarLightsMiddle[1],true);
			setVisibility(self.GreenStarLightsMiddle[2],true);
			setVisibility(self.GreenStarLightsMiddle[3],true);	
        else
		    setVisibility(self.GreenStarLightsMiddle[1],false);
			setVisibility(self.GreenStarLightsMiddle[2],false);
			setVisibility(self.GreenStarLightsMiddle[3],false);					
	    end;
		if self.GSLlights ~= nil then
		    for i=1,11 do
                if self.GSLlights >= i then
                    setVisibility(self.GreenStarLightsLeft[i],true);
                else
                    setVisibility(self.GreenStarLightsLeft[i],false);
                end;
            end;
		else
		    for i=1,11 do
                setVisibility(self.GreenStarLightsLeft[i],false);
            end;		
		end;
		if self.GSRlights ~= nil then
		    for i=1,11 do
                if self.GSRlights >= i then
                    setVisibility(self.GreenStarLightsRight[i],true);
                else
                    setVisibility(self.GreenStarLightsRight[i],false);
                end;
            end;
		else
		    for i=1,11 do
                setVisibility(self.GreenStarLightsRight[i],false);
            end;
		end;
	end;
end;

function GreenStarCombine:draw()
end;