4 protected ref map<int, ref SCR_CallsignCompanyData> m_mCompanyCallsigns =
new map<int, ref SCR_CallsignCompanyData>();
5 protected ref map<int, ref SCR_CallsignCompanyData> m_mCompanyOverflowCallsigns =
new map<int, ref SCR_CallsignCompanyData>();
7 protected int m_iOverflowIndex;
8 protected bool m_bRandomizedCallsigns;
15 m_iOverflowIndex = factionCallsignInfo.GetCompanyOverflowIndex();
16 m_bRandomizedCallsigns = factionCallsignInfo.GetIsAssignedRandomly();
18 array<ref SCR_CallsignInfo> companyArray = {};
19 factionCallsignInfo.GetCompanyArray(companyArray);
20 int count = companyArray.Count();
22 for(
int i = 0; i < count; i++)
25 companyData.Init(factionCallsignInfo);
28 if (i < m_iOverflowIndex)
29 m_mCompanyCallsigns.Insert(i, companyData);
32 m_mCompanyOverflowCallsigns.Insert(i, companyData);
43 bool GetRandomCallsign(out
int company, out
int platoon, out
int squad)
49 if (!m_mCompanyCallsigns.IsEmpty())
52 random = Math.RandomInt(0, m_mCompanyCallsigns.Count());
53 company = m_mCompanyCallsigns.GetKey(random);
54 randomCompany = m_mCompanyCallsigns.GetElement(random);
58 else if (!m_mCompanyOverflowCallsigns.IsEmpty())
61 random = Math.RandomInt(0, m_mCompanyOverflowCallsigns.Count());
62 company = m_mCompanyOverflowCallsigns.GetKey(random);
63 randomCompany = m_mCompanyOverflowCallsigns.GetElement(random);
71 randomCompany.GetRandomCallsign(platoon, squad);
84 bool GetFirstAvailibleCallsign(out
int firstAvailableCompany, out
int firstAvailablePlatoon, out
int firstAvailableSquad)
86 firstAvailableCompany =
int.MAX;
90 if (!m_mCompanyCallsigns.IsEmpty())
94 if (
index < firstAvailableCompany)
96 firstAvailableCompany =
index;
97 firstAvailableCompanyData = company;
102 else if (!m_mCompanyOverflowCallsigns.IsEmpty())
106 if (
index < firstAvailableCompany)
108 firstAvailableCompany =
index;
109 firstAvailableCompanyData = company;
119 firstAvailableCompanyData.GetFirstAvailibleCallsign(firstAvailablePlatoon, firstAvailableSquad);
130 bool GetSpecificCompanyCallsign(out
int company, out
int platoon, out
int squad)
135 if (!m_mCompanyCallsigns.Find(company, companyData))
136 m_mCompanyOverflowCallsigns.Find(company, companyData);
141 if (!m_bRandomizedCallsigns)
142 companyData.GetFirstAvailibleCallsign(platoon, squad);
144 companyData.GetRandomCallsign(platoon, squad);
149 if (!m_bRandomizedCallsigns)
150 return GetFirstAvailibleCallsign(company, platoon, squad);
152 return GetRandomCallsign(company, platoon, squad);
163 void AddCallsign(
int companyIndex,
int platoonIndex,
int squadIndex)
167 if (companyIndex < m_iOverflowIndex)
169 if (m_mCompanyCallsigns.Find(companyIndex, companyData))
171 companyData.AddCallsign(platoonIndex, squadIndex);
176 companyData.AddCallsign(platoonIndex, squadIndex);
177 m_mCompanyCallsigns.Insert(companyIndex, companyData);
182 if (m_mCompanyOverflowCallsigns.Find(companyIndex, companyData))
184 companyData.AddCallsign(platoonIndex, squadIndex);
189 companyData.AddCallsign(platoonIndex, squadIndex);
190 m_mCompanyOverflowCallsigns.Insert(companyIndex, companyData);
200 void RemoveCallsign(
int companyIndex,
int platoonIndex,
int squadIndex)
204 if (companyIndex < m_iOverflowIndex)
206 if (m_mCompanyCallsigns.Find(companyIndex, companyData))
209 if (companyData.RemoveCallsign(platoonIndex, squadIndex))
211 m_mCompanyCallsigns.Remove(companyIndex);
217 if (m_mCompanyOverflowCallsigns.Find(companyIndex, companyData))
220 if (companyData.RemoveCallsign(platoonIndex, squadIndex))
222 m_mCompanyOverflowCallsigns.Remove(companyIndex);