4 [
Attribute(uiwidget: UIWidgets.CheckBox, defvalue:
"1",
desc:
"Should action behave as a toggle")]
5 protected bool m_bIsToggle;
8 [
Attribute(uiwidget: UIWidgets.CheckBox, defvalue:
"1",
desc:
"Target state of the action, ignored if toggle")]
9 protected bool m_bTargetState;
12 [
Attribute(uiwidget: UIWidgets.Auto, defvalue:
"#AR-UserAction_State_On",
desc:
"Description of action to toggle on")]
13 protected string m_sActionStateOn;
16 [
Attribute(uiwidget: UIWidgets.Auto, defvalue:
"#AR-UserAction_State_Off",
desc:
"Description of action to toggle off")]
17 protected string m_sActionStateOff;
20 [
Attribute(uiwidget: UIWidgets.CheckBox, defvalue:
"1",
desc:
"Available only for entities seated in pilot compartment")]
21 protected bool m_bPilotOnly;
24 [
Attribute(uiwidget: UIWidgets.CheckBox,
desc:
"Available only for entities seated in a vehicle")]
25 protected bool m_bInteriorOnly;
27 protected CompartmentControllerComponent m_VehicleController;
30 override void Init(IEntity pOwnerEntity, GenericComponent pManagerComponent)
32 super.Init(pOwnerEntity, pManagerComponent);
34 m_VehicleController = CompartmentControllerComponent.Cast(pOwnerEntity.FindComponent(CompartmentControllerComponent));
38 override bool CanBeShownScript(IEntity user)
41 ChimeraCharacter character = ChimeraCharacter.Cast(user);
46 if (!character.IsInVehicle())
47 return !(m_bInteriorOnly || m_bPilotOnly);
50 CompartmentAccessComponent compartmentAccess = character.GetCompartmentAccessComponent();
51 if (!compartmentAccess)
56 BaseCompartmentSlot slot = compartmentAccess.GetCompartment();
66 Vehicle vehicle = Vehicle.Cast(
GetOwner().GetRootParent());
67 if (vehicle && vehicle.GetPilotCompartmentSlot() != slot)
72 if (m_bInteriorOnly && slot.GetOwner().GetRootParent() !=
GetOwner().GetRootParent())
79 override bool CanBePerformedScript(IEntity user)
81 return m_bIsToggle || (GetState() != m_bTargetState);
93 void SetState(
bool enable);
97 override void PerformAction(IEntity pOwnerEntity, IEntity pUserEntity)
100 SetState(!GetState());
102 SetState(m_bTargetState);
106 override bool GetActionNameScript(out
string outName)
111 prefix = uiInfo.GetName();
113 if (!prefix.IsEmpty())
117 outName = prefix + m_sActionStateOff;
119 outName = prefix + m_sActionStateOn;