31#include <js/TypeDecls.h>
99 void StartGame(JS::MutableHandleValue attribs,
const std::string& savedState);
113 void Update(
const double deltaRealTime,
bool doInterpolate =
true);
115 void Interpolate(
float simFrameLength,
float realFrameLength);
199 {
if (std::isfinite(simRate))
m_SimRate = std::max(simRate, 0.0f); }
222 void RegisterInit(
const JS::HandleValue attribs,
const std::string& savedState);
std::uint32_t PSRETURN
Definition: Errors.h:75
CGame * g_Game
Globally accessible pointer to the CGame object.
Definition: Game.cpp:72
int32_t player_id_t
valid player IDs are non-negative (see ICmpOwnership)
Definition: Player.h:26
Definition: GameView.h:37
The container that holds the rules, resources and attributes of the game.
Definition: Game.h:49
CGameView * GetView()
Get the pointer to the game view object.
Definition: Game.h:179
bool PlayerFinished(player_id_t playerID) const
Check if the given player has been defeated or won the game.
Definition: Game.cpp:513
CGameView * m_GameView
pointer to the CGameView object representing the view into the game world.
Definition: Game.h:65
player_id_t m_ViewedPlayerID
Differs from m_PlayerID if a defeated player or observer views another player.
Definition: Game.h:86
bool m_Paused
the game is paused and no updates will be performed if true.
Definition: Game.h:97
bool CheatsEnabled() const
Definition: Game.cpp:408
CSimulation2 * m_Simulation2
pointer to the CSimulation2 object operating on the game world.
Definition: Game.h:60
static const CStr EventNameSimulationUpdate
Definition: Game.h:220
void SetViewedPlayerID(player_id_t playerID)
Definition: Game.cpp:403
bool IsGameStarted() const
Get m_GameStarted.
Definition: Game.h:153
void SetSimRate(float simRate)
Set the simulation scale multiplier.
Definition: Game.h:198
void Interpolate(float simFrameLength, float realFrameLength)
Definition: Game.cpp:460
~CGame()
Destructor.
Definition: Game.cpp:114
void RegisterInit(const JS::HandleValue attribs, const std::string &savedState)
Initializes the game with the set of attributes provided.
Definition: Game.cpp:221
void StartGame(JS::MutableHandleValue attribs, const std::string &savedState)
Definition: Game.cpp:413
int LoadVisualReplayData()
Definition: Game.cpp:142
IReplayLogger & GetReplayLogger() const
Definition: Game.h:216
OsPath GetReplayPath() const
Definition: Game.h:204
PSRETURN ReallyStartGame()
Game initialization has been completed.
Definition: Game.cpp:343
bool m_CheatsEnabled
Definition: Game.h:229
std::istream * m_ReplayStream
Definition: Game.h:234
int LoadInitialState(const std::string &savedState)
Definition: Game.cpp:324
void CachePlayerColors()
Retrieving player colors from scripts is slow, so this updates an internal cache of all players' colo...
Definition: Game.cpp:471
int GetPlayerID()
Definition: Game.cpp:384
bool StartVisualReplay(const OsPath &replayPath)
Definition: Game.cpp:189
float GetSimRate() const
Definition: Game.h:201
void Update(const double deltaRealTime, bool doInterpolate=true)
Periodic heartbeat that controls the process.
Definition: Game.cpp:425
player_id_t m_PlayerID
Index assigned to the current player.
Definition: Game.h:81
CSimulation2 * GetSimulation2()
Get the pointer to the simulation2 object.
Definition: Game.h:187
CWorld * m_World
pointer to the CWorld object representing the game world.
Definition: Game.h:55
CGame(bool replayLog, const SimulationDebugOptions debugOptions={})
Constructor.
Definition: Game.cpp:80
OsPath m_ReplayPath
Definition: Game.h:232
bool IsVisualReplay() const
Get m_IsVisualReplay.
Definition: Game.h:163
float m_SimRate
Timescale multiplier for simulation rate.
Definition: Game.h:75
CTurnManager * m_TurnManager
Definition: Game.h:88
std::uint32_t m_FinalReplayTurn
Definition: Game.h:235
int GetViewedPlayerID()
Definition: Game.cpp:398
CWorld * GetWorld()
Get the pointer to the game world object.
Definition: Game.h:171
const CColor & GetPlayerColor(player_id_t player) const
Definition: Game.cpp:492
bool m_IsVisualReplay
Definition: Game.h:233
std::vector< CColor > m_PlayerColors
Definition: Game.h:225
bool m_GameStarted
the game has been initialized and ready for use if true.
Definition: Game.h:70
bool IsGameFinished() const
Check if the game is finished by testing if there's a winner.
Definition: Game.cpp:500
IReplayLogger * m_ReplayLogger
Definition: Game.h:223
void SetPlayerID(player_id_t playerID)
Definition: Game.cpp:389
CTurnManager * GetTurnManager() const
Definition: Game.h:213
void SetTurnManager(CTurnManager *turnManager)
Replace the current turn manager.
Definition: Game.cpp:131
Public API for simulation system.
Definition: Simulation2.h:57
Common turn system (used by clients and offline games).
Definition: TurnManager.h:88
CWorld is a general data class containing whatever is needed to accurately represent the world.
Definition: World.h:51
Replay log recorder interface.
Definition: Replay.h:40
Definition: DebugOptions.h:24