Sprache Deutsch Language English

Script Dokumentation LS 2015 - Mountable (Patch 1.3)

Script Dokumentation Übersicht

scripts/vehicles/specializations/Mountable.lua

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
10Mountable = {};
11
12function Mountable.prerequisitesPresent(specializations)
13 return true;
14end;
15
16function 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);
27end;
28
29function 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
37end;
38
39function Mountable:mouseEvent(posX, posY, isDown, isUp, button)
40end;
41
42function Mountable:keyEvent(unicode, sym, modifier, isDown)
43end;
44
45function Mountable:update(dt)
46end;
47
48function Mountable:updateTick(dt)
49end;
50
51function Mountable:draw()
52end;
53
54function Mountable:onEnter(isControlling)
55 self:unmountDynamic();
56end;
57
58function Mountable:onAttach(attacherVehicle, jointDescIndex)
59 self:unmountDynamic();
60end;
61
62function 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);
67end
68
69function Mountable:unmountDynamic()
70 DynamicMountUtil.unmountDynamic(self);
71end
72
73function Mountable:getSupportsMountDynamic()
74 return self.dynamicMountForceLimitScale ~= nil;
75end;
76
77function 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;
83end
Copyright (c) 2008-2015 GIANTS Software GmbH, Confidential, All Rights Reserved.
This document is to be published solely by ls-mods.de
Script Dokumentation Übersicht