Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_PlayerXPHandlerComponentSerializer.c
Go to the documentation of this file.
2{
3 //------------------------------------------------------------------------------------------------
4 override static typename GetTargetType()
5 {
7 }
8
9 //------------------------------------------------------------------------------------------------
10 override protected ESerializeResult Serialize(notnull IEntity owner, notnull GenericComponent component, notnull SaveContext context)
11 {
12 auto playerXpHandler = SCR_PlayerXPHandlerComponent.Cast(component);
13
14 const int xp = playerXpHandler.GetPlayerXP();
15 const int xpSinceLastSpawn = playerXpHandler.GetPlayerXPSinceLastSpawn();
16 const int survivalCycle = playerXpHandler.GetSurvivalRewardCycle();
17
18 if (xp == 0 && xpSinceLastSpawn == 0 && survivalCycle == 0)
19 return ESerializeResult.DEFAULT;
20
21 context.WriteValue("version", 1);
22 context.WriteDefault(xp, 0);
23 context.WriteDefault(xpSinceLastSpawn, 0);
24 context.WriteDefault(survivalCycle, 0);
25 return ESerializeResult.OK;
26 }
27
28 //------------------------------------------------------------------------------------------------
29 override protected bool Deserialize(notnull IEntity owner, notnull GenericComponent component, notnull LoadContext context)
30 {
31 auto playerXpHandler = SCR_PlayerXPHandlerComponent.Cast(component);
32
33 int version;
34 context.Read(version);
35
36 int xp;
37 if (context.Read(xp))
38 playerXpHandler.AddPlayerXP(SCR_EXPRewards.UNDEFINED, addDirectly: (xp - playerXpHandler.GetPlayerXP()));
39
40 int xpSinceLastSpawn;
41 if (context.Read(xpSinceLastSpawn))
42 playerXpHandler.SetPlayerXPSinceLastSpawn(xpSinceLastSpawn);
43
44 int survivalCycle;
45 if (context.Read(survivalCycle))
46 playerXpHandler.SetSurvivalRewardCycle(survivalCycle);
47
48 return true;
49 }
50}
class SCR_PersistentThreatSector GetTargetType()
void AddPlayerXP(SCR_EXPRewards rewardID, float multiplier=1.0, bool volunteer=false, int addDirectly=0)
bool Deserialize(notnull IEntity owner, notnull GenericComponent component, notnull LoadContext context)
ESerializeResult Serialize(notnull IEntity owner, notnull GenericComponent component, notnull SaveContext context)
ESerializeResult