TSR_ECS/src/tsr/game.hpp
2023-12-29 20:03:34 +01:00

68 lines
1.8 KiB
C++

#pragma once
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>
#include <glm/gtx/quaternion.hpp>
#include <memory>
#include <entt/entt.hpp>
#include "renderer.hpp"
#include "worldmap.hpp"
#include "physics.hpp"
#include "luaapi.hpp"
namespace TSR {
struct Timer {
float interval = 0.0f;
uint32_t last_frame = 0;
bool repeat = false;
LuaReference callback;
};
enum DebugMode : int {
DEBUG_NONE,
DEBUG_PHYSICS = 1 << 0,
DEBUG_CCT = 1 << 1,
DEBUG_NODES = 1 << 2,
DEBUG_ALL = DEBUG_PHYSICS | DEBUG_CCT | DEBUG_NODES
};
class Game {
static entt::registry s_registry;
static std::unique_ptr<WorldMap> s_map;
static std::unique_ptr<PhysicsScene> s_physics_scene;
static std::map<uint32_t, Timer> s_timers;
static uint64_t s_sv_frame;
static float s_frame_t;
static int s_tps;
static bool s_debug_draw;
static int s_debug_mode;
static void StartGame(const std::string& map_name);
static void EndGame();
public:
static void Run();
static void SvFrame();
static void ClFrame(Renderer& renderer, float frame_t);
static entt::registry& Registry() { return s_registry; }
static PhysicsScene& Physics() { return *s_physics_scene; }
static const WorldMap& Map() { return *s_map; }
static uint64_t FrameNum() { return s_sv_frame; }
static float FrameT() { return s_frame_t; }
static int TPS() { return s_tps; }
static bool DebugEnabled(DebugMode mode) { return s_debug_draw && (s_debug_mode & mode); }
static void RegisterLuaFunctions();
};
}