![]() |
V-Gears 0
Free Final Fantasy VII engine.
|
#include <ScriptManager.h>
Public Types | |
enum | Type { SYSTEM , ENTITY , UI , BATTLE } |
Script types. More... | |
![]() | |
enum | Module { FIELD = 0 , BATTLE = 1 , WORLD = 2 } |
The modules the entity manager can handle. More... | |
Public Member Functions | |
ScriptManager () | |
Constructor. More... | |
virtual | ~ScriptManager () |
Destructor. More... | |
void | Input (const VGears::Event &event) override |
Handles an input event. More... | |
void | Update (const Type type) |
Updates the state of all scripts of a given type. More... | |
void | UpdateDebug () override |
Updates the script in the manager with debug information. More... | |
void | OnResize () override |
Handles resizing events. More... | |
void | ClearField () override |
Clears all field information in the script manager. More... | |
void | ClearBattle () override |
Clears all battle information in the script manager. More... | |
void | ClearWorld () override |
Clears all world map information in the script manager. More... | |
void | RunString (const Ogre::String &lua) |
Runs a lua command string. More... | |
void | RunFile (const Ogre::String &file) |
Runs a lua file. More... | |
void | InitBinds () |
Initializes Lua binds. More... | |
void | InitCmd () |
Initializes command bindings. More... | |
void | AddEntity (const Type type, const Ogre::String &entity_name, Entity *entity) |
Adds an entity to the manager. More... | |
void | RemoveEntity (const Type type, const Ogre::String &entity_name) |
Deletes an entity from the manager. More... | |
void | AddEntityScript (const Ogre::String &entity_name, const Ogre::String &function_name, int priority) |
Adds an script to an entity. More... | |
void | RemoveEntityTopScript (ScriptEntity &entity) |
Removes the top script of an entity. More... | |
luabind::object | GetTableByEntityName (const ScriptManager::Type type, const Ogre::String &name, lua_State *state) const |
Retrieves a table. More... | |
QueueScript * | GetScriptByScriptId (const ScriptId &script) const |
Retrieves a script from it's ID. More... | |
ScriptEntity * | GetScriptEntityByName (const Type type, const Ogre::String &entity_name) const |
Retrieves a script entity by it's name and type. More... | |
const ScriptId | GetCurrentScriptId () const |
Retrieves the current script ID. More... | |
void | ContinueScriptExecution (const ScriptId &script) |
continues the execution of a script. More... | |
int | ScriptWait (const float seconds) |
Makes an script wait. More... | |
void | ScriptRequest (const Type type, const char *entity, const char *function, const int priority) |
Request an script execution. More... | |
int | ScriptRequestStartSync (const Type type, const char *entity, const char *function, const int priority) |
Request a synchronous script execution to start. More... | |
int | ScriptRequestEndSync (const Type type, const char *entity, const char *function, const int priority) |
Request a synchronous script execution to end. More... | |
bool | ScriptRequest (ScriptEntity *script_entity, const Ogre::String &function, const int priority, const Ogre::String &argument1, const Ogre::String &argument2, bool start_sync, bool end_sync) |
Request a script execution. More... | |
void | AddValueToStack (const float value) |
Adds a script to the stack. More... | |
![]() | |
Manager () | |
Constructor. More... | |
virtual | ~Manager () |
Destructor. More... | |
Module | GetModule () const |
Retrieves the currently selected module. More... | |
bool | IsModule (const Module module) const |
Checks the currently selected module. More... | |
bool | IsFieldModule () const |
Checks if the currently selected module is the field module. More... | |
bool | IsBattleModule () const |
Checks if the currently selected module is the battle module. More... | |
bool | IsWorldModule () const |
Checks if the currently selected module is the world module. More... | |
void | SetModule (const Module module) |
Sets the current module for the entity manager. More... | |
void | SetFieldModule () |
Sets the current module to the field mode. More... | |
void | SetBattleModule () |
Sets the current module to the battle mode. More... | |
void | SetWorldModule () |
Sets the current module to the world map mode. More... | |
void | SetPreviousModule () |
Sets the module that was loaded before a battle. More... | |
virtual void | Input (const VGears::Event &event)=0 |
Handles an input event. More... | |
void | Update () |
Called every frame, performs an update on the things controlled by the manager. More... | |
virtual void | UpdateDebug ()=0 |
Called every frame, performs an update on the things controlled by the manager. More... | |
virtual void | OnResize ()=0 |
Handles resizing events. More... | |
void | Clear () |
Clears the manager. More... | |
void | Clear (const Module module) |
Clears the manager. More... | |
virtual void | ClearField ()=0 |
Clear all field information in the manager. More... | |
virtual void | ClearBattle ()=0 |
Clear all battle information in the manager. More... | |
virtual void | ClearWorld ()=0 |
Clear all world map information in the manager. More... | |
void | ClearAll () |
Clears the manager. More... | |
void | ScriptSetPaused (const bool paused) |
Handles game pausing. More... | |
Private Member Functions | |
void | UpdateField () override |
Updates the script while in a field. More... | |
void | UpdateBattle () override |
Updates the scripts during a battle. More... | |
void | UpdateWorld () override |
Updates the scripts while on the world map. More... | |
Private Attributes | |
lua_State * | lua_state_ |
Lua state. More... | |
Ogre::String | system_table_name_ |
The system script table name. More... | |
Ogre::String | entity_table_name_ |
The entity script table name. More... | |
Ogre::String | battle_table_name_ |
The battle entity script table name. More... | |
Ogre::String | ui_table_name_ |
The UI script table name. More... | |
std::vector< ScriptEntity > | script_entity_ |
The list of map entity scripts. More... | |
ScriptId | current_script_id_ |
The current script ID. More... | |
Additional Inherited Members | |
![]() | |
virtual void | UpdateField ()=0 |
Updates the field entities in the manager. More... | |
virtual void | UpdateBattle ()=0 |
Updates the battle entities in the manager. More... | |
virtual void | UpdateWorld ()=0 |
Updates the world map entities in the manager. More... | |
void | Update (Module module) |
Updates the entities of one module in the manager. More... | |
![]() | |
Module | module_ |
The currently selected module. More... | |
Module | prev_module_ |
The previous module. More... | |
bool | paused_ |
Indicates if the game is paused. More... | |
enum ScriptManager::Type |
Script types.
ScriptManager::ScriptManager | ( | ) |
Constructor.
|
virtual |
Destructor.
void ScriptManager::AddEntity | ( | const Type | type, |
const Ogre::String & | entity_name, | ||
Entity * | entity | ||
) |
Adds an entity to the manager.
Usage depends on the currently active module. The entity will be added to the list of entities of the module.
[in] | type | Type of entity to add. |
[in] | entity_name | The entity name. |
[in] | entity | The entity to add. |
void ScriptManager::AddEntityScript | ( | const Ogre::String & | entity_name, |
const Ogre::String & | function_name, | ||
int | priority | ||
) |
Adds an script to an entity.
Usage depends on the currently active module. The script will be added to the list of scripts of the module.
[in] | entity_name | Name of the entity to add a script to. |
[in] | function_name | Name of the script to add. |
[in] | priority | Script priority. Lower numbers have higher priority. |
void ScriptManager::AddValueToStack | ( | const float | value | ) |
Adds a script to the stack.
[in] | value | ID of the script to add. |
|
overridevirtual |
Clears all battle information in the script manager.
Implements Manager.
|
overridevirtual |
Clears all field information in the script manager.
Implements Manager.
|
overridevirtual |
Clears all world map information in the script manager.
Implements Manager.
void ScriptManager::ContinueScriptExecution | ( | const ScriptId & | script | ) |
continues the execution of a script.
[in] | script | The ID of the script to resume. |
const ScriptId ScriptManager::GetCurrentScriptId | ( | ) | const |
Retrieves the current script ID.
QueueScript * ScriptManager::GetScriptByScriptId | ( | const ScriptId & | script | ) | const |
Retrieves a script from it's ID.
[in] | script | Script ID. |
ScriptEntity * ScriptManager::GetScriptEntityByName | ( | const Type | type, |
const Ogre::String & | entity_name | ||
) | const |
Retrieves a script entity by it's name and type.
Usage depends on the currently active module. The entity will be searched among the entities of the currently active module.
[in] | type | Entity type. |
[in] | entity_name | The entity name. |
luabind::object ScriptManager::GetTableByEntityName | ( | const ScriptManager::Type | type, |
const Ogre::String & | name, | ||
lua_State * | state | ||
) | const |
Retrieves a table.
The retrieved table depends on the currently active module.
[in] | type | Type of script. |
[in] | name | Script name. |
[in] | state | Initial script state. |
void ScriptManager::InitBinds | ( | ) |
Initializes Lua binds.
It relates the command available in the field maps to C++ functions.
void ScriptManager::InitCmd | ( | ) |
Initializes command bindings.
|
overridevirtual |
|
overridevirtual |
Handles resizing events.
Implements Manager.
void ScriptManager::RemoveEntity | ( | const Type | type, |
const Ogre::String & | entity_name | ||
) |
Deletes an entity from the manager.
Usage depends on the currently active module. The entity will be removed from the list of entities of the module. If there is no entity with name ENTITY_NAME and type TYPE, nothing will be done.
[in] | type | Type of the entity to remove. |
[in] | entity_name | Name of the entity to remove. |
void ScriptManager::RemoveEntityTopScript | ( | ScriptEntity & | entity | ) |
Removes the top script of an entity.
The entity must be in one of the currently active modules for it's script to be removed.
[in] | entity | Entity whose first script to remove. |
void ScriptManager::RunFile | ( | const Ogre::String & | file | ) |
Runs a lua file.
No errors are handled, and nothing is returned
[in] | file | Path to the lua file to run (relative to the data directory). |
void ScriptManager::RunString | ( | const Ogre::String & | lua | ) |
Runs a lua command string.
No errors are handled, and nothing is returned
[in] | lua | Lua string to run. |
void ScriptManager::ScriptRequest | ( | const Type | type, |
const char * | entity, | ||
const char * | function, | ||
const int | priority | ||
) |
Request an script execution.
The script will execute only if it's not already being executed.
[in] | type | Script type. |
[in] | entity | Entity the scripts belong to. |
[in] | function | Name of the function of the selected entity to execute. |
[in] | priority | Execution priority. |
bool ScriptManager::ScriptRequest | ( | ScriptEntity * | script_entity, |
const Ogre::String & | function, | ||
const int | priority, | ||
const Ogre::String & | argument1, | ||
const Ogre::String & | argument2, | ||
bool | start_sync, | ||
bool | end_sync | ||
) |
Request a script execution.
[in] | script_entity | Entity the scripts belong to. |
[in] | function | Name of the function of the selected entity to execute. |
[in] | priority | Execution priority. |
[in] | argument1 | First argument for the script. |
[in] | argument2 | Second argument for the script. |
[in] | start_sync | If true, the script will be started synchronously. |
[in] | end_sync |
int ScriptManager::ScriptRequestEndSync | ( | const Type | type, |
const char * | entity, | ||
const char * | function, | ||
const int | priority | ||
) |
Request a synchronous script execution to end.
[in] | type | Script type. |
[in] | entity | Entity the scripts belong to. |
[in] | function | Name of the function of the selected entity to execute. |
[in] | priority | Execution priority. |
int ScriptManager::ScriptRequestStartSync | ( | const Type | type, |
const char * | entity, | ||
const char * | function, | ||
const int | priority | ||
) |
Request a synchronous script execution to start.
[in] | type | Script type. |
[in] | entity | Entity the scripts belong to. |
[in] | function | Name of the function of the selected entity to execute. |
[in] | priority | Execution priority. |
int ScriptManager::ScriptWait | ( | const float | seconds | ) |
Makes an script wait.
[in] | seconds | Number of seconds to wait. |
void ScriptManager::Update | ( | const Type | type | ) |
Updates the state of all scripts of a given type.
[in] | type | Type of the scripts to update. |
|
overrideprivatevirtual |
Updates the scripts during a battle.
Implements Manager.
|
overridevirtual |
Updates the script in the manager with debug information.
Implements Manager.
|
overrideprivatevirtual |
Updates the script while in a field.
Implements Manager.
|
overrideprivatevirtual |
Updates the scripts while on the world map.
Implements Manager.
|
private |
The battle entity script table name.
|
private |
The current script ID.
|
private |
The entity script table name.
|
private |
Lua state.
|
private |
The list of map entity scripts.
|
private |
The system script table name.
|
private |
The UI script table name.