Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_AITargetClusterState.c
Go to the documentation of this file.
1 
7 {
8  UNINITIALIZED, // We have never processed it yet
9  NONE, // We don't know what to do with this yet
10  INVESTIGATING, // We are investigating the targets
11  ATTACKING, // We are attacking the targets
12  DEFENDING, // We defend ourselves against the targets
13  LOST // We haven't detected anything here for a long time, it's too old
14 }
15 
17 {
19 
20  // Related to our processing of this cluster
21  ref SCR_AIActivityBase m_Activity; // Activity assigned for this cluster
22  float m_fTimer_ms = 0;
23  float m_fMaxAge_s; // When age is above this, we switch to lost state
24  EAITargetClusterState m_eState = EAITargetClusterState.NONE; // Those two must be different at start to trigger a state switch event
26 
27  // Values updated by ProcessTargets() call
28  vector m_vBBMax;
29  vector m_vBBMin;
30  float m_fRadius; // Radius of cluster
36 
37 
39  {
40  m_Cluster = cluster;
41  }
42 
45  {
46  int nDetected = 0;
47  int nIdentified = 0;
48  int nLost = 0;
49  int nDestroyed = 0;
50  float maxTimestamp = 0;
51 
52  vector bbMax = vector.Zero;
53  vector bbMin = vector.Zero;
54 
55  if (m_Cluster && !m_Cluster.m_aTargets.IsEmpty())
56  {
57  bbMax = Vector(-float.MAX, -float.MAX, -float.MAX);
58  bbMin = Vector(float.MAX, float.MAX, float.MAX);
59 
60  foreach (SCR_AITargetInfo target : m_Cluster.m_aTargets)
61  {
62  EAITargetInfoCategory category = target.m_eCategory;
63  switch (category)
64  {
65  case EAITargetInfoCategory.DETECTED: nDetected++; break;
66  case EAITargetInfoCategory.IDENTIFIED: nIdentified++; break;
67  case EAITargetInfoCategory.DESTROYED: nDestroyed++; break;
68  case EAITargetInfoCategory.LOST: nLost++; break;
69  case EAITargetInfoCategory.DISARMED: nDestroyed++; break; // Disarmed counts as destroyed
70  }
71 
72  if (target.m_fTimestamp > maxTimestamp)
73  maxTimestamp = target.m_fTimestamp;
74 
75  vector tgtPos = target.m_vWorldPos;
76  for (int i = 0; i < 3; i++)
77  {
78  float tgtPosI = tgtPos[i];
79  if (tgtPosI > bbMax[i])
80  bbMax[i] = tgtPosI;
81  if (tgtPosI < bbMin[i])
82  bbMin[i] = tgtPosI;
83  }
84  }
85  }
86 
87  m_iCountLost = nLost;
88  m_iCountDetected = nDetected;
89  m_iCountIdentified = nIdentified;
90  m_iCountDestroyed = nDestroyed;
91  m_fMaxTimestamp = maxTimestamp;
92  m_vBBMin = bbMin;
93  m_vBBMax = bbMax;
94  }
95 
99  {
100  PerceptionManager pm = GetGame().GetPerceptionManager();
101  if (!pm)
102  return 0;
103 
104  return pm.GetTime() - m_fMaxTimestamp;
105  }
106 
107  //---------------------------------------------------------------------------
108  // Returns center position of cluster based on cluster bouding box
110  {
111  return 0.5 * (m_vBBMin + m_vBBMax);
112  }
113 }
m_Activity
ref SCR_AIActivityBase m_Activity
Definition: SCR_AITargetClusterState.c:21
ProcessTargets
void ProcessTargets()
Counts targets and saves them in member variables.
Definition: SCR_AITargetClusterState.c:44
m_Cluster
enum EAITargetClusterState m_Cluster
m_iCountLost
int m_iCountLost
Definition: SCR_AITargetClusterState.c:34
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
NONE
@ NONE
Definition: SCR_AITargetClusterState.c:9
SCR_AIActivityBase
Definition: SCR_AIActivity.c:1
m_iCountDetected
int m_iCountDetected
Definition: SCR_AITargetClusterState.c:32
GetCenterPosition
vector GetCenterPosition()
Definition: SCR_AITargetClusterState.c:109
m_vBBMax
vector m_vBBMax
Definition: SCR_AITargetClusterState.c:28
m_eState
EAITargetClusterState m_eState
Definition: SCR_AITargetClusterState.c:24
GetTimeSinceLastNewInformation
float GetTimeSinceLastNewInformation()
Definition: SCR_AITargetClusterState.c:98
DEFENDING
@ DEFENDING
Definition: SCR_AITargetClusterState.c:12
m_iCountDestroyed
int m_iCountDestroyed
Definition: SCR_AITargetClusterState.c:35
m_fMaxAge_s
float m_fMaxAge_s
Definition: SCR_AITargetClusterState.c:23
SCR_AIGroupTargetCluster
Definition: SCR_AIGroupTargetCluster.c:41
UNINITIALIZED
@ UNINITIALIZED
Definition: SCR_AITargetClusterState.c:8
m_fTimer_ms
float m_fTimer_ms
Definition: SCR_AITargetClusterState.c:22
m_fRadius
float m_fRadius
Definition: SCR_AITargetClusterState.c:30
INVESTIGATING
@ INVESTIGATING
Definition: SCR_AITargetClusterState.c:10
LOST
@ LOST
Definition: SCR_AITargetClusterState.c:13
ATTACKING
@ ATTACKING
Definition: SCR_AITargetClusterState.c:11
m_fMaxTimestamp
float m_fMaxTimestamp
Definition: SCR_AITargetClusterState.c:31
m_vBBMin
vector m_vBBMin
Definition: SCR_AITargetClusterState.c:29
m_ePrevState
EAITargetClusterState m_ePrevState
Definition: SCR_AITargetClusterState.c:25
EAITargetInfoCategory
EAITargetInfoCategory
Definition: SCR_AITargetInfo.c:1
SCR_AITargetClusterState
void SCR_AITargetClusterState(SCR_AIGroupTargetCluster cluster)
Definition: SCR_AITargetClusterState.c:38
EAITargetClusterState
EAITargetClusterState
Definition: SCR_AITargetClusterState.c:6
m_iCountIdentified
int m_iCountIdentified
Definition: SCR_AITargetClusterState.c:33
category
params category
Definition: SCR_VehicleDamageManagerComponent.c:180