8 [
Attribute(
desc:
"This decides what items will be resupplied when using the action")]
9 protected ref SCR_ResupplySupportStationData m_ResupplyData;
11 [
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")]
12 protected int m_iMaxResupplyCount;
14 [
Attribute(
"#AR-SupportStation_Resupply_ActionInvalid_NoInventorySpace",
desc:
"Text shown on action if player cannot resupply because inventory is full", uiwidget: UIWidgets.LocaleEditBox)]
17 [
Attribute(
"#AR-SupportStation_Resupply_ActionInvalid_InvalidNotInStorage",
desc:
"Text shown on action if player cannot resupply because the item is not in the storage of which the character wants to resupply", uiwidget: UIWidgets.LocaleEditBox)]
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))]
23 protected SCR_InventoryStorageManagerComponent m_InventoryManagerTarget;
25 protected EResupplyUnavailableReason m_eResupplyUnavailableReason;
27 protected bool m_bCanResupply;
28 protected ResourceName m_sItemToResupply;
29 protected int m_iCurrentItemAmount = -1;
31 protected const LocalizedString X_OUTOF_Y_FORMATTING =
"#AR-SupportStation_ActionFormat_ItemAmount";
32 protected const LocalizedString CURRENT_ITEM_AMOUNT_FORMATTING =
"#AR-SupportStation_ActionFormat_CurrentItemAmount";
50 return super.GetInvalidPerformReasonString(reasonInvalid);
55 protected bool GetShowButDisabled()
73 protected override bool CanHaveMultipleUsers()
79 override bool CanBeShownScript(IEntity user)
84 return super.CanBeShownScript(user);
88 override bool CanBePerformedScript(IEntity user)
97 bool canBePerformed = super.CanBePerformedScript(user);
100 if (canBePerformed && !m_bCanResupply)
103 if (m_eResupplyUnavailableReason == EResupplyUnavailableReason.ENOUGH_ITEMS)
105 else if (m_eResupplyUnavailableReason == EResupplyUnavailableReason.INVENTORY_FULL)
107 else if (m_eResupplyUnavailableReason == EResupplyUnavailableReason.NOT_IN_GIVEN_STORAGE)
109 else if (m_eResupplyUnavailableReason == EResupplyUnavailableReason.NO_VALID_WEAPON)
115 return canBePerformed;
119 protected override void CanBePerformedUpdate(IEntity user)
122 UpdateCanResupply(
GetOwner(), user);
123 super.CanBePerformedUpdate(user);
127 ResourceName GetItemToResupply()
134 protected void UpdateCanResupply(IEntity owner, IEntity user)
141 SetTargetInventory(user, owner);
163 override void PerformAction(IEntity pOwnerEntity, IEntity pUserEntity)
165 super.PerformAction(pOwnerEntity, pUserEntity);
166 UpdateCanResupply(pOwnerEntity, pUserEntity);
170 protected void SetTargetInventory(IEntity user, IEntity owner)
176 SCR_InventoryStorageManagerComponent GetTargetInventory()
189 protected override void ResetReferencesOnServer()
192 super.ResetReferencesOnServer();
196 protected override void DelayedInit(IEntity owner)
201 super.DelayedInit(owner);
208 protected override string GetActionStringParam()
216 if (m_iMaxResupplyCount < 0)
217 return WidgetManager.Translate(CURRENT_ITEM_AMOUNT_FORMATTING, m_iCurrentItemAmount);
219 return WidgetManager.Translate(X_OUTOF_Y_FORMATTING, m_iCurrentItemAmount, m_iMaxResupplyCount);
225 class SCR_ResupplySupportStationData
228 void Init(IEntity owner)
233 bool GetResupplyItemOrMuzzle(notnull IEntity targetCharacter, notnull IEntity actionOwner, SCR_SupportStationGadgetComponent supportStationGadget, out ResourceName item, out
BaseMuzzleComponent muzzle)
239 protected FactionAffiliationComponent GetFactionAffiliationGadgetOrOwner(notnull IEntity actionOwner, SCR_SupportStationGadgetComponent supportStationGadget)
241 FactionAffiliationComponent factionAffiliationComponent;
243 if (supportStationGadget)
245 factionAffiliationComponent = FactionAffiliationComponent.Cast(supportStationGadget.GetOwner().FindComponent(FactionAffiliationComponent));
246 if (factionAffiliationComponent)
247 return factionAffiliationComponent;
250 factionAffiliationComponent = FactionAffiliationComponent.Cast(actionOwner.FindComponent(FactionAffiliationComponent));
251 if (!factionAffiliationComponent)
253 IEntity parent = actionOwner.GetParent();
255 factionAffiliationComponent = FactionAffiliationComponent.Cast(parent.FindComponent(FactionAffiliationComponent));
258 return factionAffiliationComponent;
267 protected ResourceName m_sItemPrefab;
270 override bool GetResupplyItemOrMuzzle(notnull IEntity targetCharacter, notnull IEntity actionOwner, SCR_SupportStationGadgetComponent supportStationGadget, out ResourceName item, out
BaseMuzzleComponent muzzle)
272 item = m_sItemPrefab;
280 class SCR_ResupplyCatalogItemSupportStationData : SCR_ResupplySupportStationData
282 [
Attribute(
desc:
"This will go through through all the inventory items in the catalog and grab the first one with the given type (needs the SCR_EntityCatalogSupportStationResupplyData)", uiwidget: UIWidgets.SearchComboBox, enums: ParamEnumArray.FromEnum(SCR_ESupportStationResupplyType))]
283 protected SCR_ESupportStationResupplyType m_eResupplyType;
285 [
Attribute(
"0",
desc:
"If true will use the item associated with the support station default faction. Otherwise will only take defualt if no faction is set")]
286 protected bool m_bAlwaysTakeDefaultFaction;
288 protected ref map<FactionKey, ResourceName> m_mFactionItems =
new map<FactionKey, ResourceName>;
291 override void Init(IEntity owner)
293 FactionManager factionManager =
GetGame().GetFactionManager();
297 array<Faction> factions = {};
298 factionManager.GetFactionsList(factions);
303 array<SCR_EntityCatalogEntry> filteredEntityList = {};
304 array<SCR_BaseEntityCatalogData> dataList = {};
309 foreach (
Faction faction : factions)
323 for (
int i = 0; i < count; i++)
326 if (!resupplyData || resupplyData.GetResupplyType() != m_eResupplyType)
329 m_mFactionItems.Insert(faction.GetFactionKey(), filteredEntityList[i].GetPrefab());
336 override bool GetResupplyItemOrMuzzle(notnull IEntity targetCharacter, notnull IEntity actionOwner, SCR_SupportStationGadgetComponent supportStationGadget, out ResourceName item, out
BaseMuzzleComponent muzzle)
338 if (m_mFactionItems.IsEmpty())
341 FactionAffiliationComponent factionAffiliationComponent = GetFactionAffiliationGadgetOrOwner(actionOwner, supportStationGadget);
342 if (!factionAffiliationComponent)
347 if (m_bAlwaysTakeDefaultFaction)
349 faction = factionAffiliationComponent.GetDefaultAffiliatedFaction();
355 faction = factionAffiliationComponent.GetAffiliatedFaction();
358 faction = factionAffiliationComponent.GetDefaultAffiliatedFaction();
364 if (!m_mFactionItems.Find(faction.GetFactionKey(), item))
373 class SCR_ResupplyHeldWeaponSupportStationData : SCR_ResupplySupportStationData
376 protected ref array<EMuzzleType> m_aMuzzleTypes;
378 [
Attribute(
"0",
desc:
"If true will check if the found ammo is part of the entity default faction or owner default faction. Only do this check when item has no inventory, else check if item is in storage instead!")]
379 protected bool m_bCheckFaction;
382 override bool GetResupplyItemOrMuzzle(notnull IEntity targetCharacter, notnull IEntity actionOwner, SCR_SupportStationGadgetComponent supportStationGadget, out ResourceName item, out
BaseMuzzleComponent muzzle)
384 if (m_aMuzzleTypes.IsEmpty())
387 BaseWeaponManagerComponent weaponsManager = BaseWeaponManagerComponent.Cast(targetCharacter.FindComponent(BaseWeaponManagerComponent));
396 string weaponSlotType = baseWeaponComp.GetWeaponSlotType();
397 if (weaponSlotType !=
"primary" && weaponSlotType !=
"secondary")
400 array<BaseMuzzleComponent> muzzles = {};
403 baseWeaponComp.GetMuzzlesList(muzzles);
404 SCR_MuzzleInMagComponent inMagMuzzle;
408 if (m_aMuzzleTypes.Contains(muzzleComp.GetMuzzleType()))
411 inMagMuzzle = SCR_MuzzleInMagComponent.Cast(muzzleComp);
412 if (inMagMuzzle && !inMagMuzzle.CanBeReloaded())
416 item = muzzleComp.GetDefaultMagazineOrProjectileName();
432 SCR_EntityCatalogManagerComponent catalogManager = SCR_EntityCatalogManagerComponent.GetInstance();
436 FactionAffiliationComponent factionAffiliationComponent = GetFactionAffiliationGadgetOrOwner(actionOwner, supportStationGadget);
437 if (!factionAffiliationComponent)
445 if (!catalogManager.GetEntryWithPrefabFromFactionCatalog(
EEntityCatalogType.ITEM, item, faction))