18 #ifndef INCLUDED_SIMULATION2 19 #define INCLUDED_SIMULATION2 28 #include <boost/unordered_map.hpp> 154 void ResetState(
bool skipScriptedComponents =
false,
bool skipAI =
false);
169 void InitGame(JS::HandleValue data);
171 void Update(
int turnLength);
172 void Update(
int turnLength,
const std::vector<SimulationCommand>& commands);
173 void Interpolate(
float simFrameLength,
float frameOffset,
float realFrameLength);
276 #endif // INCLUDED_SIMULATION2 Definition: IComponent.h:33
JS::Value GetInitAttributes()
Get the data passed to SetInitAttributes.
Definition: Simulation2.cpp:777
const CSimContext & GetSimContext() const
Definition: Simulation2.cpp:697
IComponent * QueryInterface(entity_id_t ent, int iid) const
Definition: Simulation2.cpp:672
bool DeserializeState(std::istream &stream)
Definition: Simulation2.cpp:868
entity_id_t AddLocalEntity(const std::wstring &templateName)
Definition: Simulation2.cpp:657
void Interpolate(float simFrameLength, float frameOffset, float realFrameLength)
Definition: Simulation2.cpp:734
void ResetState(bool skipScriptedComponents=false, bool skipAI=false)
Initialise (or re-initialise) the complete simulation state.
Definition: Simulation2.cpp:848
std::string GenerateSchema()
Definition: Simulation2.cpp:874
void RenderSubmit(SceneCollector &collector, const CFrustum &frustum, bool culling)
Definition: Simulation2.cpp:739
const InterfaceListUnordered & GetEntitiesWithInterfaceUnordered(int iid)
Returns a list of components implementing the given interface, and their associated entities...
Definition: Simulation2.cpp:692
Contains pointers to various 'global' objects that are needed by the simulation code, to allow easy access without using real (evil) global variables.
Definition: SimContext.h:32
std::vector< std::string > GetRMSData()
Get random map script data.
Definition: Simulation2.cpp:909
bool LoadDefaultScripts()
Call LoadScripts for each of the game's standard simulation script paths.
Definition: Simulation2.cpp:757
std::string GetMapSettingsString()
Get the current map settings as a UTF-8 JSON string.
Definition: Simulation2.cpp:803
~CSimulation2()
Definition: Simulation2.cpp:619
void Update(int turnLength)
Definition: Simulation2.cpp:723
float GetLastFrameOffset() const
Returns the last frame offset passed to Interpolate(), i.e.
Definition: Simulation2.cpp:747
Status ReloadChangedFile(const VfsPath &path)
Reload any scripts that were loaded from the given filename.
Definition: Simulation2.cpp:843
void PreInitGame()
Replace/destroy some entities (e.g.
Definition: Simulation2.cpp:707
Public API for simulation system.
Definition: Simulation2.h:47
This interface accepts renderable objects.
Definition: Scene.h:83
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:787
NONCOPYABLE(CSimulation2)
CSimulation2Impl * m
Definition: Simulation2.h:273
Definition: Simulation2.cpp:49
std::vector< std::pair< entity_id_t, IComponent * > > InterfaceList
Definition: Simulation2.h:209
Config::Value_type Value
Definition: json_spirit_value.h:181
void BroadcastMessage(const CMessage &msg) const
Definition: Simulation2.cpp:682
void InitGame(JS::HandleValue data)
Initialise a new game, based on some script data.
Definition: Simulation2.cpp:715
std::string GetPlayerDefaults()
Get player default data.
Definition: Simulation2.cpp:939
ScriptInterface & GetScriptInterface() const
Definition: Simulation2.cpp:702
bool LoadScripts(const VfsPath &path)
Load all scripts in the specified directory (non-recursively), so they can register new component typ...
Definition: Simulation2.cpp:752
Definition: UnitManager.h:36
bool ComputeStateHash(std::string &outHash, bool quick)
Definition: Simulation2.cpp:853
i64 Status
Error handling system.
Definition: status.h:171
std::string GetAIData()
Get AI data.
Definition: Simulation2.cpp:949
CSimulation2(CUnitManager *unitManager, shared_ptr< ScriptRuntime > rt, CTerrain *terrain)
Definition: Simulation2.cpp:614
bool SerializeState(std::ostream &stream)
Definition: Simulation2.cpp:863
void LoadMapSettings()
Loads the map settings script (called after map is loaded)
Definition: Simulation2.cpp:821
std::string GetMapSizes()
Get map sizes data.
Definition: Simulation2.cpp:944
InterfaceList GetEntitiesWithInterface(int iid)
Returns a list of components implementing the given interface, and their associated entities...
Definition: Simulation2.cpp:687
std::vector< std::string > GetCivData()
Get civilization data.
Definition: Simulation2.cpp:914
void FlushDestroyedEntities()
Does the actual destruction of entities from DestroyEntity.
Definition: Simulation2.cpp:667
entity_id_t AddEntity(const std::wstring &templateName)
Construct a new entity and add it to the world.
Definition: Simulation2.cpp:647
boost::unordered_map< entity_id_t, IComponent * > InterfaceListUnordered
Definition: Simulation2.h:210
void DestroyEntity(entity_id_t ent)
Destroys the specified entity, once FlushDestroyedEntities is called.
Definition: Simulation2.cpp:662
void SetInitAttributes(JS::HandleValue settings)
Set the attributes identifying the scenario/RMS used to initialise this simulation.
Definition: Simulation2.cpp:772
void EnableOOSLog()
Definition: Simulation2.cpp:636
Abstraction around a SpiderMonkey JSContext.
Definition: ScriptInterface.h:71
int ProgressiveLoad()
RegMemFun incremental loader function.
Definition: Simulation2.cpp:838
Abstraction around a SpiderMonkey JSRuntime.
Definition: ScriptRuntime.h:38
void SetStartupScript(const std::string &script)
Set a startup script, which will get executed before the first turn.
Definition: Simulation2.cpp:762
u32 entity_id_t
Entity ID type.
Definition: Entity.h:23
void EnableRejoinTest(int rejoinTestTurn)
Definition: Simulation2.cpp:631
const std::string & GetStartupScript()
Get the current startup script.
Definition: Simulation2.cpp:767
void EnableSerializationTest()
Definition: Simulation2.cpp:626
bool DumpDebugState(std::ostream &stream)
Definition: Simulation2.cpp:858
void PostMessage(entity_id_t ent, const CMessage &msg) const
Definition: Simulation2.cpp:677
void GetMapSettings(JS::MutableHandleValue ret)
Get the current map settings.
Definition: Simulation2.cpp:808
void LoadPlayerSettings(bool newPlayers)
Loads the player settings script (called before map is loaded)
Definition: Simulation2.cpp:813