9 [
Attribute(
"{000CD338713F2B5A}Prefabs/AI/Groups/Group_Base.et")]
10 protected ResourceName m_sAIGroupPrefab;
12 [
Attribute(
"{54764D4E706F348B}Configs/Commanding/Commands.conf")]
15 [
Attribute(defvalue:
"8", UIWidgets.EditBox,
desc:
"How many AI soldiers can be recruited into single player group")]
23 protected ref map<string, ref SCR_BaseRadialCommand>
m_mNameCommand =
new map<string, ref SCR_BaseRadialCommand>();
38 return m_sAIGroupPrefab;
55 super.OnPostInit(owner);
88 PlayerController pc =
GetGame().GetPlayerManager().GetPlayerController(playerId);
93 SCR_PlayerControllerGroupComponent groupComponent = SCR_PlayerControllerGroupComponent.Cast(pc.FindComponent(SCR_PlayerControllerGroupComponent));
94 if (!groupComponent || !groupComponent.IsPlayerLeaderOwnGroup())
101 SCR_AIGroup masterGroup = groupsManager.GetPlayerGroup(playerId);
107 if (!slaveGroup || slaveGroup.GetAgentsCount() <= 0)
111 array<AIWaypoint> currentWaypoints = {};
112 slaveGroup.GetWaypoints(currentWaypoints);
113 foreach (AIWaypoint currentwp : currentWaypoints)
115 slaveGroup.RemoveWaypoint(currentwp);
118 AIFormationComponent slaveGroupFormationComp = slaveGroup.GetFormationComponent();
119 if (slaveGroupFormationComp)
120 slaveGroupFormationComp.SetFormationDisplacement(0);
123 slaveGroup.SetMaster(
null);
126 if (!commandingManager)
130 Resource groupPrefabRes = Resource.Load(commandingManager.GetGroupPrefab());
131 if (!groupPrefabRes.IsValid())
134 IEntity groupEntity =
GetGame().SpawnEntityPrefab(groupPrefabRes);
143 RplComponent RplComp = RplComponent.Cast(newSlaveGroup.FindComponent(RplComponent));
147 RplId slaveGroupRplID = RplComp.Id();
149 RplComp = RplComponent.Cast(masterGroup.FindComponent(RplComponent));
153 groupsManager.RequestSetGroupSlave(RplComp.Id(), slaveGroupRplID);
177 [
RplRpc(RplChannel.Reliable, RplRcver.Broadcast)]
178 void RPC_DoExecuteCommand(
int commandIndex, RplId cursorTargetID, RplId groupRplID, vector targetPosition,
int playerID)
180 RplComponent rplComp;
181 IEntity cursorTarget, group;
182 rplComp = RplComponent.Cast(Replication.FindItem(cursorTargetID));
184 cursorTarget = rplComp.GetEntity();
186 rplComp = RplComponent.Cast(Replication.FindItem(groupRplID));
188 group = rplComp.GetEntity();
190 rplComp = RplComponent.Cast(
GetOwner().FindComponent(RplComponent));
194 if (command.Execute(cursorTarget, group, targetPosition, playerID, rplComp.IsProxy()))
197 if (!rplComp.IsMaster())
200 PlayerController controller =
GetGame().GetPlayerManager().GetPlayerController(playerID);
204 SCR_PlayerControllerCommandingComponent commandingComp = SCR_PlayerControllerCommandingComponent.Cast(controller.FindComponent(SCR_PlayerControllerCommandingComponent));
208 commandingComp.CommandExecutedCallback(commandIndex);
219 SCR_ChimeraCharacter playerCharacter = SCR_ChimeraCharacter.Cast(
GetGame().GetPlayerManager().GetPlayerControlledEntity(playerID));
220 if (!playerCharacter)
223 SignalsManagerComponent signalManager = SignalsManagerComponent.Cast(playerCharacter.FindComponent(SignalsManagerComponent));
227 SCR_CommunicationSoundComponent soundComponent = SCR_CommunicationSoundComponent.Cast(playerCharacter.FindComponent(SCR_CommunicationSoundComponent));
232 if (soundEventName.IsEmpty())
235 int signalSoldierCalled = signalManager.FindSignal(
"SoldierCalled");
237 signalManager.SetSignalValue(signalSoldierCalled, 1000);
274 return groupCommand.GetSoundEventName();
287 return command.GetCommandName();
300 return command.CanBeShown();
313 return command.CanShowOnMap();
327 BaseContainer container = holder.GetResource().ToBaseContainer();