1[
EntityEditorProps(
category:
"GameScripted/Groups", description:
"This component should be attached to player controller and is used by groups to send requests to server.")]
25 protected static const ref
Color DEFAULT_COLOR =
new Color(0, 0, 0, 0.4);
30 static SCR_PlayerControllerGroupComponent GetPlayerControllerComponent(
int playerID)
32 PlayerController playerController =
GetGame().GetPlayerManager().GetPlayerController(playerID);
33 if (!playerController)
36 return SCR_PlayerControllerGroupComponent.Cast(playerController.FindComponent(SCR_PlayerControllerGroupComponent));
41 static SCR_PlayerControllerGroupComponent GetLocalPlayerControllerGroupComponent()
44 if (!playerController)
47 return SCR_PlayerControllerGroupComponent.Cast(playerController.FindComponent(SCR_PlayerControllerGroupComponent));
124 PlayerController playerController = PlayerController.Cast(
GetOwner());
125 if (!playerController)
128 return playerController.GetPlayerId();
149 Faction groupFaction = group.GetFaction();
152 #ifdef DEPLOY_MENU_DEBUG
153 Print(
string.Format(
"SCR_PlayerControllerGroupComponent.CanPlayerJoinGroup(%1, %2) - No group faction", playerID, group),
LogLevel.ERROR);
159 if (playerFaction != groupFaction)
161 #ifdef DEPLOY_MENU_DEBUG
162 Print(
string.Format(
"SCR_PlayerControllerGroupComponent.CanPlayerJoinGroup(%1, %2) - Faction mis-match! See, below:", playerID, group),
LogLevel.ERROR);
211 #ifdef DEPLOY_MENU_DEBUG
212 Print(
string.Format(
"SCR_PlayerControllerGroupComponent.CanPlayerJoinGroup(%1, %2) - No SCR_GroupsManagerComponent!", playerID, group),
LogLevel.ERROR);
222 if (groupsManager.GetPlayerGroup(playerID) == group)
224 #ifdef DEPLOY_MENU_DEBUG
225 Print(
string.Format(
"SCR_PlayerControllerGroupComponent.CanPlayerJoinGroup(%1, %2) - Already in group!", playerID, group),
LogLevel.ERROR);
231 if (scrPlayerFaction)
241 return groupsManager.HasPlayerRequiredRank(groupPreset, playerID,
true);
258 Faction playerFaction = factionManager.GetPlayerFaction(playerID);
262 Faction groupFaction = group.GetFaction();
263 if (playerFaction != groupFaction)
266 if (SCR_FactionCommanderHandlerComponent.GetInstance())
274 if (!scrFaction || !group.IsCreatedByCommander() || scrFaction.
GetCommanderId() != playerID)
285 if (group.GetPlayerCount() > 0)
298 return playerID == group.GetLeaderID();
315 int playerID = controller.GetPlayerId();
316 SCR_AIGroup playerGroup = groupManager.GetPlayerGroup(playerID);
536 SCR_NotificationsComponent.SendToPlayer(group.
GetLeaderID(),
ENotification.GROUPS_REQUEST_JOIN_PRIVATE_GROUP, playerID);
550 SCR_AIGroup group = groupManager.FindGroup(groupID);
554 PlayerController playerController =
GetGame().GetPlayerManager().GetPlayerController(playerID);
555 if (!playerController)
558 SCR_PlayerControllerGroupComponent playerComponent = SCR_PlayerControllerGroupComponent.Cast(playerController.FindComponent(SCR_PlayerControllerGroupComponent));
560 playerComponent.RequestJoinGroup(group.
GetGroupID());
564 SCR_NotificationsComponent.SendToPlayer(playerID,
ENotification.GROUPS_REQUEST_ACCEPTED);
578 SCR_AIGroup group = groupManager.FindGroup(groupID);
585 SCR_NotificationsComponent.SendToPlayer(playerID,
ENotification.GROUPS_REQUEST_DENIED);
613 PlayerController invitedPlayer =
GetGame().GetPlayerManager().GetPlayerController(playerID);
617 SCR_PlayerControllerGroupComponent invitedPlayerGroupComponent = SCR_PlayerControllerGroupComponent.Cast(invitedPlayer.FindComponent(SCR_PlayerControllerGroupComponent));
618 if (!invitedPlayerGroupComponent)
621 SocialComponent socialComp = SocialComponent.Cast(invitedPlayer.FindComponent(SocialComponent));
624 PlayerController inviterComponent = PlayerController.Cast(
GetOwner());
625 if (inviterComponent && socialComp.IsRestricted(inviterComponent.GetPlayerId(),
EUserInteraction.Invitation))
635 if (groupPreset && !groupsManager.HasPlayerRequiredRank(groupPreset, playerID,
true))
667 if (groupsManager.TryFindEmptyGroup(faction))
675 SCR_AIGroup newGroup = groupsManager.CreateNewPlayableGroup(faction);
700 Faction faction = factionManager.GetPlayerFaction(playerId);
708 array<SCR_EGroupRole> availableGroupRoles = groupsManager.GetAvailableGroupRoles(faction, playerId);
709 if (!availableGroupRoles || !availableGroupRoles.Contains(groupRole))
716 SCR_AIGroup newGroup = groupsManager.CreateNewPlayableGroup(faction, groupRole);
722 array<SCR_GroupRolePresetConfig> groupRolePresetConfigs = {};
726 if (preset && preset.GetGroupRole() == groupRole)
728 preset.SetupGroup(newGroup);
729 preset.SetupGroupFlag(newGroup, scrFaction);
763 SCR_PlayerControllerGroupComponent playerGroupController;
773 array<SCR_AIGroup> playableGroups = groupsManager.GetPlayableGroupsByFaction(group.
GetFaction());
774 foreach (
SCR_AIGroup groupInstance : playableGroups)
778 playerGroupController.RequestJoinGroup(groupInstance.GetGroupID());
786 newGroup = groupsManager.CreateNewPlayableGroup(group.
GetFaction());
790 playerGroupController.RequestJoinGroup(newGroup.
GetGroupID());
800 SCR_PlayerControllerGroupComponent playerGroupController;
819 SCR_PlayerControllerGroupComponent playerGroupController;
824 groupsManager.SetPrivateGroup(group.
GetGroupID(), isPrivate);
887 groupIDAfter = groupsManager.AddPlayerToGroup(groupID,
GetPlayerID());
926 groupsManager.DeleteGroupDelayed(group);
951 SCR_AIGroup group = groupsManager.FindGroup(groupID);
955 groupsManager.DeleteGroupDelayed(group);
971 playerGroupController = SCR_PlayerControllerGroupComponent.GetPlayerControllerComponent(playerID);
972 if (!playerGroupController)
975 group = groupsManager.GetPlayerGroup(playerID);
1121 SCR_AIGroup group = groupsManager.FindGroup(groupID);
1138 SCR_AIGroup group = groupsManager.FindGroup(groupID);
1159 SCR_AIGroup group = groupsManager.FindGroup(groupID);
1181 SCR_AIGroup group = groupsManager.FindGroup(groupID);
1197 if (!groupsManager || isAllowed == groupsManager.GetNewGroupsAllowed())
1209 if (!groupsManager || isAllowed == groupsManager.GetNewGroupsAllowed())
1237 SCR_AIGroup group = groupsManager.FindGroup(groupID);
1251 if (!groupsManager || isAllowed == groupsManager.GetNewGroupsAllowed())
1254 groupsManager.SetNewGroupsAllowed(isAllowed);
1264 if (!groupsManager || isAllowed == groupsManager.GetNewGroupsAllowed())
1267 groupsManager.SetCanPlayersChangeAttributes(isAllowed);
1281 SCR_AIGroup group = groupsManager.FindGroup(groupID);
1293 int foundGroupsWithFrequency = 0;
1296 array<SCR_AIGroup> existingGroups = groupsManager.GetPlayableGroupsByFaction(groupFaction);
1298 foreach (
SCR_AIGroup checkedGroup: existingGroups)
1300 if (checkedGroup.GetRadioFrequency() == formerFrequency)
1301 foundGroupsWithFrequency++;
1305 if (foundGroupsWithFrequency <= 1)
1306 groupsManager.ReleaseFrequency(formerFrequency, groupFaction);
1309 if (!groupsManager.IsFrequencyClaimed(frequency, groupFaction))
1310 groupsManager.ClaimFrequency(frequency, groupFaction);
1337 SCR_AIGroup group = groupsManager.FindGroup(groupID);
1381 if (!commandingManager)
1395 RplComponent slaveRplComp = RplComponent.Cast(group.FindComponent(RplComponent));
1399 groupManager.RequestSetGroupSlave(rplCompID, slaveRplComp.Id());
1415 array<SCR_AIGroup> groups = groupManager.GetPlayableGroupsByFaction(faction);
1419 if (group.IsAIControlledCharacterMember(character))
1432 RplComponent rplComp = RplComponent.Cast(character.FindComponent(RplComponent));
1447 SCR_PlayerControllerGroupComponent playerGroupController;
1452 RplComponent rplComp = RplComponent.Cast(
Replication.FindItem(characterID));
1456 SCR_ChimeraCharacter character = SCR_ChimeraCharacter.Cast(rplComp.GetEntity());
1480 if (!slaveGroup.IsAIActivated())
1481 slaveGroup.ActivateAI();
1485 RplId groupCompID, characterCompID;
1486 RplComponent rplComp = RplComponent.Cast(slaveGroup.FindComponent(RplComponent));
1490 groupCompID = rplComp.Id();
1491 rplComp = RplComponent.Cast(controlledEntity.FindComponent(RplComponent));
1492 characterCompID = rplComp.Id();
1494 groupManager.AskAddAiMemberToGroup(groupCompID, characterCompID);
1505 SCR_PlayerControllerGroupComponent playerGroupController;
1510 RplComponent rplComp = RplComponent.Cast(
Replication.FindItem(characterID));
1514 SCR_ChimeraCharacter character = SCR_ChimeraCharacter.Cast(rplComp.GetEntity());
1539 if (slaveGroup.GetAgentsCount() == 1)
1540 slaveGroup.Deactivate();
1544 RplId groupCompID, characterCompID;
1545 RplComponent rplComp = RplComponent.Cast(slaveGroup.FindComponent(RplComponent));
1546 groupCompID = rplComp.Id();
1547 rplComp = RplComponent.Cast(controlledEntity.FindComponent(RplComponent));
1551 characterCompID = rplComp.Id();
1553 groupManager.AskRemoveAiMemberFromGroup(groupCompID, characterCompID);
1562 RplComponent rplComp = RplComponent.Cast(character.FindComponent(RplComponent));
1572 PlayerController playerController =
GetGame().GetPlayerManager().GetPlayerController(playerID);
1573 if (!playerController)
1576 SCR_VoterComponent votingComponent = SCR_VoterComponent.Cast(playerController.FindComponent(SCR_VoterComponent));
1577 if (!votingComponent)
1580 votingComponent.Vote(
EVotingType.GROUP_LEADER, playerID);
1597 SCR_AIGroup playerGroup = groupsManager.GetPlayerGroup(playerID);
1621 SCR_AIGroup playerGroup = groupsManager.GetPlayerGroup(playerID);
1654 SCR_AIGroup playerGroup = groupsManager.GetPlayerGroup(playerID);
1665 if (!rplIdTransportUnitComponent.IsValid())
1670 baseCallsign =
base.GetCallsign();
1679 if (!rplIdTransportUnitComponent.IsValid())
1693 super.OnPostInit(owner);
1702 ConnectToDiagSystem(owner);
1704 groupsManager.GetOnPlayableGroupRemoved().Insert(
OnGroupDeleted);
1711 DisconnectFromDiagSystem(owner);
1714 super.OnDelete(owner);
1749 DbgUI.Begin(
"Groups");
1755 faction = factionManager.GetPlayerFaction(playerID);
1759 DbgUI.Text(
"Groups do not support factionless players now!!");
1766 DbgUI.Text(
"Your Faction:" + faction.GetFactionKey());
1769 DbgUI.Text(
"Playable groups of your faction:");
1773 DbgUI.Text(
"Your group:");
1774 SCR_AIGroup group = groupsManager.GetPlayerGroup(playerID);
1777 DbgUI.Text(
"." + group.ToString());
1782 if (
DbgUI.Button(
"Create and join group for my faction"))
1795 array<SCR_AIGroup> groups = groupsManager.GetPlayableGroupsByFaction(faction);
1798 DbgUI.Text(
"No groups for your faction!!");
1804 DbgUI.Text(group.ToString());
1818 SCR_AIGroup group = groupsManager.GetFirstNotFullForFaction(faction, null,
true);
1825 if (!usePredefinedData)
ArmaReforgerScripted GetGame()
bool IsPlayerLeader(int playerID)
void RemoveRallyPoint()
Removes current group Rally Point.
void SetGroupLeader(int playerID)
Called on the server (authority).
SCR_BaseGameMode GetGameMode()
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.
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
SCR_EGroupRole
Group roles.
override int GetPlayerID()
void SetRallyPoint(notnull SCR_EntityLabelPointComponent labelComp)
void SCR_FactionManager(IEntitySource src, IEntity parent)
void SCR_GameModeCampaign(IEntitySource src, IEntity parent)
void SCR_GroupsManagerComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
void RPC_AskInvitePlayer(int playerID)
void RPC_CancelJoinPrivateGroup(int playerID, int groupID)
void RequestSetCustomGroupName(int groupID, string name)
void RPC_ConfirmJoinPrivateGroup(int playerID, int groupID)
ScriptInvoker GetOnInviteAccepted()
int GetGroupInviteIdFromIndex(int index)
ref map< int, ref array< int > > m_mPlayerInvitesToGroups
void CreateAndJoinGroup(Faction faction, bool usePredefinedData=false)
int GetPlayerIdFromGroupInvite(int groupId)
void ResetGroupIDs_S()
Resets the Group ID and Selected Group ID of the player, currently only called after the player has s...
void RemoveGroupInviteId(int groupId)
void OnGroupDeleted(SCR_AIGroup group)
bool IsPlayerLeaderOwnGroup()
void RequestCreateGroup()
void RequestCreateSlaveGroup(RplId rplCompID)
bool CanPlayerRemoveGroup(int playerID, notnull SCR_AIGroup group)
void RPC_ChangePrivateGroup(int playerID, bool isPrivate)
void RequestCreateGroupWithData(SCR_EGroupRole groupRole, bool isPrivate, string name, string description, bool joinGroup=true, bool deleteIfNoPlayer=true)
void SetSelectedGroupID(int groupID)
void RPC_AskCreateGroup()
void SetTransportUnitSourceBase(notnull SCR_TransportUnitComponent transportUnit, SCR_CampaignMilitaryBaseComponent base)
void RpcAsk_SetRallyPoint(int playerID, int callsignId, bool force)
void RequestRemovePlayer(int playerID)
void RPC_PlayerRequestToJoinPrivateGroup(int playerID, RplId groupID)
ref ScriptInvokerInt m_OnSetSelectedGroupID
ScriptInvokerInt GetOnSetSelectedGroupID()
void RPC_AskSetCustomName(int groupID, string name, int authorID)
SCR_AIGroup GetPlayersGroup()
void RPC_AskSetFrequency(int groupID, int frequency)
void ClearAllRequesters(RplId groupID)
void RPC_AskSetGroupFlag(int groupID, int flagIndex, bool isFromImageset)
void PlayerRequestToJoinPrivateGroup(int playerID, RplId groupID)
void RequestRemoveAgent(SCR_ChimeraCharacter character, int playerID)
void RPC_AskJoinGroup(int groupID)
ScriptInvoker GetOnGroupChanged()
ref map< int, int > m_mGroupIdInvites
bool CanInvitePlayer(int playerID)
void RPC_AskSetCanPlayersChangeAttributes(bool isAllowed)
void RequestPromoteLeader(int playerID)
void RequestSetGroupMaxMembers(int groupID, int maxMembers)
void RPC_AskKickPlayer(int playerID)
void RequestSetCanPlayersChangeAttributes(bool isAllowed)
void AcceptJoinPrivateGroup(int playerID, bool accept)
void RpcAsk_RemoveGroup(int groupID)
ref ScriptInvoker< int > m_OnInviteAccepted
void RPC_DoChangeGroupID(int groupID)
ref ScriptInvoker< int > m_OnGroupChanged
ScriptInvoker GetOnInviteReceived()
bool CanPlayerJoinGroup(int playerID, notnull SCR_AIGroup group)
string GetGroupInviteFromPlayerName()
void RequestSetCustomGroupDescription(int groupID, string desc)
void RPC_AskRemoveAIAgent(RplId characterID, int playerID)
void RpcAsk_RemoveRallyPoint(int playerID)
void InviteThisPlayer(int groupID, int fromPlayerID)
void RpcDo_SetGroupLeader(int playerID)
void RequestKickPlayer(int playerID)
void RPC_AskSetGroupMaxMembers(int groupID, int maxMembers)
void RequestJoinGroup(int groupID)
void RPC_DoInvitePlayer(int groupID, int fromPlayerID)
ScriptInvoker GetOnInviteCancelled()
void RequestPrivateGroupChange(int playerID, bool isPrivate)
void RequestSetCustomFrequency(int groupID, int frequency)
ref ScriptInvoker< int > m_OnInviteCancelled
int GetActualGroupFrequency()
void RPC_AskSetNewGroupsAllowed(bool isAllowed)
void OnGroupChangedDelayed(int groupId)
bool WasAlreadyInvited(int playerID)
void RpcAsk_CreateGroupWithData(SCR_EGroupRole groupRole, bool isPrivate, string name, string description, bool joinGroup, bool deleteIfNoPlayer)
void RequestSetGroupFlag(int groupID, int flagIndex, bool isFromImageset)
void RPC_AskAddAIAgent(RplId characterID, int playerID)
bool InitiateComponents(int playerID, out SCR_GroupsManagerComponent groupsManager, out SCR_PlayerControllerGroupComponent playerGroupController, out SCR_AIGroup group)
void RequestGroupLeaderVote(int playerID)
ref ScriptInvoker< int, int > m_OnInviteReceived
bool HasInviteFromGroup(int groupId)
string m_sGroupInviteFromPlayerName
void AddAIToSlaveGroup(notnull IEntity controlledEntity, SCR_AIGroup group)
void RPC_AskSetCustomDescription(int groupID, string desc, int authorID)
void ListGroupsFromFaction(Faction faction)
void RpcDo_AskSetTransportUnitSourceBase(int baseCallsign, RplId rplIdTransportUnitComponent)
void RPC_AskPromoteLeader(int playerID)
void RPC_AskCreateSlaveGroup(RplId rplCompID)
void RequestRemoveGroup(int groupID)
void RequestAddAIAgent(SCR_ChimeraCharacter character, int playerID)
void SetCustomNameAndDescription(SCR_AIGroup group, string name, string description, int playerId)
void RPC_DoResetGroupIDs()
void RpcAsk_RemovePlayer(int playerID)
void RPC_ClearAllRequesters(RplId groupID)
void InvitePlayer(int playerID)
void RemoveAiFromSlaveGroup(notnull IEntity controlledEntity, SCR_AIGroup group)
void RequestSetNewGroupsAllowed(bool isAllowed)
bool IsAICharacterInAnyGroup(SCR_ChimeraCharacter character, SCR_Faction faction)
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
ScriptInvokerBase< ScriptInvokerIntMethod > ScriptInvokerInt
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.
Replication item identifier.
void AddDeniedRequester(int playerID)
void RemovePlayer(int playerID)
Called on the server (authority).
int GetPlayerCount(bool checkMasterAndSlaves=false)
bool IsPlayerLeader(int playerID)
void RemoveRequester(int playerID)
SCR_EGroupRole GetGroupRole()
void SetCustomDescription(string desc, int authorID)
called on server only
void SetCustomName(string name, int authorID)
void SetCreatedByCommander(bool isCreatedByCommander)
void AddAgentFromControlledEntity(notnull IEntity controlledEntity)
void SetRadioFrequency(int frequency)
void SetPrivate(bool isPrivate)
Called on the server (authority).
void SetRallyPoint(notnull SCR_MilitaryBaseComponent base, bool force=false)
void SetGroupFlag(int flagIndex, bool isFromImageset)
called on server only
void SetMaxMembers(int maxMembers)
called on server only
void SetCanDeleteIfNoPlayer(bool deleteEmpty)
Sets if the group should be deleted when all players leave.
static ScriptInvoker GetOnJoinPrivateGroupConfirm()
void RemoveAgentFromControlledEntity(notnull IEntity controlledEntity)
void AddRequester(int playerID)
void ClearDeniedRequester()
void RemoveRallyPoint()
Removes current group Rally Point.
static bool DeLocalizeText(out string input)
void SetGroupLeader(int playerID)
Called on the server (authority).
void SetDeleteWhenEmpty(bool deleteWhenEmpty)
Created in SCR_GameModeCampaign.
SCR_CampaignMilitaryBaseComponent FindBaseByCallsign(int callsign)
bool GetCanCreateOnlyPredefinedGroups()
void GetGroupRolePresetConfigs(notnull array< SCR_GroupRolePresetConfig > groupArray)
SCR_EGroupRole GetDefaultGroupRoleForNewGroup()
static int GetLocalPlayerId()
Returns either a valid ID of local player or 0.
void SetSourceBase(SCR_CampaignMilitaryBaseComponent sourceBase)
proto external GenericEntity GetOwner()
Get owner entity.
IEntity GetOwner()
Owner entity of the fuel tank.
override void EOnDiag(IEntity owner, float timeSlice)
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)
proto external PlayerController GetPlayerController()
EUserInteraction
Interaction type between two players.
void RplRpc(RplChannel channel, RplRcver rcver, RplCondition condition=RplCondition.None, string customConditionName="")
RplChannel
Communication channel. Reliable is guaranteed to be delivered. Unreliable not.