Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_FastTravelComponentSerializer.c
Go to the documentation of this file.
2{
3 //------------------------------------------------------------------------------------------------
4 override static typename GetTargetType()
5 {
6 return SCR_FastTravelComponent;
7 }
8
9 //------------------------------------------------------------------------------------------------
10 override protected ESerializeResult Serialize(notnull IEntity owner, notnull GenericComponent component, notnull SaveContext context)
11 {
12 auto fastTravel = SCR_FastTravelComponent.Cast(component);
13 auto world = ChimeraWorld.CastFrom(owner.GetWorld());
14
15 const WorldTimestamp nextTransportTime = fastTravel.GetNextTransportTimestamp();
16 if (!nextTransportTime)
17 return ESerializeResult.DEFAULT;
18
19 const WorldTimestamp currentTime = world.GetServerTimestamp();
20 const float cooldown = currentTime.DiffSeconds(nextTransportTime);
21
22 if (float.AlmostEqual(cooldown, 0.0))
23 return ESerializeResult.DEFAULT;
24
25 context.WriteValue("version", 1);
26 context.Write(cooldown);
27 return ESerializeResult.OK;
28 }
29
30 //------------------------------------------------------------------------------------------------
31 override protected bool Deserialize(notnull IEntity owner, notnull GenericComponent component, notnull LoadContext context)
32 {
33 auto fastTravel = SCR_FastTravelComponent.Cast(component);
34 auto world = ChimeraWorld.CastFrom(owner.GetWorld());
35
36 int version;
37 context.Read(version);
38
39 float cooldown;
40 context.Read(cooldown);
41 fastTravel.SetNextTransportTimestamp(world.GetServerTimestamp().PlusSeconds(cooldown));
42
43 return true;
44 }
45}
class SCR_PersistentThreatSector GetTargetType()
bool Deserialize(notnull IEntity owner, notnull GenericComponent component, notnull LoadContext context)
ESerializeResult Serialize(notnull IEntity owner, notnull GenericComponent component, notnull SaveContext context)
ESerializeResult