se_core::SimEngine Class Reference

SimEngine is the main manager class for the simulation engine. More...

#include <SimEngine.hpp>

List of all members.

Public Member Functions

 SimEngine ()
 Constructor.
 ~SimEngine ()
 Destructor.
const char * level ()
const char * nextLevel ()
void cleanup ()
 Cleanup the simulation engine.
void initGame ()
 Initialise engine for a new game.
void cleanupGame ()
 Reset game.
void setLevel (const char *name)
bool step (long when)
 Performs simulation step and calls listeners.
void go ()
 Game loop.
void resetAll ()
 Reset the engine.
void resetTimer ()
 Reset step counter.
void setMultiplePerformsPerStepEnabled (bool state)
 Set or reset the multiple perform() flag.
long when ()
 Get the adjusted game clock.
bool isGameOver ()
 Returns value of game over flag.
void setGameOver (bool state)
 Set the game over flag.

Static Public Member Functions

bool init ()
 Initialise the simulation engine.

Protected Member Functions

void perform (long when)
 Performs AI actions.


Detailed Description

SimEngine is the main manager class for the simulation engine.

You call the SimSchema::simEngine->step() method to step the simulation engine.

Definition at line 41 of file SimEngine.hpp.


Constructor & Destructor Documentation

se_core::SimEngine::SimEngine  ) 
 

Constructor.

Definition at line 49 of file SimEngine.cpp.

References LogDetail.

se_core::SimEngine::~SimEngine  ) 
 

Destructor.

Definition at line 58 of file SimEngine.cpp.

References LogDetail.


Member Function Documentation

void se_core::SimEngine::cleanup  ) 
 

Cleanup the simulation engine.

This should be called once, before application shuts down.

It will cast an InitListener::cleanupEngineEvent() to registered listeners.

Definition at line 216 of file SimEngine.cpp.

References se_core::InitListeners::castCleanupEngineEvent(), se_core::InitListeners::castPriorityCleanupEngineEvent(), and se_core::SimSchema::initListeners().

Referenced by se_core::SimSchema::cleanup().

void se_core::SimEngine::cleanupGame  ) 
 

Reset game.

Cleans up all areas and prepares the engine for a new game.

It will cast an InitListener::cleanupGameEvent() to registered listeners.

Definition at line 247 of file SimEngine.cpp.

References se_core::CompSchema::activeRoot(), se_core::InitListeners::castCleanupGameEvent(), se_core::RootComponent::cleanup(), se_core::Composite::cleanup(), se_core::SimSchema::initListeners(), LogWarning, se_core::SpawnManager::reset(), se_core::SpawnManager::resetAll(), and se_core::SimSchema::spawnManager().

void se_core::SimEngine::go  ) 
 

Game loop.

Parameters:
when The present clock (milliseconds)

Definition at line 77 of file SimEngine.cpp.

References se_core::CompSchema::activeRoot(), se_core::InitListeners::castCleanupLevelEvent(), se_core::SimListeners::castRenderEvent(), se_core::InitListeners::castStartGameEvent(), se_core::InitListeners::castStopGameEvent(), se_core::SimSchema::engineListeners(), se_core::SimSchema::initListeners(), and se_core::Composite::setActive().

bool se_core::SimEngine::init  )  [static]
 

Initialise the simulation engine.

This should be called once after the application starts up.

It will cast an InitListener::initEngineEvent(), so make sure that listeners that should receive this event is registered first.

Definition at line 204 of file SimEngine.cpp.

References se_core::InitListeners::castInitEngineEvent(), se_core::InitListeners::castPriorityInitEngineEvent(), and se_core::SimSchema::initListeners().

Referenced by se_core::SimSchema::init().

void se_core::SimEngine::initGame  ) 
 

Initialise engine for a new game.

It will cast an InitListener::initGameEvent() to registered listeners.

Definition at line 224 of file SimEngine.cpp.

