Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_CharacterHasGadgetCondition.c
Go to the documentation of this file.
1 //------------------------------------------------------------------------------------------------
6 {
7  [Attribute("1", UIWidgets.CheckBox, "Only if gadget is in hands", "")]
8  protected bool m_bEquipped;
9 
10  [Attribute("0", UIWidgets.CheckBox, "Only if gadget is not in hands and in ", "")]
11  protected bool m_bNotEquipped;
12 
13  [Attribute("1", UIWidgets.CheckBox, "Specified gadget type", "")]
14  protected bool m_bCheckSpecificGadget;
15 
16  [Attribute(defvalue: SCR_Enum.GetDefault(EGadgetType.MAP), UIWidgets.ComboBox, "Gadget type", "", ParamEnumArray.FromEnum(EGadgetType))]
17  protected EGadgetType m_eGadget;
18 
19  [Attribute("0", UIWidgets.CheckBox, "Pass if the gadget is turned on", "")]
20  protected bool m_bIsToggledOn;
21 
22  [Attribute("0", UIWidgets.CheckBox, "Pass if the gadget is turned off", "")]
23  protected bool m_bIsToggledOff;
24 
25  //------------------------------------------------------------------------------------------------
28  override bool IsAvailable(SCR_AvailableActionsConditionData data)
29  {
30  if (!data)
31  return false;
32 
33  bool equipped;
34 
35  SCR_GadgetComponent gadgetComponent = data.GetHeldGadgetComponent();
36  if (gadgetComponent)
37  {
38  if (m_bCheckSpecificGadget)
39  equipped = gadgetComponent.GetType() == m_eGadget;
40  else
41  equipped = true;
42  }
43 
44  // Force failure if expected as unequipped while gadget is equipped
45  if (equipped && m_bNotEquipped)
46  return false;
47 
48  bool result;
49  if (m_bEquipped)
50  {
51  result = equipped;
52  }
53  else
54  {
55  // Check gadgets that are not in hands
56  gadgetComponent = null;
57 
58  // Force failure if there is no gadget at that point
59  IEntity gadget = data.GetGadget(m_eGadget);
60  if (!gadget)
61  return false;
62 
63  // Get new gadget component or clear
64  if (m_bIsToggledOn || m_bIsToggledOff)
65  gadgetComponent = SCR_GadgetComponent.Cast(gadget.FindComponent(SCR_GadgetComponent));
66 
67  result = true;
68  }
69 
70  // Allow only toggled on or off
71  if (result && (m_bIsToggledOn || m_bIsToggledOff))
72  {
73  // Pass if either requirement is met
74  bool isToggledOn = gadgetComponent && gadgetComponent.IsToggledOn();
75  if (isToggledOn && m_bIsToggledOn)
76  result = true;
77  else if (!isToggledOn && m_bIsToggledOff)
78  result = true;
79  else
80  result = false;
81  }
82 
83  return GetReturnResult(result);
84  }
85 }
SCR_CharacterHasGadgetCondition
Definition: SCR_CharacterHasGadgetCondition.c:5
SCR_Enum
Definition: SCR_Enum.c:1
SCR_AvailableActionsConditionData
Definition: SCR_AvailableActionsConditionData.c:5
SCR_AvailableActionCondition
A single available action condition representation.
Definition: SCR_AvailableActionsCondition.c:3
Attribute
typedef Attribute
Post-process effect of scripted camera.
data
Get all prefabs that have the spawner data
Definition: SCR_EntityCatalogManagerComponent.c:305
BaseContainerProps
SCR_AIGoalReaction_Follow BaseContainerProps
Handles insects that are supposed to be spawned around selected prefabs defined in prefab names array...
Definition: SCR_AIGoalReaction.c:468