#ifndef ENGINE_HH
#define ENGINE_HH
// forward-declare
class Engine;
#include "GameState.hh"
#include "Graphics.hh"
#include "Network/Server.hh"
#include "Network/Client.hh"
#include "Logger.hh"
/**
* This is the core class that glues all the other components together and runs the main loop
*/
class Engine {
private:
// game state
Terrain *terrain;
GameState *game_state;
/** Set if setupGraphics has been called */
const GraphicsConfig *graphics_config;
// Graphics/Input
Graphics *graphics;
// network server/client
NetworkServer *net_server;
NetworkClientConnect *net_client_connect;
// XXX: currently unused: NetworkClient *net_client;
// to exit the mainloop
bool is_running;
// ClanLib resources
CL_ResourceManager resources;
public:
// default constructor
Engine (const std::string resource_xml_path = RESOURCE_XML_PATH);
/**
* Setup game world using the given terrain, returning the new GameState
*
* XXX: fix to return void
*/
GameState& setupGame (Terrain *terrain);
/**
* Setup game world using given terrain configuration
*/
void setupGame (const TerrainConfig &config);
/**
* Enable graphics
*/
void setupGraphics (const GraphicsConfig &config);
/**
* Setup server, must call setupGame first
*/
void setupNetworkServer (const std::string &listen_port);
/**
* Setup client, do *not* call setupGame, configuration comes from the server
*/
void setupNetworkClient (const std::string &connect_host, const std::string &connect_port);
/**
* Setup singleplayer, must call setupGame first
*/
void setupSinglePlayer (void);
/**
* Run the game main loop. This will not return until the game aborts due to an error, or someone calls stop().
*/
void run (void);
/**
* Terminate the main loop, causing run() to return once this loop iteration is finished
*/
void stop (void);
private:
/**
* Actually start graphics, requires that game_state is now set
*/
void startGraphics (void);
public:
// get a pointer to our resource manager
CL_ResourceManager* getResourceManager (void);
// logging utility
static Logger log (enum LogLevel level, const char *type);
};
#endif /* ENGINE_HH */