Script v1_7_1_0
- AI
- Animals
- Collections
- Contracts
- Debug
- Economy
- Elements
- EnvironmentalScore
- Errors
- Events
- GUI
- Handtools
- Hud
- I3d
- Input
- Jobs
- Maps
- Materials
- Misc
- Objects
- Parameters
- Placeables
- Placement
- Player
- Shop
- Sounds
- Specialization
- Specializations
- StateMachine
- Statistics
- Tasks
- Triggers
- Utils
- Vehicles
Engine v1_7_1_0
- AI
- Animation
- Camera
- Entity
- Fillplanes
- general
- General
- I3D
- Input
- Lighting
- Math
- Network
- Node
- NoteNode
- Overlays
- Particle System
- Physics
- Rendering
- Scenegraph
- Shape
- Sound
- Spline
- String
- Terrain Detail
- Text Rendering
- Tire Track
- VoiceChat
- XML
Foundation Reference
CylinderedFoldable
DescriptionSpecialization to repeat the loading of cylindered states after the folding state was loaded, in case the animation overlaps with the moving toolsFunctions
- initSpecialization
- onLoad
- onPostLoad
- onReadStream
- onWriteStream
- prerequisitesPresent
- registerEventListeners
initSpecialization
DescriptionDefinitioninitSpecialization()Code
23 | function CylinderedFoldable.initSpecialization() |
24 | local schema = Vehicle.xmlSchema |
25 | schema:setXMLSpecializationType("CylinderedFoldable") |
26 | |
27 | schema:register(XMLValueType.BOOL, "vehicle.cylindered#loadMovingToolStatesAfterFolding", "Load moving tool states after folding state was loaded", false) |
28 | schema:register(XMLValueType.FLOAT, "vehicle.cylindered#loadMovingToolStatesFoldTime", "Fold time in which moving tool states should be loaded") |
29 | |
30 | schema:setXMLSpecializationType() |
31 | end |
onLoad
DescriptionCalled on loadingDefinition
onLoad(table savegame)Arguments
table | savegame | savegame |
45 | function CylinderedFoldable:onLoad(savegame) |
46 | local spec = self.spec_cylinderedFoldable |
47 | |
48 | spec.loadMovingToolStatesAfterFolding = self.xmlFile:getValue("vehicle.cylindered#loadMovingToolStatesAfterFolding", false) |
49 | spec.loadMovingToolStatesFoldTime = self.xmlFile:getValue("vehicle.cylindered#loadMovingToolStatesFoldTime") |
50 | end |
onPostLoad
DescriptionDefinitiononPostLoad()Code
54 | function CylinderedFoldable:onPostLoad(savegame) |
55 | local spec = self.spec_cylinderedFoldable |
56 | if spec.loadMovingToolStatesAfterFolding then |
57 | local targetFoldTime = spec.loadMovingToolStatesFoldTime |
58 | if targetFoldTime == nil or self:getFoldAnimTime() == targetFoldTime then |
59 | Cylindered.onPostLoad(self, savegame) |
60 | end |
61 | end |
62 | end |
onReadStream
DescriptionDefinitiononReadStream()Code
66 | function CylinderedFoldable:onReadStream(streamId, connection) |
67 | -- update folding animation so it's finished and won't destroy the cylindered states in the first frame |
68 | AnimatedVehicle.updateAnimations(self, 9999999) |
69 | |
70 | -- rerun the sync of cylindered since it was overwritten by foldable |
71 | if streamReadBool(streamId) then |
72 | Cylindered.onReadStream(self, streamId, connection) |
73 | end |
74 | |
75 | -- update dependent animations initial |
76 | if connection:getIsServer() then |
77 | for i=1, #self.spec_cylindered.movingTools do |
78 | local tool = self.spec_cylindered.movingTools[i] |
79 | if tool.dirtyFlag ~= nil then |
80 | self:updateDependentAnimations(tool, 9999) |
81 | end |
82 | end |
83 | end |
84 | end |
onWriteStream
DescriptionDefinitiononWriteStream()Code
88 | function CylinderedFoldable:onWriteStream(streamId, connection) |
89 | local spec = self.spec_cylinderedFoldable |
90 | |
91 | if streamWriteBool(streamId, spec.loadMovingToolStatesFoldTime == nil or self:getFoldAnimTime() == spec.loadMovingToolStatesFoldTime) then |
92 | Cylindered.onWriteStream(self, streamId, connection) |
93 | end |
94 | end |
prerequisitesPresent
DescriptionChecks if all prerequisite specializations are loadedDefinition
prerequisitesPresent(table specializations)Arguments
table | specializations | specializations |
boolean | hasPrerequisite | true if all prerequisite specializations are loaded |
17 | function CylinderedFoldable.prerequisitesPresent(specializations) |
18 | return SpecializationUtil.hasSpecialization(Cylindered, specializations) and SpecializationUtil.hasSpecialization(Foldable, specializations) |
19 | end |
registerEventListeners
DescriptionDefinitionregisterEventListeners()Code
35 | function CylinderedFoldable.registerEventListeners(vehicleType) |
36 | SpecializationUtil.registerEventListener(vehicleType, "onLoad", CylinderedFoldable) |
37 | SpecializationUtil.registerEventListener(vehicleType, "onPostLoad", CylinderedFoldable) |
38 | SpecializationUtil.registerEventListener(vehicleType, "onReadStream", CylinderedFoldable) |
39 | SpecializationUtil.registerEventListener(vehicleType, "onWriteStream", CylinderedFoldable) |
40 | end |