Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_RespawnTimer.c
Go to the documentation of this file.
2 {
4  protected WorldTimestamp m_fStartTime;
6  protected float m_fDuration;
7 
12  void Start(WorldTimestamp timeNow)
13  {
14  m_fStartTime = timeNow;
15  }
16 
20  WorldTimestamp GetStartTime()
21  {
22  return m_fStartTime;
23  }
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 
53  float GetDuration()
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 
80  bool RplLoad(ScriptBitReader reader)
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  //------------------------------------------------------------------------------------------------
103  static bool SnapCompare(SSnapSerializerBase lhs, SSnapSerializerBase rhs, ScriptCtx ctx)
104  {
105  return lhs.CompareSnapshots(rhs, 12);
106  }
107 
108  //------------------------------------------------------------------------------------------------
109  static bool PropCompare(SCR_RespawnTimer prop, SSnapSerializerBase snapshot, ScriptCtx ctx)
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 };
m_fDuration
float m_fDuration
Definition: SendGoalMessage.c:437
SCR_RespawnTimer
Definition: SCR_RespawnTimer.c:1