Rise
The Vieneo Province
Toggle main menu visibility
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.
9
class
RejoinCountdown
10
{
11
public
:
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
32
private
:
33
bool
active
=
false
;
34
double
readyAt
= 0.0;
35
};
RejoinCountdown
Definition
RejoinCountdown.h:10
RejoinCountdown::Ready
bool Ready(double now) const
Definition
RejoinCountdown.h:26
RejoinCountdown::active
bool active
Definition
RejoinCountdown.h:33
RejoinCountdown::Reset
void Reset()
Definition
RejoinCountdown.h:25
RejoinCountdown::DelaySeconds
static constexpr double DelaySeconds
Definition
RejoinCountdown.h:12
RejoinCountdown::SecondsRemaining
double SecondsRemaining(double now) const
Definition
RejoinCountdown.h:27
RejoinCountdown::Update
void Update(bool realDeath, double now)
Definition
RejoinCountdown.h:14
RejoinCountdown::readyAt
double readyAt
Definition
RejoinCountdown.h:34
RejoinCountdown.h
Generated on
for Rise by
1.18.0