Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_AIGroupFireteam.c
Go to the documentation of this file.
1 class SCR_AIGroupFireteam : Managed
2 {
3  protected ref array<AIAgent> m_aAgents = {};
4  protected ref array<SCR_AIInfoComponent> m_aInfoComponents = {};
5 
6  protected bool m_bLocked = false;
7 
8  //--------------------------------------------------------------------------
9  void AddMember(AIAgent agent, SCR_AIInfoComponent infoComponent)
10  {
11  m_aAgents.Insert(agent);
12  m_aInfoComponents.Insert(infoComponent);
13  }
14 
15  //--------------------------------------------------------------------------
16  void RemoveMember(AIAgent agent)
17  {
18  int id = m_aAgents.Find(agent);
19  if (id == -1)
20  return;
21  m_aAgents.Remove(id);
22  m_aInfoComponents.Remove(id);
23  }
24 
25  //--------------------------------------------------------------------------
26  protected void RemoveMember(int id, out AIAgent outAgent, out SCR_AIInfoComponent outInfoComp)
27  {
28  outAgent = m_aAgents[id];
29  outInfoComp = m_aInfoComponents[id];
30 
31  m_aAgents.Remove(id);
32  m_aInfoComponents.Remove(id);
33  }
34 
35  //--------------------------------------------------------------------------
36  void GetMember(int id, out AIAgent outAgent, out SCR_AIInfoComponent outInfoComp)
37  {
38  if (!m_aAgents.IsIndexValid(id))
39  return;
40 
41  outAgent = m_aAgents[id];
42  outInfoComp = m_aInfoComponents[id];
43  }
44 
45  //--------------------------------------------------------------------------
46  AIAgent GetMember(int id)
47  {
48  if (!m_aAgents.IsIndexValid(id))
49  return null;
50 
51  return m_aAgents[id];
52  }
53 
54  //--------------------------------------------------------------------------
55  IEntity GetFirstMemberEntity()
56  {
57  if (m_aAgents.IsEmpty())
58  return null;
59  foreach (AIAgent agent : m_aAgents)
60  {
61  if (!agent)
62  continue;
63  IEntity controlledEntity = agent.GetControlledEntity();
64  return controlledEntity;
65  }
66  return null;
67  }
68 
69  //--------------------------------------------------------------------------
70  void GetMembers(notnull array<AIAgent> outAgents)
71  {
72  outAgents.Clear();
73  foreach (auto a : m_aAgents)
74  outAgents.Insert(a);
75  }
76 
77  //--------------------------------------------------------------------------
79  void MoveMembersFrom(notnull SCR_AIGroupFireteam otherFt, int count)
80  {
81  // Bail if wrong count
82  if (count <= 0)
83  return;
84 
85  // Clamp count
86  count = Math.ClampInt(count, 0, otherFt.m_aAgents.Count());
87 
88  // Remove the required amount of members
89  for (int i = 0; i < count; i++)
90  {
91  // Remove last member from other fireteam
92  int lastId = otherFt.m_aAgents.Count() - 1;
93  AIAgent agent;
94  SCR_AIInfoComponent infoComp;
95  otherFt.RemoveMember(lastId, agent, infoComp);
96 
97  // Add the member to our fireteam
98  AddMember(agent, infoComp);
99  }
100  }
101 
102  //--------------------------------------------------------------------------
103  bool HasMember(AIAgent agent)
104  {
105  return m_aAgents.Find(agent) != -1;
106  }
107 
108  //--------------------------------------------------------------------------
109  int GetMemberCount()
110  {
111  return m_aAgents.Count();
112  }
113 
114  //--------------------------------------------------------------------------
116  void Internal_OnLockDestroyed()
117  {
118  m_bLocked = false;
119  }
120 
121  //------------------------------------------------------------------------------------------------
122  // Acquiring fireteams
123 
124  //--------------------------------------------------------------------------
125  bool IsLocked()
126  {
127  return m_bLocked;
128  }
129 
130  //--------------------------------------------------------------------------
133  SCR_AIGroupFireteamLock TryLock()
134  {
135  if (m_bLocked)
136  return null;
137 
138  m_bLocked = true;
139 
141  return lock;
142  }
143 };
SCR_AIGroupFireteam
Definition: SCR_AIGroupFireteam.c:1
SCR_AIGroupFireteamLock
Definition: SCR_AIGroupFireteamLock.c:9
m_aInfoComponents
ref array< SCR_AIInfoComponent > m_aInfoComponents
Definition: SCR_AIGroupUtilityComponent.c:16