MochiEngine
Loading...
Searching...
No Matches
Mochi::Time::TimeSystem Class Reference

Class that provides several time values useful for game development. More...

#include <TimeSystem.h>

Public Member Functions

 TimeSystem (TimeSystem const &)=delete
void operator= (TimeSystem const &)=delete
void Tick (const float &dt)

Static Public Member Functions

static TimeSystem & GetInstance ()
static float GetDeltaTime ()
 Gets the last delta time, scaled by the time scale.
static float GetUnscaledDeltaTime ()
 Gets the last delta time without scale.
static float GetGameTime ()
 Gets the time passed since opening the application, scaled.
static float GetUnscaledGameTime ()
 Gets the time passed since opening the application.
static void SetTimeScale (const float &scale)
 Sets a time scale.
static float GetTimeScale ()
 Gets the current time scale.

Detailed Description

Class that provides several time values useful for game development.

This class has to be updated calling Tick with the real delta time passed since the last frame. This way, TimeSystem stores it, applies time scale if needed and updated the total time passed since the application started.

Guarantees:

  • Access everywhere in the engine to all time values provided by the class via static methods.
  • A time scale greater than 0.
  • No negative real delta time can be used to update.
  • Update is done automatically by the Engine at each frame.

Thread safety:

  • Accessing time is thread safe.

Member Function Documentation

◆ GetDeltaTime()

float Mochi::Time::TimeSystem::GetDeltaTime ( )
static

Gets the last delta time, scaled by the time scale.

Returns
Time passed since the last frame, scaled

◆ GetGameTime()

float Mochi::Time::TimeSystem::GetGameTime ( )
static

Gets the time passed since opening the application, scaled.

Returns
Time passed since opening the application, scaled

◆ GetTimeScale()

float Mochi::Time::TimeSystem::GetTimeScale ( )
static

Gets the current time scale.

Returns
Time scale

◆ GetUnscaledDeltaTime()

float Mochi::Time::TimeSystem::GetUnscaledDeltaTime ( )
static

Gets the last delta time without scale.

Returns
Real time passed since the last frame

◆ GetUnscaledGameTime()

float Mochi::Time::TimeSystem::GetUnscaledGameTime ( )
static

Gets the time passed since opening the application.

Returns
Time passed since opening the application

◆ SetTimeScale()

void Mochi::Time::TimeSystem::SetTimeScale ( const float & scale)
static

Sets a time scale.

Remarks
Scale has to be greater or equal than 0, (useful to pause if 0)
Parameters
scaleThe new time scale, greater or equal than 0

The documentation for this class was generated from the following files:
  • Engine/src/Time/TimeSystem.h
  • Engine/src/Time/TimeSystem.cpp