Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
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 
11 enum EAITargetInfoFlags
12 {
13 }
14 
15 class SCR_AITargetInfo
16 {
17  IEntity m_Entity;
20  PerceivableComponent m_Perceivable;
21  vector m_vWorldPos;
22  float m_fTimestamp; // Perception mgr time
23 
25 
26  //----------------------------------------------------------------------------------------------------------
27  void Init(IEntity entity = null,
28  vector worldPos = vector.Zero,
29  float timestamp = 0.0,
31  {
32  m_Entity = entity;
33  m_vWorldPos = worldPos;
34  m_fTimestamp = timestamp;
36 
37  if (entity)
38  {
39  // Init m_Faction
40  FactionAffiliationComponent fcomp;
41 
42  SCR_ChimeraCharacter character = SCR_ChimeraCharacter.Cast(entity);
43  if (character)
44  fcomp = character.m_pFactionComponent; // Common case
45  else
46  {
47  Vehicle veh = Vehicle.Cast(entity);
48  if (veh)
49  fcomp = veh.m_pFactionComponent;
50  else
51  fcomp = FactionAffiliationComponent.Cast(entity.FindComponent(FactionAffiliationComponent)); // Last resort
52  }
53 
54  if (fcomp)
55  m_Faction = fcomp.GetAffiliatedFaction();
56 
57  // Init pointers to components
59  m_Perceivable = PerceivableComponent.Cast(entity.FindComponent(PerceivableComponent));
60  }
61  }
62 
63  //----------------------------------------------------------------------------------------------------------
65  {
66  IEntity entity = tgt.GetTargetEntity();
67  vector pos;
68  float timestamp;
70  if (tgt.GetTargetCategory() == ETargetCategory.ENEMY)
71  {
72  pos = tgt.GetLastSeenPosition();
73  timestamp = tgt.GetTimeLastSeen();
74  category = EAITargetInfoCategory.IDENTIFIED;
75  }
76  else
77  {
78  pos = tgt.GetLastDetectedPosition();
79  timestamp = tgt.GetTimeLastDetected();
81  }
82  Init(entity, pos, timestamp, category);
83  }
84 
85  //----------------------------------------------------------------------------------------------------------
86  void InitFromGunshot(IEntity entity, vector posWorld, float timestamp)
87  {
88  Init(entity, posWorld, timestamp, category: EAITargetInfoCategory.DETECTED);
89  }
90 
91  //----------------------------------------------------------------------------------------------------------
93  {
94  ETargetCategory category = baseTarget.GetTargetCategory();
95 
96  if (category == ETargetCategory.ENEMY)
98  else if (category == ETargetCategory.DETECTED)
100 
101  // Update timestamp and position
102  if (category == ETargetCategory.ENEMY)
103  {
104  m_vWorldPos = baseTarget.GetLastSeenPosition();
105  m_fTimestamp = baseTarget.GetTimeLastSeen();
106  }
107  else
108  {
109  m_vWorldPos = baseTarget.GetLastDetectedPosition();
110  m_fTimestamp = baseTarget.GetTimeLastDetected();
111  }
112  }
113 
114  //----------------------------------------------------------------------------------------------------------
115  void UpdateFromGunshot(vector worldPos, float timestamp)
116  {
117  m_vWorldPos = worldPos;
118  m_fTimestamp = timestamp;
119 
122  }
123 
124  //----------------------------------------------------------------------------------------------------------
125  void CopyFrom(SCR_AITargetInfo other)
126  {
127  m_Entity = other.m_Entity;
128  m_vWorldPos = other.m_vWorldPos;
129  m_fTimestamp = other.m_fTimestamp;
130  m_eCategory = other.m_eCategory;
131  m_Faction = other.m_Faction;
132  }
133 };
DISARMED
@ DISARMED
Definition: SCR_AITargetInfo.c:5
UNKNOWN
@ UNKNOWN
Definition: SCR_AITargetInfo.c:3
CopyFrom
void CopyFrom(SCR_AITargetInfo other)
Definition: SCR_AITargetInfo.c:125
ETargetCategory
ETargetCategory
Definition: ETargetCategory.c:12
m_Entity
enum EAITargetInfoCategory m_Entity
Init
void Init(IEntity entity=null, vector worldPos=vector.Zero, float timestamp=0.0, EAITargetInfoCategory category=0)
Definition: SCR_AITargetInfo.c:27
BaseTarget
Definition: BaseTarget.c:12
InitFromGunshot
void InitFromGunshot(IEntity entity, vector posWorld, float timestamp)
Definition: SCR_AITargetInfo.c:86
m_vWorldPos
vector m_vWorldPos
Definition: SCR_AITargetInfo.c:21
UpdateFromBaseTarget
void UpdateFromBaseTarget(BaseTarget baseTarget)
Definition: SCR_AITargetInfo.c:92
IDENTIFIED
@ IDENTIFIED
Definition: SCR_AITargetInfo.c:8
UpdateFromGunshot
void UpdateFromGunshot(vector worldPos, float timestamp)
Definition: SCR_AITargetInfo.c:115
DETECTED
@ DETECTED
Definition: SCR_AITargetInfo.c:7
DESTROYED
@ DESTROYED
engine is destroyed
Definition: SCR_AITargetInfo.c:4
Faction
Definition: Faction.c:12
LOST
@ LOST
Definition: SCR_AITargetInfo.c:6
m_eCategory
EAITargetInfoCategory m_eCategory
Definition: SCR_AITargetInfo.c:24
m_fTimestamp
float m_fTimestamp
Definition: SCR_AITargetInfo.c:22
InitFromBaseTarget
void InitFromBaseTarget(BaseTarget tgt)
Definition: SCR_AITargetInfo.c:64
m_Faction
Faction m_Faction
Definition: SCR_AITargetInfo.c:18
m_Perceivable
PerceivableComponent m_Perceivable
Definition: SCR_AITargetInfo.c:20
EAITargetInfoCategory
EAITargetInfoCategory
Definition: SCR_AITargetInfo.c:1
DamageManagerComponent
Definition: DamageManagerComponent.c:12
m_DamageManager
DamageManagerComponent m_DamageManager
Definition: SCR_AITargetInfo.c:19
category
params category
Definition: SCR_VehicleDamageManagerComponent.c:180