Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_GroupsManagerComponent.c
Go to the documentation of this file.
1 typedef set<Faction> FactionHolder;
2 
3 [EntityEditorProps(category: "GameScripted/Groups", description: "Player groups manager, attach to game mode entity!.")]
5 {
6 }
7 
9 {
10  [Attribute()]
11  protected ResourceName m_sDefaultGroupPrefab;
12 
13  [Attribute("1000")]
15 
16  [Attribute("38000")]
18 
19  [Attribute("54000")]
21 
22  [Attribute("Flags", UIWidgets.ResourcePickerThumbnail, "Flag icon of this particular group.", params: "edds")]
23  private ref array<ResourceName> m_aGroupFlags;
24 
25  //this is changed only localy and doesnt replicate
26  protected bool m_bConfirmedByPlayer;
27 
28  protected bool m_bNewGroupsAllowed = true;
29  protected bool m_bCanPlayersChangeAttributes = true;
30 
31  protected static SCR_GroupsManagerComponent s_Instance;
32 
33 #ifdef DEBUG_GROUPS
34  static Widget s_wDebugLayout;
35 #endif
36 
37  protected ref ScriptInvoker m_OnPlayableGroupCreated = new ScriptInvoker();
38  protected ref ScriptInvoker m_OnPlayableGroupRemoved = new ScriptInvoker();
39  protected ref ScriptInvoker m_OnNewGroupsAllowedChanged = new ScriptInvoker();
40  protected ref ScriptInvoker m_OnCanPlayersChangeAttributeChanged = new ScriptInvoker();
41  protected int m_iLatestGroupID = 0;
42  protected ref map<Faction, ref array<SCR_AIGroup>> m_mPlayableGroups = new map<Faction, ref array<SCR_AIGroup>>();
43  protected ref map<Faction, int> m_mPlayableGroupFrequencies = new map<Faction, int>();
44  protected ref map<int, ref FactionHolder> m_mUsedFrequenciesMap = new map<int, ref FactionHolder>();
45  protected ref array<SCR_AIGroup> m_aDeletionQueue = {};
46  protected int m_iMovingPlayerToGroupID = -1;
47 
48  //------------------------------------------------------------------------------------------------
51  {
52  return s_Instance;
53  }
54 
55  //------------------------------------------------------------------------------------------------
57  void GetGroupFlags(notnull array<ResourceName> targetArray)
58  {
59  targetArray.Copy(m_aGroupFlags);
60  }
61 
62  //------------------------------------------------------------------------------------------------
64  ScriptInvoker GetOnPlayableGroupCreated()
65  {
67  }
68 
69  protected bool IsProxy()
70  {
71  RplComponent rplComponent = RplComponent.Cast(GetOwner().FindComponent(RplComponent));
72  if (!rplComponent)
73  return false;
74 
75  return rplComponent.IsProxy();
76  }
77 
78  //------------------------------------------------------------------------------------------------
84  int MovePlayerToGroup(int playerID, int previousGroupID, int newGroupID)
85  {
86  m_iMovingPlayerToGroupID = newGroupID;
87  SCR_AIGroup previousGroup = FindGroup(previousGroupID);
88  if (previousGroup)
89  previousGroup.RemovePlayer(playerID);
90 
91  SCR_AIGroup newGroup = FindGroup(newGroupID);
92  if (newGroup)
93  {
94  if (newGroup.IsFull())
95  {
97  return -1;
98  }
99 
100  newGroup.AddPlayer(playerID);
102  return newGroupID;
103  }
104  else
105  {
107  return -1;
108  }
109  }
110 
111  //------------------------------------------------------------------------------------------------
115  void ClearRequests(int groupID, int playerID)
116  {
117  SCR_PlayerControllerGroupComponent playerGroupController = SCR_PlayerControllerGroupComponent.GetLocalPlayerControllerGroupComponent();
118  if (!playerGroupController)
119  return;
120 
121  SCR_AIGroup group = FindGroup(groupID);
122  if (!group)
123  return;
124 
125  RplId groupRplID = Replication.FindId(group);
126 
127  array<int> requesterIDs = {};
128  group.GetRequesterIDs(requesterIDs);
129 
130  for (int i = 0, count = requesterIDs.Count(); i < count; i++)
131  {
132  if(!group.IsPlayerInGroup(playerID))
133  SCR_NotificationsComponent.SendToPlayer(requesterIDs[i], ENotification.GROUPS_REQUEST_CANCELLED);
134  }
135 
136  playerGroupController.ClearAllRequesters(groupRplID);
137  }
138 
139  //------------------------------------------------------------------------------------------------
144  int AddPlayerToGroup(int groupID, int playerID)
145  {
146  SCR_AIGroup group = FindGroup(groupID);
147  if (!group)
148  return -1;
149 
150  if (group.IsFull())
151  return -1;
152 
153  group.AddPlayer(playerID);
154  return groupID;
155  }
156 
157  //------------------------------------------------------------------------------------------------
160  {
161  //if(IsProxy()) // TO DO: Commented out coz of initial replication
162  // return;
163 
164  FactionManager factionManager = GetGame().GetFactionManager();
165  if (!factionManager)
166  return;
167 
168  SCR_GroupsManagerComponent groupManager = SCR_GroupsManagerComponent.GetInstance();
169  if (!groupManager)
170  return;
171 
172  array<Faction> factions = {};
173 
174  factionManager.GetFactionsList(factions);
175 
176  foreach (Faction faction : factions)
177  {
178  SCR_Faction scrFaction = SCR_Faction.Cast(faction);
179  if (!scrFaction)
180  return;
181 
182  array<ref SCR_GroupPreset> groups = {};
183 
184  scrFaction.GetPredefinedGroups(groups);
185 
186  foreach (SCR_GroupPreset gr : groups)
187  {
188  SCR_AIGroup newGroup = CreateNewPlayableGroup(faction);
189  if (!newGroup)
190  continue;
191 
192  newGroup.SetCanDeleteIfNoPlayer(false);
193 
194  gr.SetupGroup(newGroup);
195 
196  if (newGroup.GetGroupFlag().IsEmpty())
197  newGroup.SetGroupFlag(0, !scrFaction.GetGroupFlagImageSet().IsEmpty());
198  }
199  }
200  }
201 
202  //------------------------------------------------------------------------------------------------
205  //------------------------------------------------------------------------
206  void SetGroupLeader(int groupID, int playerID)
207  {
208  SCR_AIGroup group = FindGroup(groupID);
209  if (!group)
210  return;
211  group.SetGroupLeader(playerID);
212  }
213 
214  //------------------------------------------------------------------------------------------------
216  void SetNewGroupsAllowed(bool isAllowed)
217  {
218  if (isAllowed == m_bNewGroupsAllowed)
219  return;
220 
221  RPC_DoSetNewGroupsAllowed(isAllowed);
222  Rpc(RPC_DoSetNewGroupsAllowed, isAllowed);
223  }
224 
225  //------------------------------------------------------------------------------------------------
228  [RplRpc(RplChannel.Reliable, RplRcver.Broadcast)]
229  void RPC_DoSetNewGroupsAllowed(bool isAllowed)
230  {
231  if (isAllowed == m_bNewGroupsAllowed)
232  return;
233 
234  m_bNewGroupsAllowed = isAllowed;
236  }
237 
238  //------------------------------------------------------------------------------------------------
240  void SetCanPlayersChangeAttributes(bool isAllowed)
241  {
242  if (isAllowed == m_bCanPlayersChangeAttributes)
243  return;
244 
246  Rpc(RPC_SetCanPlayersChangeAttributes, isAllowed);
247  }
248 
249  //------------------------------------------------------------------------------------------------
252  [RplRpc(RplChannel.Reliable, RplRcver.Broadcast)]
254  {
255  if (isAllowed == m_bCanPlayersChangeAttributes)
256  return;
257 
258  m_bCanPlayersChangeAttributes = isAllowed;
260  }
261 
262  //------------------------------------------------------------------------------------------------
265  //------------------------------------------------------------------------
266  void SetPrivateGroup(int groupID, bool isPrivate)
267  {
268  SCR_AIGroup group = FindGroup(groupID);
269  if (!group)
270  return;
271  group.SetPrivate(isPrivate);
272  }
273 
274  //------------------------------------------------------------------------------------------------
278  //------------------------------------------------------------------------
279  SCR_AIGroup FindGroup(int groupID)
280  {
281  array<SCR_AIGroup> groups;
282  GetAllPlayableGroups(groups);
283 
284  for (int i = groups.Count() - 1; i >= 0; i--)
285  {
286  if (groups[i].GetGroupID() == groupID)
287  return groups[i];
288  }
289 
290  return null;
291  }
292 
293  //------------------------------------------------------------------------------------------------
295  //------------------------------------------------------------------------
297  {
299  }
300 
301  //------------------------------------------------------------------------------------------------
303  //------------------------------------------------------------------------
305  {
307  }
308 
309  //------------------------------------------------------------------------------------------------
311  //------------------------------------------------------------------------
313  {
315  }
316 
317  //------------------------------------------------------------------------------------------------
320  //------------------------------------------------------------------------
321  // Returns group by player id
323  {
324  SCR_FactionManager factionManager = SCR_FactionManager.Cast(GetGame().GetFactionManager());
325  if (!factionManager)
326  return null;
327 
328  Faction faction = factionManager.GetPlayerFaction(playerID);
329  if (!faction)
330  return null;
331 
332  array<SCR_AIGroup> playableGroups = GetPlayableGroupsByFaction(faction);
333  if (!playableGroups)
334  return null;
335 
336  for (int i = playableGroups.Count() - 1; i >= 0; i--)
337  {
338  if (playableGroups[i] && playableGroups[i].IsPlayerInGroup(playerID))
339  return playableGroups[i];
340  }
341 
342  return null;
343  }
344 
345  //------------------------------------------------------------------------------------------------
349  //------------------------------------------------------------------------
350  bool IsPlayerInAnyGroup(int playerID)
351  {
352  array<SCR_AIGroup> playableGroups;
353  GetAllPlayableGroups(playableGroups);
354  for (int i = playableGroups.Count() - 1; i >= 0; i--)
355  {
356  if (playableGroups[i].IsPlayerInGroup(playerID))
357  return true;
358  }
359 
360  return false;
361  }
362 
363 #ifdef DEBUG_GROUPS
364 
365  //------------------------------------------------------------------------------------------------
367  //------------------------------------------------------------------------
368  void UpdateDebugUI()
369  {
370  if (!s_wDebugLayout)
371  s_wDebugLayout = GetGame().GetWorkspace().CreateWidgets("{661C199F3D59BB24}UI/layouts/Debug/Groups.layout");
372 
373  VerticalLayoutWidget groupsLayout = VerticalLayoutWidget.Cast(s_wDebugLayout.FindAnyWidget("GroupsLayout"));
374  if (!groupsLayout)
375  return;
376 
377  //Clear entries
378  while (groupsLayout.GetChildren())
379  {
380  groupsLayout.GetChildren().RemoveFromHierarchy();
381  }
382 
383  array<SCR_AIGroup> playableGroups = GetAllPlayableGroups();
384  for (int i = playableGroups.Count() - 1; i >= 0; i--)
385  {
386  Widget groupEntry = GetGame().GetWorkspace().CreateWidgets("{898A1945FD29FC71}UI/layouts/Debug/GroupsGroupEntry.layout", groupsLayout);
387  RichTextWidget groupName = RichTextWidget.Cast(groupEntry.FindAnyWidget("GroupName"));
388  if (groupName)
389  groupName.SetText(playableGroups[i].GetGroupID().ToString() + ": " + playableGroups[i].GetCallsignSingleString());
390 
391  array<int> playerIDs = playableGroups[i].GetPlayerIDs();
392  int playersCount = playerIDs.Count();
393 
394  for (int j = 0; j < playersCount; j++)
395  {
396  HorizontalLayoutWidget characterEntry = HorizontalLayoutWidget.Cast(groupEntry.GetWorkspace().CreateWidgets("{952C36C11AF74465}UI/layouts/Debug/GroupsCharacterEntry.layout", groupEntry));
397  TextWidget playerNameWidget = TextWidget.Cast(characterEntry.FindAnyWidget("CharacterName"));
398  if (!playerNameWidget)
399  continue;
400 
401  playerNameWidget.SetText(GetGame().GetPlayerManager().GetPlayerName(playerIDs[j]));
402  }
403  }
404  }
405 #endif
406 
407  //------------------------------------------------------------------------------------------------
410  array<SCR_AIGroup> GetPlayableGroupsByFaction(Faction faction)
411  {
412  return m_mPlayableGroups.Get(faction);
413  }
414 
415  //------------------------------------------------------------------------------------------------
417  void GetAllPlayableGroups(out array<SCR_AIGroup> outAllGroups)
418  {
419  array<SCR_AIGroup> allGroups = {};
420  array<SCR_AIGroup> currentGroups = {};
421  for (int i = m_mPlayableGroups.Count() - 1; i >= 0; i--)
422  {
423  currentGroups = m_mPlayableGroups.GetElement(i);
424 
425  for (int j = currentGroups.Count() - 1; j >= 0; j--)
426  {
427  if (currentGroups[j])
428  allGroups.Insert(currentGroups[j]);
429  }
430  }
431 
432  outAllGroups = allGroups;
433  }
434 
435  //------------------------------------------------------------------------------------------------
436  protected void AssignGroupFrequency(notnull SCR_AIGroup group)
437  {
438  int frequency = 0;
439  Faction groupFaction = group.GetFaction();
440 
441  frequency = GetFreeFrequency(groupFaction);
442  if (frequency == -1)
443  return;
444 
445  ClaimFrequency(frequency, groupFaction);
446  group.SetRadioFrequency(frequency);
447  }
448 
449  //------------------------------------------------------------------------------------------------
453  {
454  m_aDeletionQueue.Insert(group);
455  SetEventMask(GetOwner(), EntityEvent.FRAME);
456  }
457 
458  //------------------------------------------------------------------------------------------------
461  void OnGroupPlayerRemoved(SCR_AIGroup group, int playerID)
462  {
463  // This script should only run on the server
464  if (IsProxy())
465  return;
466 
467  // Is empty?
468  if (group.GetPlayerCount() > 0)
469  return;
470 
471  //Can this group exist empty?
472  if (!group.GetDeleteIfNoPlayer())
473  {
474  if (group.IsPrivate())
475  group.SetPrivate(false);
476 
477  return;
478  }
479 
480  // Yes, can we delete it?
481  array<SCR_AIGroup> playableGroups = GetPlayableGroupsByFaction(group.GetFaction());
482  if (!playableGroups)
483  return;
484 
485  DeleteGroupDelayed(group);
486  }
487 
488  //------------------------------------------------------------------------------------------------
491  void OnGroupPlayerAdded(SCR_AIGroup group, int playerID)
492  {
493  if (IsProxy())
494  return;
495 
496  // Is group full?
497  if (group.GetPlayerCount() < group.GetMaxMembers())
498  return; // Group not full, we don't have to make any new groups
499 
500  // Group was full, we need to see if we have any other not full group
501  Faction faction = group.GetFaction();
502  if (!faction)
503  return;
504 
505  SCR_Faction scrFaction = SCR_Faction.Cast(faction);
506  if (!scrFaction)
507  return;
508 
509  array<SCR_AIGroup> groups = GetPlayableGroupsByFaction(faction);
510  if (!groups)
511  return;
512 
513  // No groups found for faction?
514  int groupsCount = groups.Count();
515  if (groupsCount == 0 && !scrFaction.GetCanCreateOnlyPredefinedGroups())
516  {
517  // Anyway we create a new one
518  CreateNewPlayableGroup(faction);
519  return;
520  }
521 
522  for (int i = groupsCount - 1; i >= 0; i--)
523  {
524  // We are checking for full groups if at least one group is not full, we return, we don't have to create new one
525  if (groups[i].GetPlayerCount() < group.GetMaxMembers())
526  return;
527  }
528 
529  // All the groups were full, create new one
530  if (!scrFaction.GetCanCreateOnlyPredefinedGroups())
531  CreateNewPlayableGroup(faction);
532  }
533 
534  //------------------------------------------------------------------------------------------------
536  private BaseRadioComponent GetCommunicationDevice(notnull IEntity controlledEntity)
537  {
538  SCR_GadgetManagerComponent gagdetManager = SCR_GadgetManagerComponent.Cast(controlledEntity.FindComponent(SCR_GadgetManagerComponent));
539  if (!gagdetManager)
540  return null;
541 
542  IEntity radio = gagdetManager.GetGadgetByType(EGadgetType.RADIO); //variable purpose = debug
543  if (!radio)
544  return null;
545 
546  return BaseRadioComponent.Cast(radio.FindComponent(BaseRadioComponent));
547  }
548 
549  //------------------------------------------------------------------------
550  private void TuneAgentsRadio(AIAgent agentEntity)
551  {
552  if (!agentEntity)
553  return;
554 
555  SCR_AIGroup group = SCR_AIGroup.Cast(agentEntity.GetParentGroup());
556  if (!group)
557  return;
558 
559  BaseRadioComponent radio = GetCommunicationDevice(agentEntity.GetControlledEntity());
560 
561  if (!radio)
562  return;
563 
564  BaseTransceiver tsv = radio.GetTransceiver(0);
565  if (!tsv)
566  return;
567 
568  tsv.SetFrequency(group.GetRadioFrequency());
569  }
570 
571  //------------------------------------------------------------------------------------------------
573  void OnGroupAgentAdded(AIAgent child)
574  {
575  GetGame().GetCallqueue().CallLater(TuneAgentsRadio, 1, false, child);
576  }
577 
578  //------------------------------------------------------------------------------------------------
581  void OnGroupAgentRemoved(SCR_AIGroup group, AIAgent child)
582  {
583  return; //For now we don't delete empty groups
584 
585  if (!group)
586  return;
587 
588  // Is group empty?
589  if (group.GetAgentsCount() > 0)
590  return;
591 
592  // Group is empty, can we delete it?
593  Faction faction = group.GetFaction();
594  if (!faction)
595  return;
596 
597  array<SCR_AIGroup> groups = GetPlayableGroupsByFaction(faction);
598  if (!groups)
599  return;
600 
601  // No groups found for faction?
602  int groupsCount = groups.Count();
603  if (groupsCount == 0)
604  return;
605 
606  // If we find any other group, which is empty, we delete this group
607  for (int i = groupsCount - 1; i >= 0; i--)
608  {
609  if (groups[i] == group)
610  continue;
611 
612  if (groups[i].GetAgentsCount() == 0)
613  {
615  return;
616  }
617  }
618  }
619 
620  //------------------------------------------------------------------------------------------------
624  {
625  m_OnPlayableGroupRemoved.Invoke(group);
626  UnregisterGroup(group);
627  delete group;
628  }
629 
630  //------------------------------------------------------------------------------------------------
633  void UnregisterGroup(notnull SCR_AIGroup group)
634  {
635  Faction faction = group.GetFaction();
636  if (!faction)
637  return;
638 
639  array<SCR_AIGroup> groups = GetPlayableGroupsByFaction(faction);
640  if (!groups)
641  return;
642 
643  int frequency = group.GetRadioFrequency();
644  int foundGroupsWithFrequency = 0;
645  array<SCR_AIGroup> existingGroups = {};
646 
647  existingGroups = GetPlayableGroupsByFaction(faction);
648  if (existingGroups)
649  {
650  foreach (SCR_AIGroup checkedGroup: existingGroups)
651  {
652  if (checkedGroup && checkedGroup.GetRadioFrequency() == frequency)
653  foundGroupsWithFrequency++;
654  }
655  }
656 
657  //if there is only our group with this frequency or none, release it before changing our frequency
658  if (foundGroupsWithFrequency <= 1)
659  ReleaseFrequency(frequency, faction);
660 
661  SCR_AIGroup slaveGroup = group.GetSlave();
662 
663  //in case the slave group doesnt have any AIs in it, delete
664  //mourTodo: handle what the AIs should do in case their master group is deleted
665  if (slaveGroup && slaveGroup.GetAgentsCount() <= 0)
666  delete slaveGroup;
667 
668  if (groups.Find(group) >= 0)
669  groups.RemoveItem(group);
670  }
671 
672  //------------------------------------------------------------------------------------------------
676  {
677  array<SCR_AIGroup> groups;
678  if (!m_mPlayableGroups.Find(group.GetFaction(), groups))
679  {
680  // No array found, let's make one
681  groups = {};
682  m_mPlayableGroups.Insert(group.GetFaction(), groups);
683  }
684 
685  if (groups.Find(group) < 0)
686  groups.Insert(group);
687 
688  group.GetOnAgentAdded().Insert(OnGroupAgentAdded);
689  group.GetOnAgentRemoved().Insert(OnGroupAgentRemoved);
690  }
691 
692  //------------------------------------------------------------------------------------------------
696  [RplRpc(RplChannel.Reliable, RplRcver.Broadcast)]
697  void RPC_DoSetGroupFaction(RplId groupID, int factionIndex)
698  {
699  FactionManager factionManager = GetGame().GetFactionManager();
700  if (!factionManager)
701  return;
702 
703  Faction faction = factionManager.GetFactionByIndex(factionIndex);
704  if (!faction)
705  return;
706 
707  SCR_AIGroup group = SCR_AIGroup.Cast(Replication.FindItem(groupID));
708  if (group)
709  group.SetFaction(faction);
710  }
711 
712  //------------------------------------------------------------------------------------------------
713  protected void AssignGroupID(SCR_AIGroup group)
714  {
715  group.SetGroupID(m_iLatestGroupID);
717  }
718 
719  //------------------------------------------------------------------------------------------------
721  void OnPlayerFactionChanged(notnull FactionAffiliationComponent owner, Faction previousFaction, Faction newFaction)
722  {
723  if (!newFaction)
724  return;
725 
726  SCR_Faction scrFaction = SCR_Faction.Cast(newFaction);
727  if (!scrFaction)
728  return;
729  if (scrFaction.GetCanCreateOnlyPredefinedGroups())
730  return;
731 
732  SCR_AIGroup newPlayerGroup = GetFirstNotFullForFaction(newFaction);
733  if (!newPlayerGroup)
734  newPlayerGroup = CreateNewPlayableGroup(newFaction);
735 
736  //group creation can fail
737  if (!newPlayerGroup || !owner)
738  return;
739 
740  PlayerController controller = PlayerController.Cast(owner.GetOwner());
741  if (!controller)
742  return;
743 
744  SCR_PlayerControllerGroupComponent groupComp = SCR_PlayerControllerGroupComponent.Cast(controller.FindComponent(SCR_PlayerControllerGroupComponent));
745  if (!groupComp)
746  return;
747 
748  SCR_AIGroup oldGroup = FindGroup(groupComp.GetGroupID());
749  if (!oldGroup)
750  return;
751 
752  oldGroup.RemovePlayer(controller.GetPlayerId());
753  }
754 
755  //------------------------------------------------------------------------------------------------
758  {
759  m_OnPlayableGroupCreated.Invoke(group);
760  }
761 
762  //------------------------------------------------------------------------------------------------
767  {
768  array<SCR_AIGroup> factionGroups = GetPlayableGroupsByFaction(faction);
769  if (!factionGroups)
770  return null;
771 
772  for (int i = factionGroups.Count() - 1; i >= 0; i--)
773  {
774  if (!factionGroups[i])
775  return null;
776 
777  if (factionGroups[i].GetPlayerCount() == 0)
778  return factionGroups[i];
779  }
780 
781  return null;
782  }
783 
784  //------------------------------------------------------------------------------------------------
789  {
790  RplComponent rplComp = RplComponent.Cast(GetOwner().FindComponent(RplComponent));
791  if (!rplComp)
792  return null;
793  // TO DO: Commented out coz of initial replication
794 
795  //bool isMaster = rplComp.IsMaster();
796  //if (!rplComp.IsMaster()) // TO DO: Commented out coz of initial replication
797  // return null;
798 
799  Resource groupResource = Resource.Load(m_sDefaultGroupPrefab);
800  if (!groupResource.IsValid())
801  return null;
802 
803  SCR_AIGroup group = SCR_AIGroup.Cast(GetGame().SpawnEntityPrefab(groupResource, GetOwner().GetWorld()));
804  if (!group)
805  return null;
806 
807  group.DeactivateAI();
808 
809  group.SetFaction(faction);
810  RegisterGroup(group);
811  AssignGroupFrequency(group);
812  AssignGroupID(group);
813 
814  //if there is commanding present, we create the slave group for AIs at the creation of the group
815  SCR_CommandingManagerComponent commandingManager = SCR_CommandingManagerComponent.GetInstance();
816  if (commandingManager)
817  {
818  IEntity groupEntity = GetGame().SpawnEntityPrefab(Resource.Load(commandingManager.GetGroupPrefab()));
819  if (!groupEntity)
820  return null;
821 
822  SCR_AIGroup slaveGroup = SCR_AIGroup.Cast(groupEntity);
823  if (!slaveGroup)
824  return null;
825 
826  slaveGroup.DeactivateAI();
827 
828  RplComponent RplComp = RplComponent.Cast(slaveGroup.FindComponent(RplComponent));
829  if (!RplComp)
830  return null;
831 
832  RplId slaveGroupRplID = RplComp.Id();
833 
834  RplComp = RplComponent.Cast(group.FindComponent(RplComponent));
835  if (!RplComp)
836  return null;
837 
838  RequestSetGroupSlave(RplComp.Id(), slaveGroupRplID);
839  }
840 
841  m_OnPlayableGroupCreated.Invoke(group);
842 
843 #ifdef DEBUG_GROUPS
844  GetGame().GetCallqueue().CallLater(UpdateDebugUI, 1, false);
845 #endif
846 
847  return group;
848  }
849 
850  //------------------------------------------------------------------------------------------------
855  SCR_AIGroup GetFirstNotFullForFaction(notnull Faction faction, SCR_AIGroup ownGroup = null, bool respectPrivate = false)
856  {
857  SCR_AIGroup group;
858  array<SCR_AIGroup> factionGroups = GetPlayableGroupsByFaction(faction);
859  if (!factionGroups)
860  return group;
861 
862  for (int i = 0, count = factionGroups.Count(); i < count; i++)
863  {
864  if (!factionGroups[i].IsFull() && factionGroups[i] != ownGroup && (!respectPrivate || !factionGroups[i].IsPrivate()))
865  {
866  group = factionGroups[i];
867  break;
868  }
869  }
870 
871  return group;
872  }
873 
874  //------------------------------------------------------------------------------------------------
878  bool CanCreateNewGroup(notnull Faction newGroupFaction)
879  {
880  SCR_Faction scrFaction = SCR_Faction.Cast(newGroupFaction);
881 
882  SCR_AIGroup playerGroup = GetPlayerGroup(SCR_PlayerController.GetLocalPlayerId());
883 
884  //disable creation of new group if player is the last in his group as there is no reason to create new one
885  if (playerGroup && playerGroup.GetPlayerCount() == 1)
886  return false;
887 
888  if (!m_bNewGroupsAllowed)
889  return false;
890 
891  FactionHolder factions = new FactionHolder();
892  if (GetFreeFrequency(newGroupFaction) == -1)
893  return false;
894 
895  if (TryFindEmptyGroup(newGroupFaction))
896  return false;
897 
898  if (scrFaction.GetCanCreateOnlyPredefinedGroups())
899  return false;
900  return true;
901  }
902 
903  //------------------------------------------------------------------------------------------------
907  {
909  }
910 
911  //------------------------------------------------------------------------------------------------
914  int GetFreeFrequency(Faction frequencyFaction)
915  {
916  FactionHolder usedForFactions = new FactionHolder();
917 
918  int factionHQFrequency; // Don't assign this frequency to any of the groups
919  SCR_Faction militaryFaction = SCR_Faction.Cast(frequencyFaction);
920  if (militaryFaction)
921  factionHQFrequency = militaryFaction.GetFactionRadioFrequency();
922 
923  int minFrequencyAvailable = m_iPlayableGroupFrequencyMin;
924 
925  while (minFrequencyAvailable <= m_iPlayableGroupFrequencyMax)
926  {
927  if (minFrequencyAvailable == factionHQFrequency)
928  {
929  minFrequencyAvailable += m_iPlayableGroupFrequencyOffset;
930  continue; // We cannot assign this frequency to any group, it is used by the factions HQ
931  }
932 
933  if (!m_mUsedFrequenciesMap.Find(minFrequencyAvailable, usedForFactions))
934  break; // No assigned frequencies for this faction yet
935 
936  if (usedForFactions.Find(frequencyFaction) == -1)
937  break; // Unused frequency found
938 
939  minFrequencyAvailable += m_iPlayableGroupFrequencyOffset;
940  }
941 
942  if (minFrequencyAvailable <= m_iPlayableGroupFrequencyMax)
943  return minFrequencyAvailable;
944 
945  Print("Ran out of frequencies for groups", LogLevel.WARNING);
946  return -1;
947 
948  }
949 
950  //------------------------------------------------------------------------------------------------
954  void ClaimFrequency(int frequency, Faction faction)
955  {
956  FactionHolder usedForFactions = new FactionHolder();
957  FactionHolder factions = new FactionHolder();
958 
959  if (!m_mUsedFrequenciesMap.Find(frequency, usedForFactions))
960  {
961  factions.Insert(faction);
962  m_mUsedFrequenciesMap.Insert(frequency, factions);
963  return;
964  }
965  if (usedForFactions.Find(faction) == -1)
966  {
967  usedForFactions.Insert(faction);
968  }
969  }
970 
971  //------------------------------------------------------------------------------------------------
976  bool IsFrequencyClaimed(int frequency, Faction faction)
977  {
978  FactionHolder usedForFactions = new FactionHolder();
979  if (!m_mUsedFrequenciesMap.Find(frequency, usedForFactions))
980  return false;
981 
982  if (usedForFactions.Find(faction))
983  return true;
984 
985  return false;
986  }
987 
988  //------------------------------------------------------------------------------------------------
992  void ReleaseFrequency(int frequency, Faction faction)
993  {
994  if (!faction || !frequency)
995  return;
996 
997  FactionHolder factions = new FactionHolder();
998  if (m_mUsedFrequenciesMap.Find(frequency, factions))
999  {
1000  if (factions.Count() <= 1 && factions.Find(faction) != -1)
1001  m_mUsedFrequenciesMap.Remove(frequency);
1002  else
1003  {
1004  int factionIdx = factions.Find(faction);
1005  if (factionIdx >= 0 && factionIdx < factions.Count())
1006  factions.Remove(factionIdx);
1007  }
1008  }
1009  }
1010 
1011  //------------------------------------------------------------------------------------------------
1015  void RequestSetGroupSlave(RplId compID, RplId slaveID)
1016  {
1017  RPC_DoSetGroupSlave(compID, slaveID);
1018  //Call next method later to be sure that SCR_AIGroup was replicated to the client succesfully (temporary solution)
1019  GetGame().GetCallqueue().CallLater(RpcWrapper, 2000, false, compID, slaveID);
1020  }
1021 
1022  //------------------------------------------------------------------------------------------------
1026  void RpcWrapper(RplId compID, RplId slaveID)
1027  {
1028  Rpc(RPC_DoSetGroupSlave, compID, slaveID);
1029  }
1030 
1031  //------------------------------------------------------------------------------------------------
1035  [RplRpc(RplChannel.Reliable, RplRcver.Broadcast)]
1036  void RPC_DoSetGroupSlave(RplId masterGroupID, RplId slaveGroupID)
1037  {
1038  SCR_AIGroup masterGroup, group;
1039  RplComponent rplComp = RplComponent.Cast(Replication.FindItem(masterGroupID));
1040  if (!rplComp)
1041  return;
1042 
1043  masterGroup = SCR_AIGroup.Cast(rplComp.GetEntity());
1044  if (!masterGroup)
1045  return;
1046 
1047  rplComp = RplComponent.Cast(Replication.FindItem(slaveGroupID));
1048  if (!rplComp)
1049  return;
1050 
1051  group = SCR_AIGroup.Cast(rplComp.GetEntity());
1052  if (!group)
1053  return;
1054 
1055  masterGroup.SetSlave(group);
1056  group.GetOnAgentRemoved().Insert(OnAIMemberRemoved);
1057  }
1058 
1059  //------------------------------------------------------------------------------------------------
1063  [RplRpc(RplChannel.Reliable, RplRcver.Broadcast)]
1064  void RPC_DoRemoveAIMemberFromGroup(RplId groupRplCompID, RplId aiCharacterComponentID)
1065  {
1066  SCR_ChimeraCharacter AIMember;
1067  array<SCR_ChimeraCharacter> AIMembers;
1068  GetAIMembers(groupRplCompID, aiCharacterComponentID, AIMembers, AIMember);
1069  if (!AIMembers || !AIMember)
1070  return;
1071 
1072  AIMembers.RemoveItem(AIMember);
1073  }
1074 
1075  //------------------------------------------------------------------------------------------------
1080  void GetAIMembers(RplId groupRplCompID, RplId aiCharacterComponentID, out array<SCR_ChimeraCharacter> members, out SCR_ChimeraCharacter AIMember)
1081  {
1082  RplComponent rplComp = RplComponent.Cast(Replication.FindItem(aiCharacterComponentID));
1083  if (!rplComp)
1084  return;
1085 
1086  AIMember = SCR_ChimeraCharacter.Cast(rplComp.GetEntity());
1087  if (!AIMember)
1088  return;
1089 
1090  rplComp = RplComponent.Cast(Replication.FindItem(groupRplCompID));
1091  if (!rplComp)
1092  return;
1093 
1094  SCR_AIGroup group = SCR_AIGroup.Cast(rplComp.GetEntity());
1095  if (!group)
1096  return;
1097 
1098  members = group.GetAIMembers();
1099  }
1100 
1101  //------------------------------------------------------------------------------------------------
1105  void AskRemoveAiMemberFromGroup(RplId groupRplCompID, RplId aiCharacterComponentID)
1106  {
1107  RPC_DoRemoveAIMemberFromGroup(groupRplCompID, aiCharacterComponentID);
1108  Rpc(RPC_DoRemoveAIMemberFromGroup, groupRplCompID, aiCharacterComponentID);
1109  }
1110 
1111  //------------------------------------------------------------------------------------------------
1115  void AskAddAiMemberToGroup(RplId groupRplCompID, RplId aiCharacterComponentID)
1116  {
1117  RPC_DoAddAIMemberToGroup(groupRplCompID, aiCharacterComponentID);
1118  Rpc(RPC_DoAddAIMemberToGroup, groupRplCompID, aiCharacterComponentID);
1119  }
1120 
1121  //------------------------------------------------------------------------------------------------
1125  [RplRpc(RplChannel.Reliable, RplRcver.Broadcast)]
1126  void RPC_DoAddAIMemberToGroup(RplId groupRplCompID, RplId aiCharacterComponentID)
1127  {
1128  SCR_ChimeraCharacter AIMember;
1129  array<SCR_ChimeraCharacter> AIMembers;
1130  GetAIMembers(groupRplCompID, aiCharacterComponentID, AIMembers, AIMember);
1131  if (!AIMembers || !AIMember)
1132  return;
1133 
1134  AIMembers.Insert(AIMember);
1135  }
1136 
1137  //------------------------------------------------------------------------------------------------
1140  void OnAIMemberRemoved(SCR_AIGroup group, AIAgent agent)
1141  {
1142  if (!group || !agent)
1143  return;
1144 
1145  SCR_ChimeraCharacter character = SCR_ChimeraCharacter.Cast(agent.GetControlledEntity());
1146  if (!character)
1147  return;
1148 
1149  RplId groupCompRplID, characterCompRplID;
1150  RplComponent rplComp = RplComponent.Cast(group.FindComponent(RplComponent));
1151  if (!rplComp)
1152  return;
1153 
1154  groupCompRplID = rplComp.Id();
1155 
1156  rplComp = RplComponent.Cast(character.FindComponent(RplComponent));
1157  if (!rplComp)
1158  return;
1159 
1160  characterCompRplID = rplComp.Id();
1161  AskRemoveAiMemberFromGroup(groupCompRplID, characterCompRplID);
1162  }
1163 
1164  //------------------------------------------------------------------------------------------------
1167  {
1168  return m_bConfirmedByPlayer;
1169  }
1170 
1171  //------------------------------------------------------------------------------------------------
1174  {
1175  return m_bNewGroupsAllowed;
1176  }
1177 
1178  //------------------------------------------------------------------------------------------------
1180  void SetConfirmedByPlayer(bool isConfirmed)
1181  {
1182  m_bConfirmedByPlayer = isConfirmed;
1183  }
1184 
1185  //------------------------------------------------------------------------------------------------
1186  override void EOnFrame(IEntity owner, float timeSlice)
1187  {
1188  DeleteGroups();
1189  }
1190 
1191  //------------------------------------------------------------------------------------------------
1194  {
1195  for (int i = m_aDeletionQueue.Count() - 1; i >= 0; i--)
1196  {
1198  m_aDeletionQueue.Remove(i);
1199  }
1200 
1201  ClearEventMask(GetOwner(), EntityEvent.FRAME);
1202  }
1203 
1204  //------------------------------------------------------------------------------------------------
1208  void TunePlayersFrequency(int playerId, IEntity player)
1209  {
1210  PlayerController controller = GetGame().GetPlayerManager().GetPlayerController(playerId);
1211  if (!controller)
1212  return;
1213 
1214  SCR_GadgetManagerComponent gadgetManager = SCR_GadgetManagerComponent.GetGadgetManager(player);
1215  if (!gadgetManager)
1216  return;
1217 
1218  IEntity radio = gadgetManager.GetGadgetByType(EGadgetType.RADIO);
1219  if (!radio)
1220  return;
1221 
1222  BaseRadioComponent radioComponent = BaseRadioComponent.Cast(radio.FindComponent(BaseRadioComponent));
1223  if (!radioComponent)
1224  return;
1225 
1226  SCR_PlayerControllerGroupComponent groupComponent = SCR_PlayerControllerGroupComponent.Cast(controller.FindComponent(SCR_PlayerControllerGroupComponent));
1227  if (!groupComponent || groupComponent.GetActualGroupFrequency() == 0)
1228  return;
1229 
1230  BaseTransceiver transceiver = radioComponent.GetTransceiver(0);
1231  if (!transceiver)
1232  return;
1233 
1234  transceiver.SetFrequency(groupComponent.GetActualGroupFrequency());
1235  }
1236 
1237  //------------------------------------------------------------------------------------------------
1238  protected override void OnPlayerRegistered(int playerId)
1239  {
1240  if (!m_pGameMode.IsMaster())
1241  return;
1242 
1243  PlayerController playerController = GetGame().GetPlayerManager().GetPlayerController(playerId);
1244  SCR_PlayerFactionAffiliationComponent playerFactionAffiliation = SCR_PlayerFactionAffiliationComponent.Cast(playerController.FindComponent(SCR_PlayerFactionAffiliationComponent));
1245  if (playerFactionAffiliation)
1246  playerFactionAffiliation.GetOnFactionChanged().Insert(OnPlayerFactionChanged);
1247  }
1248 
1249  //------------------------------------------------------------------------------------------------
1250  protected override void OnPlayerDisconnected(int playerId, KickCauseCode cause, int timeout)
1251  {
1252  // TODO@AS: Ensure authority only
1253  PlayerController playerController = GetGame().GetPlayerManager().GetPlayerController(playerId);
1254  if (playerController)
1255  {
1256  SCR_PlayerFactionAffiliationComponent playerFactionAffiliation = SCR_PlayerFactionAffiliationComponent.Cast(playerController.FindComponent(SCR_PlayerFactionAffiliationComponent));
1257  if (playerFactionAffiliation)
1258  playerFactionAffiliation.GetOnFactionChanged().Remove(OnPlayerFactionChanged);
1259  }
1260  }
1261 
1262  //------------------------------------------------------------------------------------------------
1265  {
1266  int playerID = reconnectData.m_iPlayerId;
1267  SCR_AIGroup group = GetPlayerGroup(playerID);
1268  if (group)
1269  return;
1270 
1271  SCR_FactionManager factionManager = SCR_FactionManager.Cast(GetGame().GetFactionManager());
1272  Faction faction = factionManager.GetPlayerFaction(playerID);
1273  if (!faction)
1274  return;
1275 
1276  group = GetFirstNotFullForFaction(faction);
1277  if (group)
1278  {
1279  AddPlayerToGroup(group.GetGroupID(), playerID);
1280  return;
1281  }
1282 
1283  group = CreateNewPlayableGroup(faction);
1284  if (!group)
1285  return;
1286 
1287  AddPlayerToGroup(group.GetGroupID(), playerID);
1288  }
1289 
1290  //------------------------------------------------------------------------------------------------
1291  override void OnPostInit(IEntity owner)
1292  {
1293  SetEventMask(owner, EntityEvent.INIT | EntityEvent.FRAME);
1294  }
1295 
1296  //------------------------------------------------------------------------------------------------
1297  override void EOnInit(IEntity owner)
1298  {
1299  SCR_AIGroup.GetOnPlayerAdded().Insert(OnGroupPlayerAdded);
1300  SCR_AIGroup.GetOnPlayerRemoved().Insert(OnGroupPlayerRemoved);
1301  SCR_AIGroup.GetOnPlayerLeaderChanged().Insert(ClearRequests);
1302 
1303  SCR_BaseGameMode gameMode = GetGameMode();
1304  gameMode.GetOnPlayerSpawned().Insert(TunePlayersFrequency);
1305 
1306  SCR_ReconnectComponent reconnectComp = SCR_ReconnectComponent.Cast(gameMode.FindComponent(SCR_ReconnectComponent));
1307  if (reconnectComp)
1308  reconnectComp.GetOnReconnect().Insert(OnPlayerReconnected);
1309 
1310  m_bConfirmedByPlayer = false;
1311 
1313  }
1314 
1315  //------------------------------------------------------------------------------------------------
1316  // constructor
1320  void SCR_GroupsManagerComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
1321  {
1322  if (!s_Instance)
1323  s_Instance = this;
1324  }
1325 
1326  //------------------------------------------------------------------------------------------------
1327  // destructor
1329  {
1330 #ifdef DEBUG_GROUPS
1331  if (s_wDebugLayout)
1332  s_wDebugLayout.RemoveFromHierarchy();
1333 #endif
1334  }
1335 }
~SCR_GroupsManagerComponent
void ~SCR_GroupsManagerComponent()
Definition: SCR_GroupsManagerComponent.c:1328
GetPlayableGroupsByFaction
array< SCR_AIGroup > GetPlayableGroupsByFaction(Faction faction)
Definition: SCR_GroupsManagerComponent.c:410
m_mPlayableGroups
protected ref map< Faction, ref array< SCR_AIGroup > > m_mPlayableGroups
Definition: SCR_GroupsManagerComponent.c:42
m_iPlayableGroupFrequencyOffset
protected int m_iPlayableGroupFrequencyOffset
Definition: SCR_GroupsManagerComponent.c:14
SCR_BaseGameMode
Definition: SCR_BaseGameMode.c:137
CreateNewPlayableGroup
SCR_AIGroup CreateNewPlayableGroup(Faction faction)
Definition: SCR_GroupsManagerComponent.c:788
m_OnCanPlayersChangeAttributeChanged
protected ref ScriptInvoker m_OnCanPlayersChangeAttributeChanged
Definition: SCR_GroupsManagerComponent.c:40
m_mPlayableGroupFrequencies
protected ref map< Faction, int > m_mPlayableGroupFrequencies
Definition: SCR_GroupsManagerComponent.c:43
OnGroupAgentRemoved
void OnGroupAgentRemoved(SCR_AIGroup group, AIAgent child)
Definition: SCR_GroupsManagerComponent.c:581
GetOnNewGroupsAllowedChanged
ScriptInvoker GetOnNewGroupsAllowedChanged()
Definition: SCR_GroupsManagerComponent.c:304
SCR_PlayerController
Definition: SCR_PlayerController.c:31
GetCommunicationDevice
private BaseRadioComponent GetCommunicationDevice(notnull IEntity controlledEntity)
Returns a gadget of EGadgetType.RADIO.
Definition: SCR_GroupsManagerComponent.c:536
EntityEditorProps
enum EQueryType EntityEditorProps(category:"GameScripted/Sound", description:"THIS IS THE SCRIPT DESCRIPTION.", color:"0 0 255 255")
Definition: SCR_AmbientSoundsComponent.c:12
m_bNewGroupsAllowed
protected bool m_bNewGroupsAllowed
Definition: SCR_GroupsManagerComponent.c:28
AssignGroupFrequency
protected void AssignGroupFrequency(notnull SCR_AIGroup group)
Definition: SCR_GroupsManagerComponent.c:436
SetConfirmedByPlayer
void SetConfirmedByPlayer(bool isConfirmed)
Definition: SCR_GroupsManagerComponent.c:1180
ClearRequests
void ClearRequests(int groupID, int playerID)
Definition: SCR_GroupsManagerComponent.c:115
OnGroupPlayerRemoved
void OnGroupPlayerRemoved(SCR_AIGroup group, int playerID)
Definition: SCR_GroupsManagerComponent.c:461
FactionHolder
set< Faction > FactionHolder
Definition: SCR_GroupsManagerComponent.c:1
SetCanPlayersChangeAttributes
void SetCanPlayersChangeAttributes(bool isAllowed)
called on server only
Definition: SCR_GroupsManagerComponent.c:240
GetInstance
SCR_TextsTaskManagerComponentClass ScriptComponentClass GetInstance()
Definition: SCR_TextsTaskManagerComponent.c:50
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
m_bConfirmedByPlayer
protected bool m_bConfirmedByPlayer
Definition: SCR_GroupsManagerComponent.c:26
GetNewGroupsAllowed
bool GetNewGroupsAllowed()
Definition: SCR_GroupsManagerComponent.c:1173
SCR_GadgetManagerComponent
Definition: SCR_GadgetManagerComponent.c:138
m_aGroupFlags
private ref array< ResourceName > m_aGroupFlags
Definition: SCR_GroupsManagerComponent.c:23
m_iPlayableGroupFrequencyMax
protected int m_iPlayableGroupFrequencyMax
Definition: SCR_GroupsManagerComponent.c:20
OnGroupAgentAdded
void OnGroupAgentAdded(AIAgent child)
Definition: SCR_GroupsManagerComponent.c:573
SCR_GroupPreset
Definition: SCR_GroupPreset.c:2
DeleteAndUnregisterGroup
void DeleteAndUnregisterGroup(notnull SCR_AIGroup group)
Definition: SCR_GroupsManagerComponent.c:623
EOnFrame
override void EOnFrame(IEntity owner, float timeSlice)
Definition: SCR_GroupsManagerComponent.c:1186
AssignGroupID
protected void AssignGroupID(SCR_AIGroup group)
Definition: SCR_GroupsManagerComponent.c:713
AskAddAiMemberToGroup
void AskAddAiMemberToGroup(RplId groupRplCompID, RplId aiCharacterComponentID)
Definition: SCR_GroupsManagerComponent.c:1115
RplRpc
SCR_AchievementsHandlerClass ScriptComponentClass RplRpc(RplChannel.Reliable, RplRcver.Owner)] void UnlockOnClient(AchievementId achievement)
Definition: SCR_AchievementsHandler.c:11
GetFreeFrequency
int GetFreeFrequency(Faction frequencyFaction)
Definition: SCR_GroupsManagerComponent.c:914
GetGroupID
int GetGroupID()
Definition: SCR_RestrictedDeployableSpawnPointComponent.c:507
KickCauseCode
KickCauseCode
Definition: KickCauseCode.c:19
FindGroup
SCR_AIGroup FindGroup(int groupID)
Definition: SCR_GroupsManagerComponent.c:279
GetConfirmedByPlayer
bool GetConfirmedByPlayer()
Definition: SCR_GroupsManagerComponent.c:1166
GetGameMode
SCR_BaseGameMode GetGameMode()
Definition: SCR_BaseGameModeComponent.c:15
UnregisterGroup
void UnregisterGroup(notnull SCR_AIGroup group)
Definition: SCR_GroupsManagerComponent.c:633
RPC_DoAddAIMemberToGroup
void RPC_DoAddAIMemberToGroup(RplId groupRplCompID, RplId aiCharacterComponentID)
Definition: SCR_GroupsManagerComponent.c:1126
ENotification
ENotification
Definition: ENotification.c:4
TuneAgentsRadio
private void TuneAgentsRadio(AIAgent agentEntity)
Definition: SCR_GroupsManagerComponent.c:550
IsProxy
protected bool IsProxy()
Definition: SCR_GroupsManagerComponent.c:69
MovePlayerToGroup
int MovePlayerToGroup(int playerID, int previousGroupID, int newGroupID)
Definition: SCR_GroupsManagerComponent.c:84
s_Instance
SCR_SpawnerSlotManagerClass s_Instance
Class used for managing changes and removals of slots present in world.
OnPlayerFactionChanged
void OnPlayerFactionChanged(notnull FactionAffiliationComponent owner, Faction previousFaction, Faction newFaction)
Is called only on the server (authority)
Definition: SCR_GroupsManagerComponent.c:721
RPC_DoSetNewGroupsAllowed
void RPC_DoSetNewGroupsAllowed(bool isAllowed)
Definition: SCR_GroupsManagerComponent.c:229
IsFrequencyClaimed
bool IsFrequencyClaimed(int frequency, Faction faction)
Definition: SCR_GroupsManagerComponent.c:976
CreatePredefinedGroups
void CreatePredefinedGroups()
Definition: SCR_GroupsManagerComponent.c:159
RPC_SetCanPlayersChangeAttributes
void RPC_SetCanPlayersChangeAttributes(bool isAllowed)
Definition: SCR_GroupsManagerComponent.c:253
Attribute
SCR_GroupsManagerComponentClass SCR_BaseGameModeComponentClass Attribute()] protected ResourceName m_sDefaultGroupPrefab
Post-process effect of scripted camera.
m_aDeletionQueue
protected ref array< SCR_AIGroup > m_aDeletionQueue
Definition: SCR_GroupsManagerComponent.c:45
OnPlayerRegistered
protected override void OnPlayerRegistered(int playerId)
Register provided client's respawn timer.
Definition: SCR_GroupsManagerComponent.c:1238
SCR_ReconnectData
Data class for reconnecting players.
Definition: SCR_ReconnectComponent.c:2
GetGroupFlags
void GetGroupFlags(notnull array< ResourceName > targetArray)
Definition: SCR_GroupsManagerComponent.c:57
TunePlayersFrequency
void TunePlayersFrequency(int playerId, IEntity player)
Definition: SCR_GroupsManagerComponent.c:1208
RpcWrapper
void RpcWrapper(RplId compID, RplId slaveID)
Definition: SCR_GroupsManagerComponent.c:1026
m_OnNewGroupsAllowedChanged
protected ref ScriptInvoker m_OnNewGroupsAllowedChanged
Definition: SCR_GroupsManagerComponent.c:39
CanCreateNewGroup
bool CanCreateNewGroup(notnull Faction newGroupFaction)
Definition: SCR_GroupsManagerComponent.c:878
RegisterGroup
void RegisterGroup(SCR_AIGroup group)
Definition: SCR_GroupsManagerComponent.c:675
AddPlayerToGroup
int AddPlayerToGroup(int groupID, int playerID)
Definition: SCR_GroupsManagerComponent.c:144
m_mUsedFrequenciesMap
protected ref map< int, ref FactionHolder > m_mUsedFrequenciesMap
Definition: SCR_GroupsManagerComponent.c:44
m_bCanPlayersChangeAttributes
protected bool m_bCanPlayersChangeAttributes
Definition: SCR_GroupsManagerComponent.c:29
m_iPlayableGroupFrequencyMin
protected int m_iPlayableGroupFrequencyMin
Definition: SCR_GroupsManagerComponent.c:17
m_pGameMode
SCR_BaseGameModeComponentClass m_pGameMode
The game mode entity this component is attached to.
RPC_DoSetGroupFaction
void RPC_DoSetGroupFaction(RplId groupID, int factionIndex)
Definition: SCR_GroupsManagerComponent.c:697
OnPostInit
override void OnPostInit(IEntity owner)
Editable Mine.
Definition: SCR_GroupsManagerComponent.c:1291
DeleteGroupDelayed
void DeleteGroupDelayed(SCR_AIGroup group)
Definition: SCR_GroupsManagerComponent.c:452
OnAIMemberRemoved
void OnAIMemberRemoved(SCR_AIGroup group, AIAgent agent)
Definition: SCR_GroupsManagerComponent.c:1140
RequestSetGroupSlave
void RequestSetGroupSlave(RplId compID, RplId slaveID)
Definition: SCR_GroupsManagerComponent.c:1015
OnPlayerReconnected
void OnPlayerReconnected(SCR_ReconnectData reconnectData)
Definition: SCR_GroupsManagerComponent.c:1264
m_OnPlayableGroupCreated
protected ref ScriptInvoker m_OnPlayableGroupCreated
Definition: SCR_GroupsManagerComponent.c:37
GetPlayerGroup
SCR_AIGroup GetPlayerGroup(int playerID)
Definition: SCR_GroupsManagerComponent.c:322
OnGroupPlayerAdded
void OnGroupPlayerAdded(SCR_AIGroup group, int playerID)
Definition: SCR_GroupsManagerComponent.c:491
BaseTransceiver
Definition: BaseTransceiver.c:12
RPC_DoSetGroupSlave
void RPC_DoSetGroupSlave(RplId masterGroupID, RplId slaveGroupID)
Definition: SCR_GroupsManagerComponent.c:1036
GetOwner
IEntity GetOwner()
Owner entity of the fuel tank.
Definition: SCR_FuelNode.c:128
GetAIMembers
void GetAIMembers(RplId groupRplCompID, RplId aiCharacterComponentID, out array< SCR_ChimeraCharacter > members, out SCR_ChimeraCharacter AIMember)
Definition: SCR_GroupsManagerComponent.c:1080
SetNewGroupsAllowed
void SetNewGroupsAllowed(bool isAllowed)
called on server only
Definition: SCR_GroupsManagerComponent.c:216
ClaimFrequency
void ClaimFrequency(int frequency, Faction faction)
Definition: SCR_GroupsManagerComponent.c:954
EOnInit
override void EOnInit(IEntity owner)
Initialise this component with data from FactionsManager.
Definition: SCR_GroupsManagerComponent.c:1297
GetOnPlayableGroupRemoved
ScriptInvoker GetOnPlayableGroupRemoved()
Definition: SCR_GroupsManagerComponent.c:296
Faction
Definition: Faction.c:12
SCR_GroupsManagerComponent
void SCR_GroupsManagerComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
Definition: SCR_GroupsManagerComponent.c:1320
SCR_PlayerFactionAffiliationComponent
Definition: SCR_PlayerFactionAffiliationComponent.c:16
OnGroupCreated
void OnGroupCreated(SCR_AIGroup group)
Called on clients (proxies) to notice a playable group has been created.
Definition: SCR_GroupsManagerComponent.c:757
IsPlayerInAnyGroup
bool IsPlayerInAnyGroup(int playerID)
Definition: SCR_GroupsManagerComponent.c:350
RPC_DoRemoveAIMemberFromGroup
void RPC_DoRemoveAIMemberFromGroup(RplId groupRplCompID, RplId aiCharacterComponentID)
Definition: SCR_GroupsManagerComponent.c:1064
SCR_AIGroup
Definition: SCR_AIGroup.c:68
CanPlayersChangeAttributes
bool CanPlayersChangeAttributes()
Definition: SCR_GroupsManagerComponent.c:906
m_OnPlayableGroupRemoved
protected ref ScriptInvoker m_OnPlayableGroupRemoved
Definition: SCR_GroupsManagerComponent.c:38
SetGroupLeader
void SetGroupLeader(int groupID, int playerID)
Definition: SCR_GroupsManagerComponent.c:206
GetFirstNotFullForFaction
SCR_AIGroup GetFirstNotFullForFaction(notnull Faction faction, SCR_AIGroup ownGroup=null, bool respectPrivate=false)
Definition: SCR_GroupsManagerComponent.c:855
GetOnCanPlayersChangeAttributeChanged
ScriptInvoker GetOnCanPlayersChangeAttributeChanged()
Definition: SCR_GroupsManagerComponent.c:312
params
Configs ServerBrowser KickDialogs params
Definition: SCR_NotificationSenderComponent.c:24
GetAllPlayableGroups
void GetAllPlayableGroups(out array< SCR_AIGroup > outAllGroups)
Definition: SCR_GroupsManagerComponent.c:417
SCR_FactionManager
void SCR_FactionManager(IEntitySource src, IEntity parent)
Definition: SCR_FactionManager.c:461
DeleteGroups
void DeleteGroups()
Definition: SCR_GroupsManagerComponent.c:1193
m_iLatestGroupID
protected int m_iLatestGroupID
Definition: SCR_GroupsManagerComponent.c:41
GetPlayerCount
int GetPlayerCount()
Definition: SCR_Faction.c:365
SetPrivateGroup
void SetPrivateGroup(int groupID, bool isPrivate)
Definition: SCR_GroupsManagerComponent.c:266
AskRemoveAiMemberFromGroup
void AskRemoveAiMemberFromGroup(RplId groupRplCompID, RplId aiCharacterComponentID)
Definition: SCR_GroupsManagerComponent.c:1105
SCR_CommandingManagerComponent
void SCR_CommandingManagerComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
Definition: SCR_CommandingManagerComponent.c:46
TryFindEmptyGroup
SCR_AIGroup TryFindEmptyGroup(notnull Faction faction)
Definition: SCR_GroupsManagerComponent.c:766
m_iMovingPlayerToGroupID
protected int m_iMovingPlayerToGroupID
Definition: SCR_GroupsManagerComponent.c:46
GetOnPlayableGroupCreated
ScriptInvoker GetOnPlayableGroupCreated()
Definition: SCR_GroupsManagerComponent.c:64
SCR_ReconnectComponent
Definition: SCR_ReconnectComponent.c:41
OnPlayerDisconnected
protected override void OnPlayerDisconnected(int playerId, KickCauseCode cause, int timeout)
Definition: SCR_GroupsManagerComponent.c:1250
SCR_BaseGameModeComponentClass
Definition: SCR_BaseGameModeComponent.c:2
SCR_GroupsManagerComponentClass
Definition: SCR_GroupsManagerComponent.c:4
SCR_Faction
Definition: SCR_Faction.c:6
ReleaseFrequency
void ReleaseFrequency(int frequency, Faction faction)
Definition: SCR_GroupsManagerComponent.c:992
category
params category
Definition: SCR_VehicleDamageManagerComponent.c:180
SCR_BaseGameModeComponent
void SCR_BaseGameModeComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
Definition: SCR_BaseGameModeComponent.c:199