18#ifndef INCLUDED_SIMULATION2
19#define INCLUDED_SIMULATION2
28#include <unordered_map>
153 void ResetState(
bool skipScriptedComponents =
false,
bool skipAI =
false);
170 void Update(
int turnLength);
171 void Update(
int turnLength,
const std::vector<SimulationCommand>& commands);
172 void Interpolate(
float simFrameLength,
float frameOffset,
float realFrameLength);
209 std::vector<std::pair<entity_id_t, IComponent*> >;
212 std::unordered_map<entity_id_t, IComponent*>;
Contains pointers to various 'global' objects that are needed by the simulation code,...
Definition: SimContext.h:33
Definition: Simulation2.cpp:54
Public API for simulation system.
Definition: Simulation2.h:47
int ProgressiveLoad()
RegMemFun incremental loader function.
Definition: Simulation2.cpp:862
void PreInitGame()
Replace/destroy some entities (e.g.
Definition: Simulation2.cpp:730
bool LoadScripts(const VfsPath &path)
Load all scripts in the specified directory (non-recursively), so they can register new component typ...
Definition: Simulation2.cpp:778
const CSimContext & GetSimContext() const
Definition: Simulation2.cpp:720
void FlushDestroyedEntities()
Does the actual destruction of entities from DestroyEntity.
Definition: Simulation2.cpp:690
entity_id_t AddLocalEntity(const std::wstring &templateName)
Definition: Simulation2.cpp:680
float GetLastFrameOffset() const
Returns the last frame offset passed to Interpolate(), i.e.
Definition: Simulation2.cpp:773
void SetInitAttributes(JS::HandleValue settings)
Set the attributes identifying the scenario/RMS used to initialise this simulation.
Definition: Simulation2.cpp:798
std::unordered_map< entity_id_t, IComponent * > InterfaceListUnordered
Definition: Simulation2.h:212
entity_id_t AddEntity(const std::wstring &templateName)
Construct a new entity and add it to the world.
Definition: Simulation2.cpp:670
const std::string & GetStartupScript()
Get the current startup script.
Definition: Simulation2.cpp:793
std::vector< std::string > GetVictoryConditiondData()
Get victory condition data.
Definition: Simulation2.cpp:947
void RenderSubmit(SceneCollector &collector, const CFrustum &frustum, bool culling)
Definition: Simulation2.cpp:765
JS::Value GetInitAttributes()
Get the data passed to SetInitAttributes.
Definition: Simulation2.cpp:803
std::string GetAIData()
Get AI data.
Definition: Simulation2.cpp:982
void InitGame()
Initialise a new game, based on some script data.
Definition: Simulation2.cpp:737
CSimulation2(CUnitManager *unitManager, ScriptContext &cx, CTerrain *terrain)
Definition: Simulation2.cpp:637
void LoadPlayerSettings(bool newPlayers)
Loads the player settings script (called before map is loaded)
Definition: Simulation2.cpp:836
bool SerializeState(std::ostream &stream)
Definition: Simulation2.cpp:888
std::vector< std::pair< entity_id_t, IComponent * > > InterfaceList
Definition: Simulation2.h:209
ScriptInterface & GetScriptInterface() const
Definition: Simulation2.cpp:725
InterfaceList GetEntitiesWithInterface(int iid)
Returns a list of components implementing the given interface, and their associated entities,...
Definition: Simulation2.cpp:710
void BroadcastMessage(const CMessage &msg) const
Definition: Simulation2.cpp:705
std::string GenerateSchema()
Definition: Simulation2.cpp:907
void ActivateRejoinTest(int turn)
Activate the rejoin-test feature for turn.
Definition: Simulation2.cpp:899
bool LoadDefaultScripts()
Call LoadScripts for each of the game's standard simulation script paths.
Definition: Simulation2.cpp:783
void GetMapSettings(JS::MutableHandleValue ret)
Get the current map settings.
Definition: Simulation2.cpp:831
void SetMapSettings(const std::string &settings)
Set the initial map settings (as a UTF-8-encoded JSON string), which will be used to set up the simul...
Definition: Simulation2.cpp:813
~CSimulation2()
Definition: Simulation2.cpp:642
Status ReloadChangedFile(const VfsPath &path)
Reload any scripts that were loaded from the given filename.
Definition: Simulation2.cpp:867
void Interpolate(float simFrameLength, float frameOffset, float realFrameLength)
Definition: Simulation2.cpp:760
void PostMessage(entity_id_t ent, const CMessage &msg) const
Definition: Simulation2.cpp:700
void ResetState(bool skipScriptedComponents=false, bool skipAI=false)
Initialise (or re-initialise) the complete simulation state.
Definition: Simulation2.cpp:872
IComponent * QueryInterface(entity_id_t ent, int iid) const
Definition: Simulation2.cpp:695
void EnableRejoinTest(int rejoinTestTurn)
Definition: Simulation2.cpp:654
void EnableOOSLog()
Definition: Simulation2.cpp:659
bool DeserializeState(std::istream &stream)
Definition: Simulation2.cpp:893
std::string GetMapSettingsString()
Get the current map settings as a UTF-8 JSON string.
Definition: Simulation2.cpp:826
std::vector< std::string > GetRMSData()
Get random map script data.
Definition: Simulation2.cpp:942
void DestroyEntity(entity_id_t ent)
Destroys the specified entity, once FlushDestroyedEntities is called.
Definition: Simulation2.cpp:685
void EnableSerializationTest()
Definition: Simulation2.cpp:649
bool ComputeStateHash(std::string &outHash, bool quick)
Definition: Simulation2.cpp:877
NONCOPYABLE(CSimulation2)
bool DumpDebugState(std::ostream &stream)
Definition: Simulation2.cpp:882
CSimulation2Impl * m
Definition: Simulation2.h:280
void SetStartupScript(const std::string &script)
Set a startup script, which will get executed before the first turn.
Definition: Simulation2.cpp:788
void Update(int turnLength)
Definition: Simulation2.cpp:749
void LoadMapSettings()
Loads the map settings script (called after map is loaded)
Definition: Simulation2.cpp:843
std::string GetMapSizes()
Get map sizes data.
Definition: Simulation2.cpp:977
std::string GetPlayerDefaults()
Get player default data.
Definition: Simulation2.cpp:972
const InterfaceListUnordered & GetEntitiesWithInterfaceUnordered(int iid)
Returns a list of components implementing the given interface, and their associated entities,...
Definition: Simulation2.cpp:715
Definition: UnitManager.h:38
Definition: IComponent.h:33
This interface accepts renderable objects.
Definition: Scene.h:90
Abstraction around a SpiderMonkey JSContext.
Definition: ScriptContext.h:46
Abstraction around a SpiderMonkey JS::Realm.
Definition: ScriptInterface.h:72
u32 entity_id_t
Entity ID type.
Definition: Entity.h:29
i64 Status
Error handling system.
Definition: status.h:173