40 super.InitOnServer(owner);
64 groupFaction =
m_Group.GetFaction();
107 if (playerID == mapPlayerID)
116 if (playerID == mapPlayerID)
157 if (characterCallsign <= 0)
159 characterCallsign = 1;
169 if (
m_CallsignInfo.GetCharacterRoleCallsign(SCR_PossessingManagerComponent.GetPlayerMainEntity(playerID), playerID,
m_Group, roleIndex, roleIsUnique) && roleIsUnique)
175 m_CallsignManager.SetPlayerCallsign(playerID, m_iCompanyCallsign, m_iPlatoonCallsign, m_iSquadCallsign, characterCallsign, roleIndex);
177 if (characterCallsign >= 0)
188 array<AIAgent> agents = {};
189 SCR_CallsignCharacterComponent characterCallsignComponent;
194 foreach (AIAgent agent : agents)
196 characterCallsignComponent = SCR_CallsignCharacterComponent.Cast(agent.GetControlledEntity().FindComponent(SCR_CallsignCharacterComponent));
198 if (characterCallsignComponent)
200 int characterCallsign, roleCallsign;
201 characterCallsignComponent.GetCharacterAndRoleCallsign(characterCallsign, roleCallsign);
202 characterCallsignComponent.ClearCharacterRoleCallsign();
222 SCR_CallsignGroupComponent masterCallsignComponent = SCR_CallsignGroupComponent.Cast(master.FindComponent(SCR_CallsignGroupComponent));
224 if (masterCallsignComponent)
225 return masterCallsignComponent.IsUniqueRoleInUse(roleToCheck);
238 if (currentLeader && SCR_PossessingManagerComponent.GetPlayerIdFromMainEntity(currentLeader.GetControlledEntity()) > 0)
247 IEntity leader = currentLeader.GetControlledEntity();
265 if (currentLeader == null || prevLeader == null || currentLeader == prevLeader || currentLeader.GetParentGroup() != prevLeader.GetParentGroup())
268 SCR_CallsignCharacterComponent prevLeaderCallsignComponent = SCR_CallsignCharacterComponent.Cast(prevLeader.GetControlledEntity().FindComponent(SCR_CallsignCharacterComponent));
269 if (!prevLeaderCallsignComponent)
272 int prevLeaderCharacterCallsign, prevLeaderRoleCallsign
273 prevLeaderCallsignComponent.GetCharacterAndRoleCallsign(prevLeaderCharacterCallsign, prevLeaderRoleCallsign);
289 if (SCR_PossessingManagerComponent.GetPlayerIdFromMainEntity(character.GetControlledEntity()) > 0)
295 SCR_CallsignCharacterComponent characterCallsignComponent = SCR_CallsignCharacterComponent.Cast(character.GetControlledEntity().FindComponent(SCR_CallsignCharacterComponent));
297 if (characterCallsignComponent)
309 if (SCR_PossessingManagerComponent.GetPlayerIdFromMainEntity(character.GetControlledEntity()) > 0)
315 SCR_CallsignCharacterComponent characterCallsignComponent = SCR_CallsignCharacterComponent.Cast(character.GetControlledEntity().FindComponent(SCR_CallsignCharacterComponent));
317 if (!characterCallsignComponent)
320 int characterIndex, roleIndex;
321 characterCallsignComponent.GetCharacterAndRoleCallsign(characterIndex, roleIndex);
335 protected void AssignAICallsign(AIAgent character, SCR_CallsignCharacterComponent characterCallsignComponent,
int characterCallsign = -1)
341 if (characterCallsign <= 0)
343 characterCallsign = 1;
354 if (
m_CallsignInfo.GetCharacterRoleCallsign(character.GetControlledEntity(), -1,
m_Group, roleIndex, isUnique) && isUnique)
360 characterCallsignComponent.AssignCharacterCallsign(
m_Faction, m_iCompanyCallsign, m_iPlatoonCallsign, m_iSquadCallsign, characterCallsign, roleIndex, (!
m_Group ||
m_Group.GetPlayerAndAgentCount(
true) <= 1));
362 if (characterCallsign >= 0)
375 array<AIAgent> agents = {};
376 SCR_CallsignCharacterComponent characterCallsignComponent;
378 int characterCallsign, currentRoleCallsign;
379 bool roleReassigned =
false;
384 foreach (AIAgent agent : agents)
386 if (SCR_PossessingManagerComponent.GetPlayerIdFromMainEntity(agent.GetControlledEntity()) > 0)
389 characterCallsignComponent = SCR_CallsignCharacterComponent.Cast(agent.GetControlledEntity().FindComponent(SCR_CallsignCharacterComponent));
390 if (!characterCallsignComponent)
393 characterCallsignComponent.GetCharacterAndRoleCallsign(characterCallsign, currentRoleCallsign);
396 if (currentRoleCallsign >= 0 && roleIndex !=
ERoleCallsign.SQUAD_LEADER)
400 if (
m_CallsignInfo.GetCharacterRoleCallsign(agent.GetControlledEntity(), -1,
m_Group, roleIndex, isUnique))
405 characterCallsignComponent.UpdateCharacterRoleCallsign(roleIndex);
421 roleReassigned =
true;
427 if (roleReassigned && currentRoleCallsign >= 0 && currentRoleCallsign != roleIndex)
432 override bool GetCallsignNames(out
string company, out
string platoon, out
string squad, out
string character, out
string format)
434 int companyCallsignIndex, platoonCallsignIndex, squadCallsignIndex, emptyCharacter;
435 character =
string.Empty;
437 if (!
GetCallsignIndexes(companyCallsignIndex, platoonCallsignIndex, squadCallsignIndex, emptyCharacter))
441 if (!SetCallsignInfo())
443 company = companyCallsignIndex.ToString();
444 platoon = platoonCallsignIndex.ToString();
445 squad = squadCallsignIndex.ToString();
447 format =
"ERROR %1-%2-%3";
452 company =
m_CallsignInfo.GetCompanyCallsignName(companyCallsignIndex);
453 platoon =
m_CallsignInfo.GetPlatoonCallsignName(platoonCallsignIndex);
463 characterNumber = -1;
465 if (m_iCompanyCallsign < 0 || m_iPlatoonCallsign < 0 || m_iSquadCallsign < 0)
473 companyIndex = m_iCompanyCallsign;
474 platoonIndex = m_iPlatoonCallsign;
475 squadIndex = m_iSquadCallsign;
484 if (!m_CallsignManager)
487 int company, platoon, squad;
503 if (company == m_iCompanyCallsign && m_iPlatoonCallsign == platoon && m_iSquadCallsign == squad)
506 m_iCompanyCallsign = company;
507 m_iPlatoonCallsign = platoon;
508 m_iSquadCallsign = squad;
510 Event_OnCallsignChanged.Invoke(m_iCompanyCallsign, m_iPlatoonCallsign, m_iSquadCallsign, -1, -1);
520 if (isFactionChange && faction ==
m_Faction)
530 if (!SetCallsignInfo())
536 if (!prevFaction || !m_CallsignManager)
541 Debug.Error2(
"SCR_CallsignGroupComponent",
"FactionInit when faction changed is called on a slave group. This is not supported as it will assign it's own group callsign seperate from the master group!");
545 if (m_iCompanyCallsign >= 0)
547 m_CallsignManager.MakeGroupCallsignAvailible(prevFaction, m_iCompanyCallsign, m_iPlatoonCallsign, m_iSquadCallsign);
557 if (!SetCallsignInfo())
563 if (m_iCompanyCallsign != -1 && m_iPlatoonCallsign != -1 && m_iSquadCallsign != -1)
569 array<AIAgent> agents = {};
570 SCR_CallsignCharacterComponent characterCallsignComponent;
575 array<int> availibleRandomCallsigns = {};
578 int count = agents.Count();
582 availibleRandomCallsigns.Insert(count);
588 foreach (AIAgent agent : agents)
590 characterCallsignComponent = SCR_CallsignCharacterComponent.Cast(agent.GetControlledEntity().FindComponent(SCR_CallsignCharacterComponent));
591 if (!characterCallsignComponent)
594 characterCallsignComponent.ClearCallsigns();
628 writer.WriteInt(m_iCompanyCallsign);
629 writer.WriteInt(m_iPlatoonCallsign);
630 writer.WriteInt(m_iSquadCallsign);
638 int company, platoon, squad;
640 reader.ReadInt(company);
641 reader.ReadInt(platoon);
642 reader.ReadInt(squad);
653 if (!m_bIsServer || m_iCompanyCallsign < 0 || !
m_Faction || !m_CallsignManager ||
m_bIsSlave)
656 m_CallsignManager.MakeGroupCallsignAvailible(
m_Faction, m_iCompanyCallsign, m_iPlatoonCallsign, m_iSquadCallsign);
void OnPlayerAddedToGroup(SCR_AIGroup aiGroup, int playerID)
void OnPlayerRemovedFromGroup(SCR_AIGroup aiGroup, int playerID)
override bool RplLoad(ScriptBitReader reader)
SCR_AIGroupSettingsComponentClass m_Group
enum EAIGroupCombatMode ComponentEditorProps(category:"GameScripted/AI", description:"Component for utility AI system for groups")
override void ClearCallsigns()
Called on server only before assigning new callsign to make sure everything is clear....
override bool GetCallsignNames(out string company, out string platoon, out string squad, out string character, out string format)
void AssignCallsignBroadcast(int company, int platoon, int squad, int character, int role, bool aloneInGroup)
override bool GetCallsignIndexes(out int companyIndex, out int platoonIndex, out int squadIndex, out int characterNumber=-1, out ERoleCallsign characterRole=ERoleCallsign.NONE)
void FactionInit(Faction faction, bool isFactionChange=false)
void ~SCR_CallsignGroupComponent()
bool IsUniqueRoleInUse(int roleToCheck)
void OnAIAddedToGroup(notnull AIAgent character)
void AssignGroupCallsign()
void OnAILeaderAssigned(AIAgent currentLeader, AIAgent prevLeader)
void ReplaceAILeaderRole(AIAgent currentLeader, AIAgent prevLeader)
ref map< int, int > m_mPlayerRoleCallsigns
Keeps track of specific AI role callsigns in group. map<RoleID, PlayerID>.
SCR_CallsignGroupComponent m_MasterGroupCallsignComponent
void AssignAICallsign(AIAgent character, SCR_CallsignCharacterComponent characterCallsignComponent, int characterCallsign=-1)
void OnFactionChanged(Faction faction)
ref map< int, int > m_mPlayerCallsigns
Keeps track of player callsigns in group <Callsign, PlayerID>. Player callsigns never change.
ref map< int, AIAgent > m_mAICallsigns
Keeps track of AI callsigns in group.
void AssignPlayerCallsign(int playerID, int characterCallsign=-1)
override void InitOnServer(IEntity owner)
ref map< int, AIAgent > m_mAIRoleCallsigns
Keeps track of specific AI role callsigns in group.
SCR_AIGroup m_MasterGroup
const int iLEADER_ROLE_CHARACTER_CALLSIGN
void UpdateAllCharacterRoleCallsigns()
void MakeAIRoleAvailable(int roleIndex)
SCR_CallsignGroupComponentClass m_bGroupInitCalled
Component of assigning and storing squad names.
void OnAIRemovedFromGroup(SCR_AIGroup group, AIAgent character)
void OnPlayerLeaderAssigned(int groupID, int playerID)
void DoAssignCallsign(int company, int platoon, int squad)
override bool RplSave(ScriptBitWriter writer)
ref SCR_FactionCallsignInfo m_CallsignInfo
Component of assigning and storing squad names.
static SCR_EditableEntityComponent GetEditableEntity(IEntity owner)
void RplRpc(RplChannel channel, RplRcver rcver, RplCondition condition=RplCondition.None, string customConditionName="")
RplChannel
Communication channel. Reliable is guaranteed to be delivered. Unreliable not.