Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_GetOutUserAction.c
Go to the documentation of this file.
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 compartmentAccess = character.GetCompartmentAccessComponent();
25 if (!compartmentAccess)
26 return;
27
28 if (!compartmentAccess.GetOutVehicle(EGetOutType.ANIMATED, GetRelevantDoorIndex(pUserEntity), ECloseDoorAfterActions.RETURN_TO_PREVIOUS_STATE, 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};
override bool CanBePerformed(SCR_EditableEntityComponent hoveredEntity, notnull set< SCR_EditableEntityComponent > selectedEntities, vector cursorWorldPosition, int flags)
override void PerformAction(IEntity pOwnerEntity, IEntity pUserEntity)
override bool CanBeShownScript(IEntity user)
override bool CanBePerformedScript(IEntity user)
const float MAX_GETOUT_SPEED_METER_PER_SEC_SQ
const float MAX_GETOUT_ALTITUDE_AGL_METERS
override bool GetActionNameScript(out string outName)
UIInfo - allows to define UI elements.
Definition UIInfo.c:14
enum EPhysicsLayerPresets Vehicle
Definition gameLib.c:24
IEntity GetOwner()
Owner entity of the fuel tank.
ECloseDoorAfterActions
EGetOutType
Definition EGetOutType.c:13