18 #ifndef INCLUDED_SIMULATION2
19 #define INCLUDED_SIMULATION2
28 #include <boost/unordered_map.hpp>
147 void ResetState(
bool skipScriptedComponents =
false,
bool skipAI =
false);
158 void Update(
int turnLength);
159 void Update(
int turnLength,
const std::vector<SimulationCommand>& commands);
160 void Interpolate(
float simFrameLength,
float frameOffset,
float realFrameLength);
268 #endif // INCLUDED_SIMULATION2
CSimulation2(CUnitManager *, CTerrain *)
std::string ReadJSON(VfsPath path)
const CSimContext & GetSimContext() const
void SetInitAttributes(const CScriptValRooted &settings)
Set the attributes identifying the scenario/RMS used to initialise this simulation.
IComponent * QueryInterface(entity_id_t ent, int iid) const
bool DeserializeState(std::istream &stream)
entity_id_t AddLocalEntity(const std::wstring &templateName)
void Interpolate(float simFrameLength, float frameOffset, float realFrameLength)
void ResetState(bool skipScriptedComponents=false, bool skipAI=false)
Initialise (or re-initialise) the complete simulation state.
A trivial wrapper around a jsval.
std::string GenerateSchema()
void RenderSubmit(SceneCollector &collector, const CFrustum &frustum, bool culling)
const InterfaceListUnordered & GetEntitiesWithInterfaceUnordered(int iid)
Returns a list of components implementing the given interface, and their associated entities...
Contains pointers to various 'global' objects that are needed by the simulation code, to allow easy access without using real (evil) global variables.
std::vector< std::string > GetRMSData()
Get random map script data.
bool LoadDefaultScripts()
Call LoadScripts for each of the game's standard simulation script paths.
std::string GetMapSettingsString()
Get the current map settings as a UTF-8 JSON string.
void Update(int turnLength)
float GetLastFrameOffset() const
Returns the last frame offset passed to Interpolate(), i.e.
Status ReloadChangedFile(const VfsPath &path)
Reload any scripts that were loaded from the given filename.
Public API for simulation system.
void InitGame(const CScriptVal &data)
Initialise a new game, based on some script data.
This interface accepts renderable objects.
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...
NONCOPYABLE(CSimulation2)
std::vector< std::pair< entity_id_t, IComponent * > > InterfaceList
void BroadcastMessage(const CMessage &msg) const
std::string GetPlayerDefaults()
Get player default data.
ScriptInterface & GetScriptInterface() const
bool LoadScripts(const VfsPath &path)
Load all scripts in the specified directory (non-recursively), so they can register new component typ...
bool ComputeStateHash(std::string &outHash, bool quick)
i64 Status
Error handling system.
std::string GetAIData()
Get AI data.
bool SerializeState(std::ostream &stream)
void LoadMapSettings()
Loads the map settings script (called after map is loaded)
std::string GetMapSizes()
Get map sizes data.
InterfaceList GetEntitiesWithInterface(int iid)
Returns a list of components implementing the given interface, and their associated entities...
std::vector< std::string > GetCivData()
Get civilization data.
CScriptVal GetMapSettings()
Get the current map settings.
void FlushDestroyedEntities()
Does the actual destruction of entities from DestroyEntity.
entity_id_t AddEntity(const std::wstring &templateName)
Construct a new entity and add it to the world.
boost::unordered_map< entity_id_t, IComponent * > InterfaceListUnordered
void DestroyEntity(entity_id_t ent)
Destroys the specified entity, once FlushDestroyedEntities is called.
Abstraction around a SpiderMonkey JSContext.
int ProgressiveLoad()
RegMemFun incremental loader function.
void SetStartupScript(const std::string &script)
Set a startup script, which will get executed before the first turn.
u32 entity_id_t
Entity ID type.
const std::string & GetStartupScript()
Get the current startup script.
void EnableSerializationTest()
CScriptValRooted GetInitAttributes()
Get the data passed to SetInitAttributes.
bool DumpDebugState(std::ostream &stream)
void PostMessage(entity_id_t ent, const CMessage &msg) const
void LoadPlayerSettings(bool newPlayers)
Loads the player settings script (called before map is loaded)