Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_SelectOccupantsContextAction.c
Go to the documentation of this file.
3 {
4  protected bool EntityIsOccupied(GenericEntity vehicleEntity)
5  {
6  BaseCompartmentManagerComponent compartmentManager = BaseCompartmentManagerComponent.Cast(vehicleEntity.FindComponent(BaseCompartmentManagerComponent));
7  if (!compartmentManager) return false;
8 
9  array<BaseCompartmentSlot> compartments = new array<BaseCompartmentSlot>;
10  compartmentManager.GetCompartments(compartments);
11 
12  foreach (BaseCompartmentSlot slot : compartments)
13  {
14  if (slot.GetOccupant() != null || slot.AttachedOccupant() != null)
15  {
16  return true;
17  }
18  }
19  return false;
20  }
21 
22  override bool CanBeShown(SCR_EditableEntityComponent selectedEntity, vector cursorWorldPosition, int flags)
23  {
24  return selectedEntity != null && selectedEntity.GetEntityType() == EEditableEntityType.VEHICLE;
25  }
26 
27  override bool CanBePerformed(SCR_EditableEntityComponent selectedEntity, vector cursorWorldPosition, int flags)
28  {
29  GenericEntity owner = selectedEntity.GetOwner();
30  return owner != null && EntityIsOccupied(owner);
31  }
32 
33  override void Perform(SCR_EditableEntityComponent selectedEntity, vector cursorWorldPosition)
34  {
35  GenericEntity owner = selectedEntity.GetOwner();
36  if (!owner)
37  return;
38 
39  BaseCompartmentManagerComponent compartmentManager = BaseCompartmentManagerComponent.Cast(owner.FindComponent(BaseCompartmentManagerComponent));
40  if (!compartmentManager)
41  return;
42 
44  if (!filter)
45  return;
46 
47  array<BaseCompartmentSlot> compartments = new array<BaseCompartmentSlot>;
48  compartmentManager.GetCompartments(compartments);
49 
50  set<SCR_EditableEntityComponent> toSelect = new set<SCR_EditableEntityComponent>();
51  foreach (BaseCompartmentSlot slot: compartments)
52  {
53  IEntity occupant = slot.GetOccupant();
54  if (!occupant)
55  occupant = slot.AttachedOccupant();
56 
57  if (!occupant)
58  continue;
59 
60  SCR_EditableEntityComponent editableOccupant = SCR_EditableEntityComponent.GetEditableEntity(occupant);
61  if (editableOccupant)
62  toSelect.Insert(editableOccupant);
63  }
64 
65  filter.Replace(toSelect);
66  }
67 };
EEditableEntityState
EEditableEntityState
Definition: EEditableEntityState.c:37
GenericEntity
SCR_GenericBoxEntityClass GenericEntity
SCR_SelectOccupantsContextAction
Definition: SCR_SelectOccupantsContextAction.c:2
EEditableEntityType
EEditableEntityType
Defines type of SCR_EditableEntityComponent. Assigned automatically based on IEntity inheritance.
Definition: EEditableEntityType.c:5
SCR_BaseEditableEntityFilter
Definition: SCR_BaseEditableEntityFilter.c:13
SCR_EditableEntityComponent
Definition: SCR_EditableEntityComponent.c:13
SCR_SelectedEntitiesContextAction
Definition: SCR_SelectedEntitiesContextAction.c:10
SCR_BaseContainerCustomTitleUIInfo
void SCR_BaseContainerCustomTitleUIInfo(string propertyName, string format="%1")
Definition: Attributes.c:788
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