A reimplementation of Mario Kart Wii's physics engine in C++
Loading...
Searching...
No Matches
Kinoko::System::TimerManager Class Reference

#include <TimerManager.hh>

Description

Manages the race timer to create lap splits and final times.

Definition at line 93 of file TimerManager.hh.

Public Member Functions

void init ()
void calc ()
Getters
Timer currentTimer () const
 Computes the current race timer.
u32 frameCounter () const
 Retrieves the number of frames the timer has been updated since the race started.
Setters
void setStarted (bool isSet)

Static Private Member Functions

static constexpr u32 CalcTotalMs (u32 frame)
 Converts a frame counter value to the total number of elapsed milliseconds.
static constexpr u16 CalcMinutes (u32 totalMs)
 Converts a total number of elapsed milliseconds to whole minutes.

Private Attributes

bool m_started
 Indicates whether the race has started.
u32 m_frameCounter
 The number of frames since the race started.

Static Private Attributes

static constexpr f32 REFRESH_PERIOD = 1000.0f / 59.94f
static constexpr f32 MILLISECONDS_TO_MINUTES = 1.0f / 60000.0f
static constexpr f32 MILLISECONDS_TO_SECONDS = 1.0f / 1000.0f
static constexpr f32 SECONDS_TO_MILLISECONDS = 1000.0f
static constexpr f32 MINUTES_TO_MILLISECONDS = 60000.0f

Constructor & Destructor Documentation

◆ TimerManager()

Kinoko::System::TimerManager::TimerManager ( )
Inlined in 0x805327A0

Definition at line 23 of file TimerManager.cc.

◆ ~TimerManager()

Kinoko::System::TimerManager::~TimerManager ( )
default0x805376E0

Member Function Documentation

◆ calc()

void Kinoko::System::TimerManager::calc ( )
0x80535904
Note
For Kinoko, we omit per-frame Timer calculation as a performance improvement. Upon lap completion, m_frameCounter is used to compute the lap/race time.

Definition at line 39 of file TimerManager.cc.

◆ CalcMinutes()

constexpr u16 Kinoko::System::TimerManager::CalcMinutes ( u32 totalMs)
inlinestaticnodiscardconstexprprivate

Converts a total number of elapsed milliseconds to whole minutes.

Definition at line 146 of file TimerManager.hh.

◆ CalcTotalMs()

constexpr u32 Kinoko::System::TimerManager::CalcTotalMs ( u32 frame)
inlinestaticnodiscardconstexprprivate

Converts a frame counter value to the total number of elapsed milliseconds.

Definition at line 141 of file TimerManager.hh.

◆ currentTimer()

Timer Kinoko::System::TimerManager::currentTimer ( ) const
inlinenodiscard

Computes the current race timer.

Returns
A Timer storing the current race time

Definition at line 105 of file TimerManager.hh.

◆ frameCounter()

u32 Kinoko::System::TimerManager::frameCounter ( ) const
inlinenodiscard

Retrieves the number of frames the timer has been updated since the race started.

Returns
The number of frames since the race started, m_frameCounter

currentTimer() reflects frame m_frameCounter - 1, or zero if no frames have elapsed.

Definition at line 121 of file TimerManager.hh.

◆ init()

void Kinoko::System::TimerManager::init ( )
0x80535864

Definition at line 31 of file TimerManager.cc.

◆ setStarted()

void Kinoko::System::TimerManager::setStarted ( bool isSet)
inline

Definition at line 128 of file TimerManager.hh.

Member Data Documentation

◆ m_frameCounter

u32 Kinoko::System::TimerManager::m_frameCounter
private

The number of frames since the race started.

Definition at line 151 of file TimerManager.hh.

◆ m_started

bool Kinoko::System::TimerManager::m_started
private

Indicates whether the race has started.

Definition at line 150 of file TimerManager.hh.

◆ MILLISECONDS_TO_MINUTES

f32 Kinoko::System::TimerManager::MILLISECONDS_TO_MINUTES = 1.0f / 60000.0f
staticconstexprprivate

Definition at line 135 of file TimerManager.hh.

◆ MILLISECONDS_TO_SECONDS

f32 Kinoko::System::TimerManager::MILLISECONDS_TO_SECONDS = 1.0f / 1000.0f
staticconstexprprivate

Definition at line 136 of file TimerManager.hh.

◆ MINUTES_TO_MILLISECONDS

f32 Kinoko::System::TimerManager::MINUTES_TO_MILLISECONDS = 60000.0f
staticconstexprprivate

Definition at line 138 of file TimerManager.hh.

◆ REFRESH_PERIOD

f32 Kinoko::System::TimerManager::REFRESH_PERIOD = 1000.0f / 59.94f
staticconstexprprivate

Definition at line 134 of file TimerManager.hh.

◆ SECONDS_TO_MILLISECONDS

f32 Kinoko::System::TimerManager::SECONDS_TO_MILLISECONDS = 1000.0f
staticconstexprprivate

Definition at line 137 of file TimerManager.hh.