Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
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  protected CompartmentControllerComponent m_VehicleController; // Commonly used by inheriting actions
28 
29  //------------------------------------------------------------------------------------------------
30  override void Init(IEntity pOwnerEntity, GenericComponent pManagerComponent)
31  {
32  super.Init(pOwnerEntity, pManagerComponent);
33 
34  m_VehicleController = CompartmentControllerComponent.Cast(pOwnerEntity.FindComponent(CompartmentControllerComponent));
35  }
36 
37  //------------------------------------------------------------------------------------------------
38  override bool CanBeShownScript(IEntity user)
39  {
40  // See if character is in vehicle
41  ChimeraCharacter character = ChimeraCharacter.Cast(user);
42  if (!character)
43  return false;
44 
45  // We cannot be pilot nor interior, if we are not seated in vehicle at all.
46  if (!character.IsInVehicle())
47  return !(m_bInteriorOnly || m_bPilotOnly);
48 
49  // See if character is in "this" (owner) vehicle
50  CompartmentAccessComponent compartmentAccess = character.GetCompartmentAccessComponent();
51  if (!compartmentAccess)
52  return false;
53 
54  // Character is in compartment
55  // that belongs to owner of this action
56  BaseCompartmentSlot slot = compartmentAccess.GetCompartment();
57  if (!slot)
58  return false;
59 
60  // Check pilot only condition
61  if (m_bPilotOnly)
62  {
63  if (!PilotCompartmentSlot.Cast(slot))
64  return false;
65 
66  Vehicle vehicle = Vehicle.Cast(GetOwner().GetRootParent());
67  if (vehicle && vehicle.GetPilotCompartmentSlot() != slot)
68  return false;
69  }
70 
71  // Check interior only condition
72  if (m_bInteriorOnly && slot.GetOwner().GetRootParent() != GetOwner().GetRootParent())
73  return false;
74 
75  return true;
76  }
77 
78  //------------------------------------------------------------------------------------------------
79  override bool CanBePerformedScript(IEntity user)
80  {
81  return m_bIsToggle || (GetState() != m_bTargetState);
82  }
83 
84  //------------------------------------------------------------------------------------------------
86  bool GetState()
87  {
88  return false;
89  }
90 
91  //------------------------------------------------------------------------------------------------
93  void SetState(bool enable);
94 
95  //------------------------------------------------------------------------------------------------
97  override void PerformAction(IEntity pOwnerEntity, IEntity pUserEntity)
98  {
99  if (m_bIsToggle)
100  SetState(!GetState());
101  else
102  SetState(m_bTargetState);
103  }
104 
105  //------------------------------------------------------------------------------------------------
106  override bool GetActionNameScript(out string outName)
107  {
108  UIInfo uiInfo = GetUIInfo();
109  string prefix;
110  if (uiInfo)
111  prefix = uiInfo.GetName();
112 
113  if (!prefix.IsEmpty())
114  prefix += " ";
115 
116  if (GetState())
117  outName = prefix + m_sActionStateOff;
118  else
119  outName = prefix + m_sActionStateOn;
120 
121  return true;
122  }
123 }
SCR_VehicleActionBase
Definition: SCR_VehicleActionBase.c:1
UIInfo
UIInfo - declare object, allows to define UI elements.
Definition: UIInfo.c:13
ScriptedUserAction
Definition: ScriptedUserAction.c:12
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition: SCR_RespawnBriefingComponent.c:17
PilotCompartmentSlot
Definition: PilotCompartmentSlot.c:12
GetUIInfo
SCR_UIInfo GetUIInfo()
Definition: SCR_EditableEntityCampaignBuildingModeLabelSetting.c:27
Attribute
typedef Attribute
Post-process effect of scripted camera.
GetOwner
IEntity GetOwner()
Owner entity of the fuel tank.
Definition: SCR_FuelNode.c:128