Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_AITargetInfo.c
Go to the documentation of this file.
2{
4 DESTROYED, // Destroyed or deleted
5 DISARMED, // Disarmed
6 LOST, // Lost - not seen for a lot of time
7 DETECTED, // Was detected (heard)
8 IDENTIFIED // Was seen visually
9}
10
11enum EAITargetInfoFlags
12{
13}
14
15class SCR_AITargetInfo
16{
22 float m_fTimestamp; // Perception mgr time
24
26
27 //----------------------------------------------------------------------------------------------------------
28 void Init(IEntity entity = null, PerceivableComponent perceivable = null,
29 vector worldPos = vector.Zero,
30 float timestamp = 0.0,
32 bool endangering = false,
33 Faction faction = null)
34 {
35 m_Entity = entity;
36 m_vWorldPos = worldPos;
37 m_fTimestamp = timestamp;
39 m_bEndangering = endangering;
40
41 if (entity)
42 {
43 // Init m_Faction
44 if (faction)
45 m_Faction = faction; // Faction was provided
46 else
47 {
48 // Faction was not provided, try to resolve it
49 FactionAffiliationComponent fcomp;
50
51 SCR_ChimeraCharacter character = SCR_ChimeraCharacter.Cast(entity);
52 if (character)
53 fcomp = character.m_pFactionComponent; // Common case
54 else
55 {
56 Vehicle veh = Vehicle.Cast(entity);
57 if (veh)
58 fcomp = veh.m_pFactionComponent;
59 else
60 fcomp = FactionAffiliationComponent.Cast(entity.FindComponent(FactionAffiliationComponent)); // Last resort
61 }
62
63 if (fcomp)
64 m_Faction = fcomp.GetAffiliatedFaction();
65 }
66
67 // Init pointers to components
69 if (perceivable)
70 m_Perceivable = perceivable;
71 else
72 m_Perceivable = PerceivableComponent.Cast(entity.FindComponent(PerceivableComponent));
73 }
74 }
75
76 //----------------------------------------------------------------------------------------------------------
78 {
79 IEntity entity = tgt.GetTargetEntity();
80 vector pos;
81 float timestamp;
83 if (tgt.GetTargetCategory() == ETargetCategory.ENEMY)
84 {
85 pos = tgt.GetLastSeenPosition();
86 timestamp = tgt.GetTimeLastSeen();
87 category = EAITargetInfoCategory.IDENTIFIED;
88 }
89 else
90 {
91 pos = tgt.GetLastDetectedPosition();
92 timestamp = tgt.GetTimeLastDetected();
94 }
95 PerceivableComponent perceivable = tgt.GetPerceivableComponent();
96 Init(entity, perceivable, pos, timestamp, category);
97 }
98
99 //----------------------------------------------------------------------------------------------------------
100 void InitFromGunshot(IEntity entity, PerceivableComponent perceivable, vector posWorld, Faction faction, float timestamp, bool endangering)
101 {
102 Init(entity, perceivable, posWorld, timestamp, category: EAITargetInfoCategory.DETECTED, endangering, faction);
103 }
104
105 //----------------------------------------------------------------------------------------------------------
107 {
108 ETargetCategory category = baseTarget.GetTargetCategory();
109
110 if (category == ETargetCategory.ENEMY)
112 else if (category == ETargetCategory.DETECTED)
114
115 // Update timestamp and position
116 if (category == ETargetCategory.ENEMY)
117 {
118 m_vWorldPos = baseTarget.GetLastSeenPosition();
119 m_fTimestamp = baseTarget.GetTimeLastSeen();
120 }
121 else
122 {
123 m_vWorldPos = baseTarget.GetLastDetectedPosition();
124 m_fTimestamp = baseTarget.GetTimeLastDetected();
125 }
126 }
127
128 //----------------------------------------------------------------------------------------------------------
129 void UpdateFromGunshot(vector worldPos, float timestamp, bool endangering)
130 {
131 m_vWorldPos = worldPos;
132 m_fTimestamp = timestamp;
133
136
137 m_bEndangering |= endangering;
138 }
139
140 //----------------------------------------------------------------------------------------------------------
141 void CopyFrom(SCR_AITargetInfo other)
142 {
143 m_Entity = other.m_Entity;
144 m_vWorldPos = other.m_vWorldPos;
145 m_fTimestamp = other.m_fTimestamp;
146 m_eCategory = other.m_eCategory;
147 m_Faction = other.m_Faction;
148 m_bEndangering = other.m_bEndangering;
149 }
150};
override void Init()
DamageManagerComponent m_DamageManager
EAITargetInfoCategory
@ DETECTED
@ LOST
@ DISARMED
@ DESTROYED
engine is destroyed
@ IDENTIFIED
vector m_vWorldPos
bool m_bEndangering
float m_fTimestamp
enum EAITargetInfoCategory m_Entity
void CopyFrom(SCR_AITargetInfo other)
EAITargetInfoCategory m_eCategory
void InitFromGunshot(IEntity entity, PerceivableComponent perceivable, vector posWorld, Faction faction, float timestamp, bool endangering)
void InitFromBaseTarget(BaseTarget tgt)
PerceivableComponent m_Perceivable
Faction m_Faction
void UpdateFromBaseTarget(BaseTarget baseTarget)
void UpdateFromGunshot(vector worldPos, float timestamp, bool endangering)
enum EPhysicsLayerPresets Vehicle
Definition gameLib.c:24
ETargetCategory
@ UNKNOWN
Definition EPlatform.c:24