Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_ArsenalManagerComponentSerializer.c
Go to the documentation of this file.
2{
3 //------------------------------------------------------------------------------------------------
4 override static typename GetTargetType()
5 {
6 return SCR_ArsenalManagerComponent;
7 }
8
9 //------------------------------------------------------------------------------------------------
10 override protected ESerializeResult Serialize(notnull IEntity owner, notnull GenericComponent component, notnull SaveContext context)
11 {
12 const SCR_ArsenalManagerComponent arsenalManager = SCR_ArsenalManagerComponent.Cast(component);
13 const BaseContainer source = arsenalManager.GetComponentSource(owner);
14
15 const float loadoutSpawnSupplyCostMultiplier = arsenalManager.GetLoadoutSpawnSupplyCostMultiplier();
16 float loadoutSpawnSupplyCostMultiplierDefault = 0.0;
17 if (source)
18 source.Get("m_fLoadoutSpawnSupplyCostMultiplier", loadoutSpawnSupplyCostMultiplierDefault);
19
20 const SCR_EArsenalGameModeType gameModeType = arsenalManager.GetArsenalGameModeType();
21 SCR_EArsenalGameModeType gameModeTypeDefault = -1;
22 if (source)
23 source.Get("m_eArsenalGameModeType", gameModeTypeDefault);
24
25 const SCR_EArsenalTypes enabledTypes = arsenalManager.GetEnabledArsenalTypes();
26 SCR_EArsenalTypes enabledTypesDefault = SCR_Enum.GetFlagValues(SCR_EArsenalTypes);
27 if (source)
28 source.Get("m_eArsenalTypesEnabled", enabledTypesDefault);
29
30 const bool militarySupplyAllocation = SCR_ArsenalManagerComponent.IsMilitarySupplyAllocationEnabled();
31 bool militarySupplyAllocationDefault = false;
32 if (source)
33 source.Get("m_bUseMilitarySupplyAllocation", militarySupplyAllocationDefault);
34
35 if (loadoutSpawnSupplyCostMultiplier == loadoutSpawnSupplyCostMultiplierDefault &&
36 gameModeType == gameModeTypeDefault &&
37 enabledTypes == enabledTypesDefault &&
38 militarySupplyAllocation == militarySupplyAllocationDefault)
39 return ESerializeResult.DEFAULT;
40
41 context.WriteValue("version", 1);
42 context.WriteDefault(loadoutSpawnSupplyCostMultiplier, loadoutSpawnSupplyCostMultiplierDefault);
43 context.WriteDefault(gameModeType, gameModeTypeDefault);
44 context.WriteDefault(enabledTypes, enabledTypesDefault);
45 context.WriteDefault(militarySupplyAllocation, militarySupplyAllocationDefault);
46 return ESerializeResult.OK;
47 }
48
49 //------------------------------------------------------------------------------------------------
50 override protected bool Deserialize(notnull IEntity owner, notnull GenericComponent component, notnull LoadContext context)
51 {
52 SCR_ArsenalManagerComponent arsenalManager = SCR_ArsenalManagerComponent.Cast(component);
53
54 int version;
55 context.Read(version);
56
57 float loadoutSpawnSupplyCostMultiplier;
58 if (context.Read(loadoutSpawnSupplyCostMultiplier))
59 arsenalManager.SetLoadoutSpawnCostMultiplier_S(loadoutSpawnSupplyCostMultiplier);
60
61 SCR_EArsenalGameModeType gameModeType;
62 if (context.Read(gameModeType))
63 arsenalManager.SetArsenalGameModeType_S(gameModeType);
64
65 SCR_EArsenalTypes enabledTypes;
66 if (context.Read(enabledTypes))
67 arsenalManager.SetEnabledArsenalTypes(enabledTypes);
68
69 bool militarySupplyAllocation;
70 if (context.Read(militarySupplyAllocation))
71 arsenalManager.SetMilitarySupplyAllocationEnabled(militarySupplyAllocation);
72
73 return true;
74 }
75}
class SCR_PersistentThreatSector GetTargetType()
SCR_EArsenalGameModeType
ESerializeResult Serialize(notnull IEntity owner, notnull GenericComponent component, notnull SaveContext context)
bool Deserialize(notnull IEntity owner, notnull GenericComponent component, notnull LoadContext context)
ESerializeResult