Extra2D/include/core/director.h

54 lines
1.0 KiB
C
Raw Normal View History

#pragma once
#include <core/scheduler.h>
#include <core/service.h>
namespace extra2d {
/**
* @brief
*
*
*/
class Director {
public:
static Director& inst();
bool init();
void shutdown();
void mainLoop(float dt);
void mainLoopParallel(float dt);
Scheduler& sched() { return *sched_; }
SvcMgr& svcs() { return *svcMgr_; }
float dt() const { return dt_; }
float totalTime() const { return totalTime_; }
uint64 frameCount() const { return frameCount_; }
void pause();
void resume();
bool isPaused() const { return paused_; }
void setTimeScale(float scale);
private:
Director() = default;
Unique<Scheduler> sched_;
Unique<SvcMgr> svcMgr_;
float dt_ = 0.0f;
float totalTime_ = 0.0f;
float fixedAccumulator_ = 0.0f;
float fixedDt_ = 1.0f / 60.0f;
uint64 frameCount_ = 0;
bool paused_ = false;
bool inited_ = false;
};
#define DIRECTOR extra2d::Director::inst()
} // namespace extra2d