Copyright (c) 2008-2015 GIANTS Software GmbH, Confidential, All Rights Reserved.
This document is to be published solely by ls-mods.de
1 | -- |
2 | -- Mountable |
3 | -- This is the specialization for all vehicles that may be mounted |
4 | -- |
5 | -- @author Manuel Leithner |
6 | -- @date 11/09/12 |
7 | -- |
8 | -- Copyright (C) GIANTS Software GmbH, Confidential, All Rights Reserved. |
9 | |
10 | Mountable = {}; |
11 | |
12 | function Mountable.prerequisitesPresent(specializations) |
13 | return true; |
14 | end; |
15 | |
16 | function Mountable:load(xmlFile) |
17 | |
18 | self.getSupportsMountDynamic = Mountable.getSupportsMountDynamic; |
19 | self.mountDynamic = Mountable.mountDynamic; |
20 | self.unmountDynamic = Mountable.unmountDynamic; |
21 | self.onDynamicMountJointBreak = Mountable.onDynamicMountJointBreak; |
22 | |
23 | self.dynamicMountJointIndex = nil; |
24 | self.dynamicMountObject = nil; |
25 | self.dynamicMountObjectActorId = nil; |
26 | self.dynamicMountForceLimitScale = Utils.getNoNil(getXMLFloat(xmlFile, "vehicle.dynamicMount#forceLimitScale"), 1); |
27 | end; |
28 | |
29 | function Mountable:delete() |
30 | if self.dynamicMountJointIndex ~= nil then |
31 | removeJointBreakReport(self.dynamicMountJointIndex); |
32 | removeJoint(self.dynamicMountJointIndex); |
33 | end |
34 | if self.dynamicMountObject ~= nil then |
35 | self.dynamicMountObject:removeDynamicMountedObject(self, true); |
36 | end |
37 | end; |
38 | |
39 | function Mountable:mouseEvent(posX, posY, isDown, isUp, button) |
40 | end; |
41 | |
42 | function Mountable:keyEvent(unicode, sym, modifier, isDown) |
43 | end; |
44 | |
45 | function Mountable:update(dt) |
46 | end; |
47 | |
48 | function Mountable:updateTick(dt) |
49 | end; |
50 | |
51 | function Mountable:draw() |
52 | end; |
53 | |
54 | function Mountable:onEnter(isControlling) |
55 | self:unmountDynamic(); |
56 | end; |
57 | |
58 | function Mountable:onAttach(attacherVehicle, jointDescIndex) |
59 | self:unmountDynamic(); |
60 | end; |
61 | |
62 | function Mountable:mountDynamic(object, objectActorId, jointNode, mountType, forceAcceleration) |
63 | if not self:getSupportsMountDynamic() or self.mountObject ~= nil or self.attacherVehicle ~= nil or self.isControlled then |
64 | return false; |
65 | end |
66 | return DynamicMountUtil.mountDynamic(self, self.rootNode, object, objectActorId, jointNode, mountType, forceAcceleration*self.dynamicMountForceLimitScale); |
67 | end |
68 | |
69 | function Mountable:unmountDynamic() |
70 | DynamicMountUtil.unmountDynamic(self); |
71 | end |
72 | |
73 | function Mountable:getSupportsMountDynamic() |
74 | return self.dynamicMountForceLimitScale ~= nil; |
75 | end; |
76 | |
77 | function Mountable:onDynamicMountJointBreak(jointIndex, breakingImpulse) |
78 | if jointIndex == self.dynamicMountJointIndex then |
79 | self:unmountDynamic(); |
80 | end |
81 | -- Do not delete the joint internally, we already deleted it with unmountDynamic |
82 | return false; |
83 | end
|
Copyright (c) 2008-2015 GIANTS Software GmbH, Confidential, All Rights Reserved.
This document is to be published solely by ls-mods.de