30 protected static SCR_ArsenalManagerComponent s_Instance;
32 [
Attribute(
"{27F28CF7C6698FF8}Configs/Arsenal/ArsenalSaveTypeInfoHolder.conf",
desc:
"Holds a list of save types than can be used for arsenals. Any new arsenal save type should be added to the config to allow it to be set by Editor",
params:
"conf class=SCR_ArsenalSaveTypeInfoHolder")]
35 [
Attribute(
"{183361B6DA2C304F}Configs/Arsenal/ArsenalLoadoutSaveBlacklists.conf",
desc:
"This is server only, A blacklist of entities that are not allowed to be saved at arsenals if the blacklist the item is in is enabled. Can be null.",
params:
"conf class=SCR_LoadoutSaveBlackListHolder")]
39 protected bool m_bDisable
45 protected ref ScriptInvokerBase<SCR_ArsenalManagerComponent_OnPlayerLoadoutChanged>
m_OnPlayerLoadoutUpdated =
new ScriptInvokerBase<SCR_ArsenalManagerComponent_OnPlayerLoadoutChanged>();
58 [
Attribute(
"0",
desc:
"Cost multiplier for supplies on spawning. 0 means the cost is free. Only used in gamemodes that support supply cost on spawning",
params:
"0 inf"),
RplProp(onRplName:
"OnLoadoutSpawnSupplyCostMultiplierChanged")]
61 [
RplProp(onRplName:
"OnArsenalGameModeTypeChanged"),
Attribute(
"-1",
desc:
"This value dictates which arsenal items are available in the gamemode. UNRESTRICTED means there are no restrictions and all items with an ArsenalItem data in the catalog manager", uiwidget:
UIWidgets.SearchComboBox, enums:
SCR_Enum.GetList(
SCR_EArsenalGameModeType,
new ParamEnum(
"UNRESTRICTED",
"-1")))]
64 [
Attribute(
"{39B145760CDDFF59}Configs/Arsenal/ArsenalGameModeUIData.conf",
desc:
"Holds a list of all Arsenal Game Mode data types. Any entry in here will be displayed in the Editor attributes and can be set.",
params:
"conf class=SCR_ArsenalGameModeUIDataHolder")]
67 [
RplProp(onRplName:
"OnArsenalTypeEnabledChanged"),
Attribute(
SCR_Enum.GetFlagValues(SCR_EArsenalTypes).ToString(),
desc:
"This determinds if arsenals are enabled on All entities or non-vehicle only", uiwidget:
UIWidgets.Flags, enums: ParamEnumArray.FromEnum(SCR_EArsenalTypes))]
70 [
Attribute(
desc:
"Items can be ranked locked if true. Conflict functionality only.")]
73 [
Attribute(
desc:
"Link to config that holds military supply allocation data",
params:
"conf class=SCR_MilitarySupplyAllocationConfig")]
76 [
Attribute(
"0",
desc:
"Items consume Military Supply Allocation if true")]
79 [
Attribute(
"1",
desc:
"Multiplier of refund value for items that belong to the same faction as Arsenal.",
params:
"0 1 0.01")]
82 [
Attribute(
"1",
desc:
"Multiplier of refund value for items belonging to different faction from Arsenal.",
params:
"0 1 0.01")]
88 static void GetArsenalLoadoutComponentsToCheck(out array<typename> componentsToCheck)
94 ClothNodeStorageComponent,
95 SCR_EquipmentStorageComponent,
96 SCR_WeaponAttachmentsStorageComponent,
104 static bool GetArsenalManager(out SCR_ArsenalManagerComponent arsenalManager)
116 static float GetItemRefundAmount(notnull
IEntity item, SCR_ArsenalComponent arsenalComponent,
bool mustHaveSupplyStorage, out
bool isSupplyStorageAvailable =
true)
118 isSupplyStorageAvailable = !mustHaveSupplyStorage;
121 EntityPrefabData prefabData = item.GetPrefabData();
126 ResourceName itemPrefab = prefabData.GetPrefabName();
127 if (itemPrefab.IsEmpty())
130 SCR_EntityCatalogManagerComponent entityCatalogManager = SCR_EntityCatalogManagerComponent.GetInstance();
131 if (!entityCatalogManager)
135 SCR_EArsenalSupplyCostType supplyCostType = SCR_EArsenalSupplyCostType.DEFAULT;
136 float refundMultiplier = 1;
138 SCR_ResourceGenerator generator;
140 if (arsenalComponent)
149 SCR_ResourceComponent resourceComponent = SCR_ResourceComponent.Cast(arsenalComponent.GetOwner().FindComponent(SCR_ResourceComponent));
150 if (resourceComponent)
158 else if (mustHaveSupplyStorage)
163 else if (!SCR_ResourceSystemHelper.IsGlobalResourceTypeEnabled())
169 if (!generator && mustHaveSupplyStorage)
173 set<IEntity> countedItems =
new set<IEntity>();
174 float refundAmount = GetItemRefundCost(countedItems, item, entityCatalogManager, supplyCostType, refundMultiplier, faction);
177 if (refundAmount < 0)
181 refundAmount += GetStoredItemsRefundAmount(countedItems, item, entityCatalogManager, supplyCostType, refundMultiplier, faction);
184 if (mustHaveSupplyStorage)
186 isSupplyStorageAvailable = refundAmount == 0;
188 if (refundAmount > 0 && generator)
196 static protected int GetItemRefundCost(notnull inout set<IEntity> countedItems, notnull
IEntity item, notnull SCR_EntityCatalogManagerComponent entityCatalogManager, SCR_EArsenalSupplyCostType supplyCostType,
float refundMultiplier, SCR_Faction faction,
bool minusIfInvalid =
true)
198 if (countedItems.Contains(item))
202 EntityPrefabData prefabData = item.GetPrefabData();
204 return minusIfInvalid * -1;
206 ResourceName itemPrefab = prefabData.GetPrefabName();
207 if (itemPrefab.IsEmpty())
208 return minusIfInvalid * -1;
211 SCR_EntityCatalogEntry entry = entityCatalogManager.GetEntryWithPrefabFromAnyCatalog(
EEntityCatalogType.ITEM, itemPrefab, faction);
213 return minusIfInvalid * -1;
215 array<SCR_BaseEntityCatalogData> entityDataList = {};
217 return minusIfInvalid * -1;
219 SCR_ArsenalManagerComponent arsenalManagerComponent;
220 if (!GetArsenalManager(arsenalManagerComponent))
221 return minusIfInvalid * -1;
225 refundMultiplier *= arsenalManagerComponent.m_fRefundSameFactionItemMultiplier;
227 refundMultiplier *= arsenalManagerComponent.m_fRefundDifferentFactionItemMultiplier;
229 SCR_ArsenalItem arsenalData;
230 SCR_NonArsenalItemCostCatalogData nonArsenalData;
235 foreach (SCR_BaseEntityCatalogData
data : entityDataList)
237 arsenalData = SCR_ArsenalItem.Cast(
data);
240 refundAmount = SCR_ResourceSystemHelper.RoundRefundSupplyAmount(arsenalData.
GetSupplyRefundAmount(supplyCostType,
false) * refundMultiplier);
241 countedItems.Insert(item);
245 nonArsenalData = SCR_NonArsenalItemCostCatalogData.Cast(
data);
248 refundAmount = SCR_ResourceSystemHelper.RoundRefundSupplyAmount(nonArsenalData.
GetSupplyCost(supplyCostType,
false) * refundMultiplier);
249 countedItems.Insert(item);
257 array<Managed> attachments = {};
258 item.FindComponents(AttachmentSlotComponent, attachments);
261 ResourceName attachmentPrefab;
263 AttachmentSlotComponent attachment;
265 foreach (Managed managed : attachments)
267 attachment = AttachmentSlotComponent.Cast(managed);
271 attachedEntity = attachment.GetAttachedEntity();
279 attachmentPrefab = prefabData.GetPrefabName();
280 if (attachmentPrefab.IsEmpty())
283 entry = entityCatalogManager.GetEntryWithPrefabFromAnyCatalog(
EEntityCatalogType.ITEM, attachmentPrefab, faction);
291 foreach (SCR_BaseEntityCatalogData
data : entityDataList)
293 arsenalData = SCR_ArsenalItem.Cast(
data);
296 refundAmount += SCR_ResourceSystemHelper.RoundRefundSupplyAmount(arsenalData.
GetSupplyRefundAmount(supplyCostType,
false) * refundMultiplier);
297 countedItems.Insert(attachedEntity);
301 nonArsenalData = SCR_NonArsenalItemCostCatalogData.Cast(
data);
304 refundAmount += SCR_ResourceSystemHelper.RoundRefundSupplyAmount(nonArsenalData.
GetSupplyCost(supplyCostType,
false) * refundMultiplier);
305 countedItems.Insert(attachedEntity);
317 static protected int GetStoredItemsRefundAmount(notnull inout set<IEntity> countedItems, notnull
IEntity item, notnull SCR_EntityCatalogManagerComponent entityCatalogManager, SCR_EArsenalSupplyCostType supplyCostType,
float refundMultiplier, SCR_Faction faction)
319 BaseInventoryStorageComponent inventoryStorage = BaseInventoryStorageComponent.Cast(item.FindComponent(BaseInventoryStorageComponent));
320 if (!inventoryStorage)
323 array<IEntity> storedItems = {};
324 inventoryStorage.GetAll(storedItems);
326 int storedItemRefundAmount;
328 foreach (
IEntity storedItem : storedItems)
330 storedItemRefundAmount += GetItemRefundCost(countedItems, storedItem, entityCatalogManager, supplyCostType, refundMultiplier, faction,
false);
333 storedItemRefundAmount += GetStoredItemsRefundAmount(countedItems, storedItem, entityCatalogManager, supplyCostType, refundMultiplier, faction);
336 return storedItemRefundAmount;
344 static void OnItemRefunded_S(notnull
IEntity item, notnull PlayerController playerController, SCR_ArsenalComponent arsenal)
346 SCR_ArsenalManagerComponent arsenalManager;
347 if (!GetArsenalManager(arsenalManager))
351 if ((arsenalManager && !arsenalManager.GetGameMode().IsMaster()) || (!arsenalManager && Replication.IsClient()))
354 SCR_ArsenalRefundEffectComponent arsenalRefundEffectComp = SCR_ArsenalRefundEffectComponent.Cast(item.FindComponent(SCR_ArsenalRefundEffectComponent));
355 if (!arsenalRefundEffectComp)
359 SCR_ArsenalRefundEffectComponentClass arsenalRefundEffectClass = SCR_ArsenalRefundEffectComponentClass.Cast(arsenalRefundEffectComp.GetComponentData(arsenalRefundEffectComp.GetOwner()));
360 if (!arsenalRefundEffectClass)
375 static bool IsArsenalTypeEnabled_Static(SCR_EArsenalTypes arsenalType)
377 SCR_ArsenalManagerComponent arsenalManager;
379 if (!GetArsenalManager(arsenalManager))
382 return arsenalManager.IsArsenalTypeEnabled(arsenalType);
409 SCR_NotificationsComponent.SendToEveryone(
ENotification.EDITOR_ATTRIBUTES_CHANGED_ARSENAL_TYPE_ENABLED, playerID);
425 static bool IsMilitarySupplyAllocationEnabled()
427 SCR_ArsenalManagerComponent arsenalManager;
429 if (!GetArsenalManager(arsenalManager))
432 return arsenalManager.m_bUseMilitarySupplyAllocation;
497 SCR_ArsenalManagerComponent arsenalManager;
499 if (!GetArsenalManager(arsenalManager))
502 return arsenalManager.GetArsenalGameModeType();
523 if (arsenalGameModeType <= 0)
524 arsenalGameModeType = -1;
528 SCR_NotificationsComponent.SendToEveryone(
ENotification.EDITOR_ATTRIBUTES_CHANGED_ARSENAL_GAMEMODE_TYPE, playerID, arsenalGameModeType);
544 Print(
"Arsenal Manager is missing the 'm_ArsenalGameModeUIDataHolder'!",
LogLevel.WARNING);
547 unknown.SetName(
"MISSING");
559 arsenalGameModeTypeUIInfoList.Clear();
563 Print(
"Arsenal Manager is missing the 'm_ArsenalGameModeUIDataHolder'!",
LogLevel.WARNING);
600 if (editorPlayerIdClearedLoadout > 0)
601 SCR_NotificationsComponent.SendToEveryone(
ENotification.EDITOR_CHANGED_LOADOUT_SAVE_BLACKLIST, editorPlayerIdClearedLoadout);
606 if (clearExistingLoadouts)
631 if (playerIdClearedLoadout > 0)
632 SCR_NotificationsComponent.SendLocal(
ENotification.PLAYER_LOADOUT_CLEARED_BY_EDITOR);
634 SCR_NotificationsComponent.SendLocal(
ENotification.PLAYER_LOADOUT_CLEARED);
638 [Friend(SCR_PlayerLoadoutComponent)]
659 [Friend(SCR_PlayerLoadoutComponent)]
679 return m_aPlayerLoadouts.Find(playerUID, playerLoadout) && playerLoadout.loadout !=
string.Empty;
744 static float GetLoadoutCalculatedSupplyCost(notnull SCR_BasePlayerLoadout playerLoadout,
bool getLocalPlayer,
int playerID, SCR_Faction playerFaction,
IEntity spawnTarget, out SCR_CampaignMilitaryBaseComponent spawnPointParentBase = null, out SCR_ResourceComponent spawnpointResourceComponent = null)
747 float multiplier = 1;
748 SCR_ArsenalManagerComponent arsenalManager;
749 if (!GetArsenalManager(arsenalManager))
759 spawnPointParentBase = SCR_CampaignMilitaryBaseComponent.Cast(parent.
FindComponent(SCR_CampaignMilitaryBaseComponent));
761 if (spawnPointParentBase)
767 if (spawnPointParentBase)
768 spawnpointResourceComponent = spawnPointParentBase.GetResourceComponent();
770 spawnpointResourceComponent = SCR_ResourceComponent.FindResourceComponent(spawnTarget);
773 multiplier = arsenalManager.GetCalculatedLoadoutSpawnSupplyCostMultiplier();
780 if (spawnpointResourceComponent && !spawnpointResourceComponent.IsResourceTypeEnabled())
782 else if (!spawnpointResourceComponent && !SCR_ResourceSystemHelper.IsGlobalResourceTypeEnabled())
785 float baseMultiplier = 0;
787 if (spawnPointParentBase)
789 if (!spawnPointParentBase.CostSuppliesToSpawn())
792 baseMultiplier = spawnPointParentBase.GetBaseSpawnCostFactor();
795 SCR_PlayerArsenalLoadout playerArsenalLoadout = SCR_PlayerArsenalLoadout.Cast(playerLoadout);
797 if (playerArsenalLoadout)
802 if (getLocalPlayer && arsenalManager.m_LocalPlayerLoadoutData)
804 if (baseMultiplier > 0)
805 return Math.Clamp(arsenalManager.m_LocalPlayerLoadoutData.LoadoutCost * baseMultiplier, 0,
float.MAX);
807 return Math.Clamp(arsenalManager.m_LocalPlayerLoadoutData.LoadoutCost, 0,
float.MAX);
810 else if ((gameMode && gameMode.
IsMaster()) || (!gameMode && Replication.IsServer()))
812 if (baseMultiplier > 0)
813 return Math.Clamp(playerArsenalLoadout.GetLoadoutSuppliesCost(playerID) * baseMultiplier, 0,
float.MAX);
815 return Math.Clamp(playerArsenalLoadout.GetLoadoutSuppliesCost(playerID), 0,
float.MAX);
824 SCR_EntityCatalogManagerComponent entityCatalogManager = SCR_EntityCatalogManagerComponent.GetInstance();
825 if (!entityCatalogManager)
828 ResourceName loadoutResource = playerLoadout.GetLoadoutResource();
829 if (!loadoutResource)
832 Resource resource = Resource.Load(loadoutResource);
836 SCR_EntityCatalogEntry entry = entityCatalogManager.GetEntryWithPrefabFromAnyCatalog(
EEntityCatalogType.CHARACTER, resource.GetResource().GetResourceName(), playerFaction);
839 Print(
"Loadout: '" + resource.GetResource().GetResourceName() +
"' is not in catalog so supply cost is 0!",
LogLevel.WARNING);
843 SCR_EntityCatalogLoadoutData
data = SCR_EntityCatalogLoadoutData.Cast(entry.
GetEntityDataOfType(SCR_EntityCatalogLoadoutData));
848 supplyCost =
data.GetLoadoutSpawnCost();
853 Print(
"Loadout: '" + resource.GetResource().GetResourceName() +
"' has no 'SCR_EntityCatalogLoadoutData' assigned in catalog so supply cost is taken from Campaign budget on prefab!",
LogLevel.WARNING);
855 SCR_EditableEntityUIInfo editableUIInfo = SCR_EditableEntityUIInfo.Cast(entry.
GetEntityUiInfo());
859 array<ref SCR_EntityBudgetValue> budgets = {};
865 foreach (SCR_EntityBudgetValue budget : budgets)
869 supplyCost = budget.GetBudgetValue();
880 if (baseMultiplier > 0)
881 return Math.Clamp((supplyCost * multiplier) * baseMultiplier, 0,
float.
MAX);
883 return Math.Clamp(supplyCost * multiplier, 0,
float.
MAX);
898 SCR_ArsenalManagerComponent arsenalManager;
899 if (!GetArsenalManager(arsenalManager))
903 if (!playerLoadoutData)
906 return playerLoadoutData.LoadoutPlayerSupplyAllocationCost;
923 SCR_EntityCatalogManagerComponent entityCatalogManager = SCR_EntityCatalogManagerComponent.GetInstance();
924 if (!entityCatalogManager)
927 ResourceName loadoutResource = playerLoadout.GetLoadoutResource();
928 if (!loadoutResource)
938 Print(
"Loadout: '" + resource.GetResource().GetResourceName() +
"' is not in catalog so supply cost is 0!",
LogLevel.WARNING);
947 supplyCost =
data.GetLoadoutSpawnCost();
952 Print(
"Loadout: '" + resource.GetResource().GetResourceName() +
"' has no 'SCR_EntityCatalogLoadoutData' assigned in catalog so supply cost is taken from Campaign budget on prefab!",
LogLevel.WARNING);
958 array<ref SCR_EntityBudgetValue> budgets = {};
968 supplyCost = budget.GetBudgetValue();
988 if (playerArsenalLoadout)
1002 bool overwriteArsenalItemUseMSAR;
1006 SCR_EntityCatalogManagerComponent entityCatalogManager = SCR_EntityCatalogManagerComponent.GetInstance();
1007 if (!entityCatalogManager)
1015 if (!arsenalItemData)
1018 if (nonArsenalItemData)
1019 return nonArsenalItemData.
GetSupplyCost(SCR_EArsenalSupplyCostType.DEFAULT, addAdditionalCosts);
1043 SCR_EntityCatalogManagerComponent entityCatalogManager = SCR_EntityCatalogManagerComponent.GetInstance();
1044 if (!entityCatalogManager)
1047 set<IEntity> countedItems =
new set<IEntity>();
1054 if (countedItems.Contains(item))
1057 int storedItemRefundAmount;
1058 BaseInventoryStorageComponent inventoryStorage = BaseInventoryStorageComponent.Cast(item.FindComponent(BaseInventoryStorageComponent));
1059 if (inventoryStorage)
1061 array<IEntity> storedItems = {};
1062 inventoryStorage.GetAll(storedItems);
1064 foreach (
IEntity storedItem : storedItems)
1072 return storedItemRefundAmount;
1075 if (itemPrefab.IsEmpty())
1076 return storedItemRefundAmount;
1080 return storedItemRefundAmount;
1082 float refundMultiplier = 1;
1091 countedItems.Insert(item);
1093 return refundCost + storedItemRefundAmount;
1100 if (!holder || !holder.IsValid())
1116 if (sendNotificationOnFailed)
1117 SCR_NotificationsComponent.SendToPlayer(playerId,
ENotification.PLAYER_LOADOUT_NOT_SAVED);
1122 SCR_InventoryStorageManagerComponent characterInventory = SCR_InventoryStorageManagerComponent.Cast(characterEntity.FindComponent(SCR_InventoryStorageManagerComponent));
1123 if (!characterInventory)
1125 Print(
"'SCR_ArsenalManagerComponent' is checking 'CanSaveArsenal()' but character has no inventory manager!",
LogLevel.ERROR);
1127 if (sendNotificationOnFailed)
1128 SCR_NotificationsComponent.SendToPlayer(playerId,
ENotification.PLAYER_LOADOUT_NOT_SAVED);
1133 array<SCR_EntityCatalog> itemCatalogs = {};
1134 SCR_ArsenalInventoryStorageManagerComponent arsenalInventory;
1137 if (arsenalComponent.
GetArsenalSaveType() == SCR_EArsenalSaveType.FACTION_ITEMS_ONLY || arsenalComponent.
GetArsenalSaveType() == SCR_EArsenalSaveType.FRIENDLY_AND_FACTION_ITEMS_ONLY || arsenalComponent.
GetArsenalSaveType() == SCR_EArsenalSaveType.IN_ARSENAL_ITEMS_ONLY)
1139 if (arsenalComponent.
GetArsenalSaveType() == SCR_EArsenalSaveType.FACTION_ITEMS_ONLY)
1144 Print(
"'SCR_ArsenalManagerComponent' is checking 'CanSaveArsenal()' but player has no SCR_Faction, arsenal saving will simply be allowed",
LogLevel.WARNING);
1151 Print(
string.Format(
"'SCR_ArsenalManagerComponent' is checking 'CanSaveArsenal()' but player faction '%1' has no ITEM catalog!", playerFaction.GetFactionKey()),
LogLevel.ERROR);
1153 if (sendNotificationOnFailed)
1154 SCR_NotificationsComponent.SendToPlayer(playerId,
ENotification.PLAYER_LOADOUT_NOT_SAVED);
1160 itemCatalogs.Insert(itemCatalog);
1163 else if (arsenalComponent.
GetArsenalSaveType() == SCR_EArsenalSaveType.FRIENDLY_AND_FACTION_ITEMS_ONLY)
1168 Print(
"'SCR_ArsenalManagerComponent' is checking 'CanSaveArsenal()' but player has no SCR_Faction, arsenal saving will simply be allowed",
LogLevel.WARNING);
1172 array<Faction> friendlyFactions = {};
1175 if (sendNotificationOnFailed)
1176 SCR_NotificationsComponent.SendToPlayer(playerId,
ENotification.PLAYER_LOADOUT_NOT_SAVED);
1184 foreach (
Faction faction : friendlyFactions)
1194 itemCatalogs.Insert(itemCatalog);
1197 if (itemCatalogs.IsEmpty())
1199 if (sendNotificationOnFailed)
1200 SCR_NotificationsComponent.SendToPlayer(playerId,
ENotification.PLAYER_LOADOUT_NOT_SAVED);
1209 if (!arsenalInventory)
1211 Print(
"'SCR_ArsenalManagerComponent' is checking 'CanSaveArsenal()' and arsenal check type is 'IN_ARSENAL_ITEMS_ONLY' but arsenal has no SCR_ArsenalInventoryStorageManagerComponent, so saving is simply allowed",
LogLevel.WARNING);
1217 set<ResourceName> validatedPrefabs =
new set<ResourceName>();
1218 array<IEntity> allPlayerItems = {};
1222 RplComponent itemRplComponent;
1225 int invalidItemCount = 0;
1226 SCR_ECharacterRank requiredRank = SCR_ECharacterRank.RENEGADE;
1228 foreach (
IEntity item : allPlayerItems)
1230 prefabData = item.GetPrefabData();
1251 if (sendNotificationOnFailed)
1253 itemRplComponent = RplComponent.Cast(item.FindComponent(RplComponent));
1254 if (itemRplComponent)
1255 SCR_NotificationsComponent.SendToPlayer(playerId,
ENotification.PLAYER_LOADOUT_ITEM_FAILED_ITEM_BLACKLISTED, itemRplComponent.Id());
1264 if (arsenalInventory)
1267 if (!arsenalInventory.IsPrefabInArsenalStorage(
resourceName))
1269 if (sendNotificationOnFailed)
1271 itemRplComponent = RplComponent.Cast(item.FindComponent(RplComponent));
1272 if (itemRplComponent)
1273 SCR_NotificationsComponent.SendToPlayer(playerId,
ENotification.PLAYER_LOADOUT_ITEM_FAILED_NOT_IN_ARSENAL, itemRplComponent.Id());
1281 else if (!itemCatalogs.IsEmpty())
1287 itemEntry = itemCatalog.GetEntryWithPrefab(
resourceName);
1297 if (sendNotificationOnFailed)
1299 itemRplComponent = RplComponent.Cast(item.FindComponent(RplComponent));
1300 if (itemRplComponent)
1301 SCR_NotificationsComponent.SendToPlayer(playerId,
ENotification.PLAYER_LOADOUT_ITEM_FAILED_NOT_FACTION, itemRplComponent.Id());
1311 if (arsenalItemData)
1318 if (invalidItemCount > 0 && sendNotificationOnFailed)
1319 SCR_NotificationsComponent.SendToPlayer(playerId,
ENotification.PLAYER_LOADOUT_NOT_SAVED_INVALID_ITEMS, invalidItemCount);
1327 if (sendNotificationOnFailed)
1328 SCR_NotificationsComponent.SendToPlayer(playerId,
ENotification.PLAYER_LOADOUT_NOT_SAVED_INSUFFICIENT_RANK);
1337 SCR_PlayerSupplyAllocationComponent playerSupplyAllocationComponent = SCR_PlayerSupplyAllocationComponent.Cast(playerController.FindComponent(SCR_PlayerSupplyAllocationComponent));
1338 if (playerSupplyAllocationComponent)
1342 if (sendNotificationOnFailed)
1343 SCR_NotificationsComponent.SendToPlayer(playerId,
ENotification.PLAYER_LOADOUT_NOT_SAVED_NOT_ENOUGH_MSA);
1350 return invalidItemCount == 0;
1366 if (!characterEntity)
1373 if (!clientPlayerController || clientPlayerController.
IsPossessing())
1377 SCR_ChimeraCharacter character = SCR_ChimeraCharacter.Cast(characterEntity);
1381 characterFaction = character.GetFaction();
1382 factionKey = characterFaction.GetFactionKey();
1385 if (!
CanSaveLoadout(playerId, characterEntity, characterFaction, arsenalComponent,
true))
1392 DoSetPlayerLoadout(playerId, context.SaveToString(), characterEntity, arsenalSupplyType);
1398 if (countedItems.Contains(item))
1401 int storedItemSupplyCost;
1402 BaseInventoryStorageComponent inventoryStorage = BaseInventoryStorageComponent.Cast(item.FindComponent(BaseInventoryStorageComponent));
1403 if (inventoryStorage)
1405 array<IEntity> storedItems = {};
1406 inventoryStorage.GetAll(storedItems);
1408 foreach (
IEntity storedItem : storedItems)
1416 return storedItemSupplyCost;
1419 if (itemPrefab.IsEmpty())
1420 return storedItemSupplyCost;
1422 SCR_EntityCatalogManagerComponent entityCatalogManager = SCR_EntityCatalogManagerComponent.GetInstance();
1423 if (!entityCatalogManager)
1424 return storedItemSupplyCost;
1428 return storedItemSupplyCost;
1432 if (!arsenalItemData)
1435 if (nonArsenalItemData)
1436 itemCost = nonArsenalItemData.
GetSupplyCost(SCR_EArsenalSupplyCostType.DEFAULT,
false);
1440 itemCost = arsenalItemData.
GetSupplyCost(SCR_EArsenalSupplyCostType.DEFAULT,
false);
1442 return storedItemSupplyCost;
1446 return storedItemSupplyCost;
1448 return storedItemSupplyCost + itemCost;
1457 FactionAffiliationComponent factionAffiliation = FactionAffiliationComponent.Cast(characterEntity.FindComponent(FactionAffiliationComponent));
1458 if (!factionAffiliation)
1462 if (!characterFaction)
1466 set<IEntity> countedItems =
new set<IEntity>();
1467 array<IEntity> storageEntities = {};
1469 EquipedLoadoutStorageComponent loadoutStorage = EquipedLoadoutStorageComponent.Cast(characterEntity.FindComponent(EquipedLoadoutStorageComponent));
1472 loadoutStorage.GetAll(storageEntities,
true);
1473 foreach (
IEntity entity : storageEntities)
1482 storageEntities.Clear();
1483 weaponStorage.GetAll(storageEntities,
true);
1484 foreach (
IEntity entity : storageEntities)
1498 EquipedLoadoutStorageComponent loadoutStorage = EquipedLoadoutStorageComponent.Cast(characterEntity.FindComponent(EquipedLoadoutStorageComponent));
1501 int slotsCount = loadoutStorage.GetSlotsCount();
1502 for (
int i = 0; i < slotsCount; ++i)
1508 IEntity attachedEntity = slot.GetAttachedEntity();
1509 if (!attachedEntity)
1514 while (prefabName.IsEmpty() && prefab)
1516 prefabName = prefab.GetResourceName();
1517 prefab = prefab.GetAncestor();
1520 if (prefabName.IsEmpty())
1523 SCR_ClothingLoadoutData clothingData =
new SCR_ClothingLoadoutData();
1524 clothingData.SlotIdx = i;
1525 clothingData.ClothingPrefab = prefabName;
1531 const BaseWeaponManagerComponent weaponManager = BaseWeaponManagerComponent.Cast(characterEntity.FindComponent(BaseWeaponManagerComponent));
1535 int slotsCount = weaponStorage.GetSlotsCount();
1536 for (
int i = 0; i < slotsCount; ++i)
1542 IEntity attachedEntity = slot.GetAttachedEntity();
1543 if (!attachedEntity)
1547 if (prefabName.IsEmpty())
1550 bool active =
false;
1551 if (weaponManager && weaponManager.GetCurrentWeapon())
1552 active = weaponManager.GetCurrentWeapon().GetOwner() == attachedEntity;
1555 weaponData.Active = active;
1556 weaponData.SlotIdx = i;
1557 weaponData.WeaponPrefab = prefabName;
1559 WeaponAttachmentsStorageComponent attachmentsStorage = WeaponAttachmentsStorageComponent.Cast(attachedEntity.
FindComponent(WeaponAttachmentsStorageComponent));
1560 if (attachmentsStorage)
1562 const int slotCount = attachmentsStorage.GetSlotsCount();
1563 weaponData.Attachments.Reserve(slotCount);
1564 for (
int nSlot = 0; nSlot < slotCount; ++nSlot)
1580 playerLoadout.suppliesCost = 0.0;
1581 playerLoadout.m_fMilitarySupplyAllocationCost = 0;
1584 if (!context.LoadFromString(playerLoadout.loadout))
1592 protected void DoSetPlayerLoadout(
int playerId,
string loadoutString, GameEntity characterEntity, SCR_EArsenalSupplyCostType arsenalSupplyType)
1596 bool loadoutChanged;
1597 if (!loadoutString.IsEmpty())
1603 loadoutChanged = loadoutString != playerLoadout.loadout;
1604 playerLoadout.loadout = loadoutString;
1609 FactionAffiliationComponent factionAffiliation = FactionAffiliationComponent.Cast(characterEntity.FindComponent(FactionAffiliationComponent));
1610 if (factionAffiliation && factionAffiliation.GetAffiliatedFaction())
1615 playerLoadout.suppliesCost = playerLoadout.loadoutData.LoadoutCost;
1617 playerLoadout.m_fMilitarySupplyAllocationCost = playerLoadout.loadoutData.LoadoutPlayerSupplyAllocationCost;
1618 playerLoadout.loadoutData.FactionIndex =
GetGame().GetFactionManager().GetFactionIndex(
SCR_FactionManager.SGetPlayerFaction(playerId));
1630 [Friend(SCR_PlayerLoadoutComponentSerializer)]
1637 [Friend(SCR_PlayerLoadoutComponentSerializer)]
1640 PlayerController pc =
GetGame().GetPlayerManager().GetPlayerController(playerId);
1648 if (playerLoadout && loadoutChanged)
1651 const bool loadoutValid = playerLoadout && !playerLoadout.loadout.IsEmpty();
1660 super.OnPlayerAuditSuccess(playerId);
1664 if (!playerLoadout || playerLoadout.loadout.IsEmpty())
1684 SCR_ArsenalManagerComponent.GetArsenalLoadoutComponentsToCheck(
SCR_PlayerArsenalLoadout.ARSENALLOADOUT_COMPONENTS_TO_CHECK);
1686 s_Instance = SCR_ArsenalManagerComponent.Cast(
GetGameMode().FindComponent(SCR_ArsenalManagerComponent));
1691 Print(
"'SCR_ArsenalManagerComponent' failed to loadm_Arsenal GameMode UI Data Holder config!",
LogLevel.WARNING);
1696 Print(
"'SCR_ArsenalManagerComponent' failed to load Arsenal Save Type Holder config!",
LogLevel.ERROR);
1707 [
Attribute(
desc:
"List of UIInfo for Arsenal GameMode types, Used for editor attributes and notifications. Only types in this list will be displayed in editor")]
1715 if (arsenalGameModeType <= 0)
1716 arsenalGameModeType = -1;
1721 if (
data.m_eArsenalGameModeType == arsenalGameModeType)
1722 return data.m_UIInfo;
1728 unknown.SetName(
"MISSING");
1738 arsenalGameModeTypeUIInfoList.Clear();
1745 arsenalGameModeTypeUIInfoList.Insert(
data);
1748 return arsenalGameModeTypeUIInfoList.Count();
1753class SCR_ArsenalGameModeUIData
@ VEHICLES
Vehicles and static guns.
ArmaReforgerScripted GetGame()
ResourceName resourceName
enum EAIGroupCombatMode ComponentEditorProps(category:"GameScripted/AI", description:"Component for utility AI system for groups")
SCR_ECharacterRank m_eRequiredRank
bool m_bUseMilitarySupplyAllocation
class SCR_ArsenalPlayerLoadout GADGETS
Arsenals are enabled on gadgets.
SCR_EArsenalTypes m_eArsenalTypesEnabled
void OnArsenalGameModeTypeChanged()
class SCR_ArsenalGameModeUIDataHolder SCR_BaseContainerCustomTitleUIInfo("m_UIInfo")
bool CanSaveLoadout(int playerId, notnull GameEntity characterEntity, Faction characterFaction, SCR_ArsenalComponent arsenalComponent, bool sendNotificationOnFailed)
bool GetLocalPlayerLoadoutAvailable()
ref ScriptInvokerBase< SCR_ArsenalManagerComponent_OnPlayerLoadoutChanged > m_OnPlayerLoadoutUpdated
SCR_LoadoutSaveBlackListHolder GetLoadoutSaveBlackListHolder()
void ComputeSuppliesCost(notnull SCR_Faction faction, notnull SCR_ArsenalPlayerLoadout playerLoadout, SCR_EArsenalSupplyCostType arsenalSupplyType)
void RPC_OnPlayerLoadoutCleared(int playerIdClearedLoadout)
float GetLoadoutMilitarySupplyAllocationCost(notnull SCR_BasePlayerLoadout playerLoadout, int playerId)
float m_fMilitarySupplyAllocationCost
ResourceName m_sLoadoutSaveBlackListHolder
void SetLocalPlayerLoadoutAvailable(bool available)
bool GetPlayerArsenalLoadout(UUID playerUID, out SCR_ArsenalPlayerLoadout playerLoadout)
ResourceName m_sArsenalSaveTypeInfoHolder
int GetCharacterItemSupplyCost(notnull IEntity item, notnull inout set< IEntity > countedItems, notnull SCR_Faction faction, bool getPersonalSupplyAllocationCost)
float GetCustomLoadoutMilitarySupplyAllocationCost(int playerId)
int GetCharacterLoadoutSupplyCost(notnull GameEntity characterEntity, bool getPersonalSupplyAllocationCost)
void SetPlayerArsenalLoadout(int playerId, GameEntity characterEntity, SCR_ArsenalComponent arsenalComponent, SCR_EArsenalSupplyCostType arsenalSupplyType)
int GetItemMilitarySupplyAllocationRefundCost(notnull IEntity item, inout set< IEntity > countedItems, SCR_EntityCatalogManagerComponent entityCatalogManager, SCR_ArsenalComponent arsenalComponent, SCR_Faction faction)
class SCR_ArsenalPlayerLoadout STATIC_ENTITIES
Used to allow certain arsenal types to be enabled or disabled.
SCR_EArsenalTypes GetEnabledArsenalTypes()
float m_fLoadoutSpawnSupplyCostMultiplier
ResourceName m_sArsenalGameModeUIDataHolder
bool IsArsenalTypeEnabled(SCR_EArsenalTypes arsenalType)
float GetCalculatedLoadoutSpawnSupplyCostMultiplier()
ref ScriptInvokerInt m_OnArsenalGameModeTypeChanged
void SetArsenalGameModeType_S(SCR_EArsenalGameModeType arsenalGameModeType, int playerID=0)
ref SCR_PlayerLoadoutData m_LocalPlayerLoadoutData
ScriptInvokerBool GetOnMilitarySupplyAllocationToggle()
int GetItemMilitarySupplyAllocationCost(ResourceName resource, SCR_ArsenalComponent arsenalComponent, bool addAdditionalCosts=false)
SCR_PlayerLoadoutData GetLocalPlayerLoadoutData()
ref SCR_PlayerLoadoutData loadoutData
SCR_MilitarySupplyAllocationConfig GetMilitarySupplyApplicationConfigData()
ref ScriptInvokerInt m_OnArsenalTypeEnabledChanged
void OnMilitarySupplyAllocationToggle()
void SetLoadoutBlackListActiveStates(notnull array< bool > orderedActiveStates, bool clearExistingLoadouts, int editorPlayerIdClearedLoadout=-1)
ScriptInvokerFloat GetOnLoadoutSpawnSupplyCostMultiplierChanged()
ref SCR_LoadoutSaveBlackListHolder m_LoadoutSaveBlackListHolder
void OnLoadoutSpawnSupplyCostMultiplierChanged()
float GetLoadoutSpawnSupplyCostMultiplier()
SCR_EArsenalGameModeType m_eArsenalGameModeType
SCR_PlayerLoadoutData GetPlayerLoadoutData(GameEntity characterEntity)
void SetLoadoutSpawnCostMultiplier_S(float multiplier, int playerID=0)
int GetArsenalGameModeUIInfoList(inout notnull array< SCR_ArsenalGameModeUIData > arsenalGameModeTypeUIInfoList)
ScriptInvokerBase< SCR_ArsenalManagerComponent_OnPlayerLoadoutChanged > GetOnLoadoutUpdated()
void SetMilitarySupplyAllocationEnabled(bool enable)
bool AreItemsRankLocked()
If items can be ranked locked.
int GetItemMilitarySupplyAllocationRefundAmount(notnull IEntity item, SCR_ArsenalComponent arsenalComponent)
void DoSetPlayerLoadout(int playerId, string loadoutString, GameEntity characterEntity, SCR_EArsenalSupplyCostType arsenalSupplyType)
void SetEnabledArsenalTypes(SCR_EArsenalTypes newEnabledArsenalTypes, int playerID=-1)
void RpcAsk_SetMilitarySupplyAllocationEnabled(bool enable)
class SCR_ArsenalGameModeUIDataHolder BaseContainerProps()
ref SCR_ArsenalGameModeUIDataHolder m_ArsenalGameModeUIDataHolder
ref SCR_ArsenalSaveTypeInfoHolder m_ArsenalSaveTypeInfoHolder
void SyncPlayerloadout(int playerId, SCR_ArsenalPlayerLoadout playerLoadout, bool loadoutChanged=true, bool notification=false)
float m_fRefundSameFactionItemMultiplier
SCR_EArsenalGameModeType GetArsenalGameModeType()
ScriptInvokerInt GetOnArsenalGameModeTypeChanged()
void OnArsenalTypeEnabledChanged()
SCR_UIInfo GetArsenalGameModeUIInfo(SCR_EArsenalGameModeType arsenalGameModeType)
SCR_ArsenalSaveTypeInfoHolder GetArsenalSaveTypeInfoHolder()
ref map< UUID, ref SCR_ArsenalPlayerLoadout > m_aPlayerLoadouts
bool m_bLocalPlayerLoadoutAvailable
ref ScriptInvokerFloat m_OnLoadoutSpawnSupplyCostMultiplierChanged
float GetDefaultLoadoutMilitarySuppplyAllocationCost(notnull SCR_BasePlayerLoadout playerLoadout)
func SCR_ArsenalManagerComponent_OnPlayerLoadoutChanged
float m_fRefundDifferentFactionItemMultiplier
ScriptInvokerInt GetOnArsenalTypeEnabledChanged()
ref ScriptInvokerBool m_OnMilitarySupplyAllocationToggle
ResourceName m_sMilitarySupplyAllocationConfigHolder
SCR_BaseGameMode GetGameMode()
void SCR_BaseGameModeComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
SCR_CacheNoteComponentClass ScriptComponentClass RplProp()] protected ref array< string > m_aLines
override void OnPlayerAuditSuccess(int playerId)
Get all prefabs that have the spawner data
void SCR_FactionManager(IEntitySource src, IEntity parent)
void SCR_FilteredInventoryStorageComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
ScriptInvokerBase< ScriptInvokerFloatMethod > ScriptInvokerFloat
ScriptInvokerBase< ScriptInvokerBoolMethod > ScriptInvokerBool
ScriptInvokerBase< ScriptInvokerIntMethod > ScriptInvokerInt
SCR_SpawnerSlotManagerClass s_Instance
Class used for managing changes and removals of slots present in world.
void SCR_UniversalInventoryStorageComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
enum EVehicleType IEntity
proto external Managed FindComponent(typename typeName)
proto external EntityPrefabData GetPrefabData()
proto external IEntity GetParent()
Container context loading JSON format.
Container context saving in JSON format.
Object holding reference to resource. In destructor release the resource.
SCR_Faction GetAssignedFaction()
bool IsArsenalUsingSupplies()
SCR_ArsenalItemListConfig GetOverwriteArsenalConfig()
SCR_EArsenalSaveType GetArsenalSaveType()
SCR_EArsenalSupplyCostType GetSupplyCostType()
SCR_ArsenalInventoryStorageManagerComponent GetArsenalInventoryComponent()
SCR_UIInfo GetArsenalGameModeUIInfo(SCR_EArsenalGameModeType arsenalGameModeType)
ref array< ref SCR_ArsenalGameModeUIData > m_aArsenalGameModeTypeUIInfoList
int GetArsenalGameModeUIInfoList(inout notnull array< SCR_ArsenalGameModeUIData > arsenalGameModeTypeUIInfoList)
int GetSupplyRefundAmount(SCR_EArsenalSupplyCostType supplyCostType, bool addAdditionalCosts=true)
bool GetUseMilitarySupplyAllocation()
int GetSupplyCost(SCR_EArsenalSupplyCostType supplyCostType, bool addAdditionalCosts=true)
SCR_ECharacterRank GetRequiredRank()
int GetMilitarySupplyAllocationCost(SCR_EArsenalSupplyCostType supplyCostType, bool addAdditionalCosts=true)
SCR_EArsenalItemMode GetItemMode()
bool GetUseMilitarySupplyAllocationForPrefab(ResourceName prefab, out SCR_EArsenalItemType itemUseMilitarySupplyAllocation)
SCR_BaseArsenalRefundEffect ExecuteFirstValidRefundEffect(notnull IEntity item, notnull PlayerController playerController, SCR_ArsenalComponent arsenal)
bool GetEntityBudgetCost(out notnull array< ref SCR_EntityBudgetValue > outBudgets)
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)
Get list of entity Data of all types Ignores Disabled Elements param[out] Array of enabled entity Data list return List size *int GetEntityDataList(notnull out array< SCR_BaseEntityCatalogData > entityDataList)
Get Catalog parent the entity entry is in return Catalog parent *SCR_EntityCatalog GetCatalogParent()
Get UI info Prefab needs to be an editable entity or have a custom UI info logic Note that if UIInfo is NULL then the autotest will fail return Ui info *SCR_UIInfo GetEntityUiInfo()
SCR_EntityCatalog GetFactionEntityCatalogOfType(EEntityCatalogType catalogType, bool printNotFound=true)
bool IsCustomLoadoutSupported()
int GetFriendlyFactions(notnull out array< Faction > friendlyFactions, bool includeSelf=true)
Base Used for items and attachments which should not be shown in the arsenal but should have a cost t...
int GetSupplyCost(SCR_EArsenalSupplyCostType supplyCostType, bool addAdditionalCosts=true)
static void ComputeSuppliesCost(LoadContext context, SCR_Faction faction, SCR_ArsenalPlayerLoadout playerLoadout, SCR_EArsenalSupplyCostType arsenalSupplyType, int depth=0)
static int GetLocalPlayerId()
Returns either a valid ID of local player or 0.
void DoSetPlayerHasLoadout(bool loadoutValid, bool loadoutChanged, bool notification)
void DoSendPlayerLoadout(SCR_PlayerLoadoutData loadoutData)
SCR_ECharacterRank GetPlayerRankByXP()
override float GetAggregatedResourceValue()
override float GetAggregatedMaxResourceValue()
float GetResourceMultiplier()
override void EOnInit(IEntity owner)
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
SCR_FieldOfViewSettings Attribute
EntityEvent
Various entity events.
proto external PlayerController GetPlayerController()
void RplRpc(RplChannel channel, RplRcver rcver, RplCondition condition=RplCondition.None, string customConditionName="")
RplChannel
Communication channel. Reliable is guaranteed to be delivered. Unreliable not.