Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_DisembarkContextAction.c
Go to the documentation of this file.
1 //
4 {
5  protected bool IsCharacterInVehicle(SCR_EditableEntityComponent selectedEntity)
6  {
7  SCR_EditableCharacterComponent character = SCR_EditableCharacterComponent.Cast(selectedEntity);
8  if (character && character.GetPlayerID() <= 0)
9  {
10  return character.GetVehicle();
11  }
12  return false;
13  }
14 
15  override bool CanBeShown(SCR_EditableEntityComponent selectedEntity, vector cursorWorldPosition, int flags)
16  {
17  if (!selectedEntity)
18  return false;
19 
20  GenericEntity owner = selectedEntity.GetOwner();
21  if (!owner)
22  return false;
23 
24  BaseCompartmentManagerComponent compartmentManager = BaseCompartmentManagerComponent.Cast(owner.FindComponent(BaseCompartmentManagerComponent));
25  if (compartmentManager)
26  {
27  return true;
28  }
29  else
30  {
31  return IsCharacterInVehicle(selectedEntity);
32  }
33  }
34 
35  override bool CanBePerformed(SCR_EditableEntityComponent selectedEntity, vector cursorWorldPosition, int flags)
36  {
37  if (!selectedEntity)
38  return false;
39 
40  GenericEntity owner = selectedEntity.GetOwner();
41  if (!owner)
42  return false;
43 
44  BaseCompartmentManagerComponent compartmentManager = BaseCompartmentManagerComponent.Cast(owner.FindComponent(BaseCompartmentManagerComponent));
45  if (compartmentManager)
46  {
47  array<CompartmentAccessComponent> crewCompartmentAccess = new array<CompartmentAccessComponent>;
48  selectedEntity.GetCrew(crewCompartmentAccess);
49 
50  return !crewCompartmentAccess.IsEmpty();
51  }
52  else
53  {
54  return IsCharacterInVehicle(selectedEntity);
55  }
56  }
57 
58  override void Perform(SCR_EditableEntityComponent selectedEntity, vector cursorWorldPosition)
59  {
60  if (!selectedEntity)
61  return;
62 
63  array<CompartmentAccessComponent> crewCompartmentAccess = new array<CompartmentAccessComponent>;
64  SCR_EditableCharacterComponent character = SCR_EditableCharacterComponent.Cast(selectedEntity);
65 
66  //~Todo: Bug: If All characters of the same group are selected (But not the group) then disembarking does not unregister the vehicle of the group
67  //If character selected check if vehicle is still in use by another group memeber before removing it from group
68  if (character && character.GetPlayerID() <= 0)
69  {
70  selectedEntity.GetCrew(crewCompartmentAccess, false);
71 
72  //Unregister vehicle
73  character.RemoveUsableVehicle(character.GetVehicle().GetOwner());
74 
75  //Get out
76  foreach (CompartmentAccessComponent compartmentAccess: crewCompartmentAccess)
77  {
78  if (compartmentAccess.CanGetOutVehicleViaDoor(-1))
79  compartmentAccess.GetOutVehicle(-1, false);
80  }
81 
82  return;
83  }
84 
85  //If vehicle is selected make sure to instantly remove itself from characters
86  SCR_EditableVehicleComponent vehicle = SCR_EditableVehicleComponent.Cast(selectedEntity);
87  if (vehicle)
88  {
89  selectedEntity.GetCrew(crewCompartmentAccess, false);
90  foreach (CompartmentAccessComponent compartmentAccess: crewCompartmentAccess)
91  {
92  character = SCR_EditableCharacterComponent.Cast(compartmentAccess.GetOwner().FindComponent(SCR_EditableCharacterComponent));
93 
94  //~ Ignore Players
95  if (!character || character.GetPlayerID() > 0)
96  continue
97 
98  //~Unregister vehicle
99  character.RemoveUsableVehicle(vehicle.GetOwner(), false);
100 
101  if (compartmentAccess.CanGetOutVehicleViaDoor(-1))
102  compartmentAccess.GetOutVehicle(-1, false);
103  }
104 
105  return;
106  }
107  }
108 };
SCR_DisembarkContextAction
Definition: SCR_DisembarkContextAction.c:3
GenericEntity
SCR_GenericBoxEntityClass GenericEntity
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