39 if (!resource || !resource.IsValid())
50 if (inventoryEntitySource)
53 if (inventoryEntityUiInfo)
55 uiInfo = inventoryEntityUiInfo.GetUIInfo();
57 if (uiInfo && !uiInfo.GetName().IsEmpty())
67 if (weaponEntitySource)
71 if (uiInfo && !uiInfo.GetName().IsEmpty())
93class SCR_ResupplySupportStationData
105 protected FactionAffiliationComponent GetFactionAffiliationGadgetOrOwner(notnull
IEntity actionOwner, SCR_SupportStationGadgetComponent supportStationGadget)
107 FactionAffiliationComponent factionAffiliationComponent;
109 if (supportStationGadget)
111 factionAffiliationComponent = FactionAffiliationComponent.Cast(supportStationGadget.GetOwner().FindComponent(FactionAffiliationComponent));
112 if (factionAffiliationComponent)
113 return factionAffiliationComponent;
116 factionAffiliationComponent = FactionAffiliationComponent.Cast(actionOwner.FindComponent(FactionAffiliationComponent));
117 if (!factionAffiliationComponent)
121 factionAffiliationComponent = FactionAffiliationComponent.Cast(parent.
FindComponent(FactionAffiliationComponent));
124 return factionAffiliationComponent;
150class SCR_ResupplyCatalogItemSupportStationData : SCR_ResupplySupportStationData
152 [
Attribute(
desc:
"This will go 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))]
153 protected SCR_ESupportStationResupplyType m_eResupplyType;
155 [
Attribute(
"0",
desc:
"If true will use the item associated with the support station default faction. Otherwise will only take default if no faction is set")]
156 protected bool m_bAlwaysTakeDefaultFaction;
158 protected ref map<FactionKey, ref SCR_EntityCatalogEntry> m_mFactionItems =
new map<FactionKey, ref SCR_EntityCatalogEntry>();
163 FactionManager factionManager =
GetGame().GetFactionManager();
167 array<Faction> factions = {};
168 factionManager.GetFactionsList(factions);
170 SCR_Faction scrFaction;
171 SCR_EntityCatalog itemCatalog;
173 array<SCR_EntityCatalogEntry> filteredEntityList = {};
174 array<SCR_BaseEntityCatalogData> dataList = {};
175 SCR_EntityCatalogSupportStationResupplyData resupplyData;
179 foreach (
Faction faction : factions)
181 scrFaction = SCR_Faction.Cast(faction);
189 count = itemCatalog.GetEntityListWithData(SCR_EntityCatalogSupportStationResupplyData, filteredEntityList, dataList);
193 for (
int i = 0; i < count; i++)
195 resupplyData = SCR_EntityCatalogSupportStationResupplyData.Cast(dataList[i]);
196 if (!resupplyData || resupplyData.
GetResupplyType() != m_eResupplyType)
199 m_mFactionItems.Insert(faction.GetFactionKey(), filteredEntityList[i]);
206 SCR_ECharacterRank
GetRequiredRank(notnull
IEntity actionOwner, SCR_SupportStationGadgetComponent supportStationGadget)
208 SCR_ECharacterRank requiredRank = SCR_ECharacterRank.PRIVATE;
210 if (m_mFactionItems.IsEmpty())
213 FactionAffiliationComponent factionAffiliationComponent = GetFactionAffiliationGadgetOrOwner(actionOwner, supportStationGadget);
214 if (!factionAffiliationComponent)
218 if (!m_bAlwaysTakeDefaultFaction)
219 faction = factionAffiliationComponent.GetAffiliatedFaction();
222 faction = factionAffiliationComponent.GetDefaultAffiliatedFaction();
227 SCR_EntityCatalogEntry catalogEntry;
228 if (!m_mFactionItems.Find(faction.GetFactionKey(), catalogEntry) || !catalogEntry)
231 SCR_ArsenalItem itemData = SCR_ArsenalItem.Cast(catalogEntry.
GetEntityDataOfType(SCR_ArsenalItem));
239 int GetRequiredAvailableAllocatedSupplies(notnull
IEntity actionOwner, SCR_SupportStationGadgetComponent supportStationGadget)
241 if (m_mFactionItems.IsEmpty())
244 FactionAffiliationComponent factionAffiliationComponent = GetFactionAffiliationGadgetOrOwner(actionOwner, supportStationGadget);
245 if (!factionAffiliationComponent)
248 if (m_bAlwaysTakeDefaultFaction)
251 Faction faction = factionAffiliationComponent.GetAffiliatedFaction();
255 SCR_EntityCatalogEntry catalogEntry;
256 if (!m_mFactionItems.Find(faction.GetFactionKey(), catalogEntry) || !catalogEntry)
259 SCR_ArsenalItem itemData = SCR_ArsenalItem.Cast(catalogEntry.
GetEntityDataOfType(SCR_ArsenalItem));
261 return itemData.
GetSupplyCost(SCR_EArsenalSupplyCostType.DEFAULT);
267 override bool GetResupplyItemOrMuzzle(notnull
IEntity targetCharacter, notnull
IEntity actionOwner, SCR_SupportStationGadgetComponent supportStationGadget, out ResourceName item, out BaseMuzzleComponent muzzle)
269 if (m_mFactionItems.IsEmpty())
272 FactionAffiliationComponent factionAffiliationComponent = GetFactionAffiliationGadgetOrOwner(actionOwner, supportStationGadget);
273 if (!factionAffiliationComponent)
278 if (m_bAlwaysTakeDefaultFaction)
280 faction = factionAffiliationComponent.GetDefaultAffiliatedFaction();
286 faction = factionAffiliationComponent.GetAffiliatedFaction();
289 faction = factionAffiliationComponent.GetDefaultAffiliatedFaction();
295 SCR_EntityCatalogEntry catalogEntry;
296 if (!m_mFactionItems.Find(faction.GetFactionKey(), catalogEntry) || !catalogEntry)
300 return !SCR_StringHelper.IsEmptyOrWhiteSpace(item);
305class SCR_ResupplyHeldWeaponSupportStationData : SCR_ResupplySupportStationData
308 protected ref array<EMuzzleType> m_aMuzzleTypes;
310 [
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!")]
311 protected bool m_bCheckFaction;
314 override bool GetResupplyItemOrMuzzle(notnull
IEntity targetCharacter, notnull
IEntity actionOwner, SCR_SupportStationGadgetComponent supportStationGadget, out ResourceName item, out BaseMuzzleComponent muzzle)
316 if (m_aMuzzleTypes.IsEmpty())
319 BaseWeaponManagerComponent weaponsManager = BaseWeaponManagerComponent.Cast(targetCharacter.FindComponent(BaseWeaponManagerComponent));
324 BaseWeaponComponent baseWeaponComp = weaponsManager.GetCurrentWeapon();
328 string weaponSlotType = baseWeaponComp.GetWeaponSlotType();
329 if (weaponSlotType !=
"primary" && weaponSlotType !=
"secondary")
332 array<BaseMuzzleComponent> muzzles = {};
335 baseWeaponComp.GetMuzzlesList(muzzles);
336 SCR_MuzzleInMagComponent inMagMuzzle;
338 foreach (BaseMuzzleComponent muzzleComp : muzzles)
340 if (m_aMuzzleTypes.Contains(muzzleComp.GetMuzzleType()))
343 inMagMuzzle = SCR_MuzzleInMagComponent.Cast(muzzleComp);
344 if (inMagMuzzle && !inMagMuzzle.CanBeReloaded())
348 item = muzzleComp.GetDefaultMagazineOrProjectileName();
364 SCR_EntityCatalogManagerComponent catalogManager = SCR_EntityCatalogManagerComponent.GetInstance();
368 FactionAffiliationComponent factionAffiliationComponent = GetFactionAffiliationGadgetOrOwner(actionOwner, supportStationGadget);
369 if (!factionAffiliationComponent)
372 SCR_Faction faction = SCR_Faction.Cast(factionAffiliationComponent.GetDefaultAffiliatedFaction());
377 if (!catalogManager.GetEntryWithPrefabFromFactionCatalog(
EEntityCatalogType.ITEM, item, faction))
385 int GetRequiredAvailableAllocatedSupplies(notnull
IEntity actionOwner, ResourceName
resourceName)
387 SCR_EntityCatalogManagerComponent entityCatalogManager = SCR_EntityCatalogManagerComponent.GetInstance();
388 if (!entityCatalogManager)
395 SCR_ArsenalItem arsenalItemData = SCR_ArsenalItem.Cast(catalogEntry.
GetEntityDataOfType(SCR_ArsenalItem));
396 if (!arsenalItemData)
402 return arsenalItemData.
GetSupplyCost(SCR_EArsenalSupplyCostType.GADGET_ARSENAL,
false);