Engine¶
Inherited: None
Description¶
The Engine class is one of the central parts of the Thunder Engine. This class is created first and removed last in your game. It is responsible for many basic functions, such as game cycle, management of game modules, loading and unloading of game resources, work with game settings.
Public Methods¶
Static Methods¶
void |
addModule (Module * module) |
Actor * |
composeActor (const TString & component, const TString & name, Object * parent = nullptr) |
bool |
init () |
bool |
isGameMode () |
bool |
isResourceExist (const TString & path) |
Resource * |
loadResource (const TString & path) |
Resource * |
loadResourceAsync (const TString & path) |
Scene * |
loadScene (const TString & path, bool additive) |
bool |
loadTranslator (const TString & name) |
reference (Object * object) |
|
bool |
reloadBundle () |
void |
reloadResource (const TString & path) |
RenderSystem * |
renderSystem () |
ResourceSystem * |
|
void |
setApplicationName (const TString & name) |
void |
setApplicationVersion (const TString & version) |
void |
setGameMode (bool flag) |
void |
setOrganizationName (const TString & name) |
bool |
setPlatformAdaptor (PlatformAdaptor * platform) |
void |
setValue (const TString & key, const Variant & value) |
bool |
start () |
void |
syncValues () |
translate (const TString & source) |
|
void |
|
void |
unloadResource (Resource * resource) |
void |
unloadResource (const TString & path) |
void |
unloadScene (Scene * scene) |
void |
update () |
value (const TString & key, const Variant & defaultValue = Variant()) |
|
World * |
world () |
Methods Description¶
Engine::Engine ()
Constructs Engine.
Engine::~Engine ()
Destructs Engine, related objects, registered object factories and platform adaptor.
void Engine::addModule (Module * module)
Adds a game module to pool. This module will be used during update() method execution.
Example:
if(engine->init()) {
Engine::addModule(new RenderGL(engine));
engine->start();
}
TString Engine::applicationName ()
Returns the name of this application. This name is used to create the path to the settings and logs for this application.
See also setApplicationName().
TString Engine::applicationVersion ()
Returns the version of this application.
See also setApplicationVersion().
Creates an Actor with name and attached component. Created Actor will be added to the hierarchy of parent. This method helps to create all dependencies for the component.
Warning: This method should be used only in Editor mode.
bool Engine::init ()
Initializes all engine systems. Returns true if successful; otherwise returns false.
bool Engine::isGameMode ()
Returns true if game started; otherwise returns false.
bool Engine::isResourceExist (TString & path)
Returns true if resource with path exists; otherwise returns false.
Returns an instance for loading resource by the provided path.
Note: In case of resource was loaded previously this function will return the same instance.
See also unloadResource().
Returns an instance for loading resource by the provided path. The resource will be loaded asynchronously. This means you should check the state of resource before use it.
Note: In case of resource was loaded previously this function will return the same instance.
See also unloadResource().
Loads the scene stored in the .map files by the it’s path to the Engine.
Note: The previous scenes will be not unloaded in the case of an additive flag is true.
bool Engine::loadTranslator (TString & name)
Loads translation table with provided file name. This method generates the LanguageChange event for the Engine instance. An Engine instance will propagate the event to all top-level widgets, where reimplementation of event() can re-translate user-visible Strings. Returns true on success; otherwise returns false.
TString Engine::locationAppConfig ()
Returns path to application config directory.
TString Engine::organizationName ()
Returns the name of the organization that wrote this application. This name is used to create the path to the settings and logs for this application.
See also setOrganizationName().
Returns resource path for the provided resource object.
bool Engine::reloadBundle ()
This method reads the index file for the resource bundle. The index file helps to find required game resources. Returns true in case of success; otherwise returns false.
void Engine::reloadResource (TString & path)
Reloads the resource located along the path.
See also loadResource().
RenderSystem * Engine::renderSystem ()
Returns the render system which can be used in external modules.
ResourceSystem * Engine::resourceSystem ()
Returns the resource management system which can be used in external modules.
void Engine::setApplicationName (TString & name)
Sets the name of this application.
See also applicationName().
void Engine::setApplicationVersion (TString & version)
Sets the version of this application.
See also applicationVersion().
void Engine::setGameMode (bool flag)
Set game flag to true if game started; otherwise set false.
See also isGameMode().
void Engine::setOrganizationName (TString & name)
Sets the name of the organization that wrote this application.
See also organizationName().
bool Engine::setPlatformAdaptor (PlatformAdaptor * platform)
Replaces a current platform adaptor with new one; Returns true if replacement been succeeded; otherwise returns false.
Note: The previous platform adaptor will not be deleted.
Sets the value of setting key to value. If the key already exists, the previous value will be overwritten.
See also value().
bool Engine::start ()
Starts the main game cycle. Also this method loads the first level of your game. Returns true if successful; otherwise returns false.
void Engine::syncValues ()
Applies all unsaved settings.
Returns the translation text for the source String.
void Engine::unloadAllScenes ()
Unloads all scenes from the World.
void Engine::unloadResource (Resource * resource)
Forcely unloads the resource from memory.
Warning: After this call, the reference on the resource may become an invalid at any time and must not be used anymore.
See also loadResource().
void Engine::unloadResource (TString & path)
Forcely unloads the resource located along the path from memory.
Warning: After this call, the reference on the resource may become an invalid at any time and must not be used anymore.
See also loadResource().
void Engine::unloadScene (Scene * scene)
Unloads the scene from the World.
void Engine::update ()
This method launches all your game modules responsible for processing all the game logic. It calls on each iteration of the game cycle.
Note: Usually, this method calls internally and must not be called manually.
Returns the value for setting key. If the setting doesn’t exist, returns defaultValue.
See also setValue().
World * Engine::world ()
Returns game World.
Note: The game can have only one scene graph. World is a root object, all map loads on this World.