Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_RefundVehicleAmmoSupportStationAction.c
Go to the documentation of this file.
2{
3 [Attribute("1", desc: "Hide the action if the entity has no parent")]
4 protected bool m_bHideIfNoParent;
5
6 [Attribute("1", desc: "When refunding how much of the supplies are refunded. (Supply taken from Catalog)", params: "0")]
7 protected float m_fRefundMultiplier;
8
10 protected SCR_EntityCatalogManagerComponent m_EntityCatalogManager;
11
13 protected int m_iTotalBarrelCount;
14 protected int m_iFullBarrelCount;
15 protected const LocalizedString X_OUTOF_Y_FORMATTING = "#AR-SupportStation_ActionFormat_ItemAmount";
16 protected const LocalizedString INVALID_EMPTY = "#AR-SupportStation_Refund_Helicopter_Weapon_Invalid_Empty";
17
18 //~ Used to get supply cost. Is set to empty if new supply cost needs to be obtained and is checked with the m_EntityToRefund.Prefab to see if it is still the same item to refund
22 protected SCR_EArsenalSupplyCostType m_eArsenalSupplyCostType = SCR_EArsenalSupplyCostType.DEFAULT;
23 protected SCR_BaseSupportStationComponent m_LastCheckedSupportStation;
24
25 //------------------------------------------------------------------------------------------------
27 {
28 //~ Get supply cost type if support station changed
30 {
32
34 if (arsenalComp)
36 }
37
38 //~ Get actual supply cost
39 if (m_ArsenalData)
40 return m_ArsenalData.GetSupplyCost(m_eArsenalSupplyCostType, false);
41 else if (m_NonArsenalData)
42 return m_NonArsenalData.GetSupplyCost(m_eArsenalSupplyCostType);
43
44 return 0;
45 }
46
47 //------------------------------------------------------------------------------------------------
48 override bool CanBeShownScript(IEntity user)
49 {
50 //~ Not valid or has no parent
52 return false;
53
54 if (m_bHideIfNoParent && (!GetOwner() || !GetOwner().GetParent()))
55 return false;
56
57 return super.CanBeShownScript(user);
58 }
59
60 //------------------------------------------------------------------------------------------------
62 {
63 if (reasonInvalid == ESupportStationReasonInvalid.RESUPPLY_NOT_IN_STORAGE)
64 return INVALID_EMPTY;
65
66 return super.GetInvalidPerformReasonString(reasonInvalid);
67 }
68
69 //------------------------------------------------------------------------------------------------
70 override bool CanBePerformedScript(IEntity user)
71 {
72 m_EntityToRefund = null;
74
75 for (int i = m_iTotalBarrelCount - 1; i >= 0; i--)
76 {
77 if (!m_RocketMuzzleComp.CanReloadBarrel(i))
78 {
80 m_EntityToRefund = m_RocketMuzzleComp.GetBarrelProjectile(i);
81
83 }
84 }
85
86 if (m_iFullBarrelCount <= 0)
87 {
88 //~ No rockets in storages
89 SetCanPerform(false, ESupportStationReasonInvalid.RESUPPLY_NOT_IN_STORAGE);
90 return false;
91 }
92
93 return super.CanBePerformedScript(user);
94 }
95
96 //------------------------------------------------------------------------------------------------
97 protected override void CanBePerformedUpdate(IEntity user)
98 {
99 super.CanBePerformedUpdate(user);
100
101 //~ Check if a catalog manager exists and supplies are enabled as no need to do the supply check if they are not
103 return;
104
105 //~ No item to refund
106 if (!m_EntityToRefund)
107 {
108 m_ArsenalData = null;
109 m_NonArsenalData = null;
110 return;
111 }
112
113 //~ For some reason the ammo is not a prefab (Which is technically not possible)
114 EntityPrefabData prefabData = m_EntityToRefund.GetPrefabData();
115 if (!prefabData)
116 {
117 m_ArsenalData = null;
118 m_NonArsenalData = null;
119 return;
120 }
121
122 //~ For some reason could not get the ResourceName from prefab data
123 ResourceName prefabToRefund = prefabData.GetPrefabName();
124 if (prefabToRefund.IsEmpty())
125 {
126 m_ArsenalData = null;
127 m_NonArsenalData = null;
128 m_sRefundPrefab = string.Empty;
129 return;
130 }
131
132 //~ The prefab to refund has changed so update supply amount
133 if (prefabToRefund != m_sRefundPrefab)
134 {
135 m_sRefundPrefab = prefabToRefund;
136
137 //~ Check if can find the entry in the catalog
138 SCR_EntityCatalogEntry catalogEntry = m_EntityCatalogManager.GetEntryWithPrefabFromAnyCatalog(EEntityCatalogType.ITEM, m_sRefundPrefab, m_SupportStationComponent.GetFaction());
139 if (!catalogEntry)
140 {
141 Print("'SCR_RefundVehicleAmmoSupportStationAction' could not find SCR_EntityCatalogEntry for '" + m_sRefundPrefab + "' so the action will not have any supply refund amount!", LogLevel.WARNING);
142 m_ArsenalData = null;
143 m_NonArsenalData = null;
144 return;
145 }
146
147 //~ Check if can find the arsenal data
149 if (!m_ArsenalData)
151
153 Print("'SCR_RefundVehicleAmmoSupportStationAction' could not find SCR_ArsenalItem nor m_NonArsenalData for '" + m_sRefundPrefab + "' so the action will not have any supply refund amount!", LogLevel.WARNING);
154 }
155 }
156
157 //------------------------------------------------------------------------------------------------
162
163 //------------------------------------------------------------------------------------------------
165 {
166 return ESupportStationType.VEHICLE_WEAPON;
167 }
168
169 //------------------------------------------------------------------------------------------------
170 protected override void DelayedInit(IEntity owner)
171 {
172 if (!owner)
173 return;
174
175 super.DelayedInit(owner);
176
179 return;
180
181 m_iTotalBarrelCount = m_RocketMuzzleComp.GetBarrelsCount();
182
183 m_EntityCatalogManager = SCR_EntityCatalogManagerComponent.GetInstance();
184 }
185
186 //------------------------------------------------------------------------------------------------
187 protected override string GetActionStringParam()
188 {
190 return string.Empty;
191
193 }
194
195 //------------------------------------------------------------------------------------------------
196 override bool GetActionNameScript(out string outName)
197 {
198 UIInfo uiInfo = GetUIInfo();
199 if (!uiInfo)
200 return super.GetActionNameScript(outName);
201
202 //~ No item to refund
203 if (!m_EntityToRefund)
204 {
205 outName = uiInfo.GetDescription();
206 return super.GetActionNameScript(outName);
207 }
208
209 //~ Item to refund has no inventory component
211 if (!inventoryItem)
212 {
213 outName = uiInfo.GetDescription();
214 return super.GetActionNameScript(outName);
215 }
216
217 //~ Item to refund has no UIInfo or no name assigned
218 UIInfo itemUIInfo = inventoryItem.GetUIInfo();
219 if (!itemUIInfo || itemUIInfo.GetName().IsEmpty())
220 {
221 outName = uiInfo.GetDescription();
222 return super.GetActionNameScript(outName);
223 }
224
225 outName = WidgetManager.Translate(uiInfo.GetName(), itemUIInfo.GetName());
226
227 return super.GetActionNameScript(outName);
228 }
229
230}
EEntityCatalogType
ESupportStationType
Faction GetParent()
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
SCR_EArsenalSupplyCostType GetSupplyCostType()
SCR_BaseSupportStationComponent m_SupportStationComponent
void SetCanPerform(bool canPerform, ESupportStationReasonInvalid reasonInvalid)
Get prefab entity Data of type Ignores disabled Data s param dataType class of Data type you with to obtain return Entity Data of given type Null if not found *SCR_BaseEntityCatalogData GetEntityDataOfType(typename dataType)
Base Used for items and attachments which should not be shown in the arsenal but should have a cost t...
override LocalizedString GetInvalidPerformReasonString(ESupportStationReasonInvalid reasonInvalid)
UIInfo - allows to define UI elements.
Definition UIInfo.c:14
IEntity GetOwner()
Owner entity of the fuel tank.
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
Definition LogLevel.c:14
SCR_FieldOfViewSettings Attribute