Arma Reforger Explorer
1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Toggle main menu visibility
Loading...
Searching...
No Matches
SCR_CampaignMobileAssemblyStandaloneComponent.c
Go to the documentation of this file.
1
class
SCR_CampaignMobileAssemblyStandaloneComponentClass
:
ScriptComponentClass
2
{
3
}
4
5
class
SCR_CampaignMobileAssemblyStandaloneComponent :
ScriptComponent
6
{
7
static
ref
ScriptInvokerVoid
s_OnSpawnPointOwnerChanged
=
new
ScriptInvokerVoid
();
8
static
ref
ScriptInvokerVoid
s_OnUpdateRespawnCooldown =
new
ScriptInvokerVoid
();
9
10
static
const
int
RESPAWN_COOLDOWN = 60000;
11
12
protected
RplComponent
m_RplComponent
;
13
14
protected
MapItem
m_MapItem
;
15
16
protected
IEntity
m_Vehicle
;
17
18
protected
SCR_CampaignFaction
m_ParentFaction
;
19
protected
SCR_CampaignFaction
m_Faction
;
20
21
protected
bool
m_bIsInRadioRange
;
22
protected
bool
m_bCooldownDone
=
true
;
23
24
protected
const
EResourceType
RESOURCE_TYPE
=
EResourceType
.SUPPLIES;
25
protected
const
EResourceGeneratorID
RESOURCE_GENERATOR_ID
=
EResourceGeneratorID
.DEFAULT;
26
27
[
RplProp
(onRplName:
"OnFactionChanged"
)]
28
protected
int
m_iFaction
=
SCR_CampaignMilitaryBaseComponent
.
INVALID_FACTION_INDEX
;
29
30
[
RplProp
(onRplName:
"OnParentFactionIDSet"
)]
31
protected
int
m_iParentFaction
=
SCR_CampaignMilitaryBaseComponent
.
INVALID_FACTION_INDEX
;
32
33
[
RplProp
()]
34
protected
WorldTimestamp
m_fRespawnAvailableSince
;
35
36
[
RplProp
()]
37
protected
int
m_iRadioRange
;
38
39
//------------------------------------------------------------------------------------------------
40
override
void
OnPostInit
(
IEntity
owner)
41
{
42
if
(!
GetGame
().InPlayMode())
43
return
;
44
45
SCR_GameModeCampaign
campaign =
SCR_GameModeCampaign
.GetInstance();
46
47
if
(!campaign)
48
return
;
49
50
super.OnPostInit(owner);
51
52
m_RplComponent
= RplComponent.Cast(owner.
FindComponent
(RplComponent));
53
54
GetGame
().GetCallqueue().CallLater(
UpdateRadioCoverage
, 1000,
true
);
55
GetGame
().GetCallqueue().CallLater(
UpdateRespawnCooldown
, 250,
true
, null);
56
57
if
(
IsProxy
())
58
{
59
campaign.GetInstance().GetOnFactionAssignedLocalPlayer().Insert(
OnParentFactionIDSet
);
60
}
61
else
62
{
63
// Only update respawn cooldown if a load state has not been applied
64
ChimeraWorld
world =
GetGame
().GetWorld();
65
if
(world.GetWorldTime() > 10000)
66
{
67
m_fRespawnAvailableSince
= world.GetServerTimestamp().PlusMilliseconds(RESPAWN_COOLDOWN);
68
m_bCooldownDone
=
false
;
69
}
70
else
71
{
72
m_fRespawnAvailableSince
= world.GetServerTimestamp();
73
m_bCooldownDone
=
true
;
74
}
75
Replication
.BumpMe();
76
}
77
}
78
79
//------------------------------------------------------------------------------------------------
80
override
void
OnDelete
(
IEntity
owner)
81
{
82
super.OnDelete(owner);
83
84
GetGame
().GetCallqueue().Remove(
UpdateRadioCoverage
);
85
GetGame
().GetCallqueue().Remove(
UpdateRespawnCooldown
);
86
87
SCR_GameModeCampaign
campaign =
SCR_GameModeCampaign
.GetInstance();
88
89
if
(!campaign)
90
return
;
91
92
campaign.GetInstance().GetOnFactionAssignedLocalPlayer().Remove(
OnParentFactionIDSet
);
93
}
94
95
//------------------------------------------------------------------------------------------------
96
protected
bool
IsProxy
()
97
{
98
return
(
m_RplComponent
&&
m_RplComponent
.IsProxy());
99
}
100
101
//------------------------------------------------------------------------------------------------
103
void
SetVehicle
(
IEntity
vehicle)
104
{
105
m_Vehicle
= vehicle;
106
}
107
108
//------------------------------------------------------------------------------------------------
110
IEntity
GetVehicle
()
111
{
112
return
m_Vehicle
;
113
}
114
115
//------------------------------------------------------------------------------------------------
117
void
SetParentFactionID
(
int
factionID)
118
{
119
m_iParentFaction
= factionID;
120
Replication
.BumpMe();
121
OnParentFactionIDSet
();
122
}
123
124
//------------------------------------------------------------------------------------------------
125
void
OnParentFactionIDSet
()
126
{
127
SCR_CampaignFactionManager fManager = SCR_CampaignFactionManager.Cast(
GetGame
().GetFactionManager());
128
m_ParentFaction
=
SCR_CampaignFaction
.Cast(fManager.GetFactionByIndex(
m_iParentFaction
));
129
130
if
(!
m_ParentFaction
)
131
return
;
132
133
SCR_CoverageRadioComponent radioComponent = SCR_CoverageRadioComponent.Cast(
GetOwner
().
FindComponent
(BaseRadioComponent));
134
135
if
(radioComponent)
136
radioComponent.SetEncryptionKey(
m_ParentFaction
.GetFactionRadioEncryptionKey());
137
138
m_ParentFaction
.SetMobileAssembly(
this
);
139
140
// Delay so map item can initialize
141
if
(!
System
.IsConsoleApp())
142
GetGame
().GetCallqueue().CallLater(
UpdateMapItem
,
SCR_GameModeCampaign
.MINIMUM_DELAY);
143
144
SCR_RadioCoverageSystem
.
UpdateAll
();
145
UpdateRadioCoverage
();
146
}
147
148
//------------------------------------------------------------------------------------------------
150
int
GetParentFactionID
()
151
{
152
return
m_iParentFaction
;
153
}
154
155
//------------------------------------------------------------------------------------------------
157
SCR_CampaignFaction
GetParentFaction
()
158
{
159
return
m_ParentFaction
;
160
}
161
162
//------------------------------------------------------------------------------------------------
164
SCR_CampaignFaction
GetFaction
()
165
{
166
return
m_Faction
;
167
}
168
169
//------------------------------------------------------------------------------------------------
171
void
SetRadioRange
(
int
range)
172
{
173
m_iRadioRange
= range;
174
}
175
176
//------------------------------------------------------------------------------------------------
178
int
GetRadioRange
()
179
{
180
return
m_iRadioRange
;
181
}
182
183
//------------------------------------------------------------------------------------------------
184
protected
void
UpdateMapItem
()
185
{
186
SCR_GameModeCampaign
campaign =
SCR_GameModeCampaign
.GetInstance();
187
188
if
(!campaign)
189
return
;
190
191
SCR_MapDescriptorComponent mapDescriptor = SCR_MapDescriptorComponent.Cast(
GetOwner
().
FindComponent
(SCR_MapDescriptorComponent));
192
193
if
(mapDescriptor)
194
m_MapItem
= mapDescriptor.Item();
195
196
Faction
playerFaction =
SCR_FactionManager
.SGetLocalPlayerFaction();
197
198
if
(!
m_MapItem
||
m_ParentFaction
!= playerFaction)
199
return
;
200
201
m_MapItem
.SetVisible(
true
);
202
203
switch
(
m_ParentFaction
.GetFactionKey())
204
{
205
case
campaign.GetFactionKeyByEnum(
SCR_ECampaignFaction
.BLUFOR):
206
{
207
m_MapItem
.SetFactionIndex(EFactionMapID.WEST);
208
break
;
209
}
210
211
case
campaign.GetFactionKeyByEnum(
SCR_ECampaignFaction
.OPFOR):
212
{
213
m_MapItem
.SetFactionIndex(EFactionMapID.EAST);
214
break
;
215
}
216
217
default
:
218
{
219
m_MapItem
.SetFactionIndex(EFactionMapID.UNKNOWN);
220
}
221
}
222
}
223
224
//------------------------------------------------------------------------------------------------
225
void
OnFactionChanged
()
226
{
227
SCR_CampaignFactionManager fManager = SCR_CampaignFactionManager.Cast(
GetGame
().GetFactionManager());
228
229
if
(!fManager)
230
return
;
231
232
FactionKey
fKey;
233
Faction
f = fManager.GetFactionByIndex(
m_iFaction
);
234
235
if
(f)
236
{
237
fKey = f.GetFactionKey();
238
m_Faction
=
SCR_CampaignFaction
.Cast(f);
239
}
240
241
SCR_SpawnPoint
.Cast(
GetOwner
()).
SetFaction
(f);
242
s_OnSpawnPointOwnerChanged
.Invoke();
243
}
244
245
//------------------------------------------------------------------------------------------------
247
bool
IsInRadioRange
()
248
{
249
return
m_bIsInRadioRange
;
250
}
251
252
//------------------------------------------------------------------------------------------------
254
MapItem
GetMapItem
()
255
{
256
return
m_MapItem
;
257
}
258
259
//------------------------------------------------------------------------------------------------
261
void
UpdateRadioCoverage
()
262
{
263
if
(!
m_ParentFaction
)
264
return
;
265
266
bool
inRangeNow =
SCR_GameModeCampaign
.GetInstance().GetBaseManager().IsEntityInFactionRadioSignal(
GetOwner
(),
m_ParentFaction
);
267
m_bIsInRadioRange
= inRangeNow;
268
269
DamageManagerComponent
damageComponent =
DamageManagerComponent
.Cast(
GetOwner
().
FindComponent
(
DamageManagerComponent
));
270
271
if
(damageComponent && damageComponent.GetState() ==
EDamageState
.DESTROYED)
272
{
273
if
(
m_MapItem
)
274
m_MapItem
.SetVisible(
false
);
275
276
if
(!
IsProxy
())
277
{
278
SCR_CoverageRadioComponent radioComponent = SCR_CoverageRadioComponent.Cast(
GetOwner
().
FindComponent
(BaseRadioComponent));
279
280
if
(radioComponent)
281
radioComponent.SetPower(
false
);
282
}
283
}
284
285
if
(
IsProxy
())
286
return
;
287
288
if
(!
m_bIsInRadioRange
&&
m_iFaction
!=
SCR_CampaignMilitaryBaseComponent
.
INVALID_FACTION_INDEX
)
289
{
290
m_iFaction
=
SCR_CampaignMilitaryBaseComponent
.
INVALID_FACTION_INDEX
;
291
Replication
.BumpMe();
292
OnFactionChanged
();
293
}
294
295
if
(
m_bIsInRadioRange
&&
m_iFaction
==
SCR_CampaignMilitaryBaseComponent
.
INVALID_FACTION_INDEX
&&
m_bCooldownDone
)
296
{
297
m_iFaction
=
m_iParentFaction
;
298
Replication
.BumpMe();
299
OnFactionChanged
();
300
}
301
}
302
303
//------------------------------------------------------------------------------------------------
306
void
UpdateRespawnCooldown
(
Widget
w = null)
307
{
308
if
(!
m_ParentFaction
)
309
return
;
310
311
SCR_CampaignMilitaryBaseComponent
hq =
m_ParentFaction
.GetMainBase();
312
313
TextWidget
respawn;
314
ImageWidget
respawnImg;
315
316
if
(!hq)
317
return
;
318
319
ResourceName
imageset = hq.
GetBuildingIconImageset
();
320
321
if
(w && imageset)
322
{
323
respawn =
TextWidget
.Cast(w.FindAnyWidget(
"Respawn"
));
324
respawnImg =
ImageWidget
.Cast(w.FindAnyWidget(
"RespawnIMG"
));
325
respawnImg.LoadImageFromSet(0, imageset,
"RespawnBig"
);
326
}
327
328
ChimeraWorld
world =
GetOwner
().
GetWorld
();
329
if
(
m_fRespawnAvailableSince
.Greater(world.GetServerTimestamp()))
330
{
331
if
(
m_bCooldownDone
)
332
m_bCooldownDone
=
false
;
333
334
if
(
RplSession
.Mode() !=
RplMode
.Dedicated)
335
{
336
if
(!w)
337
s_OnUpdateRespawnCooldown.Invoke();
338
else
339
{
340
respawn.SetVisible(
true
);
341
respawnImg.SetVisible(
true
);
342
343
float
respawnCooldown =
Math
.Ceil(
m_fRespawnAvailableSince
.DiffMilliseconds(world.GetServerTimestamp()) * 0.001);
344
int
d, h, m, s;
345
string
sStr;
346
SCR_DateTimeHelper
.GetDayHourMinuteSecondFromSeconds(respawnCooldown, d, h, m, s);
347
sStr = s.ToString();
348
349
if
(s < 10)
350
sStr =
"0"
+ sStr;
351
352
respawn.SetTextFormat(
"#AR-Campaign_MobileAssemblyCooldown"
, m, sStr);
353
}
354
}
355
}
356
else
357
{
358
GetGame
().GetCallqueue().Remove(
UpdateRespawnCooldown
);
359
360
if
(w)
361
{
362
if
(
RplSession
.Mode() !=
RplMode
.Dedicated)
363
{
364
respawn.SetVisible(
false
);
365
respawnImg.SetVisible(
false
);
366
}
367
}
368
else
369
{
370
if
(!
m_bCooldownDone
)
371
{
372
m_bCooldownDone
=
true
;
373
s_OnUpdateRespawnCooldown.Invoke();
374
375
if
(!
IsProxy
() &&
IsInRadioRange
())
376
{
377
m_iFaction
=
m_iParentFaction
;
378
Replication
.BumpMe();
379
OnFactionChanged
();
380
}
381
}
382
}
383
}
384
}
385
386
//------------------------------------------------------------------------------------------------
389
void
UpdateSuppliesAmount
(
Widget
w = null)
390
{
391
if
(!w || !
m_ParentFaction
)
392
return
;
393
394
SCR_CampaignMilitaryBaseComponent
hq =
m_ParentFaction
.GetMainBase();
395
if
(!hq)
396
return
;
397
398
ResourceName
imageset = hq.
GetBuildingIconImageset
();
399
if
(!imageset)
400
return
;
401
402
TextWidget
resource =
TextWidget
.Cast(w.FindAnyWidget(
"Supplies"
));
403
ImageWidget
resourceImg =
ImageWidget
.Cast(w.FindAnyWidget(
"SuppliesIMG"
));
404
405
if
(!resource || !resourceImg)
406
return
;
407
408
SCR_ResourceComponent resourceComp = SCR_ResourceComponent.FindResourceComponent(
GetOwner
());
409
if
(!resourceComp)
410
return
;
411
412
SCR_ResourceConsumer resourceConsumer;
413
if
(!resourceComp.GetConsumer(
RESOURCE_GENERATOR_ID
,
RESOURCE_TYPE
, resourceConsumer))
414
return
;
415
416
float
resourceAmount = resourceConsumer.GetAggregatedResourceValue();
417
float
maxResourceAmount = resourceConsumer.GetAggregatedMaxResourceValue();
418
419
resource.SetTextFormat(
"#AR-Campaign_BaseSuppliesAmount"
, resourceAmount, maxResourceAmount);
420
resourceImg.LoadImageFromSet(0, imageset,
"SuppliesBig"
);
421
422
resource.SetVisible(
true
);
423
resourceImg.SetVisible(
true
);
424
}
425
}
GetGame
ArmaReforgerScripted GetGame()
Definition
game.c:1398
RplMode
RplMode
Mode of replication.
Definition
RplMode.c:9
m_Faction
Faction m_Faction
Definition
SCR_AITargetInfo.c:18
m_Vehicle
enum EAICompartmentType m_Vehicle
RplProp
SCR_CacheNoteComponentClass ScriptComponentClass RplProp()] protected ref array< string > m_aLines
m_RplComponent
RplComponent m_RplComponent
Definition
SCR_CampaignBuildingManagerComponent.c:64
SCR_ECampaignFaction
SCR_ECampaignFaction
Definition
SCR_CampaignFactionManager.c:134
UpdateRespawnCooldown
void UpdateRespawnCooldown()
Definition
SCR_CampaignMilitaryBaseComponent.c:2229
m_bIsInRadioRange
bool m_bIsInRadioRange
Definition
SCR_CampaignMobileAssemblyComponent.c:21
IsInRadioRange
bool IsInRadioRange()
Definition
SCR_CampaignMobileAssemblyComponent.c:275
UpdateRadioCoverage
void UpdateRadioCoverage()
Definition
SCR_CampaignMobileAssemblyComponent.c:282
GetRadioRange
int GetRadioRange()
Definition
SCR_CampaignMobileAssemblyComponent.c:91
SetRadioRange
void SetRadioRange(int range)
Definition
SCR_CampaignMobileAssemblyStandaloneComponent.c:171
UpdateMapItem
void UpdateMapItem()
Definition
SCR_CampaignMobileAssemblyStandaloneComponent.c:184
UpdateSuppliesAmount
void UpdateSuppliesAmount(Widget w=null)
Definition
SCR_CampaignMobileAssemblyStandaloneComponent.c:389
GetParentFaction
SCR_CampaignFaction GetParentFaction()
Definition
SCR_CampaignMobileAssemblyStandaloneComponent.c:157
m_iFaction
int m_iFaction
Definition
SCR_CampaignMobileAssemblyStandaloneComponent.c:28
UpdateRespawnCooldown
void UpdateRespawnCooldown(Widget w=null)
Definition
SCR_CampaignMobileAssemblyStandaloneComponent.c:306
OnFactionChanged
void OnFactionChanged()
Definition
SCR_CampaignMobileAssemblyStandaloneComponent.c:225
SetParentFactionID
void SetParentFactionID(int factionID)
Definition
SCR_CampaignMobileAssemblyStandaloneComponent.c:117
SetVehicle
void SetVehicle(IEntity vehicle)
Definition
SCR_CampaignMobileAssemblyStandaloneComponent.c:103
RESOURCE_GENERATOR_ID
const EResourceGeneratorID RESOURCE_GENERATOR_ID
Definition
SCR_CampaignMobileAssemblyStandaloneComponent.c:25
GetFaction
SCR_CampaignFaction GetFaction()
Definition
SCR_CampaignMobileAssemblyStandaloneComponent.c:164
m_bCooldownDone
bool m_bCooldownDone
Definition
SCR_CampaignMobileAssemblyStandaloneComponent.c:22
m_iRadioRange
int m_iRadioRange
Definition
SCR_CampaignMobileAssemblyStandaloneComponent.c:37
m_fRespawnAvailableSince
WorldTimestamp m_fRespawnAvailableSince
Definition
SCR_CampaignMobileAssemblyStandaloneComponent.c:34
GetVehicle
IEntity GetVehicle()
Definition
SCR_CampaignMobileAssemblyStandaloneComponent.c:110
m_ParentFaction
SCR_CampaignFaction m_ParentFaction
Definition
SCR_CampaignMobileAssemblyStandaloneComponent.c:18
OnParentFactionIDSet
void OnParentFactionIDSet()
Definition
SCR_CampaignMobileAssemblyStandaloneComponent.c:125
GetParentFactionID
int GetParentFactionID()
Definition
SCR_CampaignMobileAssemblyStandaloneComponent.c:150
GetMapItem
MapItem GetMapItem()
Definition
SCR_CampaignMobileAssemblyStandaloneComponent.c:254
s_OnSpawnPointOwnerChanged
SCR_CampaignMobileAssemblyStandaloneComponentClass s_OnSpawnPointOwnerChanged
m_iParentFaction
int m_iParentFaction
Definition
SCR_CampaignMobileAssemblyStandaloneComponent.c:31
m_MapItem
MapItem m_MapItem
Definition
SCR_CampaignMobileAssemblyStandaloneComponent.c:14
SCR_FactionManager
void SCR_FactionManager(IEntitySource src, IEntity parent)
Definition
SCR_FactionManager.c:498
SCR_GameModeCampaign
void SCR_GameModeCampaign(IEntitySource src, IEntity parent)
Definition
SCR_GameModeCampaign.c:1812
EResourceType
EResourceType
Definition
SCR_ResourceContainer.c:2
EResourceGeneratorID
EResourceGeneratorID
Definition
SCR_ResourceGenerator.c:2
ScriptInvokerVoid
ScriptInvokerBase< ScriptInvokerVoidMethod > ScriptInvokerVoid
Definition
SCR_ScriptInvokerHelper.c:9
RESOURCE_TYPE
SCR_SuppliesTransferWaypoint RESOURCE_TYPE
ChimeraWorld
Definition
ChimeraWorld.c:13
DamageManagerComponent
Definition
DamageManagerComponent.c:13
Faction
Definition
Faction.c:13
FactionKey
Definition
FactionKey.c:3
GenericComponent::FindComponent
proto external GenericComponent FindComponent(typename typeName)
IEntity
Definition
IEntity.c:13
IEntity::FindComponent
proto external Managed FindComponent(typename typeName)
IEntity::GetWorld
proto external BaseWorld GetWorld()
ImageWidget
Definition
ImageWidget.c:13
MapItem
Definition
MapItem.c:13
Math
Definition
Math.c:13
Replication
Main replication API.
Definition
Replication.c:14
ResourceName
Definition
ResourceName.c:13
RplSession
Definition
RplSession.c:8
SCR_CampaignFaction
Definition
SCR_CampaignFaction.c:2
SCR_CampaignMilitaryBaseComponent
Definition
SCR_CampaignMilitaryBaseComponent.c:38
SCR_CampaignMilitaryBaseComponent::GetBuildingIconImageset
ResourceName GetBuildingIconImageset()
Definition
SCR_CampaignMilitaryBaseComponent.c:1731
SCR_CampaignMilitaryBaseComponent::INVALID_FACTION_INDEX
static const int INVALID_FACTION_INDEX
Definition
SCR_CampaignMilitaryBaseComponent.c:90
SCR_CampaignMobileAssemblyStandaloneComponentClass
Definition
SCR_CampaignMobileAssemblyStandaloneComponent.c:2
SCR_DateTimeHelper
Definition
SCR_DateTimeHelper.c:2
SCR_RadioCoverageSystem
Definition
SCR_RadioCoverageSystem.c:6
SCR_RadioCoverageSystem::UpdateAll
static bool UpdateAll(bool forceRecalculation=false)
Definition
SCR_RadioCoverageSystem.c:36
SCR_SpawnPoint
Spawn point entity defines positions on which players can possibly spawn.
Definition
SCR_SpawnPoint.c:28
SCR_SpawnPoint::SetFaction
void SetFaction(Faction faction)
Definition
SCR_SpawnPoint.c:460
ScriptComponentClass
Definition
ScriptComponentClass.c:8
ScriptComponent
Definition
ScriptComponent.c:24
ScriptComponent::GetOwner
proto external GenericEntity GetOwner()
Get owner entity.
System
Definition
System.c:13
TextWidget
Definition
TextWidget.c:16
Widget
Definition
Widget.c:13
WorldTimestamp
Definition
WorldTimestamp.c:26
IsProxy
bool IsProxy()
Definition
SCR_CampaignBuildingCompositionComponent.c:509
EDamageState
EDamageState
Definition
EDamageState.c:13
OnPostInit
@ OnPostInit
Definition
SndComponentCallbacks.c:15
OnDelete
@ OnDelete
Definition
SndComponentCallbacks.c:16
scripts
Game
Campaign
SCR_CampaignMobileAssemblyStandaloneComponent.c
Generated by
1.17.0