Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_GetOutUserAction.c
Go to the documentation of this file.
1 class SCR_GetOutAction : SCR_CompartmentUserAction
2 {
3  protected const float MAX_GETOUT_SPEED_METER_PER_SEC_SQ = 17.36138889;
4  protected const float MAX_GETOUT_ALTITUDE_AGL_METERS = 3;
5 
6  //------------------------------------------------------------------------------------------------
7  override void PerformAction(IEntity pOwnerEntity, IEntity pUserEntity)
8  {
9  if (!pOwnerEntity)
10  return;
11 
12  ChimeraCharacter character = ChimeraCharacter.Cast(pUserEntity);
13  if (!character)
14  return;
15 
16  CharacterControllerComponent controller = character.GetCharacterController();
17  if (controller && controller.IsUnconscious())
18  return;
19 
20  BaseCompartmentSlot targetCompartment = GetCompartmentSlot();
21  if (!targetCompartment)
22  return;
23 
24  CompartmentAccessComponent compartmentAcess = character.GetCompartmentAccessComponent();
25  if (!compartmentAcess)
26  return;
27 
28  if (!compartmentAcess.GetOutVehicle(GetRelevantDoorIndex(pUserEntity), false))
29  return;
30 
31  super.PerformAction(pOwnerEntity, pUserEntity);
32  }
33 
34  //------------------------------------------------------------------------------------------------
35  override bool CanBePerformedScript(IEntity user)
36  {
37  ChimeraCharacter character = ChimeraCharacter.Cast(user);
38  if (!character)
39  return false;
40 
41  CharacterControllerComponent controller = character.GetCharacterController();
42  if (controller && controller.IsUnconscious())
43  return false;
44 
45  CompartmentAccessComponent compartmentAccess = character.GetCompartmentAccessComponent();
46  if (!compartmentAccess)
47  return false;
48 
49  if (!compartmentAccess.IsInCompartment())
50  return false;
51 
52  if (compartmentAccess.IsGettingIn() || compartmentAccess.IsGettingOut())
53  return false;
54 
55  BaseCompartmentSlot compartment = compartmentAccess.GetCompartment();
56  if (!compartment)
57  return false;
58 
59  // Do not allow plain GetOut with speeds higher than 15 km/phys
60  Vehicle vehicle = Vehicle.Cast(GetOwner().GetRootParent());
61 
62  if (vehicle)
63  {
64  Physics phys = vehicle.GetPhysics();
65 
66  if (phys)
67  {
68  vector velocity = phys.GetVelocity();
69 
70  if ((velocity.LengthSq()) > MAX_GETOUT_SPEED_METER_PER_SEC_SQ)
71  return false;
72  }
73 
74  // Disallow GetOut when flying is above 3 meters
75  HelicopterControllerComponent helicopterController = HelicopterControllerComponent.Cast(vehicle.GetVehicleController());
76  if (helicopterController)
77  {
78  VehicleHelicopterSimulation simulation = VehicleHelicopterSimulation.Cast(helicopterController.GetBaseSimulation());
79  if (simulation && simulation.GetAltitudeAGL() > MAX_GETOUT_ALTITUDE_AGL_METERS)
80  return false;
81  }
82  }
83 
84  BaseCompartmentSlot thisCompartment = GetCompartmentSlot();
85  return thisCompartment == compartment;
86  }
87 
88  //------------------------------------------------------------------------------------------------
89  override bool CanBeShownScript(IEntity user)
90  {
91  return CanBePerformed(user);
92  }
93 
94  //------------------------------------------------------------------------------------------------
95  override bool GetActionNameScript(out string outName)
96  {
97  BaseCompartmentSlot compartment = GetCompartmentSlot();
98  if (!compartment)
99  return false;
100 
101  UIInfo actionInfo = GetUIInfo();
102  if (!actionInfo)
103  return false;
104 
105  outName = actionInfo.GetName();
106 
107  return true;
108  }
109 };
SCR_GetOutAction
Definition: SCR_GetOutUserAction.c:1
UIInfo
UIInfo - declare object, allows to define UI elements.
Definition: UIInfo.c:13
GetUIInfo
SCR_UIInfo GetUIInfo()
Definition: SCR_EditableEntityCampaignBuildingModeLabelSetting.c:27
GetOwner
IEntity GetOwner()
Owner entity of the fuel tank.
Definition: SCR_FuelNode.c:128