-- -- Halmteiler -- Specialization for Halmteiler -- -- @author Karol Gruszczyk (MySQly) -- @version v1.0 -- @date 11/01/17 -- @history: v1.0 - Initial version -- Halmteiler = {} function Halmteiler.prerequisitesPresent(specializations) return SpecializationUtil.hasSpecialization(Cutter, specializations) and SpecializationUtil.hasSpecialization(Attachable, specializations) end function Halmteiler:load(xmlFile) self.ptoAttachedPart = Utils.indexToObject(self.components, getXMLString(self.xmlFile, "vehicle.pto#attachedNode")) self.ptoNotAttachedPart = Utils.indexToObject(self.components, getXMLString(self.xmlFile, "vehicle.pto#notAttachedNode")) self.rapeAttachedPart = Utils.indexToObject(self.components, getXMLString(self.xmlFile, "vehicle.rapeTable#attachedNode")) self.rapeNotAttachedPart = Utils.indexToObject(self.components, getXMLString(self.xmlFile, "vehicle.rapeTable#notAttachedNode")) self.leftWheatSpikeCallback = SpecializationUtil.callSpecializationsFunction("leftWheatSpikeCallback") self.rightWheatSpikeCallback = SpecializationUtil.callSpecializationsFunction("rightWheatSpikeCallback") local leftWheatSpikeTrigger = Utils.indexToObject(self.components, getXMLString(self.xmlFile, string.format("vehicle.wheatSpikes#leftTriggerNode"))) local rightWheatSpikeTrigger = Utils.indexToObject(self.components, getXMLString(self.xmlFile, string.format("vehicle.wheatSpikes#rightTriggerNode"))) self.leftWheatSpikeAnim = getXMLString(self.xmlFile, "vehicle.wheatSpikes#leftAnimName") self.rightWheatSpikeAnim = getXMLString(self.xmlFile, "vehicle.wheatSpikes#rightAnimName") self.inLeftWheatSpikeTrigger = false self.inRightWheatSpikeTrigger = false self.leftWheatSpikeDir = 1 self.rightWheatSpikeDir = 1 addTrigger(leftWheatSpikeTrigger, "leftWheatSpikeCallback", self); addTrigger(rightWheatSpikeTrigger, "rightWheatSpikeCallback", self); end function Halmteiler:delete() removeTrigger(self.leftWheatSpikeTrigger) removeTrigger(self.rightWheatSpikeTrigger) end function Halmteiler:mouseEvent(posX, posY, isDown, isUp, button) end function Halmteiler:keyEvent(unicode, sym, modifier, isDown) end function Halmteiler:update(dt) local ptoVisible = false if self.attacherVehicle ~= nil and self.attacherVehicle.attacherJoints ~= nil then for k, joint in pairs(self.attacherVehicle.attacherJoints) do if joint.ptoOutput ~= nil then ptoVisible = getVisibility(joint.ptoOutput.rootNode) end end end local rapeAttached = false if self.attachedImplements ~= nil and table.getn(self.attachedImplements) > 0 then rapeAttached = true end if self.inLeftWheatSpikeTrigger or self.inRightWheatSpikeTrigger then g_currentMission:addHelpButtonText(g_i18n:getText("SET_WHEATSPIKE"), InputBinding.SET_WHEATSPIKE); setTextColor(1.0, 1.0, 1.0, 1.0); setTextAlignment(RenderText.ALIGN_LEFT); renderText(0.5, 0.06, 0.02, g_i18n:getText("SET_WHEATSPIKE")) if InputBinding.hasEvent(InputBinding.SET_WHEATSPIKE) then if self.inLeftWheatSpikeTrigger then self:playAnimation(self.leftWheatSpikeAnim, self.leftWheatSpikeDir, Utils.clamp(self:getAnimationTime(self.leftWheatSpikeAnim), 0, 1), true); self.leftWheatSpikeDir = -1 * self.leftWheatSpikeDir else self:playAnimation(self.rightWheatSpikeAnim, self.rightWheatSpikeDir, Utils.clamp(self:getAnimationTime(self.rightWheatSpikeAnim), 0, 1), true); self.rightWheatSpikeDir = -1 * self.rightWheatSpikeDir end end end if self.attacherVehicle ~= nil then local vehicle = self.attacherVehicle local turnedOn = vehicle.turnOnVehicle.isTurnedOn if turnedOn and not rapeAttached and (self.leftWheatSpikeDir == 1 or self.rightWheatSpikeDir == 1) then if vehicle.isAIThreshing ~= nil then if vehicle.isAIThreshing then vehicle:stopAIThreshing(); end end vehicle:setIsTurnedOn(false) g_currentMission:showBlinkingWarning(g_i18n:getText("WHEATSPIKE_WARNING"), 2000) end end end function Halmteiler:updateTick(dt) end function Halmteiler:onTurnedOn() end function Halmteiler:onTurnedOff() end function Halmteiler:draw() end function Halmteiler:leftWheatSpikeCallback(triggerId, otherId, onEnter, onLeave, onStay) if onEnter and g_currentMission.controlPlayer and g_currentMission.player ~= nil and otherId == g_currentMission.player.rootNode then self.inLeftWheatSpikeTrigger = true elseif onLeave and g_currentMission.player ~= nil and otherId == g_currentMission.player.rootNode then self.inLeftWheatSpikeTrigger = false end end function Halmteiler:rightWheatSpikeCallback(triggerId, otherId, onEnter, onLeave, onStay) if onEnter and g_currentMission.controlPlayer and g_currentMission.player ~= nil and otherId == g_currentMission.player.rootNode then self.inRightWheatSpikeTrigger = true elseif onLeave and g_currentMission.player ~= nil and otherId == g_currentMission.player.rootNode then self.inRightWheatSpikeTrigger = false end end