![]() |
Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
|
The container that holds the rules, resources and attributes of the game. More...
#include <Game.h>

Public Member Functions | |
| CGame (bool replayLog) | |
| Constructor. More... | |
| ~CGame () | |
| Destructor. More... | |
| void | StartGame (JS::MutableHandleValue attribs, const std::string &savedState) |
| PSRETURN | ReallyStartGame () |
| Game initialization has been completed. More... | |
| bool | StartVisualReplay (const OsPath &replayPath) |
| void | Update (const double deltaRealTime, bool doInterpolate=true) |
| Periodic heartbeat that controls the process. More... | |
| void | Interpolate (float simFrameLength, float realFrameLength) |
| int | GetPlayerID () |
| void | SetPlayerID (player_id_t playerID) |
| int | GetViewedPlayerID () |
| void | SetViewedPlayerID (player_id_t playerID) |
| bool | IsGameFinished () const |
| Check if the game is finished by testing if there's a winner. More... | |
| void | CachePlayerColors () |
| Retrieving player colors from scripts is slow, so this updates an internal cache of all players' colors. More... | |
| const CColor & | GetPlayerColor (player_id_t player) const |
| bool | IsGameStarted () const |
| Get m_GameStarted. More... | |
| bool | IsVisualReplay () const |
| Get m_IsVisualReplay. More... | |
| CWorld * | GetWorld () |
| Get the pointer to the game world object. More... | |
| CGameView * | GetView () |
| Get the pointer to the game view object. More... | |
| CSimulation2 * | GetSimulation2 () |
| Get the pointer to the simulation2 object. More... | |
| void | SetSimRate (float simRate) |
| Set the simulation scale multiplier. More... | |
| float | GetSimRate () const |
| OsPath | GetReplayPath () const |
| void | SetTurnManager (CTurnManager *turnManager) |
| Replace the current turn manager. More... | |
| CTurnManager * | GetTurnManager () const |
| IReplayLogger & | GetReplayLogger () const |
Public Attributes | |
| bool | m_Paused |
| the game is paused and no updates will be performed if true. More... | |
Private Member Functions | |
| NONCOPYABLE (CGame) | |
| void | RegisterInit (const JS::HandleValue attribs, const std::string &savedState) |
| Initializes the game with the set of attributes provided. More... | |
| int | LoadInitialState (const std::string &savedState) |
| int | LoadVisualReplayData () |
Private Attributes | |
| CWorld * | m_World |
| pointer to the CWorld object representing the game world. More... | |
| CSimulation2 * | m_Simulation2 |
| pointer to the CSimulation2 object operating on the game world. More... | |
| CGameView * | m_GameView |
| pointer to the CGameView object representing the view into the game world. More... | |
| bool | m_GameStarted |
| the game has been initialized and ready for use if true. More... | |
| float | m_SimRate |
| Timescale multiplier for simulation rate. More... | |
| player_id_t | m_PlayerID |
| Index assigned to the current player. More... | |
| player_id_t | m_ViewedPlayerID |
| Differs from m_PlayerID if a defeated player or observer views another player. More... | |
| CTurnManager * | m_TurnManager |
| IReplayLogger * | m_ReplayLogger |
| std::vector< CColor > | m_PlayerColors |
| bool | m_IsSavedGame |
| OsPath | m_ReplayPath |
| bool | m_IsVisualReplay |
| std::istream * | m_ReplayStream |
| u32 | m_FinalReplayTurn |
Static Private Attributes | |
| static const CStr | EventNameSimulationUpdate = "SimulationUpdate" |
The container that holds the rules, resources and attributes of the game.
The CGame object is responsible for creating a game that is defined by a set of attributes provided. The CGame object is also responsible for maintaining the relations between CPlayer and CWorld, CSimulation and CWorld.
| CGame::CGame | ( | bool | replayLog | ) |
Constructor.
| CGame::~CGame | ( | ) |
Destructor.
| void CGame::CachePlayerColors | ( | ) |
Retrieving player colors from scripts is slow, so this updates an internal cache of all players' colors.
Call this just before rendering, so it will always have the latest colors.
| const CColor & CGame::GetPlayerColor | ( | player_id_t | player | ) | const |
| int CGame::GetPlayerID | ( | ) |
|
inline |
|
inline |
|
inline |
|
inline |
Get the pointer to the simulation2 object.
|
inline |
|
inline |
Get the pointer to the game view object.
| int CGame::GetViewedPlayerID | ( | ) |
|
inline |
Get the pointer to the game world object.
| void CGame::Interpolate | ( | float | simFrameLength, |
| float | realFrameLength | ||
| ) |
| bool CGame::IsGameFinished | ( | ) | const |
Check if the game is finished by testing if there's a winner.
It is used to end a non visual autostarted game.
|
inline |
Get m_GameStarted.
|
inline |
Get m_IsVisualReplay.
|
private |
|
private |
|
private |
| PSRETURN CGame::ReallyStartGame | ( | ) |
Game initialization has been completed.
Set game started flag and start the session.
|
private |
Initializes the game with the set of attributes provided.
Makes calls to initialize the game view, world, and simulation objects. Calls are made to facilitate progress reporting of the initialization.
| void CGame::SetPlayerID | ( | player_id_t | playerID | ) |
|
inline |
Set the simulation scale multiplier.
| simRate | Float value to set m_SimRate to. Because m_SimRate is also used to scale TimeSinceLastFrame it must be clamped to 0.0f. |
| void CGame::SetTurnManager | ( | CTurnManager * | turnManager | ) |
Replace the current turn manager.
This class will take ownership of the pointer.
| void CGame::SetViewedPlayerID | ( | player_id_t | playerID | ) |
| void CGame::StartGame | ( | JS::MutableHandleValue | attribs, |
| const std::string & | savedState | ||
| ) |
| bool CGame::StartVisualReplay | ( | const OsPath & | replayPath | ) |
| void CGame::Update | ( | const double | deltaRealTime, |
| bool | doInterpolate = true |
||
| ) |
Periodic heartbeat that controls the process.
performs all per-frame updates. Simulation update is called and game status update is called.
| deltaRealTime | Elapsed real time since last beat/frame, in seconds. |
| doInterpolate | Perform graphics interpolation if true. |
|
staticprivate |
|
private |
|
private |
the game has been initialized and ready for use if true.
|
private |
pointer to the CGameView object representing the view into the game world.
|
private |
|
private |
| bool CGame::m_Paused |
the game is paused and no updates will be performed if true.
|
private |
|
private |
Index assigned to the current player.
1-8 to control players, 0 for gaia, -1 for observer.
|
private |
|
private |
|
private |
|
private |
Timescale multiplier for simulation rate.
|
private |
pointer to the CSimulation2 object operating on the game world.
|
private |
|
private |
Differs from m_PlayerID if a defeated player or observer views another player.