Script v1.7.1.0
- AI
- Animals
- Contracts
- Debug
- Economy
- Effects
- ConveyorBeltEffect
- CutterEffect
- Effect
- EffectManager
- LevelerEffect
- MorphPositionEffect
- ParticleEffect
- PipeEffect
- ShaderPlaneEffect
- SlurrySideToSideEffect
- TipEffect
- WindrowerEffect
- Events
- Farms
- GUI
- Handtools
- I3d
- Materials
- Misc
- Objects
- Placeables
- Player
- Shop
- Sounds
- Specializations
- Triggers
- Utils
- Vehicles
- Weather
Engine v1.7.1.0
- AI
- Animation
- Camera
- Entity
- Fillplanes
- General
- I3D
- Input
- Lighting
- Math
- Network
- Node
- Overlays
- Particle System
- Physics
- Rendering
- Scenegraph
- Shape
- Sound
- Spline
- String
- Terrain Detail
- Text Rendering
- Tire Track
- XML
- general
Foundation Reference
EffectManager
DescriptionManages running effectsParent
AbstractManagerFunctions
- deleteEffects
- getEffectClass
- initDataStructures
- loadEffect
- loadFromNode
- new
- registerEffectClass
- resetEffect
- resetEffects
- setFillType
- setMinMaxWidth
- startEffect
- startEffects
- stopEffect
- stopEffects
- update
deleteEffects
DescriptionDelete list of effectsDefinition
deleteEffects()Code
115 | function EffectManager:deleteEffects(effects) |
116 | if effects ~= nil then |
117 | for _, effect in pairs(effects) do |
118 | self.runningEffects[effect] = nil |
119 | effect:delete() |
120 | end |
121 | end |
122 | end |
getEffectClass
DescriptionDefinitiongetEffectClass()
initDataStructures
DescriptionInitialize data structuresDefinition
initDataStructures()Code
24 | function EffectManager:initDataStructures() |
25 | self.runningEffects = {} |
26 | self.registeredEffectClasses = {} |
27 | end |
loadEffect
DescriptionLoad effect from xmlDefinition
loadEffect()Code
31 | function EffectManager:loadEffect(xmlFile, baseName, rootNode, parent, i3dMapping) |
32 | local effects = {} |
33 | |
34 | local i = 0 |
35 | while true do |
36 | local key = string.format(baseName .. ".effectNode(%d)", i) |
37 | if not hasXMLProperty(xmlFile, key) then |
38 | break |
39 | end |
40 | |
41 | local effectClassName = Utils.getNoNil(getXMLString(xmlFile, key.."#effectClass"), "ShaderPlaneEffect") |
42 | local effectClass = self:getEffectClass(effectClassName) |
43 | if effectClass == nil then |
44 | if parent.customEnvironment ~= nil and parent.customEnvironment ~= "" then |
45 | effectClass = self:getEffectClass(parent.customEnvironment.."."..effectClassName) |
46 | end |
47 | if effectClass == nil then |
48 | -- Fallback to the old method if no registered class is found |
49 | effectClass = ClassUtil.getClassObject(effectClassName) |
50 | end |
51 | end |
52 | if effectClass ~= nil then |
53 | local effect = effectClass:new() |
54 | if effect ~= nil then |
55 | table.insert(effects, effect:load(xmlFile, key, rootNode, parent, i3dMapping)) |
56 | end |
57 | else |
58 | print("Warning: Unkown effect '"..effectClassName.."' in '"..Utils.getNoNil(parent.configFileName, parent.xmlFilename).."'") |
59 | end |
60 | i = i + 1 |
61 | end |
62 | |
63 | return effects |
64 | end |
loadFromNode
DescriptionLoad effect from nodeDefinition
loadFromNode()Code
68 | function EffectManager:loadFromNode(node, parent) |
69 | local effects = {} |
70 | |
71 | for i=0, getNumOfChildren(node)-1 do |
72 | local child = getChildAt(node, i) |
73 | local effectClassName = Utils.getNoNil(getUserAttribute(child, "effectClass"), "ShaderPlaneEffect") |
74 | local effectClass = self:getEffectClass(effectClassName) |
75 | if effectClass == nil then |
76 | if parent.customEnvironment ~= nil and parent.customEnvironment ~= "" then |
77 | effectClass = self:getEffectClass(parent.customEnvironment.."."..effectClassName) |
78 | end |
79 | if effectClass == nil then |
80 | -- Fallback to the old method if no registered class is found |
81 | effectClass = ClassUtil.getClassObject(effectClassName) |
82 | end |
83 | end |
84 | if effectClass ~= nil then |
85 | local effect = effectClass:new() |
86 | if effect ~= nil then |
87 | table.insert(effects, effect:loadFromNode(child, parent)) |
88 | end |
89 | else |
90 | print("Warning: Unkown effect '"..effectClassName.."' in '"..getName(node).."'") |
91 | end |
92 | end |
93 | |
94 | return effects |
95 | end |
new
DescriptionCreating managerDefinition
new()Return Values
table | instance | instance of object |
16 | function EffectManager:new(customMt) |
17 | local self = AbstractManager:new(customMt or EffectManager_mt) |
18 | |
19 | return self |
20 | end |
registerEffectClass
DescriptionGlobally register effect classDefinition
registerEffectClass()Code
99 | function EffectManager:registerEffectClass(className, effectClass) |
100 | if not ClassUtil.getIsValidClassName(className) then |
101 | print("Error: Invalid effect class name: "..className) |
102 | return |
103 | end |
104 | self.registeredEffectClasses[className] = effectClass |
105 | end |
resetEffect
DescriptionReset a single effectDefinition
resetEffect()Code
184 | function EffectManager:resetEffect(effect) |
185 | if effect ~= nil then |
186 | self.runningEffects[effect] = nil |
187 | effect:reset() |
188 | end |
189 | end |
resetEffects
DescriptionReset a list of effectsDefinition
resetEffects()Code
174 | function EffectManager:resetEffects(effects) |
175 | if effects ~= nil then |
176 | for _, effect in pairs(effects) do |
177 | self:resetEffect(effect) |
178 | end |
179 | end |
180 | end |
setFillType
DescriptionSet fillype for a list of effectsDefinition
setFillType()Code
193 | function EffectManager:setFillType(effects, fillType) |
194 | if effects ~= nil then |
195 | for _, effect in pairs(effects) do |
196 | if effect.setFillType ~= nil then |
197 | effect:setFillType(fillType) |
198 | end |
199 | end |
200 | end |
201 | end |
setMinMaxWidth
DescriptionSet minimum and maximum width for a single effectDefinition
setMinMaxWidth()Code
205 | function EffectManager:setMinMaxWidth(effects, minWidth, maxWidth, reset) |
206 | if effects ~= nil then |
207 | for _, effect in pairs(effects) do |
208 | if effect.setMinMaxWidth ~= nil then |
209 | effect:setMinMaxWidth(minWidth, maxWidth, reset) |
210 | end |
211 | end |
212 | end |
213 | end |
startEffect
DescriptionStart a single effectDefinition
startEffect()Code
148 | function EffectManager:startEffect(effect) |
149 | if effect ~= nil and effect:start() then |
150 | self.runningEffects[effect] = effect |
151 | end |
152 | end |
startEffects
DescriptionStart a list of effectsDefinition
startEffects()Code
138 | function EffectManager:startEffects(effects) |
139 | if effects ~= nil then |
140 | for _, effect in pairs(effects) do |
141 | self:startEffect(effect) |
142 | end |
143 | end |
144 | end |
stopEffect
DescriptionStop a single effectDefinition
stopEffect()Code
166 | function EffectManager:stopEffect(effect) |
167 | if effect ~= nil and effect:stop() then |
168 | self.runningEffects[effect] = effect |
169 | end |
170 | end |
stopEffects
DescriptionStop a list of effectsDefinition
stopEffects()Code
156 | function EffectManager:stopEffects(effects) |
157 | if effects ~= nil then |
158 | for _, effect in pairs(effects) do |
159 | self:stopEffect(effect) |
160 | end |
161 | end |
162 | end |
update
DescriptionDefinitionupdate()