Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_VehicleActionBase.c
Go to the documentation of this file.
2{
4 [Attribute(uiwidget: UIWidgets.CheckBox, defvalue: "1", desc: "Should action behave as a toggle")]
5 protected bool m_bIsToggle;
6
8 [Attribute(uiwidget: UIWidgets.CheckBox, defvalue: "1", desc: "Target state of the action, ignored if toggle")]
9 protected bool m_bTargetState;
10
12 [Attribute(uiwidget: UIWidgets.Auto, defvalue: "#AR-UserAction_State_On", desc: "Description of action to toggle on")]
13 protected string m_sActionStateOn;
14
16 [Attribute(uiwidget: UIWidgets.Auto, defvalue: "#AR-UserAction_State_Off", desc: "Description of action to toggle off")]
17 protected string m_sActionStateOff;
18
20 [Attribute(uiwidget: UIWidgets.CheckBox, defvalue: "1", desc: "Available only for entities seated in pilot compartment")]
21 protected bool m_bPilotOnly;
22
24 [Attribute(uiwidget: UIWidgets.CheckBox, desc: "Available only for entities seated in a vehicle")]
25 protected bool m_bInteriorOnly;
26
27 [Attribute(desc: "When anything is defined in here, this action will only be visible if the compartmet section of the compartment the player in in, is defined in here.")]
28 protected ref array<int> m_aDefinedCompartmentSectionsOnly;
29
30 [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.")]
31 protected ref array<int> m_aExcludeDefinedCompartmentSections;
32
33 protected CompartmentControllerComponent m_VehicleController; // Commonly used by inheriting actions
34
35 //------------------------------------------------------------------------------------------------
36 override void Init(IEntity pOwnerEntity, GenericComponent pManagerComponent)
37 {
38 super.Init(pOwnerEntity, pManagerComponent);
39
41 }
42
43 //------------------------------------------------------------------------------------------------
44 override bool CanBeShownScript(IEntity user)
45 {
46 // See if character is in vehicle
47 ChimeraCharacter character = ChimeraCharacter.Cast(user);
48 if (!character)
49 return false;
50
51 // We cannot be pilot nor interior, if we are not seated in vehicle at all.
52 if (!character.IsInVehicle())
53 return !(m_bInteriorOnly || m_bPilotOnly);
54
55 // See if character is in "this" (owner) vehicle
56 CompartmentAccessComponent compartmentAccess = character.GetCompartmentAccessComponent();
57 if (!compartmentAccess)
58 return false;
59
60 // Character is in compartment
61 // that belongs to owner of this action
62 BaseCompartmentSlot slot = compartmentAccess.GetCompartment();
63 if (!slot)
64 return false;
65
66 // Check pilot only condition
67 if (m_bPilotOnly)
68 {
69 if (!PilotCompartmentSlot.Cast(slot))
70 return false;
71
72 Vehicle vehicle = Vehicle.Cast(GetOwner().GetRootParent());
73 if (vehicle && vehicle.GetPilotCompartmentSlot() != slot)
74 return false;
75 }
76
77 // Check interior only condition
78 if (m_bInteriorOnly && slot.GetOwner().GetRootParent() != GetOwner().GetRootParent())
79 return false;
80
81 int compartmentSection = slot.GetCompartmentSection();
82
83 if (!m_aDefinedCompartmentSectionsOnly.IsEmpty() && !m_aDefinedCompartmentSectionsOnly.Contains(compartmentSection))
84 return false;
85
86 if (!m_aExcludeDefinedCompartmentSections.IsEmpty() && m_aExcludeDefinedCompartmentSections.Contains(compartmentSection))
87 return false;
88
89 return true;
90 }
91
92 //------------------------------------------------------------------------------------------------
93 override bool CanBePerformedScript(IEntity user)
94 {
95 return m_bIsToggle || (GetState() != m_bTargetState);
96 }
97
98 //------------------------------------------------------------------------------------------------
100 bool GetState()
101 {
102 return false;
103 }
104
105 //------------------------------------------------------------------------------------------------
107 void SetState(bool enable);
108
109 //------------------------------------------------------------------------------------------------
111 override void PerformAction(IEntity pOwnerEntity, IEntity pUserEntity)
112 {
113 if (m_bIsToggle)
114 SetState(!GetState());
115 else
117 }
118
119 //------------------------------------------------------------------------------------------------
120 override bool GetActionNameScript(out string outName)
121 {
122 UIInfo uiInfo = GetUIInfo();
123 string prefix;
124 if (uiInfo)
125 prefix = uiInfo.GetName();
126
127 if (!prefix.IsEmpty())
128 prefix += " ";
129
130 if (GetState())
131 outName = prefix + m_sActionStateOff;
132 else
133 outName = prefix + m_sActionStateOn;
134
135 return true;
136 }
137}
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
int GetCompartmentSection()
Switching seats is allowed only between compartments with matching area.
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.
proto external Managed FindComponent(typename typeName)
ref array< int > m_aDefinedCompartmentSectionsOnly
bool m_bInteriorOnly
Available only for entities seated in a vehicle.
bool m_bTargetState
Target state of the action, ignored if toggle.
ref array< int > m_aExcludeDefinedCompartmentSections
override bool GetActionNameScript(out string outName)
bool GetState()
Current state of the feature.
override void Init(IEntity pOwnerEntity, GenericComponent pManagerComponent)
override bool CanBeShownScript(IEntity user)
string m_sActionStateOn
Description of action to toggle on.
CompartmentControllerComponent m_VehicleController
override void PerformAction(IEntity pOwnerEntity, IEntity pUserEntity)
By default toggle the current state of the interaction.
string m_sActionStateOff
Description of action to toggle off.
override bool CanBePerformedScript(IEntity user)
bool m_bPilotOnly
Available only for entities seated in pilot compartment.
void SetState(bool enable)
Script to change state of the feature.
bool m_bIsToggle
Should action behave as a toggle.
UIInfo - allows to define UI elements.
Definition UIInfo.c:14
enum EPhysicsLayerPresets Vehicle
Definition gameLib.c:24
SCR_FieldOfViewSettings Attribute