2[
ComponentEditorProps(
category:
"GameScripted/Commander", description:
"Handles interactions for the faction Commander role. Should be attached to player controller.")]
17 [
Attribute(
"#AR-FactionCommander_TaskObjective",
desc:
"'Create objective' default text.",
category:
"Defaults")]
83 protected static int s_iLastGeneratedTaskId;
85 static const string TASK_ID =
"%1_Task_%2";
86 static const string REQUESTED_TASK_ID =
"%1_RequestedTask_%2";
121 static int GenerateTaskID()
123 return s_iLastGeneratedTaskId++;
127 static bool IsLocalPlayerCommander()
129 PlayerController pc =
GetGame().GetPlayerController();
134 SCR_Faction faction = SCR_Faction.Cast(
SCR_FactionManager.SGetPlayerFaction(pc.GetPlayerId()));
191 requestHandler.SetMenuEntry(handler.GetMenuEntry());
193 if (!disabledText.IsEmpty())
200 if (!iconName.IsEmpty())
202 if (imagesetName.IsEmpty())
205 entry.
SetIcon(imagesetName, iconName);
226 if (!disabledText.IsEmpty())
233 if (!iconName.IsEmpty())
235 if (imagesetName.IsEmpty())
238 entry.
SetIcon(imagesetName, iconName);
260 array<SCR_AIGroup> playableGroups = groupsManager.GetPlayableGroupsByFaction(faction);
276 if (!disabledText.IsEmpty())
283 if (!iconName.IsEmpty())
285 if (imagesetName.IsEmpty())
288 entry.
SetIcon(imagesetName, iconName);
494 if (mapFactionCommanderRadialMenu && !mapFactionCommanderRadialMenu.
GetCommanderMenuConfig(faction).IsEmpty())
507 array<ref SCR_FactionCommanderMenuEntry> entries = {};
510 foreach (
int index, SCR_FactionCommanderMenuEntry entry : entries)
512 if (entry.IsEnabled())
522 if (!mainCommandMenuHandler || !entry)
529 protected bool ShouldCategoryBeHidden(SCR_FactionCommanderMenuEntry configEntry, array<ref SCR_FactionCommanderMenuEntry> childEntries)
532 PlayerController pc =
GetGame().GetPlayerController();
541 if (configEntry.IsGroupOrder() || configEntry.IsSupportRequest())
544 foreach (
int index, SCR_FactionCommanderMenuEntry entry : childEntries)
546 if (!entry.IsGroupOrder() && !entry.IsSupportRequest())
561 PrintFormat(
"Faction Commander menu entry config '%1' is missing its handler class. Skipping...", configEntry.GetName(), level:
LogLevel.WARNING);
567 rootConfigEntry = configEntry;
575 string name = configEntry.GetName();
577 array<ref SCR_FactionCommanderMenuEntry> childEntries = {};
578 configEntry.GetEntries(childEntries);
580 if (!childEntries.IsEmpty() || configEntry.IsCategory() || configEntry.IsGroupOrder())
583 if (!childEntries.IsEmpty() || !configEntry.IsSupportRequest() || SCR_FactionCommanderPlayerComponent.IsLocalPlayerCommander())
604 if (!disabledText.IsEmpty())
607 string iconName = configEntry.GetIconName();
609 if (!iconName.IsEmpty())
610 entry.
SetIcon(configEntry.GetIconImageset(), iconName);
629 parentCategory = null;
631 string name = configEntry.GetName();
648 if (!disabledText.IsEmpty())
651 string iconName = configEntry.GetIconName();
653 if (!iconName.IsEmpty())
654 category.SetIcon(configEntry.GetIconImageset(), iconName);
661 if (configEntry.IsSupportRequest())
674 if (configEntry.IsGroupOrder())
677 foreach (SCR_FactionCommanderMenuEntry childEntry : childEntries)
679 if (childEntry.IsEnabled())
745 position[1] =
GetGame().GetWorld().GetSurfaceY(worldPos[0], worldPos[1]);
771 if (requesterGroupId == -1)
785 SCR_AIGroup requesterGroup = groupsManager.FindGroup(requesterGroupId);
800 string taskID =
string.Format(REQUESTED_TASK_ID, faction.GetFactionKey(), GenerateTaskID());
802 SCR_BaseRequestedTaskEntity
task = SCR_BaseRequestedTaskEntity.Cast(taskSystem.CreateTask(taskPrefab, taskID,
"",
"", destination, playerId));
809 taskSystem.SetTaskOwnership(
task, SCR_ETaskOwnership.EXECUTOR);
811 task.SetTaskRequesterId(requesterGroupId);
812 taskSystem.AddTaskFaction(
task, faction.GetFactionKey());
818 task.SetTaskName(taskUIInfo.GetName(), {SCR_MapEntity.GetGridLabel(destination)});
821 string company, platoon, squad, character, format;
822 requesterGroup.
GetCallsigns(company, platoon, squad, character, format);
823 task.SetTaskDescription(taskUIInfo.GetDescription(), {string.Format(format, company, platoon, squad)});
852 Faction faction =
GetGame().GetFactionManager().GetFactionByIndex(factionIndex);
863 string taskID =
string.Format(TASK_ID, faction.GetFactionKey(), GenerateTaskID());
865 SCR_Task task = taskSystem.CreateTask(taskPrefab, taskID,
"",
"", destination, playerId);
872 taskSystem.SetTaskOwnership(
task, SCR_ETaskOwnership.EXECUTOR);
874 taskSystem.AddTaskFaction(
task, faction.GetFactionKey());
880 task.SetTaskName(taskUIInfo.GetName(), {SCR_MapEntity.GetGridLabel(destination)});
902 PlayerController sender = PlayerController.Cast(
GetOwner());
910 array<string> taskOwnerFactionKeys =
task.GetOwnerFactionKeys();
911 if (!taskOwnerFactionKeys || !taskOwnerFactionKeys.Contains(faction.GetFactionKey()))
914 int senderPlayerId = sender.GetPlayerId();
941 PlayerController sender = PlayerController.Cast(
GetOwner());
949 array<string> taskOwnerFactionKeys =
task.GetOwnerFactionKeys();
950 if (!taskOwnerFactionKeys || !taskOwnerFactionKeys.Contains(faction.GetFactionKey()))
953 int senderPlayerId = sender.GetPlayerId();
956 SCR_BaseRequestedTaskEntity requestedTask = SCR_BaseRequestedTaskEntity.Cast(
task);
957 if (!requestedTask || !requestedTask.IsPlayerFromRequesterGroup(senderPlayerId))
960 SCR_PlayerControllerGroupComponent playerControllerGroupComponent = SCR_PlayerControllerGroupComponent.GetPlayerControllerComponent(senderPlayerId);
961 if (!playerControllerGroupComponent || !playerControllerGroupComponent.IsPlayerLeaderOwnGroup())
966 taskSystem.DeleteTask(
task);
989 PlayerController sender = PlayerController.Cast(
GetOwner());
997 array<string> taskOwnerFactionKeys =
task.GetOwnerFactionKeys();
998 if (!taskOwnerFactionKeys || !taskOwnerFactionKeys.Contains(faction.GetFactionKey()))
1005 taskSystem.DeleteTask(
task);
1045 if (!
task.GetOwnerFactionKeys() || !
task.GetOwnerFactionKeys().Contains(faction.GetFactionKey()))
1075 super.EOnInit(owner);
1083 RplComponent rpl = RplComponent.Cast(
m_PlayerController.FindComponent(RplComponent));
1087 if (rpl && rpl.IsOwner())
1094 super.OnPostInit(owner);
ArmaReforgerScripted GetGame()
RplMode
Mode of replication.
enum EAIGroupCombatMode ComponentEditorProps(category:"GameScripted/AI", description:"Component for utility AI system for groups")
SCR_EditableEntityComponent m_HoveredEntity
SCR_BaseGameMode GetGameMode()
SCR_CacheNoteComponentClass ScriptComponentClass RplProp()] protected ref array< string > m_aLines
override void OnEntryHovered(SCR_SelectionMenuEntry entry, int id)
Triggered when a radial menu entry is hovered on.
void OnRadialMenuBeforeOpen()
Called each time the radial menu is before open in the map.
override void ClearRadialMenu()
void OnMapClose(MapConfiguration config)
void OnMapOpen(MapConfiguration config)
void ProcessEvents(bool activate)
SCR_CharacterSoundComponentClass GetComponentData()
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
void SetNextVolunteeringTimestamp(int playerId, WorldTimestamp timestamp)
string GetRequestOrderEntryDisplayName()
Returns the display name to be shown in radial menu for the Request order category.
IEntity m_CurrentHoveredEntity
SCR_Task m_CurrentHoveredTask
void FinishTask(string taskId)
bool IsTaskValid(SCR_Task task)
WorldTimestamp m_ReplaceCommanderCooldown
void OnCommandPerformed(SCR_SelectionMenuEntry element, float[] worldPos)
Called when a radial menu action is triggered.
void AddCreateObjectiveOrder(SCR_SelectionMenuCategoryEntry category, notnull SCR_FactionCommanderBaseMenuHandler handler)
void CreateTask(ResourceName taskPrefab, vector position, SCR_AIGroup group, int playerId)
WorldTimestamp GetNextVolunteeringTimestamp()
ref map< SCR_SelectionMenuEntry, ref SCR_FactionCommanderBaseMenuHandler > m_mEntryHandlers
void GetRequestOrderEntryIconData(out ResourceName imagesetName, out string iconName)
Returns the imageset and icon name to be shown in radial menu for the Faction order category.
void OnContextualMenuInit()
Called when opening the radial menu for the first time after opening the map.
void OnTaskHovered(SCR_Task task)
string GetGroupEntryDisplayName(SCR_AIGroup group)
Returns the display name to be shown in radial menu for the given group.
void CreateRequestedTask(string taskPrefab, vector position, int requesterGroupId, SCR_AIGroup group, int playerId, SCR_FactionCommanderBaseMenuHandler handler=null)
void CreateConfigCategory(notnull SCR_FactionCommanderMenuEntry configEntry, SCR_SelectionMenuCategoryEntry parentCategory, notnull array< ref SCR_FactionCommanderMenuEntry > childEntries, SCR_FactionCommanderMenuEntry rootConfigEntry)
Creates a radial menu category from config data (SCR_FactionCommanderMenuEntry).
SCR_GroupTaskManagerComponent m_GroupTaskManager
void GetGroupEntryIconData(SCR_AIGroup group, out ResourceName imagesetName, out string iconName)
Returns the imageset and icon name to be shown in radial menu for the given group and category.
void CancelTask(string taskId)
string GetCreateObjectiveOrderEntryDisplayName()
Returns the display name to be shown in radial menu for the create objective order.
WorldTimestamp m_fNextVolunteeringAvailableAt
void OnCommanderRightsLost()
bool m_bShouldClearHoveredTask
void GetCreateObjectiveOrderEntryIconData(out ResourceName imagesetName, out string iconName)
Returns the imageset and icon name to be shown in radial menu for the create objective order.
void CreateConfigEntry(notnull SCR_FactionCommanderMenuEntry configEntry, SCR_SelectionMenuCategoryEntry parentCategory, SCR_FactionCommanderMenuEntry rootConfigEntry)
Creates a radial menu entry from config data SCR_FactionCommanderMenuEntry.
bool ShouldCategoryBeHidden(SCR_FactionCommanderMenuEntry configEntry, array< ref SCR_FactionCommanderMenuEntry > childEntries)
WorldTimestamp GetReplaceCommanderCooldownTimestamp()
ref map< SCR_SelectionMenuEntry, SCR_AIGroup > m_mEntryGroups
SCR_SelectionMenuEntry GetEntryByName(string name)
ref map< SCR_SelectionMenuEntry, SCR_SelectionMenuCategoryEntry > m_mEntryParents
ref map< SCR_SelectionMenuEntry, ref SCR_FactionCommanderMenuEntry > m_mTaskRootMenuEntries
void RpcAsk_CancelTask(string taskId)
void AddRequestOrder(SCR_SelectionMenuCategoryEntry category, notnull SCR_FactionCommanderBaseMenuHandler handler)
void RpcAsk_FinishTask(string taskId)
void OnRadialMenuClose()
Called each time the radial menu is closed in the map.
SCR_FactionCommanderPlayerComponentClass m_bMenuVisible
string GetDefaultRequestOrderIcon()
void OnCommanderRightsGained()
SCR_AIGroup GetAssignedGroup(SCR_SelectionMenuEntry entry)
Returns a group associated with given entry.
void RpcAsk_CreateTask(string taskPrefab, int assigneeId, int playerId, vector destination, int factionIndex)
ref map< string, SCR_SelectionMenuEntry > m_mEntryNames
void RpcAsk_AssignGroupToTask(int groupId, string taskId)
SCR_MapCursorModule m_MapCursorModule
void AssignGroupToTask(int groupId, string taskId)
void CreateConfigEntries()
Adds entries as defined in the hierarchy config (stored in SCR_Faction).
void RpcAsk_CreateRequestedTask(string taskPrefab, vector destination, int requesterGroupId, int assigneeId, int playerId)
void SetReplaceCommanderCooldownTimestamp(WorldTimestamp timeStamp)
void FillMenuWithGroups(SCR_SelectionMenuCategoryEntry category, notnull SCR_FactionCommanderBaseMenuHandler handler)
Adds all groups of Commander's faction under a given category as menu entries.
string GetDefaultCreateObjectiveOrderIcon()
SCR_FactionCommanderMenuEntry GetConfigForEntry(notnull SCR_SelectionMenuEntry entry)
string GetDefaultGroupOrderIcon()
void SCR_FactionManager(IEntitySource src, IEntity parent)
SCR_FastTravelComponentClass m_PlayerController
void SCR_GroupTaskManagerComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
void SCR_GroupsManagerComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
SCR_MapEntity m_MapEntity
SCR_MapRadialUI m_MapContextualMenu
SCR_RadialMenu m_RadialMenu
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
void SCR_Task(IEntitySource src, IEntity parent)
proto external int SetEventMask(notnull IEntity owner, int mask)
proto external GenericComponent FindComponent(typename typeName)
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)
Object holding reference to resource. In destructor release the resource.
void GetCallsigns(out string company, out string platoon, out string squad, out string character, out string format)
void SetMenuEntry(SCR_FactionCommanderMenuEntry menuEntry)
bool CanEntryBeSelected(notnull Faction commanderFaction, int playerId, vector position, IEntity hoveredEntity, out string disabledText="")
void OnCommandIssued(notnull Faction commanderFaction, int playerId, vector position, IEntity hoveredEntity, SCR_AIGroup group)
bool CanQuickEntryBeShown(notnull Faction commanderFaction, int playerId, vector position, IEntity hoveredEntity)
bool CanEntryBeShown(notnull Faction commanderFaction, int playerId, vector position, IEntity hoveredEntity)
bool CanRequestEntryBeSelected(notnull Faction commanderFaction, int playerId, vector position, IEntity hoveredEntity, out string disabledText="")
bool CanRequestEntryBeShown(notnull Faction commanderFaction, int playerId, vector position, IEntity hoveredEntity)
bool CanCreateObjectiveEntryBeShown(notnull Faction commanderFaction, int playerId, vector position, IEntity hoveredEntity)
bool CanCreateObjectiveEntryBeSelected(notnull Faction commanderFaction, int playerId, vector position, IEntity hoveredEntity, out string disabledText="")
void GetEntries(out notnull array< ref SCR_FactionCommanderMenuEntry > entries)
Handles interactions for the faction Commander role. Should be attached to player controller.
string GetStringCreateObjective()
string m_sCreateObjectiveOrderIcon
string GetStringRequest()
string m_sStringCreateObjective
string m_sRequestOrderIcon
string GetCreateObjectiveOrderIcon()
string GetGroupOrderIcon()
string GetRequestOrderIcon()
static Faction GetEntityFaction(notnull IEntity entity)
bool IsPlayerCommander(int playerId)
ResourceName GetCommanderMenuConfig()
static string GetTranslatedGroupNameAndRoleName(notnull SCR_AIGroup group)
SCR_MapModuleBase GetMapModule(typename moduleType)
static ScriptInvokerBase< MapConfigurationInvoker > GetOnMapClose()
Get on map close invoker.
SCR_MapUIBaseComponent GetMapUIComponent(typename componentType)
static ScriptInvokerBase< MapConfigurationInvoker > GetOnMapOpen()
Get on map open invoker.
static SCR_MapEntity GetMapInstance()
Get map entity instance.
Class for overriding commands on the map.
ResourceName GetCommanderMenuConfig(notnull Faction faction)
static SCR_MapRadialUI GetInstance()
static SCR_TaskManagerUIComponent GetInstance()
SCR_TaskHoveredInvoker GetOnTaskHovered()
proto external GenericEntity GetOwner()
Get owner entity.
void EOnInit(IEntity owner)
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
proto void PrintFormat(string fmt, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL, LogLevel level=LogLevel.NORMAL)
SCR_FieldOfViewSettings Attribute
EntityEvent
Various entity events.
void OnOwnershipChanged(bool changing, bool becameOwner)
void RplRpc(RplChannel channel, RplRcver rcver, RplCondition condition=RplCondition.None, string customConditionName="")
RplCondition
Conditional replication rule. Fine grained selection of receivers.
RplChannel
Communication channel. Reliable is guaranteed to be delivered. Unreliable not.