Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_AIToggleFlashlights.c
Go to the documentation of this file.
2{
3 [Attribute("true", UIWidgets.CheckBox, "Set flashlights active or inactive?")]
4 protected bool m_bEnable;
5
7 protected SCR_AICharacterSettingsComponent m_Settings;
8
9 //------------------------------------------------------------------------------------------------------
10 override static string GetOnHoverDescription()
11 {
12 return "Sets all flashlights attached to vest enabled or disabled. Returns failure if no suitable flashlight found.";
13 }
14
15
16 //------------------------------------------------------------------------------------------------------
17 override void OnInit(AIAgent owner)
18 {
19 m_GadgetManager = SCR_GadgetManagerComponent.GetGadgetManager(owner.GetControlledEntity());
20 m_Settings = SCR_AICharacterSettingsComponent.Cast(owner.FindComponent(SCR_AICharacterSettingsComponent));
21 }
22
23 //------------------------------------------------------------------------------------------------------
24 protected override string GetNodeMiddleText()
25 {
26 return string.Format("Flashlights Enabled: %1", m_bEnable);
27 }
28
29 //------------------------------------------------------------------------------------------------------
30 ENodeResult ToggleFlashlights(notnull SCR_GadgetManagerComponent gadgetManager, SCR_AICharacterSettingsComponent settingsComp, bool newState)
31 {
32 array<SCR_GadgetComponent> gadgets = gadgetManager.GetGadgetsByType(EGadgetType.FLASHLIGHT);
33
34 if (!gadgets)
35 return ENodeResult.FAIL;
36
37 if (gadgets.IsEmpty())
38 return ENodeResult.FAIL;
39
40 // Bail if settings don't allow us to interact with lights
41 if (settingsComp)
42 {
44 if (setting && !setting.IsLightInterractionAllowed())
45 return ENodeResult.SUCCESS;
46 }
47
48 bool success = false;
49 foreach (SCR_GadgetComponent gadget : gadgets)
50 {
51 if (!gadget)
52 continue;
53
54 InventoryItemComponent invComp = InventoryItemComponent.Cast(gadget.GetOwner().FindComponent(InventoryItemComponent));
55
56 if (!invComp)
57 continue;
58
59 EquipmentStorageSlot slot = EquipmentStorageSlot.Cast(invComp.GetParentSlot());
60
61 // Don't toggle gadgets not in slot
62 if (!slot)
63 continue;
64
65 bool occluded = slot.IsOccluded();
66 bool newToggledState = newState && !occluded;
67 bool currentState = gadget.IsToggledOn();
68
69 if (newToggledState != gadget.IsToggledOn())
70 gadget.ToggleActive(newToggledState, SCR_EUseContext.FROM_ACTION);
71
72 success |= true;
73 }
74
75 if (success)
76 return ENodeResult.SUCCESS;
77 else
78 return ENodeResult.FAIL;
79 }
80
81 //------------------------------------------------------------------------------------------------------
82 static protected override bool VisibleInPalette()
83 {
84 return false;
85 }
86};
87
88
89
91{
92 //------------------------------------------------------------------------------------------------------
93 override ENodeResult EOnTaskSimulate(AIAgent owner, float dt)
94 {
95 if (!m_GadgetManager)
96 return ENodeResult.FAIL;
97
99 };
100
101 //------------------------------------------------------------------------------------------------------
102 override static protected bool VisibleInPalette()
103 {
104 return true;
105 }
106};
107
108
109
111{
112 //------------------------------------------------------------------------------------------------------
113 override void OnAbort(AIAgent owner, Node nodeCausingAbort)
114 {
115 if (!m_GadgetManager)
116 return;
117
119 }
120
121 //------------------------------------------------------------------------------------------------------
122 override ENodeResult EOnTaskSimulate(AIAgent owner, float dt)
123 {
124 return ENodeResult.RUNNING;
125 }
126
127 //------------------------------------------------------------------------------------------------------
128 override static protected bool VisibleInPalette()
129 {
130 return true;
131 }
132};
SCR_EUseContext
Definition Node.c:13
SCR_GadgetManagerComponent m_GadgetManager
ENodeResult ToggleFlashlights(notnull SCR_GadgetManagerComponent gadgetManager, SCR_AICharacterSettingsComponent settingsComp, bool newState)
static override string GetOnHoverDescription()
override void OnInit(AIAgent owner)
SCR_AICharacterSettingsComponent m_Settings
static SCR_GadgetManagerComponent GetGadgetManager(IEntity entity)
ENodeResult
Definition ENodeResult.c:13
SCR_FieldOfViewSettings Attribute