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

Trimble1 = {};

Trimble1.modDir = g_currentModDirectory;

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

function Trimble1:load(savegame)

    self.AnimacaoTrimble1 = SpecializationUtil.callSpecializationsFunction("AnimacaoTrimble1"); 
    
    self.Trimble1 = {};
    
    local trigger = Utils.indexToObject( self.components, getXMLString(self.xmlFile, string.format("vehicle.Trimble1#trigger")) );
    if trigger == nil then
        print("[Erro: Trimble1] 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.Trimble1#IC_Numero", i));
    
    self.Trimble1.TS = TS;
    self.Trimble1.trigger = trigger;
    self.Trimble1.TMP = false;
        
    addTrigger( trigger, "AnimacaoTrimble1", self );
    
end;

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

function Trimble1:readStream(streamId, connection)
end;

function Trimble1:writeStream(streamId, connection)
end;

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

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

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

function Trimble1:onLeave()
end;

function Trimble1:draw()
end;

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