|
Thrive
|
The heart of the game. More...
#include <engine.h>
Classes | |
| struct | Implementation |
Public Member Functions | |
| Engine () | |
| Constructor. | |
| Engine (const Engine &other)=delete | |
| Non-copyable. | |
| ~Engine () | |
| Destructor. | |
| ComponentFactory & | componentFactory () |
| Returns the internal component factory. More... | |
| GameState * | createGameState (std::string name, std::vector< std::unique_ptr< System >> systems, GameState::Initializer initializer, std::string guiLayoutName) |
| Creates a new game state. More... | |
| GameState * | currentGameState () const |
| Returns the currently active game state. More... | |
| PlayerData & | playerData () |
| Object holding generic player data. | |
| RNG & | rng () |
| The engine's RNG. | |
| GameState * | getGameState (const std::string &name) const |
| Retrieves a game state. More... | |
| void | init () |
| Initializes the engine. More... | |
| OIS::InputManager * | inputManager () const |
| The engine's input manager. | |
| const Keyboard & | keyboard () const |
| Returns the keyboard interface. | |
| void | load (std::string filename) |
| Loads a savegame. More... | |
| bool | fileExists (std::string filePath) |
| checks if a file exists More... | |
| lua_State * | luaState () |
| The script engine's Lua state. | |
| const Mouse & | mouse () const |
| Returns the mouse interface. | |
| Ogre::Root * | ogreRoot () const |
| The Ogre root object. | |
| void | save (std::string filename) |
| Creates a savegame. More... | |
| void | saveCreation (EntityId entityId, const EntityManager &entityManager, std::string name, std::string type) const |
| Saves a creation to file. More... | |
| void | saveCreation (EntityId entityId, std::string name, std::string type) const |
| Overload of above. | |
| EntityId | loadCreation (std::string file, EntityManager &entityManager) |
| Loads a creation from file. More... | |
| EntityId | loadCreation (std::string file) |
| Overload of above. | |
| void | screenShot (std::string path) |
| Takes a screenshot. More... | |
| std::string | getCreationFileList (std::string stage) const |
| Obtains a list of filenames for saved creations that match the provided type. More... | |
| void | setCurrentGameState (GameState *gameState) |
| Sets the current game state. More... | |
| void | shutdown () |
| Shuts the engine down. More... | |
| void | quit () |
| Request the game to close. | |
| void | pauseGame () |
| Pauses system updates of the game. | |
| void | resumeGame () |
| Resumes system updates of the game. | |
| SoundManager * | soundManager () const |
| void | update (int milliseconds) |
| Renders a single frame. More... | |
| int | getResolutionWidth () const |
| Returns the width of the games window. More... | |
| int | getResolutionHeight () const |
| Returns the width of the games window. More... | |
| void | timedSystemShutdown (System &system, int milliseconds) |
| Keeps a system alive after being shut down for a specified amount of time. More... | |
| bool | isSystemTimedShutdown (System &system) const |
| Returns whether the specified system has already been set for a timed shutdown. More... | |
| EntityId | transferEntityGameState (EntityId oldEntityId, EntityManager *oldEntityManager, GameState *newGameState) |
| Transfers an entity from one gamestate to another. More... | |
| Ogre::RenderWindow * | renderWindow () const |
| The render window. | |
| void | registerConsoleObject (luabind::object consoleObject) |
| Registers the console object. | |
| const std::string & | thriveVersion () const |
| Gets the current version of thrive as a string. More... | |
Static Public Member Functions | |
| static luabind::scope | luaBindings () |
| Lua bindings. More... | |
The heart of the game.
The engine keeps an ordered list of System objects and updates them each frame. It handles initialization and shutdown of graphics, physics, scripts and more.
| ComponentFactory & Engine::componentFactory | ( | ) |
Returns the internal component factory.
| GameState * Engine::createGameState | ( | std::string | name, |
| std::vector< std::unique_ptr< System >> | systems, | ||
| GameState::Initializer | initializer, | ||
| std::string | guiLayoutName | ||
| ) |
Creates a new game state.
| name | The game state's name |
| systems | The systems active in the game state |
| initializer | The initialization function for the game state |
null. It is returned as a pointer as a convenience for Lua bindings, which don't handle references well. | GameState * Engine::currentGameState | ( | ) | const |
Returns the currently active game state.
If no game state has been set yet, returns nullptr
| bool Engine::fileExists | ( | std::string | filePath | ) |
checks if a file exists
| filename | The file to check for |
| std::string Engine::getCreationFileList | ( | std::string | stage | ) | const |
Obtains a list of filenames for saved creations that match the provided type.
| stage | The game stage to filter creations on |
| GameState * Engine::getGameState | ( | const std::string & | name | ) | const |
Retrieves a game state.
| name | The game state's name |
nullptr if no game state with this name exists. | int Engine::getResolutionHeight | ( | ) | const |
Returns the width of the games window.
| int Engine::getResolutionWidth | ( | ) | const |
Returns the width of the games window.
| void Engine::init | ( | ) |
Initializes the engine.
This sets up basic data structures for the different engine parts (input, graphics, physics, etc.) and then calls System::init() on all systems.
| bool Engine::isSystemTimedShutdown | ( | System & | system | ) | const |
Returns whether the specified system has already been set for a timed shutdown.
| system | The system to check for |
| void Engine::load | ( | std::string | filename | ) |
Loads a savegame.
| filename | The file to load |
| EntityId Engine::loadCreation | ( | std::string | file, |
| EntityManager & | entityManager | ||
| ) |
Loads a creation from file.
| file | The file to load from |
| entityManager | The entity manager that will manage the loaded entity |
|
static |
Lua bindings.
Exposes:
| void Engine::save | ( | std::string | filename | ) |
Creates a savegame.
| filename | The file to save |
| void Engine::saveCreation | ( | EntityId | entityId, |
| const EntityManager & | entityManager, | ||
| std::string | name, | ||
| std::string | type | ||
| ) | const |
Saves a creation to file.
| entityId | The entity which represents the creation to save |
| entityManager | The entity manager that manages the entity |
| name | The name of the file |
| type | The type of creation. This also becomes the file extension. |
| void Engine::screenShot | ( | std::string | path | ) |
Takes a screenshot.
| path | The path and filename relative to exe |
| void Engine::setCurrentGameState | ( | GameState * | gameState | ) |
Sets the current game state.
The game state will be activated at the beginning of the next frame.
gameState must not be null. It's passed by pointer as a convenience for the Lua bindings (which can't handle references well).
| gameState | The new game state |
| void Engine::shutdown | ( | ) |
Shuts the engine down.
This calls System::shutdown() on all systems and then destroys the data structures created in Engine::init().
| const std::string & Engine::thriveVersion | ( | ) | const |
Gets the current version of thrive as a string.
The version is loaded from thriveversion.ver file. It returns as "unknown" if that file was not found
| void Engine::timedSystemShutdown | ( | System & | system, |
| int | milliseconds | ||
| ) |
Keeps a system alive after being shut down for a specified amount of time.
Note that this causes update to be called for the specified duration so be careful to ensure that the system is not enabled or it will get update calls twice.
| system | The system to keep updated |
| milliseconds | The number of milliseconds to keep the system updated for |
| EntityId Engine::transferEntityGameState | ( | EntityId | oldEntityId, |
| EntityManager * | oldEntityManager, | ||
| GameState * | newGameState | ||
| ) |
Transfers an entity from one gamestate to another.
| oldEntityId | The id of the entity to transfer in the old entitymanager |
| oldEntityManager | The old entitymanager which is currently handling the entity |
| newGameState | The new gamestate to transfer the entity to |
| void Engine::update | ( | int | milliseconds | ) |
Renders a single frame.
Before calling update() the first time, you need to call Engine::init().
| milliseconds | The number of milliseconds to advance. For real-time, this is the number of milliseconds since the last frame. |
1.8.10