Arma Reforger Explorer
1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SpectateTargetComponent.c
Go to the documentation of this file.
1
[
ComponentEditorProps
(
category
:
"GameScripted/Spectating"
, description:
"Entity that this is attached to becomes selectable by the Spectator Camera."
)]
2
class
SCR_SpectateTargetComponentClass
: ScriptComponentClass
3
{
4
}
5
6
class
SCR_SpectateTargetComponent
:
ScriptComponent
7
{
8
// List of all spectate targets
9
private
static
ref array <SCR_SpectateTargetComponent>
s_aSpectateTargets
=
null
;
10
11
private
DamageManagerComponent
m_DamageManagerComponent
=
null
;
12
private
IEntity
m_Entity
=
null
;
13
14
//------------------------------------------------------------------------------------------------
16
IEntity
GetEntity
()
17
{
18
return
m_Entity
;
19
}
20
21
//------------------------------------------------------------------------------------------------
23
bool
IsAlive
()
24
{
25
if
(!
m_DamageManagerComponent
)
26
return
true
;
27
28
return
m_DamageManagerComponent
.GetState() !=
EDamageState
.DESTROYED;
29
}
30
31
//------------------------------------------------------------------------------------------------
34
static
SCR_SpectateTargetComponent
GetSpectateTarget(
int
index
)
35
{
36
if
(!
s_aSpectateTargets
)
37
return
null
;
38
39
int
count =
s_aSpectateTargets
.Count();
40
if
(
index
>= 0 &&
index
< count)
41
{
42
return
s_aSpectateTargets
[
index
];
43
}
44
else
45
return
null
;
46
}
47
48
//------------------------------------------------------------------------------------------------
50
static
int
GetSpectateTargetCount()
51
{
52
if
(!
s_aSpectateTargets
)
53
return
0;
54
55
return
s_aSpectateTargets
.Count();
56
}
57
58
//------------------------------------------------------------------------------------------------
59
private
static
void
RegisterTarget(
SCR_SpectateTargetComponent
spectateTarget)
60
{
61
if
(!
s_aSpectateTargets
)
62
s_aSpectateTargets
=
new
array<SCR_SpectateTargetComponent>();
63
64
if
(
s_aSpectateTargets
)
65
{
66
s_aSpectateTargets
.Insert(spectateTarget);
67
}
68
}
69
70
//------------------------------------------------------------------------------------------------
71
private
static
void
UnregisterTarget(
SCR_SpectateTargetComponent
spectateTarget)
72
{
73
if
(!
s_aSpectateTargets
)
74
return
;
75
76
int
index
=
s_aSpectateTargets
.Find(spectateTarget);
77
if
(
index
!= -1)
78
{
79
s_aSpectateTargets
.RemoveItem(spectateTarget);
80
81
int
cnt =
s_aSpectateTargets
.Count();
82
if
(cnt - 1 >= 0)
83
s_aSpectateTargets
.Resize(cnt-1);
84
}
85
86
int
count =
s_aSpectateTargets
.Count();
87
if
(count <= 0)
88
{
89
s_aSpectateTargets
.Clear();
90
s_aSpectateTargets
=
null
;
91
}
92
}
93
94
//------------------------------------------------------------------------------------------------
95
// constructor
99
void
SCR_SpectateTargetComponent
(IEntityComponentSource src, IEntity ent, IEntity parent)
100
{
101
if
(!
GetGame
().GetWorldEntity())
102
return
;
103
104
RegisterTarget(
this
);
105
m_Entity
= ent;
106
GenericEntity
genericEntity =
GenericEntity
.Cast(ent);
107
m_DamageManagerComponent
=
DamageManagerComponent
.Cast(genericEntity.FindComponent(
DamageManagerComponent
));
108
}
109
110
//------------------------------------------------------------------------------------------------
111
// destructor
112
void
~SCR_SpectateTargetComponent
()
113
{
114
UnregisterTarget(
this
);
115
}
116
}
ComponentEditorProps
SCR_FragmentEntityClass ComponentEditorProps
m_Entity
private IEntity m_Entity
Definition:
SpectateTargetComponent.c:12
ScriptComponent
SCR_SiteSlotEntityClass ScriptComponent
GetGame
ArmaReforgerScripted GetGame()
Definition:
game.c:1424
IsAlive
bool IsAlive()
Definition:
SpectateTargetComponent.c:23
EDamageState
EDamageState
Definition:
EDamageState.c:12
GenericEntity
SCR_GenericBoxEntityClass GenericEntity
SCR_SpectateTargetComponentClass
Definition:
SpectateTargetComponent.c:2
m_DamageManagerComponent
private DamageManagerComponent m_DamageManagerComponent
Definition:
SpectateTargetComponent.c:11
SCR_SpectateTargetComponent
void SCR_SpectateTargetComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
Definition:
SpectateTargetComponent.c:99
~SCR_SpectateTargetComponent
void ~SCR_SpectateTargetComponent()
Definition:
SpectateTargetComponent.c:112
index
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
Definition:
SCR_DestructionSynchronizationComponent.c:17
GetEntity
IEntity GetEntity()
Definition:
SpectateTargetComponent.c:16
s_aSpectateTargets
SCR_SpectateTargetComponentClass s_aSpectateTargets
DamageManagerComponent
Definition:
DamageManagerComponent.c:12
category
params category
Definition:
SCR_VehicleDamageManagerComponent.c:180
scripts_Arma_Reforger_v1.1.0.42
scripts
Game
Components
SpectateTargetComponent.c
Generated by
1.8.17