Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_CreateNewGroupContextAction.c
Go to the documentation of this file.
1 // Script File
2 //Get all characters. Check if A group (or more) is selected. Check if all characters in the group are selected. Ignore if true. If only of the same group do not preform
3 
6 {
7  override bool CanBeShown(SCR_EditableEntityComponent hoveredEntity, notnull set<SCR_EditableEntityComponent> selectedEntities, vector cursorWorldPosition, int flags)
8  {
9  if (hoveredEntity && (!selectedEntities.Contains(hoveredEntity) || SCR_PossessingManagerComponent.GetPlayerIdFromControlledEntity(hoveredEntity.GetOwner()) > 0))
10  return false;
11 
12  foreach (SCR_EditableEntityComponent entity : selectedEntities)
13  {
14  if (entity.GetEntityType() == EEditableEntityType.CHARACTER && SCR_PossessingManagerComponent.GetPlayerIdFromControlledEntity(entity.GetOwner()) <= 0)
15  return true;
16  }
17 
18  return false;
19  }
20 
21  //Can always preform if has AI characters
22  override bool CanBePerformed(SCR_EditableEntityComponent hoveredEntity, notnull set<SCR_EditableEntityComponent> selectedEntities, vector cursorWorldPosition, int flags)
23  {
24  SCR_EditableEntityComponent parentGroup = null;
25  int entityCount = 0;
26 
28  foreach (SCR_EditableEntityComponent entity : selectedEntities)
29  {
30  if (entity.GetEntityType() == EEditableEntityType.CHARACTER && SCR_PossessingManagerComponent.GetPlayerIdFromControlledEntity(entity.GetOwner()) <= 0)
31  {
32  SCR_EditableEntityComponent newParentGroup = entity.GetParentEntity();
33 
34  entityCount++;
35 
36  if (parentGroup == null)
37  parentGroup = newParentGroup;
38  else if (parentGroup != newParentGroup)
39  return true;
40  }
41  }
42 
43  return (parentGroup && parentGroup.GetChildrenCount() != entityCount);
44  }
45 
46 
47  override void Perform(SCR_EditableEntityComponent hoveredEntity, notnull set<SCR_EditableEntityComponent> selectedEntities, vector cursorWorldPosition,int flags, int param = -1)
48  {
50  SCR_EditableCharacterComponent newLeader;
51 
52  foreach (SCR_EditableEntityComponent entity: selectedEntities)
53  {
54  if (entity.GetEntityType() != EEditableEntityType.CHARACTER || SCR_PossessingManagerComponent.GetPlayerIdFromMainEntity(entity.GetOwner()) > 0)
55  continue;
56 
57  if (!group)
58  {
59  newLeader = SCR_EditableCharacterComponent.Cast(entity);
60 
61  if (newLeader)
62  group = newLeader.CreateGroupForCharacter();
63 
64  continue;
65  }
66 
67  entity.SetParentEntity(group);
68  }
69 
70  }
71 
72 
73 };
SCR_BaseContextAction
Definition: SCR_BaseContextAction.c:7
EEditableEntityType
EEditableEntityType
Defines type of SCR_EditableEntityComponent. Assigned automatically based on IEntity inheritance.
Definition: EEditableEntityType.c:5
SCR_EditableEntityComponent
Definition: SCR_EditableEntityComponent.c:13
SCR_BaseContainerCustomTitleUIInfo
void SCR_BaseContainerCustomTitleUIInfo(string propertyName, string format="%1")
Definition: Attributes.c:788
SCR_CreateNewGroupContextAction
Definition: SCR_CreateNewGroupContextAction.c:5
BaseContainerProps
SCR_AIGoalReaction_Follow BaseContainerProps
Handles insects that are supposed to be spawned around selected prefabs defined in prefab names array...
Definition: SCR_AIGoalReaction.c:468