Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_ResupplySupportStationAction.c
Go to the documentation of this file.
1//~ Use the inherent versions!
2[BaseContainerProps(), BaseContainerCustomStringTitleField("USE INHERITED VERSION ONLY!")]
4{
5 [Attribute(ESupportStationType.RESUPPLY_AMMO.ToString(), desc: "Which Resupply this action is: Medical or ammo", uiwidget: UIWidgets.SearchComboBox, enums: ParamEnumArray.FromEnum(ESupportStationType))]
7
8 [Attribute("-1", desc: "How much of the given item (or weapon magazines) can be in the inventory of the character. -1 means it is unlimited")]
9 protected int m_iMaxResupplyCount;
10
11 [Attribute("#AR-SupportStation_Resupply_ActionInvalid_NoInventorySpace", desc: "Text shown on action if player cannot resupply because inventory is full", uiwidget: UIWidgets.LocaleEditBox)]
13
14 [Attribute("#AR-SupportStation_Resupply_ActionInvalid_RankTooLow", desc: "Text shown on action if player cannot resupply because their rank is Renegade", uiwidget: UIWidgets.LocaleEditBox)]
16
17 [Attribute("#AR-SupportStation_Resupply_ActionInvalid_NotEnoughAvailableAllocatedSupplies", desc: "Text shown on action if player cannot resupply because the player does not have enough Available Allocated Supplies", uiwidget: UIWidgets.LocaleEditBox)]
19
20 [Attribute(ENotification.UNKNOWN.ToString(), desc: "Notification when the action is used. Shown to player using the action if resupply self or on the player that is being resupplied if resupply other. Leave unknown to ignore", uiwidget: UIWidgets.SearchComboBox, enums: ParamEnumArray.FromEnum(ENotification))]
22
24
25 protected SCR_ArsenalManagerComponent m_ArsenalManager;
26
27 protected SCR_InventoryStorageManagerComponent m_InventoryManagerTarget;
28
29 protected EResupplyUnavailableReason m_eResupplyUnavailableReason;
30
31 protected bool m_bCanResupply;
32 protected int m_iCurrentItemAmount = -1;
33
34 protected const LocalizedString X_OUTOF_Y_FORMATTING = "#AR-SupportStation_ActionFormat_ItemAmount";
35 protected const LocalizedString CURRENT_ITEM_AMOUNT_FORMATTING = "#AR-SupportStation_ActionFormat_CurrentItemAmount";
36
37 //------------------------------------------------------------------------------------------------
39 {
41 }
42
43 //------------------------------------------------------------------------------------------------
45 {
46 if (reasonInvalid == ESupportStationReasonInvalid.RESUPPLY_ENOUGH_ITEMS)
48 else if (reasonInvalid == ESupportStationReasonInvalid.RESUPPLY_INVENTORY_FULL)
50 else if (reasonInvalid == ESupportStationReasonInvalid.RANK_TOO_LOW)
52 else if (reasonInvalid == ESupportStationReasonInvalid.NOT_ENOUGH_AVAILABLE_ALLOCATED_SUPPLIES)
54
55 return super.GetInvalidPerformReasonString(reasonInvalid);
56 }
57
58 //------------------------------------------------------------------------------------------------
59 //~ Returns true if the action is shown but disabled because of no supplies, max items or inventory full. Otherwise hide it to avoid to many options
60 protected bool GetShowButDisabled()
61 {
62 if (m_eResupplyUnavailableReason == EResupplyUnavailableReason.NOT_IN_GIVEN_STORAGE)
63 return false;
64
65 if (m_eResupplyUnavailableReason == EResupplyUnavailableReason.ENOUGH_ITEMS || m_eResupplyUnavailableReason == EResupplyUnavailableReason.INVENTORY_FULL)
66 return true;
67
69 return true;
70
71 return false;
72 }
73
74 //------------------------------------------------------------------------------------------------
79
80 //------------------------------------------------------------------------------------------------
81 protected override bool CanHaveMultipleUsers()
82 {
83 return true;
84 }
85
86 //------------------------------------------------------------------------------------------------
87 override bool CanBeShownScript(IEntity user)
88 {
89 if (!m_ResupplyData)
90 return false;
91
92 if (m_ArsenalComponent && !m_ArsenalComponent.IsArsenalEnabled())
93 return false;
94
95 return super.CanBeShownScript(user);
96 }
97
98 //------------------------------------------------------------------------------------------------
99 override bool CanBePerformedScript(IEntity user)
100 {
101 if (GetItemPrefab().IsEmpty())
102 {
104 if (GetItemPrefab().IsEmpty())
105 return false;
106 }
107
108 bool canBePerformed = super.CanBePerformedScript(user);
109
110 //~ Cannot resupply as resupply action unavailible
111 if (canBePerformed && !m_bCanResupply)
112 {
113 //~ Set reason action is unavailible
114 if (m_eResupplyUnavailableReason == EResupplyUnavailableReason.ENOUGH_ITEMS)
115 SetCanPerform(false, ESupportStationReasonInvalid.RESUPPLY_ENOUGH_ITEMS);
116 else if (m_eResupplyUnavailableReason == EResupplyUnavailableReason.INVENTORY_FULL)
117 SetCanPerform(false, ESupportStationReasonInvalid.RESUPPLY_INVENTORY_FULL);
118 else if (m_eResupplyUnavailableReason == EResupplyUnavailableReason.NOT_IN_GIVEN_STORAGE)
119 SetCanPerform(false, ESupportStationReasonInvalid.RESUPPLY_NOT_IN_STORAGE);
120 else if (m_eResupplyUnavailableReason == EResupplyUnavailableReason.NO_VALID_WEAPON)
121 SetCanPerform(false, ESupportStationReasonInvalid.RESUPPLY_NO_VALID_WEAPON);
122 else if (m_eResupplyUnavailableReason == EResupplyUnavailableReason.RANK_TOO_LOW)
123 SetCanPerform(false, ESupportStationReasonInvalid.RANK_TOO_LOW);
124 else if (m_eResupplyUnavailableReason == EResupplyUnavailableReason.NOT_ENOUGH_AVAILABLE_ALLOCATED_SUPPLIES)
125 SetCanPerform(false, ESupportStationReasonInvalid.NOT_ENOUGH_AVAILABLE_ALLOCATED_SUPPLIES);
126
127 return false;
128 }
129
130 return canBePerformed;
131 }
132
133 //------------------------------------------------------------------------------------------------
134 protected override void CanBePerformedUpdate(IEntity user)
135 {
136 //~ Check if can add to inventory. Only called every x seconds to save performance
138 super.CanBePerformedUpdate(user);
139 }
140
141 //------------------------------------------------------------------------------------------------
142 //~ Can Resupply loops through entire inventory so only call this every x seconds
143 protected void UpdateCanResupply(IEntity owner, IEntity user)
144 {
145 m_bCanResupply = false;
146
147 //~ Reset reason
148 m_eResupplyUnavailableReason = EResupplyUnavailableReason.NO_VALID_WEAPON;
149
150 SetTargetInventory(user, owner);
152 return;
153
154 BaseMuzzleComponent muzzle;
155 if (!m_ResupplyData.GetResupplyItemOrMuzzle(m_InventoryManagerTarget.GetOwner(), owner, m_SupportStationGadget, m_sItemPrefab, muzzle))
156 return;
157
158 //~ No valid item found
160 return;
161
162 //~ Check if resupply is availible (And get current item amount)
163 if (muzzle)
165 else
167
168 m_bCanResupply = m_eResupplyUnavailableReason == EResupplyUnavailableReason.RESUPPLY_VALID;
169
170 //~ Check for rank if items are ranked locked and disable the action if player is Renegade or doesnt meet rank requirement
171 if (!m_bCanResupply || !m_ArsenalManager || !m_ArsenalManager.AreItemsRankLocked())
172 return;
173
174 SCR_ECharacterRank characterRank = SCR_CharacterRankComponent.GetCharacterRank(m_InventoryManagerTarget.GetOwner());
175 SCR_ResupplyCatalogItemSupportStationData catalogSupportData = SCR_ResupplyCatalogItemSupportStationData.Cast(m_ResupplyData);
176 SCR_ResupplyHeldWeaponSupportStationData muzzleSupportData = SCR_ResupplyHeldWeaponSupportStationData.Cast(m_ResupplyData);
177
178 if (characterRank <= SCR_ECharacterRank.RENEGADE || (catalogSupportData && characterRank < catalogSupportData.GetRequiredRank(owner, m_SupportStationGadget)))
179 m_eResupplyUnavailableReason = EResupplyUnavailableReason.RANK_TOO_LOW;
180
181 if (SCR_ArsenalManagerComponent.IsMilitarySupplyAllocationEnabled())
182 {
183 PlayerManager playerManager = GetGame().GetPlayerManager();
184 int playerId = playerManager.GetPlayerIdFromControlledEntity(user);
185
186 SCR_PlayerController playerController = SCR_PlayerController.Cast(playerManager.GetPlayerController(playerId));
187 SCR_PlayerSupplyAllocationComponent playerSupplyAllocationComponent;
188
189 if (playerController)
190 playerSupplyAllocationComponent = SCR_PlayerSupplyAllocationComponent.Cast(playerController.FindComponent(SCR_PlayerSupplyAllocationComponent));
191
192 if (muzzle)
193 {
194 if (playerSupplyAllocationComponent && muzzleSupportData && !playerSupplyAllocationComponent.HasPlayerEnoughAvailableAllocatedSupplies(muzzleSupportData.GetRequiredAvailableAllocatedSupplies(owner, m_sItemPrefab)))
195 m_eResupplyUnavailableReason = EResupplyUnavailableReason.NOT_ENOUGH_AVAILABLE_ALLOCATED_SUPPLIES;
196 }
197 else
198 {
199 if (playerSupplyAllocationComponent && catalogSupportData && !playerSupplyAllocationComponent.HasPlayerEnoughAvailableAllocatedSupplies(catalogSupportData.GetRequiredAvailableAllocatedSupplies(owner, m_SupportStationGadget)))
200 m_eResupplyUnavailableReason = EResupplyUnavailableReason.NOT_ENOUGH_AVAILABLE_ALLOCATED_SUPPLIES;
201 }
202 }
203
204 m_bCanResupply = m_eResupplyUnavailableReason == EResupplyUnavailableReason.RESUPPLY_VALID;
205 }
206
207 //------------------------------------------------------------------------------------------------
208 override void PerformAction(IEntity pOwnerEntity, IEntity pUserEntity)
209 {
210 super.PerformAction(pOwnerEntity, pUserEntity);
211 UpdateCanResupply(pOwnerEntity, pUserEntity);
212 }
213
214 //------------------------------------------------------------------------------------------------
215 protected void SetTargetInventory(IEntity user, IEntity owner)
216 {
217 return;
218 }
219
220 //------------------------------------------------------------------------------------------------
221 SCR_InventoryStorageManagerComponent GetTargetInventory()
222 {
224 }
225
226 //------------------------------------------------------------------------------------------------
227 //~ Get inventory of who ever provide the item. This simply checkes if the item is in the inventory. This should be an arsenal as it does not remove anything from the inventory
229 {
230 return null;
231 }
232
233 //------------------------------------------------------------------------------------------------
234 protected override void ResetReferencesOnServer()
235 {
236 m_sItemPrefab = string.Empty;
237 super.ResetReferencesOnServer();
238 }
239
240 //------------------------------------------------------------------------------------------------
241 protected override void DelayedInit(IEntity owner)
242 {
243 if (!owner)
244 return;
245
246 super.DelayedInit(owner);
247
249
250 SCR_ArsenalManagerComponent.GetArsenalManager(m_ArsenalManager);
251 }
252
253 //------------------------------------------------------------------------------------------------
254 protected override string GetActionStringParam()
255 {
256 if (!m_bCanPerform)
257 {
258 if (m_eResupplyUnavailableReason != EResupplyUnavailableReason.INVENTORY_FULL)
259 return string.Empty;
260 }
261
262 if (m_iMaxResupplyCount < 0)
264
266 }
267}
268
ENotification
ESupportStationType
ArmaReforgerScripted GetGame()
Definition game.c:1398
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
void SCR_CharacterRankComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
class SCR_HitZoneGroupNameHolder BaseContainerCustomStringTitleField("USE INHERITED VERSION ONLY!")
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
static SCR_ArsenalComponent FindArsenalComponent(notnull IEntity entity, bool getFromSlotted=true)
InventoryStorageManagerComponent GetProviderInventory()
void SetTargetInventory(IEntity user, IEntity owner)
void UpdateCanResupply(IEntity owner, IEntity user)
override void PerformAction(IEntity pOwnerEntity, IEntity pUserEntity)
override LocalizedString GetInvalidPerformReasonString(ESupportStationReasonInvalid reasonInvalid)
SCR_InventoryStorageManagerComponent GetTargetInventory()
SCR_InventoryStorageManagerComponent m_InventoryManagerTarget
SCR_SupportStationGadgetComponent m_SupportStationGadget
void SetCanPerform(bool canPerform, ESupportStationReasonInvalid reasonInvalid)
ESupportStationReasonInvalid m_eCannotPerformReason
static bool IsEmptyOrWhiteSpace(string input)
IEntity GetOwner()
Owner entity of the fuel tank.
SCR_FieldOfViewSettings Attribute
proto native bool IsEmpty()