39 super.InitOnServer(owner);
55 IEntity leader =
m_Group.GetLeaderEntity();
60 groupFaction =
m_Group.GetFaction();
103 if (playerID == mapPlayerID)
112 if (playerID == mapPlayerID)
153 if (characterCallsign <= 0)
155 characterCallsign = 1;
165 if (
m_CallsignInfo.GetCharacterRoleCallsign(SCR_PossessingManagerComponent.GetPlayerMainEntity(playerID), playerID,
m_Group, roleIndex, roleIsUnique) && roleIsUnique)
171 m_CallsignManager.SetPlayerCallsign(playerID, m_iCompanyCallsign, m_iPlatoonCallsign, m_iSquadCallsign, characterCallsign, roleIndex);
173 if (characterCallsign >= 0)
184 array<AIAgent> agents = {};
185 SCR_CallsignCharacterComponent characterCallsignComponent;
190 foreach (AIAgent agent: agents)
192 characterCallsignComponent = SCR_CallsignCharacterComponent.Cast(agent.GetControlledEntity().FindComponent(SCR_CallsignCharacterComponent));
194 if (characterCallsignComponent)
196 int characterCallsign, roleCallsign;
197 characterCallsignComponent.GetCharacterAndRoleCallsign(characterCallsign, roleCallsign);
198 characterCallsignComponent.ClearCharacterRoleCallsign();
218 SCR_CallsignGroupComponent masterCallsignComponent = SCR_CallsignGroupComponent.Cast(master.FindComponent(SCR_CallsignGroupComponent));
220 if (masterCallsignComponent)
221 return masterCallsignComponent.IsUniqueRoleInUse(roleToCheck);
234 if (currentLeader && SCR_PossessingManagerComponent.GetPlayerIdFromMainEntity(currentLeader.GetControlledEntity()) > 0)
243 IEntity leader = currentLeader.GetControlledEntity();
261 if (currentLeader ==
null || prevLeader ==
null || currentLeader == prevLeader || currentLeader.GetParentGroup() != prevLeader.GetParentGroup())
264 SCR_CallsignCharacterComponent prevLeaderCallsignComponent = SCR_CallsignCharacterComponent.Cast(prevLeader.GetControlledEntity().FindComponent(SCR_CallsignCharacterComponent));
265 if (!prevLeaderCallsignComponent)
268 int prevLeaderCharacterCallsign, prevLeaderRoleCallsign
269 prevLeaderCallsignComponent.GetCharacterAndRoleCallsign(prevLeaderCharacterCallsign, prevLeaderRoleCallsign);
285 if (SCR_PossessingManagerComponent.GetPlayerIdFromMainEntity(character.GetControlledEntity()) > 0)
291 SCR_CallsignCharacterComponent characterCallsignComponent = SCR_CallsignCharacterComponent.Cast(character.GetControlledEntity().FindComponent(SCR_CallsignCharacterComponent));
293 if (characterCallsignComponent)
305 if (SCR_PossessingManagerComponent.GetPlayerIdFromMainEntity(character.GetControlledEntity()) > 0)
311 SCR_CallsignCharacterComponent characterCallsignComponent = SCR_CallsignCharacterComponent.Cast(character.GetControlledEntity().FindComponent(SCR_CallsignCharacterComponent));
313 if (!characterCallsignComponent)
316 int characterIndex, roleIndex;
317 characterCallsignComponent.GetCharacterAndRoleCallsign(characterIndex, roleIndex);
331 protected void AssignAICallsign(AIAgent character, SCR_CallsignCharacterComponent characterCallsignComponent,
int characterCallsign = -1)
337 if (characterCallsign <= 0)
339 characterCallsign = 1;
350 if (
m_CallsignInfo.GetCharacterRoleCallsign(character.GetControlledEntity(), -1,
m_Group, roleIndex, isUnique) && isUnique)
356 characterCallsignComponent.AssignCharacterCallsign(
m_Faction, m_iCompanyCallsign, m_iPlatoonCallsign, m_iSquadCallsign, characterCallsign, roleIndex, (!
m_Group ||
m_Group.GetPlayerAndAgentCount(
true) <= 1));
358 if (characterCallsign >= 0)
372 array<AIAgent> agents = {};
373 SCR_CallsignCharacterComponent characterCallsignComponent;
375 int characterCallsign, currentRoleCallsign;
376 bool roleReassigned =
false;
381 foreach (AIAgent agent: agents)
383 if (SCR_PossessingManagerComponent.GetPlayerIdFromMainEntity(agent.GetControlledEntity()) > 0)
386 characterCallsignComponent = SCR_CallsignCharacterComponent.Cast(agent.GetControlledEntity().FindComponent(SCR_CallsignCharacterComponent));
387 if (!characterCallsignComponent)
390 characterCallsignComponent.GetCharacterAndRoleCallsign(characterCallsign, currentRoleCallsign);
393 if (currentRoleCallsign >= 0 && roleIndex !=
ERoleCallsign.SQUAD_LEADER)
397 if (
m_CallsignInfo.GetCharacterRoleCallsign(agent.GetControlledEntity(), -1,
m_Group, roleIndex, isUnique))
402 characterCallsignComponent.UpdateCharacterRoleCallsign(roleIndex);
419 roleReassigned =
true;
425 if (roleReassigned && currentRoleCallsign >= 0)
430 override bool GetCallsignNames(out
string company, out
string platoon, out
string squad, out
string character, out
string format)
432 int companyCallsignIndex, platoonCallsignIndex, squadCallsignIndex, emptyCharacter;
433 character =
string.Empty;
435 if (!
GetCallsignIndexes(companyCallsignIndex, platoonCallsignIndex, squadCallsignIndex, emptyCharacter))
439 if (!SetCallsignInfo())
441 company = companyCallsignIndex.ToString();
442 platoon = platoonCallsignIndex.ToString();
443 squad = squadCallsignIndex.ToString();
445 format =
"ERROR %1-%2-%3";
450 company =
m_CallsignInfo.GetCompanyCallsignName(companyCallsignIndex);
451 platoon =
m_CallsignInfo.GetPlatoonCallsignName(platoonCallsignIndex);
461 characterNumber = -1;
463 if (m_iCompanyCallsign < 0 || m_iPlatoonCallsign < 0 || m_iSquadCallsign < 0)
471 companyIndex = m_iCompanyCallsign;
472 platoonIndex = m_iPlatoonCallsign;
473 squadIndex = m_iSquadCallsign;
482 if (!m_CallsignManager)
485 int company, platoon, squad;
493 [
RplRpc(RplChannel.Reliable, RplRcver.Broadcast)]
496 if (company == m_iCompanyCallsign && m_iPlatoonCallsign == platoon && m_iSquadCallsign == squad)
499 m_iCompanyCallsign = company;
500 m_iPlatoonCallsign = platoon;
501 m_iSquadCallsign = squad;
503 Event_OnCallsignChanged.Invoke(m_iCompanyCallsign, m_iPlatoonCallsign, m_iSquadCallsign, -1, -1);
513 if (isFactionChange && faction ==
m_Faction)
523 if (!SetCallsignInfo())
529 if (!prevFaction || !m_CallsignManager)
532 if (m_iCompanyCallsign >= 0)
534 m_CallsignManager.MakeGroupCallsignAvailible(prevFaction, m_iCompanyCallsign, m_iPlatoonCallsign, m_iSquadCallsign);
544 if (!SetCallsignInfo())
552 array<AIAgent> agents = {};
553 SCR_CallsignCharacterComponent characterCallsignComponent;
558 array<int> availibleRandomCallsigns = {};
561 int count = agents.Count();
565 availibleRandomCallsigns.Insert(count);
571 foreach (AIAgent agent: agents)
573 characterCallsignComponent = SCR_CallsignCharacterComponent.Cast(agent.GetControlledEntity().FindComponent(SCR_CallsignCharacterComponent));
574 characterCallsignComponent.ClearCallsigns();
576 if (characterCallsignComponent)
607 writer.WriteInt(m_iCompanyCallsign);
608 writer.WriteInt(m_iPlatoonCallsign);
609 writer.WriteInt(m_iSquadCallsign);
617 int company, platoon, squad, groupSize;
619 reader.ReadInt(company);
620 reader.ReadInt(platoon);
621 reader.ReadInt(squad);
632 if (!m_bIsServer || m_iCompanyCallsign < 0 || !
m_Faction || !m_CallsignManager)
635 m_CallsignManager.MakeGroupCallsignAvailible(
m_Faction, m_iCompanyCallsign, m_iPlatoonCallsign, m_iSquadCallsign);