#pragma once

#include <memory>

#include "GameContext.hpp"
#include "debug/tools/EntityManagerGui.hpp"
#include "debug/tools/NetworkStatsGui.hpp"
#include "network/ServerConnection.hpp"
#include "world/controllers/ClientWorldController.hpp"

namespace tw::app {

/**
 * The game world state.
 * Responsible for updating the game simulation and rendering debug information.
 */
class GameState {
    GameContext m_context;
    std::unique_ptr<tw::net::ServerConnection> m_connection;
    std::unique_ptr<tw::ClientWorldController> m_controller;
    tw::dbg::tools::EntityManagerGui m_entity_gui;
    tw::dbg::tools::NetworkStatsGui m_network_gui;

public:
    /**
     * Constructs the game state with the given context and connection.
     * The connection must be established before creating the game state.
     */
    GameState(GameContext context, std::unique_ptr<tw::net::ServerConnection> connection);

    /**
     * Takes the debug panels back out of the menu.
     */
    ~GameState();

    /**
     * Updates the game state: draws debug GUIs, updates the controller,
     * and steps the world physics.
     */
    void update(double delta_time);
};

} // namespace tw::app
