Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_RespawnSystemComponentSerializer.c
Go to the documentation of this file.
2{
3 //------------------------------------------------------------------------------------------------
4 override static typename GetTargetType()
5 {
6 return SCR_RespawnSystemComponent;
7 }
8
9 //------------------------------------------------------------------------------------------------
10 override protected ESerializeResult Serialize(notnull IEntity owner, notnull GenericComponent component, notnull SaveContext context)
11 {
12 const SCR_RespawnSystemComponent respawnSystem = SCR_RespawnSystemComponent.Cast(component);
13 const BaseContainer source = respawnSystem.GetComponentSource(owner);
14
15 const bool respawnEnabled = respawnSystem.IsRespawnEnabled();
16 bool respawnEnabledDefault = true;
17 if (source)
18 source.Get("m_bEnableRespawn", respawnEnabledDefault);
19
20 // Not directly on component but info belongs to it anyway
21 float respawnTime = 10.0;
22 float respawnTimeDefault = 10.0;
23 const SCR_RespawnTimerComponent respawnTimeComponent = SCR_RespawnTimerComponent.Cast(owner.FindComponent(SCR_RespawnTimerComponent));
24 if (respawnTimeComponent)
25 {
26 respawnTime = respawnTimeComponent.GetRespawnTime();
27 const BaseContainer timerSource = respawnTimeComponent.GetComponentSource(owner);
28 if (timerSource)
29 timerSource.Get("m_fRespawnTime", respawnTimeDefault);
30 }
31
32 if (respawnEnabled == respawnEnabledDefault && float.AlmostEqual(respawnTime, respawnTimeDefault))
33 return ESerializeResult.DEFAULT;
34
35 context.WriteValue("version", 1);
36 context.WriteDefault(respawnEnabled, respawnEnabledDefault);
37 context.WriteDefault(respawnTime, respawnTimeDefault);
38 return ESerializeResult.OK;
39 }
40
41 //------------------------------------------------------------------------------------------------
42 override protected bool Deserialize(notnull IEntity owner, notnull GenericComponent component, notnull LoadContext context)
43 {
44 SCR_RespawnSystemComponent respawnSystem = SCR_RespawnSystemComponent.Cast(component);
45
46 int version;
47 context.Read(version);
48
49 bool respawnEnabled;
50 if (context.Read(respawnEnabled))
51 respawnSystem.ServerSetEnableRespawn(respawnEnabled);
52
53 float respawnTime;
54 if (context.Read(respawnTime))
55 {
56 const SCR_RespawnTimerComponent respawnTimeComponent = SCR_RespawnTimerComponent.Cast(owner.FindComponent(SCR_RespawnTimerComponent));
57 if (respawnTimeComponent)
58 respawnTimeComponent.SetRespawnTime(respawnTime);
59 }
60
61 return true;
62 }
63}
class SCR_PersistentThreatSector GetTargetType()
void SCR_RespawnTimerComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
ESerializeResult Serialize(notnull IEntity owner, notnull GenericComponent component, notnull SaveContext context)
bool Deserialize(notnull IEntity owner, notnull GenericComponent component, notnull LoadContext context)
ESerializeResult