Copyright (c) 2008-2015 GIANTS Software GmbH, Confidential, All Rights Reserved.
This document is to be published solely by ls-mods.de
1 | -- |
2 | -- ReverseDriving |
3 | -- This is the specialization for vehicles with reverse driving functionality |
4 | -- |
5 | -- @author Manuel Leithner |
6 | -- @date 10/12/13 |
7 | -- |
8 | -- Copyright (C) GIANTS Software GmbH, Confidential, All Rights Reserved. |
9 | |
10 | source("dataS/scripts/vehicles/specializations/ReverseDrivingSetStateEvent.lua"); |
11 | |
12 | ReverseDriving = {}; |
13 | |
14 | function ReverseDriving.prerequisitesPresent(specializations) |
15 | return SpecializationUtil.hasSpecialization(Drivable, specializations); |
16 | end; |
17 | |
18 | function ReverseDriving:load(xmlFile) |
19 | |
20 | self.setIsReverseDriving = SpecializationUtil.callSpecializationsFunction("setIsReverseDriving"); |
21 | |
22 | self:setIsReverseDriving(false, true); |
23 | self.isReverseDriving = false; |
24 | end; |
25 | |
26 | function ReverseDriving:delete() |
27 | end; |
28 | |
29 | function ReverseDriving:mouseEvent(posX, posY, isDown, isUp, button) |
30 | end; |
31 | |
32 | function ReverseDriving:keyEvent(unicode, sym, modifier, isDown) |
33 | end; |
34 | |
35 | function ReverseDriving:update(dt) |
36 | if self:getIsActive() then |
37 | if self:getIsActiveForInput() then |
38 | if InputBinding.hasEvent(InputBinding.CHANGE_DRIVING_DIRECTION) then |
39 | self:setIsReverseDriving(not self.isReverseDriving); |
40 | end; |
41 | end; |
42 | end; |
43 | end; |
44 | |
45 | function ReverseDriving:draw() |
46 | if self.isClient then |
47 | if self:getIsActiveForInput() then |
48 | g_currentMission:addHelpButtonText(g_i18n:getText("CHANGE_DRIVING_DIRECTION"), InputBinding.CHANGE_DRIVING_DIRECTION); |
49 | end; |
50 | end; |
51 | end; |
52 | |
53 | function ReverseDriving:setIsReverseDriving(isReverseDriving, noEventSend) |
54 | if isReverseDriving ~= self.isReverseDriving then |
55 | ReverseDrivingSetStateEvent.sendEvent(self, isReverseDriving, noEventSend) |
56 | self.isReverseDriving = isReverseDriving; |
57 | local dir = 1; |
58 | if not isReverseDriving then |
59 | dir = -1; |
60 | end; |
61 | |
62 | self.reverserDirection = -dir; |
63 | |
64 | if self.playAnimation ~= nil then |
65 | self:playAnimation("reverseDirection", dir, self:getAnimationTime("reverseDirection"), true); |
66 | end; |
67 | end; |
68 | end;
|
Copyright (c) 2008-2015 GIANTS Software GmbH, Confidential, All Rights Reserved.
This document is to be published solely by ls-mods.de