1 [
EntityEditorProps(
category:
"GameScripted/Commanding", description:
"This component should be attached to player controller and is used by commanding to send requests to server.")]
8 [
Attribute(
"{ECC45EC468D76CF4}Configs/Commanding/CommandingMenu.conf")]
9 protected ResourceName m_sCommandingMenuConfigPath;
11 [
Attribute(
"{2FFBD92174DDF3E0}Configs/Commanding/CommandingMapMenu.conf")]
33 protected static const float ABOVE_TERRAIN_OFFSET = 0.5;
36 protected static const float COMMANDING_VISUAL_RANGE = 10000;
41 static SCR_PlayerControllerCommandingComponent GetPlayerControllerCommandingComponent(
int playerID)
43 PlayerController playerController =
GetGame().GetPlayerManager().GetPlayerController(playerID);
44 if (!playerController)
47 return SCR_PlayerControllerCommandingComponent.Cast(playerController.FindComponent(SCR_PlayerControllerCommandingComponent));
52 static SCR_PlayerControllerCommandingComponent GetLocalPlayerControllerCommandingComponent()
55 if (!playerController)
58 return SCR_PlayerControllerCommandingComponent.Cast(playerController.FindComponent(SCR_PlayerControllerCommandingComponent));
64 super.OnPostInit(owner);
65 SetEventMask(owner, EntityEvent.INIT);
70 Resource holder = BaseContainerTools.LoadContainer(m_sCommandingMenuConfigPath);
71 BaseContainer container = holder.GetResource().ToBaseContainer();
92 controller.UpdateMenuData();
124 BaseGameMode gameMode =
GetGame().GetGameMode();
182 float height =
GetGame().GetWorld().GetSurfaceY(worldPos[0], worldPos[1]);
186 position[1] = height + ABOVE_TERRAIN_OFFSET;
198 SCR_PlayerControllerGroupComponent playerGroupController = SCR_PlayerControllerGroupComponent.GetLocalPlayerControllerGroupComponent();
199 if (!playerGroupController)
203 if (playerGroupController.GetGroupID() != groupID)
206 bool enabled = playerID ==
GetGame().GetPlayerController().GetPlayerId();
214 SCR_PlayerControllerGroupComponent playerGroupController = SCR_PlayerControllerGroupComponent.GetLocalPlayerControllerGroupComponent();
215 if (!playerGroupController)
222 SCR_AIGroup playersGroup = groupsManager.FindGroup(groupID);
244 SCR_NotificationsComponent.SendLocal(
ENotification.COMMANDING_NO_RIGHTS);
258 if (targetPosition != vector.Zero)
264 PlayerController controller =
GetGame().GetPlayerController();
269 IEntity controlledEntity = controller.GetControlledEntity();
272 camera.GetTransform(mat);
273 vector end = mat[3] + mat[2] * COMMANDING_VISUAL_RANGE;
281 m_PhysicsHelper.TraceSegmented(mat[3], end, TraceFlags.ENTS | TraceFlags.WORLD | TraceFlags.ANY_CONTACT, EPhysicsLayerDefs.Projectile, controlledEntity);
298 if (!commandingManager)
303 SCR_PlayerControllerGroupComponent groupController = SCR_PlayerControllerGroupComponent.GetLocalPlayerControllerGroupComponent();
305 if (!groupController || !groupManager)
308 SCR_AIGroup playersGroup = groupManager.FindGroup(groupController.GetGroupID());
312 RplComponent rplComp;
315 rplComp = RplComponent.Cast(playersGroup.FindComponent(RplComponent));
316 groupController.RequestCreateSlaveGroup(rplComp.Id());
330 rplComp = RplComponent.Cast(slaveGroup.FindComponent(RplComponent));
331 RplId groupRplID = rplComp.Id();
332 RplId cursorTargetRplID;
340 cursorTargetRplID = rplComp.Id();
353 [
RplRpc(RplChannel.Reliable, RplRcver.Server)]
357 if (!commandingManager)
360 commandingManager.RequestCommandExecution(commandIndex, cursorTargetID, groupRplID, targetPoisition ,playerID);
374 [
RplRpc(RplChannel.Reliable, RplRcver.Owner)]
385 if (commandIndex <= 0)
391 if (mapEntity && mapEntity.IsOpen())
398 int gestureID = command.GetCommandGestureID();
400 IEntity playerControlledEntity =
GetGame().GetPlayerController().GetControlledEntity();
402 if (!playerControlledEntity)
406 if (!characterComponent)
409 characterComponent.TryStartCharacterGesture(gestureID, 3000);
440 array<ref SCR_PlayerCommandingMenuBaseElement> elements =
category.GetCategoryElements();
451 if (!createdCategory)
468 array<ref SCR_PlayerCommandingMenuBaseElement> elements =
category.GetCategoryElements();
477 if (elementCategory.GetCanShowOnMap())
495 if (!commandingManager)
499 if (!commandingManager.CanShowOnMap(commandElement.GetCommandName()))
505 mapEntry.SetName(commandElement.GetCommandDisplayText());
507 mapEntry.SetIcon(command.GetIconImageset(), command.GetIconName());
540 newCategory.SetName(
category.GetCategoryDisplayText());
548 parentCategory.AddEntry(newCategory);
561 if (!commandingManager)
564 if (!commandingManager.CanShowCommand(command.GetCommandName()))
571 string displayName = command.GetCommandCustomName();
572 if (displayName.IsEmpty())
573 displayName = command.GetCommandDisplayText();
575 entry.SetName(displayName);
576 entry.SetId(command.GetCommandName());
577 entry.SetIcon(groupCommand.GetIconImageset(), groupCommand.GetIconName());
578 entry.Enable(groupCommand.CanBePerformed());
581 parentCategory.AddEntry(entry);