Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_ResourceEncapsulatorActionBase.c
Go to the documentation of this file.
2{
3 override bool _WB_GetCustomTitle(BaseContainer source, out string title)
4 {
5 title = source.GetClassName();
6 title.Replace("SCR_ResourceEncapsulatorAction", "");
8 return true;
9 }
10}
11
13class SCR_ResourceEncapsulatorActionBase
14{
15 void PerformAction(SCR_ResourceContainer representativeContainer, SCR_ResourceContainer representedContainer)
16 {
17
18 }
19}
20
22class SCR_ResourceEncapsulatorActionChangeResourceValue : SCR_ResourceEncapsulatorActionBase
23{
24 [Attribute(uiwidget: UIWidgets.SpinBox, params: string.Format("0.0 %1 1.0", float.MAX))]
25 protected float m_fResourceValueCurrent;
26
27 [Attribute(uiwidget: UIWidgets.CheckBox)]
28 protected bool m_bShouldChangeMaximum;
29
30 [Attribute(uiwidget: UIWidgets.SpinBox, params: "0.0 inf 1.0")]
31 protected float m_fResourceValueMax;
32
33 override void PerformAction(SCR_ResourceContainer representativeContainer, SCR_ResourceContainer representedContainer)
34 {
35 if (!representedContainer)
36 return;
37
38 const SCR_ResourceEncapsulator encapsulator = representativeContainer.GetResourceEncapsulator();
39 const SCR_ResourceContainerQueueBase queue = encapsulator.GetContainerQueue();
40 const int containerQueueCount = queue.GetContainerCount();
41
42 if (containerQueueCount == 0)
43 return;
44
45 float resourcesCurrent = m_fResourceValueCurrent;
46 int resourcesResultMax = m_fResourceValueMax / containerQueueCount;
47 SCR_ResourceContainer container;
48
50 {
51 for (int i = containerQueueCount - 1; i >= 0; --i)
52 {
53 container = queue.GetContainerAt(i);
54
55 if (i == 0)
57 else
58 container.SetMaxResourceValue(resourcesResultMax, true);
59 }
60 }
61
62 encapsulator.RequestConsumtion(encapsulator.GetAggregatedResourceValue());
64 }
65
66 //------------------------------------------------------------------------------------------------
68 {
70 }
71
72 //------------------------------------------------------------------------------------------------
74 {
76 return -1.0;
77
79 }
80}
81
83class SCR_ResourceEncapsulatorActionDisableUserActions : SCR_ResourceEncapsulatorActionBase
84{
85 override void PerformAction(SCR_ResourceContainer representativeContainer, SCR_ResourceContainer representedContainer)
86 {
87 if (!representedContainer)
88 return;
89
90 IEntity owner = representedContainer.GetOwner();
91
92 if (!owner)
93 return;
94
95 ActionsManagerComponent actionManagerComponent = ActionsManagerComponent.Cast(owner.FindComponent(ActionsManagerComponent));
96
97 if (!actionManagerComponent)
98 return;
99
100 actionManagerComponent.Deactivate(owner);
101 }
102}
103
105class SCR_ResourceEncapsulatorActionDisableInventoryStorage : SCR_ResourceEncapsulatorActionBase
106{
107 override void PerformAction(SCR_ResourceContainer representativeContainer, SCR_ResourceContainer representedContainer)
108 {
109 if (!representedContainer)
110 return;
111
112 IEntity owner = representedContainer.GetOwner();
113
114 if (!owner)
115 return;
116
117 InventoryItemComponent inventoryComponent = InventoryItemComponent.Cast(owner.FindComponent(InventoryItemComponent));
118
119 if (!inventoryComponent)
120 return;
121
122 inventoryComponent.DisablePhysics();
123 inventoryComponent.ActivateOwner(false);
124 }
125}
126
128class SCR_ResourceEncapsulatorActionChangeRights : SCR_ResourceEncapsulatorActionBase
129{
130 [Attribute(defvalue: EResourceRights.NONE.ToString(), uiwidget: UIWidgets.ComboBox, desc: "Limits the taking of resources to a specific group", enums: ParamEnumArray.FromEnum(EResourceRights))]
131 protected EResourceRights m_eResourceRights;
132
133 override void PerformAction(SCR_ResourceContainer representativeContainer, SCR_ResourceContainer representedContainer)
134 {
135 if (!representedContainer)
136 return;
137
138 representedContainer.SetResourceRights(m_eResourceRights);
139 }
140}
141
143class SCR_ResourceEncapsulatorActionChangeDecay : SCR_ResourceEncapsulatorActionBase
144{
145 [Attribute(uiwidget: UIWidgets.CheckBox)]
146 protected bool m_bEnableResourceDecay;
147
148 [Attribute(uiwidget: UIWidgets.SpinBox, params: "0.0 inf 1.0")]
149 protected float m_fResourceDecay;
150
151 [Attribute(uiwidget: UIWidgets.SpinBox, params: string.Format("0.0 %1 1.0", float.MAX))]
152 protected float m_fResourceDecayTickrate;
153
154 [Attribute(uiwidget: UIWidgets.SpinBox, params: string.Format("0.0 %1 1.0", float.MAX))]
155 protected float m_fResourceDecayTimeout;
156
157 override void PerformAction(SCR_ResourceContainer representativeContainer, SCR_ResourceContainer representedContainer)
158 {
159 if (!representedContainer)
160 return;
161
162 representedContainer.EnableDecay(m_bEnableResourceDecay, false);
163 representedContainer.SetResourceDecay(m_fResourceDecay, false);
164 representedContainer.SetResourceDecayTickrate(m_fResourceDecayTickrate);
165 representedContainer.SetResourceDecayTimeout(m_fResourceDecayTimeout);
166 }
167}
168
170class SCR_ResourceEncapsulatorActionChangeOnEmptyBehavior : SCR_ResourceEncapsulatorActionBase
171{
172 [Attribute(defvalue: EResourceContainerOnEmptyBehavior.NONE.ToString(), uiwidget: UIWidgets.ComboBox, desc: "Sets the behavior of when the container resource value reaches 0.", enums: ParamEnumArray.FromEnum(EResourceContainerOnEmptyBehavior))]
173 protected EResourceContainerOnEmptyBehavior m_eOnEmptyBehavior;
174
175 override void PerformAction(SCR_ResourceContainer representativeContainer, SCR_ResourceContainer representedContainer)
176 {
177 if (!representedContainer)
178 return;
179
180 representedContainer.SetOnEmptyBehavior(m_eOnEmptyBehavior);
181 }
182}
183
185class SCR_ResourceEncapsulatorActionChangeGain : SCR_ResourceEncapsulatorActionBase
186{
187 [Attribute(uiwidget: UIWidgets.CheckBox)]
188 protected bool m_bEnableResourceGain;
189
190 [Attribute(uiwidget: UIWidgets.SpinBox, params: "0.0 inf 1.0")]
191 protected float m_fResourceGain;
192
193 [Attribute(uiwidget: UIWidgets.SpinBox, params: string.Format("0.0 %1 1.0", float.MAX))]
194 protected float m_fResourceGainTickrate;
195
196 [Attribute(uiwidget: UIWidgets.SpinBox, params: string.Format("0.0 %1 1.0", float.MAX))]
197 protected float m_fResourceGainTimeout;
198
199 override void PerformAction(SCR_ResourceContainer representativeContainer, SCR_ResourceContainer representedContainer)
200 {
201 if (!representedContainer)
202 return;
203
204 representedContainer.EnableGain(m_bEnableResourceGain, false);
205 representedContainer.SetResourceGain(m_fResourceGain, false);
206 representedContainer.SetResourceGainTickrate(m_fResourceGainTickrate);
207 representedContainer.SetResourceGainTimeout(m_fResourceGainTimeout);
208 }
209}
210
EResourceContainerOnEmptyBehavior
SCR_ResourceEncapsulatorActionTypeTitle BaseContainerCustomTitle BaseContainerProps()] class SCR_ResourceEncapsulatorActionBase
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
enum EVehicleType IEntity
proto external Managed FindComponent(typename typeName)
bool EnableDecay(bool shouldEnable, bool notifyChange=true)
bool SetResourceDecay(float value, bool notifyChange=true)
SCR_ResourceEncapsulator GetResourceEncapsulator()
void SetResourceGainTickrate(float tickrate)
void SetResourceGainTimeout(float timeout)
bool SetResourceGain(float value, bool notifyChange=true)
bool SetMaxResourceValue(float value, bool notifyChange=true)
void SetOnEmptyBehavior(EResourceContainerOnEmptyBehavior behavior)
bool EnableGain(bool shouldEnable, bool notifyChange=true)
void SetResourceDecayTimeout(float timeout)
void SetResourceDecayTickrate(float tickrate)
SCR_ResourceContainer GetContainerAt(int index)
override void PerformAction(SCR_ResourceContainer representativeContainer, SCR_ResourceContainer representedContainer)
void RequestGeneration(float resourceAmount, bool notifyChange=true)
override float GetAggregatedResourceValue()
void RequestConsumtion(float resourceCost, bool notifyChange=true)
override float GetAggregatedMaxResourceValue()
override SCR_ResourceContainerQueueBase GetContainerQueue()
SCR_FieldOfViewSettings Attribute
@ PerformAction