Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_RespawnTimer.c
Go to the documentation of this file.
2{
6 protected float m_fDuration;
7
12 void Start(WorldTimestamp timeNow)
13 {
14 m_fStartTime = timeNow;
15 }
16
24
30 bool IsFinished(WorldTimestamp timeNow, float additionalTime = 0)
31 {
32 return timeNow.GreaterEqual(m_fStartTime.PlusSeconds(m_fDuration + additionalTime));
33 }
34
40 float GetRemainingTime(WorldTimestamp timeNow, float additionalTime = 0)
41 {
42 WorldTimestamp endTime = m_fStartTime.PlusSeconds(m_fDuration + additionalTime);
43 float rem = endTime.DiffMilliseconds(timeNow);
44 if (rem <= 0)
45 return 0.0;
46
47 return rem / 1000.0;
48 }
49
54 {
55 return m_fDuration;
56 }
57
61 void SetDuration(float duration)
62 {
63 m_fDuration = duration;
64 }
65
69 bool RplSave(ScriptBitWriter writer)
70 {
71 writer.Write(m_fStartTime, 64);
72 writer.WriteFloat(m_fDuration);
73
74 return true;
75 }
76
81 {
82 reader.Read(m_fStartTime, 64);
83 reader.ReadFloat(m_fDuration);
84
85 return true;
86 }
87
88 //################################################################################################
90 //------------------------------------------------------------------------------------------------
91 static void Encode(SSnapSerializerBase snapshot, ScriptCtx ctx, ScriptBitSerializer packet)
92 {
93 snapshot.Serialize(packet, 12);
94 }
95
96 //------------------------------------------------------------------------------------------------
97 static bool Decode(ScriptBitSerializer packet, ScriptCtx ctx, SSnapSerializerBase snapshot)
98 {
99 return snapshot.Serialize(packet, 12);
100 }
101
102 //------------------------------------------------------------------------------------------------
104 {
105 return lhs.CompareSnapshots(rhs, 12);
106 }
107
108 //------------------------------------------------------------------------------------------------
110 {
111 return snapshot.Compare(prop.m_fStartTime, 8)
112 && snapshot.Compare(prop.m_fDuration, 4);
113 }
114
115 //------------------------------------------------------------------------------------------------
116 static bool Extract(SCR_RespawnTimer prop, ScriptCtx ctx, SSnapSerializerBase snapshot)
117 {
118 snapshot.SerializeBytes(prop.m_fStartTime, 8);
119 snapshot.SerializeBytes(prop.m_fDuration, 4);
120 return true;
121 }
122
123 //------------------------------------------------------------------------------------------------
124 static bool Inject(SSnapSerializerBase snapshot, ScriptCtx ctx, SCR_RespawnTimer prop)
125 {
126 snapshot.SerializeBytes(prop.m_fStartTime, 8);
127 snapshot.SerializeBytes(prop.m_fDuration, 4);
128 return true;
129 }
130};
bool RplSave(ScriptBitWriter writer)
static void Encode(SSnapSerializerBase snapshot, ScriptCtx ctx, ScriptBitSerializer packet)
Codec methods.
bool RplLoad(ScriptBitReader reader)
static bool Extract(SCR_RespawnTimer prop, ScriptCtx ctx, SSnapSerializerBase snapshot)
float GetRemainingTime(WorldTimestamp timeNow, float additionalTime=0)
WorldTimestamp m_fStartTime
Time at which respawn timer was engaged.
WorldTimestamp GetStartTime()
float m_fDuration
The duration of this timer in seconds.
void Start(WorldTimestamp timeNow)
static bool Inject(SSnapSerializerBase snapshot, ScriptCtx ctx, SCR_RespawnTimer prop)
static bool PropCompare(SCR_RespawnTimer prop, SSnapSerializerBase snapshot, ScriptCtx ctx)
void SetDuration(float duration)
static bool Decode(ScriptBitSerializer packet, ScriptCtx ctx, SSnapSerializerBase snapshot)
static bool SnapCompare(SSnapSerializerBase lhs, SSnapSerializerBase rhs, ScriptCtx ctx)
bool IsFinished(WorldTimestamp timeNow, float additionalTime=0)