Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_PlayerSupplyAllocationComponentSerializer.c
Go to the documentation of this file.
2{
3 //------------------------------------------------------------------------------------------------
4 override static typename GetTargetType()
5 {
6 return SCR_PlayerSupplyAllocationComponent;
7 }
8
9 //------------------------------------------------------------------------------------------------
10 override protected ESerializeResult Serialize(notnull IEntity owner, notnull GenericComponent component, notnull SaveContext context)
11 {
12 auto supplyAllocation = SCR_PlayerSupplyAllocationComponent.Cast(component);
13
14 const int maxAllocation = supplyAllocation.GetPlayerMilitarySupplyAllocation();
15 const int availableAllocation = supplyAllocation.GetPlayerAvailableAllocatedSupplies();
16
17 if (maxAllocation == 0 && availableAllocation == 0)
18 return ESerializeResult.DEFAULT;
19
20 context.WriteValue("version", 1);
21 context.Write(maxAllocation);
22 context.Write(availableAllocation);
23 return ESerializeResult.OK;
24 }
25
26 //------------------------------------------------------------------------------------------------
27 override protected bool Deserialize(notnull IEntity owner, notnull GenericComponent component, notnull LoadContext context)
28 {
29 auto supplyAllocation = SCR_PlayerSupplyAllocationComponent.Cast(component);
30
31 int version;
32 context.Read(version);
33
34 int maxAllocation;
35 if (context.Read(maxAllocation))
36 supplyAllocation.SetPlayerMilitarySupplyAllocation(maxAllocation);
37
38 int availableAllocation;
39 if (context.Read(availableAllocation))
40 supplyAllocation.AddPlayerAvailableAllocatedSupplies(availableAllocation - supplyAllocation.GetPlayerAvailableAllocatedSupplies());
41
42 return true;
43 }
44}
class SCR_PersistentThreatSector GetTargetType()
ESerializeResult Serialize(notnull IEntity owner, notnull GenericComponent component, notnull SaveContext context)
bool Deserialize(notnull IEntity owner, notnull GenericComponent component, notnull LoadContext context)
ESerializeResult