#ifndef GAMESTATE_HH
#define GAMESTATE_HH
class GameState;
#include "PhysicsWorld.hh"
#include "Player.hh"
#include "Projectile.hh"
#include "Rope.hh"
#include "Input.hh"
#include "GraphicsPointer.hh"
#include "Config.hh"
#include <list>
#include <stdexcept>
#include <cmath>
class GameStateEventHandler {
friend class GameState;
protected:
virtual void on_player_joined (Player *p) = 0;
virtual void on_player_left (Player *p) = 0;
};
class GameState {
public:
std::list<Player*> player_list;
std::list<Projectile*> projectiles;
PhysicsWorld world;
/**
* The one LocalPlayer that *we* control
*/
LocalPlayer *local_player;
protected:
/**
* Notify someone about events?
*/
GameStateEventHandler *event_handler;
public:
/**
* ...
*
* This should take some arguments
*/
GameState (void);
/**
* Set event handler, only one can be set
*/
void setEventHandler (GameStateEventHandler *handler);
/**
* Adds projectile to our list of projectiles to draw
*/
void addProjectile(Projectile *projectile);
/**
* Get our current LocalPlayer if we have one, else return NULL (client hasn't connected yet)
*/
LocalPlayer *getLocalPlayer (void);
/**
* Check that local_player is NULL, and sets it to the given player
*/
void setLocalPlayer (LocalPlayer *player);
/**
* Add the given player to our player_list
*/
void addPlayer (Player *player);
/**
* Removes the given player from player_list. If the given player was the local_player, set that to NULL
*/
void removePlayer (Player *player);
/**
* Draws the terrain, players and projectiles
*/
virtual void draw (Graphics *g, PixelCoordinate camera, bool displayWeapon);
};
#endif