4 static const string ARSENALLOADOUT_FACTIONKEY_NONE =
"none";
5 static const string ARSENALLOADOUT_KEY =
"arsenalLoadout";
6 static const string ARSENALLOADOUT_FACTION_KEY =
"faction";
9 override bool IsLoadoutAvailable(
int playerId)
11 SCR_ArsenalManagerComponent arsenalManager;
12 if (SCR_ArsenalManagerComponent.GetArsenalManager(arsenalManager))
15 return arsenalManager.GetPlayerArsenalLoadout(
GetGame().GetBackendApi().GetPlayerIdentityId(playerId), arsenalLoadout);
21 override bool IsLoadoutAvailableClient()
23 SCR_ArsenalManagerComponent arsenalManager;
24 if (SCR_ArsenalManagerComponent.GetArsenalManager(arsenalManager))
25 return arsenalManager.GetLocalPlayerLoadoutAvailable();
33 static float GetLoadoutSuppliesCost(
string playerUID)
35 SCR_ArsenalManagerComponent arsenalManager;
36 if (SCR_ArsenalManagerComponent.GetArsenalManager(arsenalManager))
38 float supplyCostMulti = arsenalManager.GetLoadoutSpawnSupplyCostMultiplier();
41 if (supplyCostMulti <= 0)
45 if (arsenalManager.GetPlayerArsenalLoadout(playerUID, arsenalLoadout))
46 return arsenalLoadout.suppliesCost * supplyCostMulti;
55 static float GetLoadoutSuppliesCost(
int playerID)
57 string playerUID =
GetGame().GetBackendApi().GetPlayerIdentityId(playerID);
58 return GetLoadoutSuppliesCost(playerUID);
62 override void OnLoadoutSpawned(
GenericEntity pOwner,
int playerId)
64 super.OnLoadoutSpawned(pOwner, playerId);
65 SCR_ArsenalManagerComponent arsenalManager;
66 if (!SCR_ArsenalManagerComponent.GetArsenalManager(arsenalManager))
69 string playerUID =
GetGame().GetBackendApi().GetPlayerIdentityId(playerId);
70 GameEntity playerEntity = GameEntity.Cast(pOwner);
72 if (!playerEntity || !arsenalManager.GetPlayerArsenalLoadout(playerUID, playerArsenalItems))
75 FactionAffiliationComponent factionComponent = FactionAffiliationComponent.Cast(playerEntity.FindComponent(FactionAffiliationComponent));
76 if (!factionComponent)
79 SCR_JsonLoadContext context =
new SCR_JsonLoadContext();
80 bool loadSuccess =
true;
81 loadSuccess &= context.ImportFromString(playerArsenalItems.loadout);
84 loadSuccess &= context.ReadValue(ARSENALLOADOUT_FACTION_KEY, factionKey) && factionKey != ARSENALLOADOUT_FACTIONKEY_NONE;
85 loadSuccess &= factionKey == factionComponent.GetAffiliatedFaction().GetFactionKey();
86 loadSuccess &= context.ReadValue(ARSENALLOADOUT_KEY, playerEntity);
90 arsenalManager.SetPlayerArsenalLoadout(playerId,
null,
null, SCR_EArsenalSupplyCostType.RESPAWN_COST);