Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
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.")]
5
6class 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 //------------------------------------------------------------------------------------------------
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 {
37 return null;
38
39 int count = s_aSpectateTargets.Count();
40 if (index >= 0 && index < count)
41 {
43 }
44 else
45 return null;
46 }
47
48 //------------------------------------------------------------------------------------------------
50 static int GetSpectateTargetCount()
51 {
53 return 0;
54
55 return s_aSpectateTargets.Count();
56 }
57
58 //------------------------------------------------------------------------------------------------
59 private static void RegisterTarget(SCR_SpectateTargetComponent spectateTarget)
60 {
62 s_aSpectateTargets = new array<SCR_SpectateTargetComponent>();
63
65 {
66 s_aSpectateTargets.Insert(spectateTarget);
67 }
68 }
69
70 //------------------------------------------------------------------------------------------------
71 private static void UnregisterTarget(SCR_SpectateTargetComponent spectateTarget)
72 {
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}
ArmaReforgerScripted GetGame()
Definition game.c:1398
enum EAIGroupCombatMode ComponentEditorProps(category:"GameScripted/AI", description:"Component for utility AI system for groups")
enum EAITargetInfoCategory m_Entity
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
SCR_SpectateTargetComponentClass s_aSpectateTargets
enum EVehicleType IEntity
proto external Managed FindComponent(typename typeName)
IEntity GetEntity()
EDamageState