Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_AIFireteamsActivity.c
Go to the documentation of this file.
1 
7 {
8  protected ref TFireteamLockRefArray m_aAssignedFireteams = {}; // Don't manipulate yourself, use register/unregister!
9 
10  //------------------------------------------------------------------------------------------------
11  void SCR_AIFireteamsActivity(SCR_AIGroupUtilityComponent utility, AIWaypoint relatedWaypoint,)
12  {
13  SetIsUniqueInActionQueue(false);
14  utility.m_FireteamMgr.GetOnFireteamRemoved().Insert(Event_OnFireteamRemovedFromGroup);
15  }
16 
17  //------------------------------------------------------------------------------------------------
19  {
20  if (m_Utility)
21  m_Utility.m_FireteamMgr.GetOnFireteamRemoved().Remove(Event_OnFireteamRemovedFromGroup);
22  }
23 
24  //------------------------------------------------------------------------------------------------
25  override void OnActionRemoved()
26  {
27  // Unregister all fireteams, don't call the event
28  m_aAssignedFireteams.Clear();
29  }
30 
31 
32  //------------------------------------------------------------------------------------------------
33  void GetAssignedFireteams(notnull TFireteamLockRefArray outFireteams)
34  {
35  foreach (auto ft : m_aAssignedFireteams)
36  outFireteams.Insert(ft);
37  }
38 
39  //------------------------------------------------------------------------------------------------
40  // Fireteam registration
41  // Inherited class should register and unregister the fireteams itself.
42 
43  //------------------------------------------------------------------------------------------------
45  protected void RegisterFireteam(notnull SCR_AIGroupFireteamLock ftLock)
46  {
47  if (SCR_AIGroupFireteamLock.FindFireteamLock(m_aAssignedFireteams, ftLock) != -1)
48  return;
49 
50  m_aAssignedFireteams.Insert(ftLock);
51  }
52 
53  //------------------------------------------------------------------------------------------------
54  protected void UnregisterFireteam(notnull SCR_AIGroupFireteamLock ftLock)
55  {
56  int id = SCR_AIGroupFireteamLock.FindFireteamLock(m_aAssignedFireteams, ftLock);
57  if (id != -1)
58  return;
59 
60  m_aAssignedFireteams.Remove(id);
61 
62  if (m_aAssignedFireteams.IsEmpty())
63  OnAssignedFireteamsEmpty();
64  }
65 
66  //------------------------------------------------------------------------------------------------
67  protected void UnregisterFireteam(notnull SCR_AIGroupFireteam ft)
68  {
69  int id = SCR_AIGroupFireteamLock.FindFireteamLock(m_aAssignedFireteams, ft);
70  if (id == -1)
71  return;
72 
73  m_aAssignedFireteams.Remove(id);
74 
75  if (m_aAssignedFireteams.IsEmpty())
76  OnAssignedFireteamsEmpty();
77  }
78 
79  //------------------------------------------------------------------------------------------------
80  private void Event_OnFireteamRemovedFromGroup(SCR_AIGroupFireteam ft)
81  {
82  // Bail if it wasn't one of FTs of this activity
83  if (SCR_AIGroupFireteamLock.FindFireteamLock(m_aAssignedFireteams, ft) == -1)
84  return;
85 
86  // Call the virtual method
87  OnFireteamRemovedFromGroup(ft);
88  }
89 
90  //------------------------------------------------------------------------------------------------
92  void OnAssignedFireteamsEmpty()
93  {
94  #ifdef AI_DEBUG
95  AddDebugMessage("All fireteams are destroyed, activity is failed");
96  #endif
97  Fail();
98  }
99 
100  //------------------------------------------------------------------------------------------------
103  void OnFireteamRemovedFromGroup(SCR_AIGroupFireteam ft);
104 
105  //------------------------------------------------------------------------------------------------
106  override string GetDebugPanelText()
107  {
108  // List all assigned fireteams
109  string str = "FTs: ";
110  foreach (SCR_AIGroupFireteamLock ftLock : m_aAssignedFireteams)
111  {
112  str = str + string.Format("%1, ", m_Utility.m_FireteamMgr.GetFireteamId(ftLock.GetFireteam()));
113  }
114 
115  return str;
116  }
117 };
SCR_AIFireteamsActivity
Definition: SCR_AIFireteamsActivity.c:6
SCR_AIActivityBase
Definition: SCR_AIActivity.c:1
SCR_AIGroupFireteam
Definition: SCR_AIGroupFireteam.c:1
TFireteamLockRefArray
array< ref SCR_AIGroupFireteamLock > TFireteamLockRefArray
Definition: SCR_AIGroupFireteamLock.c:6
SCR_AIGroupFireteamLock
Definition: SCR_AIGroupFireteamLock.c:9