Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/GuiInterface.js
Show First 20 Lines • Show All 51 Lines • ▼ Show 20 Lines | |||||
* This is used by the GUI and also by AI scripts. | * This is used by the GUI and also by AI scripts. | ||||
*/ | */ | ||||
GuiInterface.prototype.GetSimulationState = function() | GuiInterface.prototype.GetSimulationState = function() | ||||
{ | { | ||||
let ret = { | let ret = { | ||||
"players": [] | "players": [] | ||||
}; | }; | ||||
let numPlayers = Engine.QueryInterface(SYSTEM_ENTITY, IID_PlayerManager).GetNumPlayers(); | let cmpPlayerManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_PlayerManager); | ||||
let numPlayers = cmpPlayerManager.GetNumPlayers(); | |||||
for (let i = 0; i < numPlayers; ++i) | for (let i = 0; i < numPlayers; ++i) | ||||
{ | { | ||||
let cmpPlayer = QueryPlayerIDInterface(i); | let cmpPlayer = QueryPlayerIDInterface(i); | ||||
let cmpPlayerEntityLimits = QueryPlayerIDInterface(i, IID_EntityLimits); | let cmpPlayerEntityLimits = QueryPlayerIDInterface(i, IID_EntityLimits); | ||||
// Work out what phase we are in | // Work out what phase we are in | ||||
let phase = ""; | let phase = ""; | ||||
let cmpTechnologyManager = QueryPlayerIDInterface(i, IID_TechnologyManager); | let cmpTechnologyManager = QueryPlayerIDInterface(i, IID_TechnologyManager); | ||||
▲ Show 20 Lines • Show All 84 Lines • ▼ Show 20 Lines | GuiInterface.prototype.GetSimulationState = function() | ||||
if (cmpCinemaManager) | if (cmpCinemaManager) | ||||
ret.cinemaPlaying = cmpCinemaManager.IsPlaying(); | ret.cinemaPlaying = cmpCinemaManager.IsPlaying(); | ||||
// Add the game type and allied victory | // Add the game type and allied victory | ||||
let cmpEndGameManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_EndGameManager); | let cmpEndGameManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_EndGameManager); | ||||
ret.victoryConditions = cmpEndGameManager.GetVictoryConditions(); | ret.victoryConditions = cmpEndGameManager.GetVictoryConditions(); | ||||
ret.alliedVictory = cmpEndGameManager.GetAlliedVictory(); | ret.alliedVictory = cmpEndGameManager.GetAlliedVictory(); | ||||
// Add the max world population. | |||||
ret.maxWorldPopulation = cmpPlayerManager.GetMaxWorldPopulation(); | |||||
// Add basic statistics to each player | // Add basic statistics to each player | ||||
for (let i = 0; i < numPlayers; ++i) | for (let i = 0; i < numPlayers; ++i) | ||||
{ | { | ||||
let cmpPlayerStatisticsTracker = QueryPlayerIDInterface(i, IID_StatisticsTracker); | let cmpPlayerStatisticsTracker = QueryPlayerIDInterface(i, IID_StatisticsTracker); | ||||
if (cmpPlayerStatisticsTracker) | if (cmpPlayerStatisticsTracker) | ||||
ret.players[i].statistics = cmpPlayerStatisticsTracker.GetBasicStatistics(); | ret.players[i].statistics = cmpPlayerStatisticsTracker.GetBasicStatistics(); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 1,851 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator