Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_CallsignCompanyData.c
Go to the documentation of this file.
1 
5 {
6  protected ref map<int, ref SCR_CallsignPlatoonData> m_mPlatoonCallsigns = new map<int, ref SCR_CallsignPlatoonData>;
7 
8  //---------------------------------------- On Init ----------------------------------------\\
9 
13  void Init(SCR_FactionCallsignInfo factionCallsignInfo)
14  {
15  array<ref SCR_CallsignInfo> platoonArray = new array<ref SCR_CallsignInfo>;
16  factionCallsignInfo.GetPlatoonArray(platoonArray);
17  int count = platoonArray.Count();
18 
19  for(int i = 0; i < count; i++)
20  {
22  platoonData.Init(factionCallsignInfo);
23  m_mPlatoonCallsigns.Insert(i, platoonData);
24  }
25  }
26 
27  //---------------------------------------- Get Random Callsign ----------------------------------------\\
28 
34  void GetRandomCallsign(out int platoon, out int squad)
35  {
36  Math.Randomize(-1);
37  int random = Math.RandomInt(0, m_mPlatoonCallsigns.Count());
38  platoon = m_mPlatoonCallsigns.GetKey(random);
39  SCR_CallsignPlatoonData randomPlatoon = m_mPlatoonCallsigns.GetElement(random);
40 
41  squad = randomPlatoon.GetRandomSquad();
42  }
43 
44  //---------------------------------------- Get first availible Callsign ----------------------------------------\\
45 
51  void GetFirstAvailibleCallsign(out int firstAvailiblePlatoon, out int firstAvailibleSquad)
52  {
53  firstAvailiblePlatoon = int.MAX;
54  SCR_CallsignPlatoonData firstAvailiblePlatoonData;
55 
56  foreach (int index, SCR_CallsignPlatoonData platoon: m_mPlatoonCallsigns)
57  {
58  if (index < firstAvailiblePlatoon)
59  {
60  firstAvailiblePlatoon = index;
61  firstAvailiblePlatoonData = platoon;
62  }
63  }
64 
65  firstAvailibleSquad = firstAvailiblePlatoonData.GetFirstAvailibleSquad();
66  }
67 
68  //---------------------------------------- Add availible Callsign ----------------------------------------\\
69 
74  void AddCallsign(int platoonIndex, int squadIndex)
75  {
76  SCR_CallsignPlatoonData platoonData;
77 
78  if (m_mPlatoonCallsigns.Find(platoonIndex, platoonData))
79  {
80  platoonData.AddSquad(squadIndex);
81  }
82  else
83  {
84  platoonData = new SCR_CallsignPlatoonData();
85  platoonData.AddSquad(squadIndex);
86  m_mPlatoonCallsigns.Insert(platoonIndex, platoonData);
87  }
88  }
89 
90  //---------------------------------------- Remove availible Callsign ----------------------------------------\\
91 
96  bool RemoveCallsign(int plattonIndex, int squadIndex)
97  {
98  SCR_CallsignPlatoonData platoonData;
99 
100  if (m_mPlatoonCallsigns.Find(plattonIndex, platoonData))
101  {
102  //Check if all squads are used then remove platoon
103  if (platoonData.RemoveSquad(squadIndex))
104  {
105  m_mPlatoonCallsigns.Remove(plattonIndex);
106  return m_mPlatoonCallsigns.IsEmpty();
107  }
108  }
109 
110  return false;
111  }
112 };
SCR_FactionCallsignInfo
Definition: SCR_FactionCallsignInfo.c:5
SCR_CallsignPlatoonData
Definition: SCR_CallsignPlatoonData.c:4
SCR_CallsignCompanyData
Definition: SCR_CallsignCompanyData.c:4
index
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
Definition: SCR_DestructionSynchronizationComponent.c:17