References se_core::CompSchema::activeRoot(), se_core::InitListeners::castInitGameEvent(), se_core::Composite::init(), se_core::SimSchema::initListeners(), and LogWarning.

bool se_core::SimEngine::isGameOver  )  [inline]
 

Returns value of game over flag.

Returns:
true, game is over, false, game is not over.

Definition at line 162 of file SimEngine.hpp.

const char* se_core::SimEngine::level  )  [inline]
 

Definition at line 62 of file SimEngine.hpp.

const char* se_core::SimEngine::nextLevel  )  [inline]
 

Definition at line 63 of file SimEngine.hpp.

void se_core::SimEngine::perform long  when  )  [protected]
 

Performs AI actions.

Algorithm as follow: move() - precalced next coor becomes present coor slide() - slide on walls for all action channels: actionQueue.performScheduledActions() - performs actions for all action channels: actionQueue.scheduleNextActions() - scripts plans next action thingFactory.performDestructions() - destroy those who died this step apply() - precalc next coor testCollisions() - test and adjust for collisions for all action channels: actionQueue.beginNextInitiative() - cleans up action queue update scriptTracker - updates script (cutscene) tracker

Parameters:
when Ajusted game clock (milliseconds) for the present step (adjusted for pauses, frame skipping, etc).

Definition at line 162 of file SimEngine.cpp.

References se_core::CompSchema::activeRoot(), se_core::InitListeners::castCleanupLevelEvent(), se_core::InitListeners::castInitLevelEvent(), se_core::SimSchema::initListeners(), LogWarning, se_core::SpawnManager::performDestructions(), se_core::Composite::setActive(), se_core::SimSchema::spawnManager(), and se_core::SpawnManager::step().

void se_core::SimEngine::resetAll  ) 
 

Reset the engine.

After this, everything has to be loaded again.

Definition at line 268 of file SimEngine.cpp.

References se_core::SpawnManager::reset(), se_core::SpawnManager::resetAll(), and se_core::SimSchema::spawnManager().

void se_core::SimEngine::resetTimer  )  [inline]
 

Reset step counter.

Definition at line 125 of file SimEngine.hpp.

void se_core::SimEngine::setGameOver bool  state  ) 
 

Set the game over flag.

Parameters:
state true, game is over, false, game is not over.

Definition at line 239 of file SimEngine.cpp.

References LogDetail.

void se_core::SimEngine::setLevel const char *  name  ) 
 

Definition at line 71 of file SimEngine.cpp.

void se_core::SimEngine::setMultiplePerformsPerStepEnabled bool  state  ) 
 

Set or reset the multiple perform() flag.

If true, the step() method will perform AI logic more than once if the AI has lagged behind the game clock. This means that movement will be smooth, but that screen updates may be skipped.

If false, the AI will just skip the AI performs it is lagged behind ignoring the fact that it has lagged behind. This may make game movements jerky, but will make it easier to have a consistent number of screen updates per AI perform().

Parameters:
state New state

Definition at line 65 of file SimEngine.cpp.

bool se_core::SimEngine::step long  when  ) 
 

Performs simulation step and calls listeners.

Call this method as often as possible within the game loop. Performs all AI actions. Also casts events that lower layers may hook on to to process stuff before the AI processing starts, or after the AI has caught up and become up to date.

Parameters:
when The present clock (milliseconds)

Definition at line 106 of file SimEngine.cpp.

References se_core::SimListeners::castPostSimTickEvent(), se_core::SimListeners::castPreSimTickEvent(), and se_core::SimSchema::engineListeners().

long se_core::SimEngine::when  )  [inline]
 

Get the adjusted game clock.

The adjusted game clock for the presently perform()ing or last peform()ed AI step.

Returns:
Adjusted game clock (milliseconds)

Definition at line 153 of file SimEngine.hpp.


The documentation for this class was generated from the following files:

Home Page | SagaEngine trunk (updated nightly) reference generated Sun Dec 2 20:06:28 2007 by Doxygen version 1.3.9.1.

SourceForge.net Logo