Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_ToggleHandbrakeAction.c
Go to the documentation of this file.
2{
3 [Attribute(desc: "When anything is defined in here, this action will only be visible if the compartment section of the compartment the player is in is defined in here.")]
4 protected ref array<int> m_aDefinedCompartmentSectionsOnly;
5
6 [Attribute(desc: "When aynthing is defined in here, this action won't be visible if the compartment section of the compartment the player is in is defined in here.")]
7 protected ref array<int> m_aExcludeDefinedCompartmentSections;
8
9 protected const LocalizedString CONTROLLED_BY_DRIVER = "#AR-UserAction_ControlledByDriver";
10 protected const LocalizedString OCCUPIED_BY_ENEMY = "#AR-UserAction_SeatHostile";
11
12 //------------------------------------------------------------------------------------------------
14 override bool CanBeShownScript(IEntity user)
15 {
16 if (!super.CanBeShownScript(user))
17 return false;
18
20 {
22 return SCR_InteractionHandlerComponent.CanBeShownInVehicle(
24 this,
25 false,
26 m_eShownInVehicleState != EUserActionInVehicleState.IN_VEHICLE_PILOT,
27 m_eShownInVehicleState != EUserActionInVehicleState.NOT_IN_VEHICLE,
30 );
31 }
32
33 return true;
34 }
35
36 //------------------------------------------------------------------------------------------------
37 override bool CanBePerformedScript(IEntity user)
38 {
39 Vehicle vehicleEntity = Vehicle.Cast(GetOwner().GetRootParent());
40 if (!vehicleEntity)
41 return false;
42
43 if (!vehicleEntity.IsOccupied())
44 return true;
45
46 SCR_ChimeraCharacter character = SCR_ChimeraCharacter.Cast(user);
47 if (!character)
48 return false;
49
50 Faction characterFaction = character.GetFaction();
51 Faction vehicleFaction = vehicleEntity.GetFaction();
52 // Faction can be enemy to itself (in FFA or in mods) so we need to make sure the factions are different before checking the friendlyness
53 // otherwise we might have a driver being unable to pull his own handbrake
54 if (characterFaction && vehicleFaction && (vehicleFaction != characterFaction && characterFaction.IsFactionEnemy(vehicleFaction)))
55 {
57 return false;
58 }
59
60 if (!SCR_InteractionHandlerComponent.CanBeShownInVehicle(
62 this,
63 true,
64 m_eShownInVehicleState != EUserActionInVehicleState.IN_VEHICLE_PILOT,
65 m_eShownInVehicleState != EUserActionInVehicleState.NOT_IN_VEHICLE,
68 ))
69 {
71 return false;
72 }
73
74 return true;
75 }
76
77 //------------------------------------------------------------------------------------------------
79 override void PerformAction(IEntity pOwnerEntity, IEntity pUserEntity)
80 {
81 Vehicle vehicleEntity = Vehicle.Cast(GetOwner().GetRootParent());
82 if (!vehicleEntity)
83 return;
84
85 CarControllerComponent controller = CarControllerComponent.Cast(vehicleEntity.GetVehicleController());
86 if (!controller)
87 return;
88
89 VehicleWheeledSimulation simulation = controller.GetSimulation();
90 if (!simulation)
91 return;
92
93 bool handBrake = controller.GetPersistentHandBrake();
94 controller.SetPersistentHandBrake(!handBrake);
95 simulation.SetBreak(!handBrake, !handBrake);
96
97 //get number of all gears where neautral is also one of them and it is the middle one
98 int gears = simulation.GearboxGearsCount();
99 //find neutral gear id by removing all forward gears
100 if (handBrake)
101 gears = gears - simulation.GearboxForwardGearsCount() - 1;//neutral
102 else
103 gears = gears - simulation.GearboxForwardGearsCount();//first
104
105 //set gear to neutral
106 simulation.SetGear(gears);
107 }
108
109 //------------------------------------------------------------------------------------------------
112 override bool GetActionNameScript(out string outName)
113 {
114 Vehicle vehicleEntity = Vehicle.Cast(GetOwner().GetRootParent());
115 if (!vehicleEntity)
116 return false;
117
118 UIInfo info = GetUIInfo();
119 if (!info)
120 return false;
121
122 CarControllerComponent carControllerComp = CarControllerComponent.Cast(vehicleEntity.GetVehicleController());
123 if (!carControllerComp)
124 return false;
125
126 if (carControllerComp.GetPersistentHandBrake())
127 outName = info.GetDescription();
128 else
129 outName = info.GetName();
130
131 return true;
132 }
133}
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
void SetCannotPerformReason(string reason)
proto external IEntity GetOwner()
Returns the parent entity of this action.
proto external UIInfo GetUIInfo()
Returns the UIInfo set for this user action or null if none.
A scripted action class having optional logic to check if vehicle is valid.
EUserActionInVehicleState m_eShownInVehicleState
override void PerformAction(IEntity pOwnerEntity, IEntity pUserEntity)
Called when someone tries to perform the action, user entity is typically character.
override bool CanBePerformedScript(IEntity user)
const LocalizedString OCCUPIED_BY_ENEMY
const LocalizedString CONTROLLED_BY_DRIVER
ref array< int > m_aDefinedCompartmentSectionsOnly
override bool GetActionNameScript(out string outName)
ref array< int > m_aExcludeDefinedCompartmentSections
override bool CanBeShownScript(IEntity user)
Can this entity be shown in the UI by the provided user entity?
UIInfo - allows to define UI elements.
Definition UIInfo.c:14
enum EPhysicsLayerPresets Vehicle
Definition gameLib.c:24
SCR_FieldOfViewSettings Attribute