support for building without Network/Graphics, although the disable-graphics case is kind of hackish still
#ifndef ENGINE_HH
#define ENGINE_HH
// forward-declare
class Engine;
#include "GameState.hh"
#include "Configuration.hh"
#include "Logger.hh"
// forward-declare component pointer types
// XXX: move to some kind of Components.hh file?
namespace graphics { class Graphics; }
class NetworkServer;
class NetworkClientConnect;
class NetworkClient;
/**
* 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;
// Graphics/Input
graphics::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.
*
* Requires: GRAPHICS_ENABLED
*/
void setupGraphics (const DisplayConfig &config);
/**
* Setup server, must call setupGame first
*
* Requires: NETWORK_ENABLED
*/
void setupNetworkServer (const std::string &listen_port);
/**
* Setup client, do *not* call setupGame, configuration comes from the server
*
* Requires: NETWORK_ENABLED
*/
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:
/**
* Puts graphics into GameView mode, using our GameState and the given player
*/
void startGameView (LocalPlayer *player);
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 */