#pragma once #include #include #include #include #include #include #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 s_map; static std::unique_ptr s_physics_scene; static std::map 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(); }; }