--
-- Trimble2
--
-- @Hugo94Fr
-- @23/09/2015
-- @Converted Fs17
-- @26/12/2016

Trimble2 = {};

Trimble2.modDir = g_currentModDirectory;

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

function Trimble2:load(savegame)

    self.AnimacaoTrimble2 = SpecializationUtil.callSpecializationsFunction("AnimacaoTrimble2"); 
    
    self.Trimble2 = {};
    
    local trigger = Utils.indexToObject( self.components, getXMLString(self.xmlFile, string.format("vehicle.Trimble2#trigger")) );
    if trigger == nil then
        print("[Erro: Trimble2] index ok, mas o trigger nas esta localizado. Volte a ver a linha "..tostring(i+1).." no seu xml");
    end;
    
    local TS = getXMLInt(self.xmlFile, string.format("vehicle.Trimble2#IC_Numero", i));
    
    self.Trimble2.TS = TS;
    self.Trimble2.trigger = trigger;
    self.Trimble2.TMP = false;
        
    addTrigger( trigger, "AnimacaoTrimble2", self );
    
end;

function Trimble2:delete()
    if self.Trimble2.trigger ~= nil then
        removeTrigger(self.Trimble2.trigger);
    end;
end;

function Trimble2:readStream(streamId, connection)
end;

function Trimble2:writeStream(streamId, connection)
end;

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

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

function Trimble2:update(dt)
    
    if self.Trimble2.TMP then
        g_currentMission:addHelpButtonText( g_i18n:getText("Trimble2"), InputBinding.Trimble2 );    
        setTextColor(1.0, 1.0, 1.0, 1.0);
        setTextAlignment(RenderText.ALIGN_CENTER);                 
        renderText( 0.5, 0.06, 0.05, g_i18n:getText("Trimble2") );
        if InputBinding.hasEvent(InputBinding.Trimble2)then
            local obj = self.interactiveObjects[self.Trimble2.TS];
            if obj ~= nil then
                self:doActionOnObject(self.Trimble2.TS);
            end;
        end
    end;
end;

function Trimble2:onLeave()
end;

function Trimble2:draw()
end;

function Trimble2:AnimacaoTrimble2(triggerId, otherId, onEnter, onLeave, onStay)
    
    if onEnter and g_currentMission.controlPlayer and g_currentMission.player ~= nil and otherId == g_currentMission.player.rootNode then
        self.Trimble2.TMP = true;
    elseif onLeave and g_currentMission.player ~= nil and otherId == g_currentMission.player.rootNode then
        self.Trimble2.TMP = false;
    end;
    
end;