Copyright (c) 2008-2015 GIANTS Software GmbH, Confidential, All Rights Reserved.
This document is to be published solely by ls-mods.de
1 | -- |
2 | -- Honk |
3 | -- Specialization for honking |
4 | -- |
5 | -- @author Manuel Leithner |
6 | -- @date 19/12/2013 |
7 | -- |
8 | -- Copyright (C) GIANTS Software GmbH, Confidential, All Rights Reserved. |
9 | |
10 | Honk = {}; |
11 | source("dataS/scripts/vehicles/specializations/HonkEvent.lua"); |
12 | |
13 | function Honk.prerequisitesPresent(specializations) |
14 | return SpecializationUtil.hasSpecialization(Drivable, specializations); |
15 | end; |
16 | |
17 | function Honk:load(xmlFile) |
18 | |
19 | self.playHonk = SpecializationUtil.callSpecializationsFunction("playHonk"); |
20 | |
21 | if self.isClient then |
22 | self.sampleHonk = Utils.loadSample(xmlFile, {}, "vehicle.honkSound", nil, self.baseDirectory, self.components[1].node); |
23 | end; |
24 | end; |
25 | |
26 | function Honk:delete() |
27 | if self.isClient then |
28 | Utils.deleteSample(self.sampleHonk); |
29 | end; |
30 | end; |
31 | |
32 | function Honk:readStream(streamId, connection) |
33 | end; |
34 | |
35 | function Honk:writeStream(streamId, connection) |
36 | end; |
37 | |
38 | function Honk:mouseEvent(posX, posY, isDown, isUp, button) |
39 | end; |
40 | |
41 | function Honk:keyEvent(unicode, sym, modifier, isDown) |
42 | end; |
43 | |
44 | function Honk:update(dt) |
45 | if self.isEntered and self.isClient and self:getIsActiveForInput(false) then |
46 | if self.sampleHonk ~= nil then |
47 | -- only send event if honking key is pressed or released |
48 | if InputBinding.isPressed(InputBinding.HONK) then |
49 | if not self.sampleHonk.isPlaying then |
50 | self:playHonk(true); |
51 | end; |
52 | else |
53 | if self.sampleHonk.isPlaying then |
54 | self:playHonk(false); |
55 | end; |
56 | end; |
57 | end; |
58 | end; |
59 | end; |
60 | |
61 | function Honk:updateTick(dt) |
62 | end; |
63 | |
64 | function Honk:draw() |
65 | if GS_IS_CONSOLE_VERSION then |
66 | if self.isClient and self:getIsActiveForInput(true) then |
67 | g_currentMission:addHelpButtonText(g_i18n:getText("Honk"), InputBinding.HONK); |
68 | end; |
69 | end; |
70 | end; |
71 | |
72 | function Honk:onDeactivateSounds() |
73 | if self.isClient then |
74 | Utils.stopSample(self.sampleHonk, true); |
75 | Utils.stop3DSample(self.sampleHonk); |
76 | end; |
77 | end; |
78 | |
79 | function Honk:playHonk(isPlaying, noEventSend) |
80 | if self.sampleHonk ~= nil then |
81 | HonkEvent.sendEvent(self, isPlaying, noEventSend); |
82 | |
83 | if isPlaying then |
84 | if self:getIsActive() then |
85 | if self:getIsActiveForSound() then |
86 | Utils.playSample(self.sampleHonk, 0, 0, nil); |
87 | elseif self.isControlled then |
88 | -- enable 3d sound to vehicle on another player's game |
89 | Utils.play3DSample(self.sampleHonk); |
90 | end; |
91 | end; |
92 | else |
93 | Honk.onDeactivateSounds(self); |
94 | end; |
95 | end; |
96 | end;
|
Copyright (c) 2008-2015 GIANTS Software GmbH, Confidential, All Rights Reserved.
This document is to be published solely by ls-mods.de