2004-07-27 23:00:53 +02:00
|
|
|
#ifndef _ps_Game_H
|
|
|
|
#define _ps_Game_H
|
|
|
|
|
|
|
|
// Kludge: Our included headers might want to subgroup the Game group, so do it
|
|
|
|
// here, before including the other guys
|
2005-01-07 01:47:44 +01:00
|
|
|
#include "ps/Errors.h"
|
2004-07-27 23:00:53 +02:00
|
|
|
ERROR_GROUP(Game);
|
|
|
|
|
|
|
|
#include "World.h"
|
|
|
|
#include "Simulation.h"
|
|
|
|
#include "GameView.h"
|
|
|
|
|
2004-08-05 15:07:51 +02:00
|
|
|
#include <vector>
|
2004-07-27 23:00:53 +02:00
|
|
|
|
2005-07-03 18:25:48 +02:00
|
|
|
class CPlayer;
|
|
|
|
class CGameAttributes;
|
|
|
|
|
2005-02-21 18:13:31 +01:00
|
|
|
// Default player limit (not counting the Gaia player)
|
|
|
|
// This may be overriden by system.cfg ("max_players")
|
2005-01-23 05:14:49 +01:00
|
|
|
#define PS_MAX_PLAYERS 6
|
|
|
|
|
2004-07-27 23:00:53 +02:00
|
|
|
class CGame
|
|
|
|
{
|
|
|
|
CWorld m_World;
|
|
|
|
CSimulation m_Simulation;
|
|
|
|
CGameView m_GameView;
|
|
|
|
|
|
|
|
CPlayer *m_pLocalPlayer;
|
2004-11-07 22:59:52 +01:00
|
|
|
std::vector<CPlayer *> m_Players;
|
2004-08-16 17:19:17 +02:00
|
|
|
uint m_NumPlayers;
|
2004-09-21 16:40:43 +02:00
|
|
|
|
|
|
|
bool m_GameStarted;
|
2004-07-27 23:00:53 +02:00
|
|
|
|
|
|
|
public:
|
2004-08-05 15:07:51 +02:00
|
|
|
CGame();
|
|
|
|
~CGame();
|
2004-07-27 23:00:53 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
Initialize all local state and members for playing a game described by
|
2004-08-16 17:19:17 +02:00
|
|
|
the attribute class, and start the game.
|
|
|
|
|
2004-07-31 17:57:18 +02:00
|
|
|
Return: 0 on OK - a PSRETURN code otherwise
|
2004-07-27 23:00:53 +02:00
|
|
|
*/
|
2004-08-16 17:19:17 +02:00
|
|
|
PSRETURN StartGame(CGameAttributes *pGameAttributes);
|
2005-03-22 03:17:55 +01:00
|
|
|
PSRETURN ReallyStartGame();
|
|
|
|
|
2004-07-27 23:00:53 +02:00
|
|
|
/*
|
|
|
|
Perform all per-frame updates
|
|
|
|
*/
|
|
|
|
void Update(double deltaTime);
|
|
|
|
|
2004-08-16 17:19:17 +02:00
|
|
|
inline CPlayer *GetLocalPlayer()
|
|
|
|
{ return m_pLocalPlayer; }
|
2004-11-07 22:59:52 +01:00
|
|
|
inline void SetLocalPlayer(CPlayer *pLocalPlayer)
|
|
|
|
{ m_pLocalPlayer=pLocalPlayer; }
|
|
|
|
|
2005-01-29 01:11:50 +01:00
|
|
|
// PT: No longer inline, because it does too much error checking. When
|
|
|
|
// everything stops trying to access players before they're loaded, feel
|
|
|
|
// free to put the inline version back.
|
|
|
|
CPlayer *GetPlayer(uint idx);
|
2005-01-18 01:46:18 +01:00
|
|
|
|
|
|
|
inline std::vector<CPlayer*>* GetPlayers()
|
|
|
|
{ return( &m_Players ); }
|
|
|
|
|
2004-08-16 17:19:17 +02:00
|
|
|
inline uint GetNumPlayers()
|
|
|
|
{ return m_NumPlayers; }
|
|
|
|
|
2004-09-21 16:40:43 +02:00
|
|
|
inline bool IsGameStarted()
|
|
|
|
{
|
|
|
|
return m_GameStarted;
|
|
|
|
}
|
|
|
|
|
2004-07-27 23:00:53 +02:00
|
|
|
inline CWorld *GetWorld()
|
|
|
|
{ return &m_World; }
|
|
|
|
inline CGameView *GetView()
|
|
|
|
{ return &m_GameView; }
|
2004-08-16 17:19:17 +02:00
|
|
|
inline CSimulation *GetSimulation()
|
|
|
|
{ return &m_Simulation; }
|
2005-03-22 03:17:55 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
PSRETURN RegisterInit(CGameAttributes* pAttribs);
|
2004-07-27 23:00:53 +02:00
|
|
|
};
|
|
|
|
|
2004-07-31 17:57:18 +02:00
|
|
|
extern CGame *g_Game;
|
|
|
|
|
2004-07-27 23:00:53 +02:00
|
|
|
#endif
|