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(
desc:
"Config of pairs of actions and commanding menu configs to decide which action opens which menu")]
11 [
Attribute(
"{2FFBD92174DDF3E0}Configs/Commanding/CommandingMapMenu.conf")]
42 protected static const float ABOVE_TERRAIN_OFFSET = 0.5;
45 protected static const float COMMANDING_VISUAL_RANGE = 10000;
50 static SCR_PlayerControllerCommandingComponent GetPlayerControllerCommandingComponent(
int playerID)
52 PlayerController playerController =
GetGame().GetPlayerManager().GetPlayerController(playerID);
53 if (!playerController)
56 return SCR_PlayerControllerCommandingComponent.Cast(playerController.FindComponent(SCR_PlayerControllerCommandingComponent));
61 static SCR_PlayerControllerCommandingComponent GetLocalPlayerControllerCommandingComponent()
64 if (!playerController)
67 return SCR_PlayerControllerCommandingComponent.Cast(playerController.FindComponent(SCR_PlayerControllerCommandingComponent));
73 super.OnPostInit(owner);
83 BaseContainer container = holder.GetResource().ToBaseContainer();
101 if (!actionConfigPair)
116 if (isChanging || becameOwner)
122 if (!actionConfigPair)
145 configPath = actionConfigPair.
GetConfig();
150 if (!holder || !holder.IsValid())
153 BaseContainer container = holder.GetResource().ToBaseContainer();
207 BaseGameMode gameMode =
GetGame().GetGameMode();
227 BaseGameMode gameMode =
GetGame().GetGameMode();
273 if (!holder || !holder.IsValid())
276 BaseContainer container = holder.GetResource().ToBaseContainer();
295 float height =
GetGame().GetWorld().GetSurfaceY(worldPos[0], worldPos[1]);
299 position[1] = height + ABOVE_TERRAIN_OFFSET;
310 SCR_PlayerControllerGroupComponent playerGroupController = SCR_PlayerControllerGroupComponent.GetLocalPlayerControllerGroupComponent();
311 if (!playerGroupController)
315 if (playerGroupController.GetGroupID() != groupID)
318 bool enabled = playerID ==
GetGame().GetPlayerController().GetPlayerId();
326 SCR_PlayerControllerGroupComponent playerGroupController = SCR_PlayerControllerGroupComponent.GetLocalPlayerControllerGroupComponent();
327 if (!playerGroupController)
334 SCR_AIGroup playersGroup = groupsManager.FindGroup(groupID);
381 if (commandName.IsEmpty())
388 if (!commandingManager)
414 vector screenPosition =
GetGame().GetWorkspace().ProjWorldToScreen(worldPosition, world, cameraIndex);
415 posX = screenPosition[0];
416 posY = screenPosition[1];
426 PlayerController controller =
GetGame().GetPlayerController();
431 IEntity controlledEntity = controller.GetControlledEntity();
434 camera.GetTransform(mat);
435 vector end = mat[3] + mat[2] * range;
436 array<IEntity> excludeArray = {};
437 excludeArray.Insert(controlledEntity);
440 if (playerCharacter && playerCharacter.IsInVehicle())
442 CompartmentAccessComponent compartmentComp = playerCharacter.GetCompartmentAccessComponent();
445 IEntity vehicleIn = compartmentComp.GetVehicleIn(playerCharacter);
447 excludeArray.Insert(vehicleIn);
463 entryId = entry.
GetId();
465 if (entryId ==
string.Empty)
511 if (targetPosition !=
vector.Zero)
543 if (!commandingManager)
548 SCR_PlayerControllerGroupComponent groupController = SCR_PlayerControllerGroupComponent.GetLocalPlayerControllerGroupComponent();
550 if (!groupController || !groupManager)
553 SCR_AIGroup playersGroup = groupManager.FindGroup(groupController.GetGroupID());
557 RplComponent rplComp;
560 rplComp = RplComponent.Cast(playersGroup.FindComponent(RplComponent));
561 groupController.RequestCreateSlaveGroup(rplComp.Id());
575 rplComp = RplComponent.Cast(slaveGroup.FindComponent(RplComponent));
576 RplId groupRplID = rplComp.Id();
577 RplId cursorTargetRplID;
585 cursorTargetRplID = rplComp.Id();
609 if (!commandingManager)
613 float soundEventSeed =
Math.RandomFloatInclusive(0, 1);
614 commandingManager.RequestCommandExecution(commandIndex, cursorTargetID, groupRplID, targetPoisition, playerID, soundEventSeed);
639 if (commandIndex <= 0)
645 if (mapEntity && mapEntity.
IsOpen())
654 IEntity playerControlledEntity =
GetGame().GetPlayerController().GetControlledEntity();
656 if (!playerControlledEntity)
660 if (!characterComponent)
663 if (characterComponent.IsWeaponADS())
666 characterComponent.TryStartCharacterGesture(gestureID, 3000);
698 array<ref SCR_PlayerCommandingMenuBaseElement> elements =
category.GetCategoryElements();
704 bool canThisCategoryBeShown;
711 if (!createdCategory)
715 if (!canThisCategoryBeShown)
718 rootCategory.RemoveEntry(createdCategory);
723 canBeShown = canThisCategoryBeShown || canBeShown;
742 array<ref SCR_PlayerCommandingMenuBaseElement> elements =
category.GetCategoryElements();
762 parentCategory.RemoveEntry(mapEntryCategory);
770 string iconName =
category.GetIconName();
771 if (mapEntryCategory && !imagesetName.IsEmpty() && !iconName.IsEmpty())
772 mapEntryCategory.SetIcon(imagesetName, iconName);
785 if (!commandingManager)
792 SCR_PlayerCommandingMenuCommand commandElement = SCR_PlayerCommandingMenuCommand.Cast(element);
793 if (!commandingManager.CanShowOnMap(commandElement.GetCommandName()))
801 mapEntry.SetName(commandingManager.GetCommandDisplayTextByName(commandElement.GetCommandName()));
805 mapEntry.Enable(canPerform);
820 SCR_PlayerCommandingMenuCommand commandElement = SCR_PlayerCommandingMenuCommand.Cast(newElement);
842 id = parentCategory.GetId() +
SCR_StringHelper.UNDERSCORE + parentCategory.GetEntries().Count().ToString();
846 newCategory.SetId(
id);
847 newCategory.SetName(
category.GetCategoryDisplayText());
850 string iconName =
category.GetIconName();
851 if (!imagesetName.IsEmpty() && !iconName.IsEmpty())
852 newCategory.SetIcon(imagesetName, iconName);
860 parentCategory.
AddEntry(newCategory);
873 if (!commandingManager)
880 if (!commandingManager.CanShowCommand(command.GetCommandName()))
887 string displayName = command.GetCommandCustomName();
888 if (displayName.IsEmpty())
889 displayName = commandingManager.GetCommandDisplayTextByName(command.GetCommandName());
900 entry.SetId(command.GetCommandName());
902 entry.Enable(canPerform && canExecute);
906 else if (!canExecute)
910 parentCategory.AddEntry(entry);
989 if (!commandEntry.IsEnabled())
997 if (!characterController)
1000 SCR_InventoryStorageManagerComponent storageManager = SCR_InventoryStorageManagerComponent.Cast(characterController.GetInventoryStorageManager());
1001 if (!storageManager)
1005 if (!characterStorage)
ArmaReforgerScripted GetGame()
InputManager GetInputManager()
void OnMapClose(MapConfiguration config)
void OnMapOpen(MapConfiguration config)
void SCR_CommandingManagerComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
enum SCR_ECompassType EntityEditorProps(category:"GameScripted/Gadgets", description:"Compass", color:"0 0 255 255")
Prefab data class for compass component.
void SCR_GroupsManagerComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
void CommandExecutedCallback(int commandIndex)
void RPC_CommandExecutedCallback(int commandIndex)
SCR_ECommandVisualizationDuration
@ BRIEF
shows the command visualization only for few seconds
@ LONGLASTING
shows the command visualization for as long as the command is active
@ PERMANENT
shows the command visualization permanently, use for debug purposes
void OnPlayerRadialMenuBeforeOpen()
void PhysicsCommandTrace(float range=COMMANDING_VISUAL_RANGE)
bool m_bIsCommandSelected
void RPC_RequestExecuteCommand(int commandIndex, RplId cursorTargetID, RplId groupRplID, vector targetPoisition, int playerID)
void OnGroupChanged(int groupID)
string m_sSelectedCommandEntry
void OnControllerTakeControl(SCR_RadialMenuController controller)
void PlayCommandGesture(int commandIndex)
void ExecuteCommand(vector targetPosition, IEntity tracedEntity)
void DrawWaypointVisualization(vector targetPosition, float wpRadius, bool deletePrevious=true)
void SetupPlayerRadialMenu()
ref SCR_PlayerCommandingMenuConfig m_CommandingMapMenuConfig
SCR_SelectionMenuEntry AddCommandElement(SCR_PlayerCommandingMenuCommand command, SCR_SelectionMenuCategoryEntry parentCategory=null)
ref SCR_RadialMenuController m_RadialMenuController
void ShowCommandPreview(string commandName)
void OnRadialMenuSelected(SCR_SelectionMenu menu, SCR_SelectionMenuEntry entry)
ref array< ref Shape > m_aShapes
void SetShownCommandPreview(SCR_InfoDisplayExtended infoDisplay)
void SetupMapRadialMenu()
SCR_InfoDisplayExtended m_CurrentShownCommandPreview
ref SCR_PhysicsHelper m_PhysicsHelper
void OnPlayerRadialMenuOpen()
void OnRadialMenuPerformed(SCR_SelectionMenu menu, SCR_SelectionMenuEntry entry)
bool AddElementsFromCategoryToMap(notnull SCR_PlayerCommandingMenuCategoryElement category, SCR_SelectionMenuCategoryEntry parentCategory=null)
SCR_MapMenuCommandingEntry InsertElementToMapRadial(SCR_PlayerCommandingMenuBaseElement element, notnull SCR_PlayerCommandingMenuCategoryElement category, SCR_SelectionMenuCategoryEntry mapCategory)
void OnControllerLostControl(SCR_RadialMenuController controller, bool hasControl)
void DeleteShownCommand()
If a command is currently being displayed, hide/delete it.
void BindToQuickslot(int slotIndex)
bool m_bIsCommandExecuting
void UpdateRadialMenu(IEntity owner, bool isOpen)
void PrepareExecuteCommand(string commandName, vector targetPosition="0 0 0")
void SetShownCommand(SCR_InfoDisplayExtended infoDisplay)
ResourceName m_sCommandingMapMenuConfigPath
SCR_MapRadialUI m_MapContextualMenu
void HideCommandPreview()
Hide command preview.
ref SCR_PlayerCommandingMenuActionsSetup m_CommandingMenuPairsConfig
bool m_bSlaveGroupRequested
bool AddElementsFromCategory(SCR_PlayerCommandingMenuCategoryElement category, SCR_SelectionMenuCategoryEntry rootCategory=null)
void OnRadialMenuOpenFailed(SCR_SelectionMenu menu, SCR_ESelectionMenuFailReason reason)
SCR_SelectionMenuEntry AddRadialMenuElement(SCR_PlayerCommandingMenuBaseElement newElement, SCR_SelectionMenuCategoryEntry parentCategory=null)
string m_sExecutedCommandName
void OnPlayerRadialMenuClose()
SCR_SelectionMenuEntry AddCategoryElement(SCR_PlayerCommandingMenuCategoryElement category, SCR_SelectionMenuCategoryEntry parentCategory=null)
void OnGroupLeaderChanged(int groupID, int playerID)
void RemoveListenersFromRadial()
SCR_RadialMenu m_RadialMenu
void OpenCommandingMenu()
ref SCR_PlayerCommandingMenuConfig m_CommandingMenuConfig
SCR_CommandingManagerComponent m_CommandingManager
void OnMapCommandPerformed(SCR_SelectionMenuEntry element, float[] worldPos)
SCR_InfoDisplayExtended m_CurrentShownCommand
bool GetWorldToScreenPosition(BaseWorld world, vector worldPosition, out float posX, out float posY, int cameraIndex=-1)
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
proto external int SetEventMask(notnull IEntity owner, int mask)
void Rpc(func method, void p0=NULL, void p1=NULL, void p2=NULL, void p3=NULL, void p4=NULL, void p5=NULL, void p6=NULL, void p7=NULL)
proto external Managed FindComponent(typename typeName)
Object holding reference to resource. In destructor release the resource.
Replication item identifier.
bool IsPlayerLeader(int playerID)
int GetCommandGestureID()
override void VisualizeCommandPreview(vector targetPosition)
bool CanBeExecuted(IEntity target)
LocalizedString GetCannotExecuteReason()
LocalizedString GetCannotPerformReason()
bool CanBePerformed(notnull SCR_ChimeraCharacter user)
ResourceName GetIconImageset()
void VisualizeCommand(vector targetPosition)
void InsertContainerIntoQuickslot(SCR_QuickslotBaseContainer container, int slotIndex)
static SCR_HUDManagerComponent GetHUDManager()
static ScriptInvokerBase< MapConfigurationInvoker > GetOnMapClose()
Get on map close invoker.
bool IsOpen()
Check if the map is opened.
static ScriptInvokerBase< MapConfigurationInvoker > GetOnMapOpen()
Get on map open invoker.
static SCR_MapEntity GetMapInstance()
Get map entity instance.
ScriptInvokerMenuEntryPerformed GetOnEntryPerformedInvoker()
static SCR_MapRadialUI GetInstance()
void SetCanUpdatePosition(bool canUpdate)
Commanding menus config to setup different menus to different keybinds.
Commanding menu base element class.
Commanding menu base element class.
Commanding menu config root.
static int GetLocalPlayerId()
Returns either a valid ID of local player or 0.
OnOwnershipChangedInvoker GetOnOwnershipChangedInvoker()
static IEntity GetLocalControlledEntity()
void SetCommandText(string text)
static void RefreshQuickSlots(int id=-1)
static SCR_WeaponSwitchingBaseUI GetWeaponSwitchingBaseUI()
proto external GenericEntity GetOwner()
Get owner entity.
CameraManagerClass GenericEntityClass CurrentCamera()
Returns the current camera.
SCR_FieldOfViewSettings Attribute
EntityEvent
Various entity events.
proto external PlayerController GetPlayerController()
proto external int GetPlayerId()
void OnOwnershipChanged(bool changing, bool becameOwner)
void RplRpc(RplChannel channel, RplRcver rcver, RplCondition condition=RplCondition.None, string customConditionName="")
RplChannel
Communication channel. Reliable is guaranteed to be delivered. Unreliable not.