14#include <unordered_map>
65 explicit GameLogic(std::shared_ptr<ecs::wrapper::ECSWorld> world =
nullptr,
66 std::shared_ptr<ThreadPool> threadPool =
nullptr,
67 std::shared_ptr<EventBus> eventBus =
nullptr);
72 void update(
float deltaTime, uint32_t currentTick)
override;
73 uint32_t
spawnPlayer(uint32_t playerId,
const std::string &playerName)
override;
76 uint32_t sequenceId)
override;
122 bool loadMap(
const std::string &mapFilePath);
147 std::shared_ptr<ecs::wrapper::ECSWorld>
_world;
Type-safe event publication/subscription system.
Base interface for all ECS systems.
Manages entities, their signatures and component type registrations.
Manages Lua state and script execution for the server.
ECS system that executes Lua scripts for entities.
Deterministic, authoritative server game logic.
const GameRules & getGameRules() const override
Get the game rules (const version)
uint32_t getLastProcessedInput(uint32_t playerId) const override
Get the last processed input sequence ID for a player.
GameRules & getGameRules()
Get the game rules.
void _applyPlayerInput(uint32_t playerId, const PlayerInput &input)
Apply a single input snapshot to a player entity.
void _executeSystems(float deltaTime)
Execute all systems in order.
uint32_t spawnPlayer(uint32_t playerId, const std::string &playerName) override
Spawn a player entity.
std::shared_ptr< ThreadPool > _threadPool
void resetGame() override
Reset game state (new game)
std::unordered_map< uint32_t, std::deque< PlayerInput > > _pendingInput
void _checkGameOverCondition()
Check if all players are dead and trigger game over.
bool initialize() override
Initialize game logic and ECS systems.
void despawnPlayer(uint32_t playerId) override
Remove a player from the game.
bool loadMap(const std::string &mapFilePath)
Load and activate a new map from a JSON file.
static constexpr float FIXED_TIMESTEP
std::shared_ptr< GameStateManager > getStateManager()
Get the game state manager.
void _cleanupDeadEntities()
Clean up dead entities.
std::unordered_map< uint32_t, ecs::Address > _playerMap
std::shared_ptr< EventBus > _eventBus
std::unique_ptr< scripting::LuaEngine > _luaEngine
ecs::Registry & getRegistry() override
Get reference to the ECS registry.
std::shared_ptr< ecs::wrapper::ECSWorld > _world
bool isGameActive() const override
Check if the game is active.
std::atomic< bool > _initialized
void update(float deltaTime, uint32_t currentTick) override
Update game state for one frame.
void onGameStart()
Notify Lua scripts that the game has started.
void _processInput()
Process accumulated player input.
std::shared_ptr< GameStateManager > _stateManager
std::unordered_map< uint32_t, uint32_t > _lastReceivedSequenceId
std::unordered_map< uint32_t, uint32_t > _lastAppliedSequenceId
std::shared_ptr< ecs::wrapper::ECSWorld > getECSWorld()
Get the ECS world instance.
void processPlayerInput(uint32_t playerId, int inputX, int inputY, bool isShooting, uint32_t sequenceId) override
Process player input event.
Centralized game rules and configuration.
Interface for server-side game logic orchestration.
Maximum number of distinct component types supported by the Registry.