Rise
The Vieneo Province
Loading...
Searching...
No Matches
RejoinCountdown.h
Go to the documentation of this file.
1#pragma once
2
3#include <algorithm>
4#include <cmath>
5
6// Independent of deathinhibit, which protects the vehicle from repeated
7// damage and can remain at FLT_MAX while dead. Use monotonic client time,
8// not the clamped physics timestep or simulator clock.
10{
11public:
12 static constexpr double DelaySeconds = 15.0;
13
14 void Update(bool realDeath, double now)
15 {
16 if (!realDeath)
17 Reset();
18 else if (!active)
19 {
20 active = true;
21 readyAt = now + DelaySeconds;
22 }
23 }
24
25 void Reset() { active = false; readyAt = 0.0; }
26 bool Ready(double now) const { return active && now >= readyAt; }
27 double SecondsRemaining(double now) const
28 {
29 return active ? std::ceil((std::max)(0.0, readyAt - now)) : DelaySeconds;
30 }
31
32private:
33 bool active = false;
34 double readyAt = 0.0;
35};
bool Ready(double now) const
static constexpr double DelaySeconds
double SecondsRemaining(double now) const
void Update(bool realDeath, double now)