Nebula
Loading...
Searching...
No Matches
timemanager.h
Go to the documentation of this file.
1#pragma once
2//------------------------------------------------------------------------------
9//------------------------------------------------------------------------------
10#include "core/singleton.h"
11#include "game/manager.h"
12#include "timing/time.h"
13
14#define TIMESOURCE_GAMEPLAY uint32_t('GPTS')
15#define TIMESOURCE_INPUT uint32_t('IPTS')
16#define TIMESOURCE_SYSTEM uint32_t('SYTS')
17
18namespace Game
19{
20
21//------------------------------------------------------------------------------
26{
28 uint32_t hash = 0;
29};
30
31//------------------------------------------------------------------------------
50struct TimeSource
51{
62};
63
64//------------------------------------------------------------------------------
74namespace Time
75{
78
80 TimeSource* const GetTimeSource(uint32_t TIMESOURCE_HASH);
81
83 void SetGlobalTimeFactor(float factor);
84
87};
88
89//------------------------------------------------------------------------------
95class TimeManager : public Game::Manager
96{
99public:
100 TimeManager();
101 virtual ~TimeManager();
102
103 void OnActivate() override;
104 void OnDeactivate() override;
105 void OnBeginFrame() override;
106};
107
108} // namespace Game
Managers are objects which care about some specific functionality of a feature.
Definition manager.h:32
Singleton object which manages all Game::TimeSource objects.
void OnBeginFrame() override
called before frame by the feature
Definition timemanager.cc:176
virtual __DeclareClass(TimeManager) __DeclareSingleton(TimeManager) public ~TimeManager()
Definition timemanager.cc:119
void OnDeactivate() override
called when removed from game server
Definition timemanager.cc:165
void OnActivate() override
Definition timemanager.cc:128
TimeSource *const CreateTimeSource(TimeSourceCreateInfo const &info)
create a timesource. The global time manager handles the timesources.
void SetGlobalTimeFactor(float factor)
set global time scale. This should be used sparingly. You can usually set individual time sources tim...
TimeSource *const GetTimeSource(uint32_t TIMESOURCE_HASH)
get a time source by hash
float GetGlobalTimeFactor()
get the global time scale
Game::EditorState.
Definition graphicsmanager.h:60
These are the standard time source objects provided by Application layer:
int Tick
the tick datatype (one tick == 1 millisecond)
Definition time.h:20
double Time
the time datatype
Definition time.h:18
#define __DeclareSingleton(type)
Definition osxsingleton.h:24
#define __DeclareClass(type)
Used to create a timesource.
Definition timemanager.h:26
uint32_t hash
time source hash number. Ex. 'ABC1'
Definition timemanager.h:28
An object that keeps track of running time and frame time (delta time).
float timeFactor
time factor for this time source
Definition timemanager.h:61
Timing::Time const time
total time this timesource has run for
Definition timemanager.h:55
int pauseCounter
increment this to pause time, decrement to continue running
Definition timemanager.h:59
Timing::Time const frameTime
delta time between this frame and last frame
Definition timemanager.h:53
Timing::Tick const ticks
number of ticks that this time source has run for
Definition timemanager.h:57
Typedefs for the Timing subsystem.