forked from FAForever/fa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaeonunits.lua
334 lines (293 loc) · 12.9 KB
/
aeonunits.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
--****************************************************************************
--**
--** File : /lua/aeonunits.lua
--** Author(s): John Comes, Gordon Duclos
--**
--** Summary :
--**
--** Copyright © 2005 Gas Powered Games, Inc. All rights reserved.
--****************************************************************************
----------------------------------------------------------------------------
-- AEON DEFAULT UNITS
----------------------------------------------------------------------------
local DefaultUnitsFile = import("/lua/defaultunits.lua")
local FactoryUnit = DefaultUnitsFile.FactoryUnit
local ConstructionUnit = DefaultUnitsFile.ConstructionUnit
local EnergyCreationUnit = DefaultUnitsFile.EnergyCreationUnit
local LandFactoryUnit = DefaultUnitsFile.LandFactoryUnit
local SeaFactoryUnit = DefaultUnitsFile.SeaFactoryUnit
local ShieldStructureUnit = DefaultUnitsFile.ShieldStructureUnit
local RadarJammerUnit = DefaultUnitsFile.RadarJammerUnit
local EffectTemplate = import("/lua/effecttemplates.lua")
local EffectUtil = import("/lua/effectutilities.lua")
local CreateAeonFactoryBuildingEffects = EffectUtil.CreateAeonFactoryBuildingEffects
---------------------------------------------------------------
-- FACTORIES
---------------------------------------------------------------
---@class AFactoryUnit : FactoryUnit
AFactoryUnit = ClassUnit(FactoryUnit) {
---@param self AFactoryUnit
---@param unitBeingBuilt Unit
StartBuildFx = function(self, unitBeingBuilt)
local thread = self:ForkThread(CreateAeonFactoryBuildingEffects, unitBeingBuilt, self.BuildEffectBones, 'Attachpoint', self.BuildEffectsBag)
unitBeingBuilt.Trash:Add(thread)
end,
---@param self AFactoryUnit
OnPaused = function(self)
-- When factory is paused take some action
if self:IsUnitState('Building') and self.UnitBeingBuilt then
self:StopUnitAmbientSound('ConstructLoop')
FactoryUnit.StopBuildingEffects(self, self.UnitBeingBuilt)
end
FactoryUnit.OnPaused(self)
end,
---@param self AFactoryUnit
OnUnpaused = function(self)
FactoryUnit.OnUnpaused(self)
if self:IsUnitState('Building') and self.UnitBeingBuilt then
FactoryUnit.StopBuildingEffects(self, self.UnitBeingBuilt)
self:StartBuildFx(self:GetFocusUnit())
end
end,
}
---------------------------------------------------------------
-- AIR STRUCTURES
---------------------------------------------------------------
---@class AAirFactoryUnit : AirFactoryUnit
AAirFactoryUnit = ClassUnit(DefaultUnitsFile.AirFactoryUnit) {
StartBuildFx = AFactoryUnit.StartBuildFx,
OnPaused = AFactoryUnit.OnPaused,
OnUnpaused = AFactoryUnit.OnUnpaused,
}
---------------------------------------------------------------
-- AIR UNITS
---------------------------------------------------------------
---@class AAirUnit : AirUnit
AAirUnit = ClassUnit(DefaultUnitsFile.AirUnit) {}
---------------------------------------------------------------
-- AIR STAGING STRUCTURES
---------------------------------------------------------------
---@class AAirStagingPlatformUnit : AirStagingPlatformUnit
AAirStagingPlatformUnit = ClassUnit(DefaultUnitsFile.AirStagingPlatformUnit) {}
---------------------------------------------------------------
-- WALL STRUCTURES
---------------------------------------------------------------
---@class AConcreteStructureUnit : ConcreteStructureUnit
AConcreteStructureUnit = ClassUnit(DefaultUnitsFile.ConcreteStructureUnit) {}
---------------------------------------------------------------
-- Construction Units
---------------------------------------------------------------
---@class AConstructionUnit : ConstructionUnit
AConstructionUnit = ClassUnit(ConstructionUnit) {
---@param self AConstructionUnit
---@param unitBeingBuilt Unit
---@param order string
CreateBuildEffects = function(self, unitBeingBuilt, order)
EffectUtil.CreateAeonConstructionUnitBuildingEffects(self, unitBeingBuilt, self.BuildEffectsBag)
end,
}
---------------------------------------------------------------
-- ENERGY CREATION UNITS
---------------------------------------------------------------
---@class AEnergyCreationUnit : EnergyCreationUnit
AEnergyCreationUnit = ClassUnit(EnergyCreationUnit) {
---@param self AEnergyCreationUnit
---@param builder Unit
---@param layer Layer
OnStopBeingBuilt = function(self,builder,layer)
EnergyCreationUnit.OnStopBeingBuilt(self, builder, layer)
if self.AmbientEffects then
for k, v in EffectTemplate[self.AmbientEffects] do
CreateAttachedEmitter(self, 0, self.Army, v)
end
end
end,
}
---------------------------------------------------------------
-- ENERGY STORAGE STRUCTURES
---------------------------------------------------------------
---@class AEnergyStorageUnit : EnergyStorageUnit
AEnergyStorageUnit = ClassUnit(DefaultUnitsFile.EnergyStorageUnit) {}
---------------------------------------------------------------
-- HOVERING LAND UNITS
---------------------------------------------------------------
---@class AHoverLandUnit : HoverLandUnit
AHoverLandUnit = ClassUnit(DefaultUnitsFile.HoverLandUnit) {}
---------------------------------------------------------------
-- LAND FACTORY STRUCTURES
---------------------------------------------------------------
---@class ALandFactoryUnit : LandFactoryUnit
ALandFactoryUnit = ClassUnit(LandFactoryUnit) {
StartBuildFx = AFactoryUnit.StartBuildFx,
OnPaused = AFactoryUnit.OnPaused,
OnUnpaused = AFactoryUnit.OnUnpaused,
}
---------------------------------------------------------------
-- LAND UNITS
---------------------------------------------------------------
---@class ALandUnit : LandUnit
ALandUnit = ClassUnit(DefaultUnitsFile.LandUnit) {}
---------------------------------------------------------------
-- MASS COLLECTION UNITS
---------------------------------------------------------------
---@class AMassCollectionUnit : MassCollectionUnit
AMassCollectionUnit = ClassUnit(DefaultUnitsFile.MassCollectionUnit) {}
---------------------------------------------------------------
-- MASS FABRICATION STRUCTURES
---------------------------------------------------------------
---@class AMassFabricationUnit : MassFabricationUnit
AMassFabricationUnit = ClassUnit(DefaultUnitsFile.MassFabricationUnit) {}
---------------------------------------------------------------
-- MASS STORAGE UNITS
---------------------------------------------------------------
---@class AMassStorageUnit : MassStorageUnit
AMassStorageUnit = ClassUnit(DefaultUnitsFile.MassStorageUnit) {}
---------------------------------------------------------------
-- RADAR STRUCTURES
---------------------------------------------------------------
---@class ARadarUnit : RadarUnit
ARadarUnit = ClassUnit(DefaultUnitsFile.RadarUnit) {}
---------------------------------------------------------------
-- RADAR STRUCTURES
---------------------------------------------------------------
---@class ASonarUnit : SonarUnit
ASonarUnit = ClassUnit(DefaultUnitsFile.SonarUnit) {}
---------------------------------------------------------------
-- SEA FACTORY STRUCTURES
---------------------------------------------------------------
---@class ASeaFactoryUnit : SeaFactoryUnit
ASeaFactoryUnit = ClassUnit(SeaFactoryUnit) {
---@param self ASeaFactoryUnit
---@param unitBeingBuilt Unit
StartBuildFx = function(self, unitBeingBuilt)
local thread = self:ForkThread(CreateAeonFactoryBuildingEffects, unitBeingBuilt, self.BuildEffectBones, 'Attachpoint01', self.BuildEffectsBag)
unitBeingBuilt.Trash:Add(thread)
end,
OnPaused = AFactoryUnit.OnPaused,
OnUnpaused = AFactoryUnit.OnUnpaused,
}
---------------------------------------------------------------
-- SEA UNITS
---------------------------------------------------------------
---@class ASeaUnit : SeaUnit
ASeaUnit = ClassUnit(DefaultUnitsFile.SeaUnit) {}
---------------------------------------------------------------
-- SHIELD LAND UNITS
---------------------------------------------------------------
---@class AShieldHoverLandUnit : ShieldHoverLandUnit
AShieldHoverLandUnit = ClassUnit(DefaultUnitsFile.ShieldHoverLandUnit) {}
---------------------------------------------------------------
-- SHIELD LAND UNITS
---------------------------------------------------------------
---@class AShieldLandUnit : ShieldLandUnit
AShieldLandUnit = ClassUnit(DefaultUnitsFile.ShieldLandUnit) {}
---------------------------------------------------------------
-- SHIELD STRUCTURES
---------------------------------------------------------------
---@class AShieldStructureUnit : ShieldStructureUnit
---@field Rotator? moho.RotateManipulator
AShieldStructureUnit = ClassUnit(ShieldStructureUnit) {
RotateSpeed = 60,
---@param self AShieldStructureUnit
OnShieldEnabled = function(self)
ShieldStructureUnit.OnShieldEnabled(self)
if not self.Rotator then
self.Rotator = CreateRotator(self, 'Pod', 'z', nil, 0, 50, 0)
self.Trash:Add(self.Rotator)
end
self.Rotator:SetSpinDown(false)
self.Rotator:SetTargetSpeed(self.RotateSpeed)
end,
---@param self AShieldStructureUnit
OnShieldDisabled = function(self)
ShieldStructureUnit.OnShieldDisabled(self)
if self.Rotator then
self.Rotator:SetTargetSpeed(0)
end
end,
}
---------------------------------------------------------------
-- STRUCTURES
---------------------------------------------------------------
---@class AStructureUnit : StructureUnit
AStructureUnit = ClassUnit(DefaultUnitsFile.StructureUnit) {}
---------------------------------------------------------------
-- SUBMARINE UNITS
---------------------------------------------------------------
---@class ASubUnit : SubUnit
ASubUnit = ClassUnit(DefaultUnitsFile.SubUnit) {}
---------------------------------------------------------------
-- TRANSPORT BEACON UNITS
---------------------------------------------------------------
---@class ATransportBeaconUnit : TransportBeaconUnit
ATransportBeaconUnit = ClassUnit(DefaultUnitsFile.TransportBeaconUnit) {}
---------------------------------------------------------------
-- WALKING LAND UNITS
---------------------------------------------------------------
---@class AWalkingLandUnit : WalkingLandUnit
AWalkingLandUnit = ClassUnit(DefaultUnitsFile.WalkingLandUnit) {}
---------------------------------------------------------------
-- WALL STRUCTURES
---------------------------------------------------------------
---@class AWallStructureUnit : WallStructureUnit
AWallStructureUnit = ClassUnit(DefaultUnitsFile.WallStructureUnit) {}
---------------------------------------------------------------
-- CIVILIAN STRUCTURES
---------------------------------------------------------------
---@class ACivilianStructureUnit : AStructureUnit
ACivilianStructureUnit = ClassUnit(AStructureUnit) {}
---------------------------------------------------------------
-- QUANTUM GATE UNITS
---------------------------------------------------------------
---@class AQuantumGateUnit : QuantumGateUnit
AQuantumGateUnit = ClassUnit(DefaultUnitsFile.QuantumGateUnit) {}
---------------------------------------------------------------
-- RADAR JAMMER UNITS
---------------------------------------------------------------
---@class ARadarJammerUnit : RadarJammerUnit
---@field Rotator? moho.RotateManipulator
---@field OpenAnim? moho.AnimationManipulator
ARadarJammerUnit = ClassUnit(RadarJammerUnit) {
RotateSpeed = 60,
---@param self ARadarJammerUnit
---@param builder Unit
---@param layer Layer
OnStopBeingBuilt = function(self, builder, layer)
RadarJammerUnit.OnStopBeingBuilt(self, builder, layer)
local bp = self:GetBlueprint()
local bpAnim = bp.Display.AnimationOpen
if not bpAnim then return end
if not self.OpenAnim then
self.OpenAnim = CreateAnimator(self)
self.OpenAnim:PlayAnim(bpAnim)
self.Trash:Add(self.OpenAnim)
end
if not self.Rotator then
self.Rotator = CreateRotator(self, 'B02', 'z', nil, 0, 50, 0)
self.Trash:Add(self.Rotator)
end
end,
---@param self ARadarJammerUnit
OnIntelEnabled = function(self, intel)
RadarJammerUnit.OnIntelEnabled(self, intel)
if self.OpenAnim then
self.OpenAnim:SetRate(1)
end
if not self.Rotator then
self.Rotator = CreateRotator(self, 'B02', 'z', nil, 0, 50, 0)
self.Trash:Add(self.Rotator)
end
self.Rotator:SetSpinDown(false)
self.Rotator:SetTargetSpeed(self.RotateSpeed)
end,
---@param self ARadarJammerUnit
OnIntelDisabled = function(self, intel)
RadarJammerUnit.OnIntelDisabled(self, intel)
if self.OpenAnim then
self.OpenAnim:SetRate(-1)
end
if self.Rotator then
self.Rotator:SetTargetSpeed(0)
end
end,
}