Nymph Game Engine
Chaiscript based Game Engine
|
Class for script object. More...
#include <script_object.h>
Public Member Functions | |
ScriptObject (const std::string &name) | |
ScriptObject constructor. More... | |
ScriptObject (const ScriptObject &other) | |
Copy constructor for ScriptObject. More... | |
~ScriptObject ()=default | |
Destroys the object. More... | |
void | setClassName (const std::string &name) |
Sets the class name on the scripting object. More... | |
std::string | getClassName () const noexcept |
void | onStart () |
Calls onStart in the attached script object. More... | |
void | onUpdate (const float delta) |
Calls onUpdate in the attached script object. More... | |
void | onDestroy () |
Calls onDestroy in the attached script object. More... | |
bool | shouldBeSerialized () const noexcept |
Json::Value | getSaveData () const noexcept |
void | loadSavedData (Json::Value &save_data) |
bool | representsDynamicObject (const chaiscript::dispatch::Dynamic_Object &obj) const noexcept |
virtual void | onNotifyNow (std::shared_ptr< Events::Event > event) override |
When receiving an event that is immediate, onNotifyNow is used. It acts as an interrupt to make sure the object is notified before another engine loop. This is pure virtual and is implemented on a case by case basis in derived classes. More... | |
virtual void | handleQueuedEvent (std::shared_ptr< Events::Event > event) override |
HandleQueuedEvent allows derived classes to define behaviour for when queuedEvents are received. More... | |
Public Member Functions inherited from Events::Subject | |
virtual | ~Subject ()=default |
virtual void | notify (std::shared_ptr< Event > event) |
notify is used to tell observers of an event. More... | |
virtual void | notifyNow (std::shared_ptr< Event > event) |
notifyNow is used to tell observers of an event as an interrupt. More... | |
virtual void | addObserver (std::shared_ptr< Observer > observer) |
Adds an observer. More... | |
virtual void | removeObserver (std::shared_ptr< Observer > observer) |
Removes an observer. More... | |
Public Member Functions inherited from Events::Observer | |
virtual | ~Observer () |
void | onNotify (std::shared_ptr< Event > event) |
When receiving an event that is non-immediate, onNotify is used. The event is added to the event queue that is processed when processEventQueue is called. More... | |
void | processEventQueue () |
This should be called once ever loop for every Observer to properly use queued events. More... | |
Friends | |
class | ScriptingSystem |
Additional Inherited Members | |
Protected Member Functions inherited from Events::Observer | |
std::shared_ptr< Event > | getEvent () |
bool | eventsWaiting () const noexcept |
Class for script object.
Script::ScriptObject::ScriptObject | ( | const std::string & | name | ) |
ScriptObject constructor.
[in] | name | The name |
Script::ScriptObject::ScriptObject | ( | const ScriptObject & | other | ) |
Copy constructor for ScriptObject.
[in] | other | The other |
|
default |
Destroys the object.
|
noexcept |
Referenced by generated::getScriptObjectModule().
|
noexcept |
|
overridevirtual |
HandleQueuedEvent allows derived classes to define behaviour for when queuedEvents are received.
[in] | event | The event |
Implements Events::Observer.
References Events::ANIMATION_TRIGGER, Events::CHANGE_TEXT, Events::CHARACTER_TYPED, Events::CURSOR_ENTER, Events::CURSOR_LEAVE, Events::DEBUG_COMMAND, Events::KEY_DOWN, Events::KEY_REPEAT, Events::KEY_UP, Events::LIST_CHARACTERS, Events::LIST_LAYERS, Events::LIST_MAPS, Events::LOAD_CHARACTER, Events::LOAD_MAP, Events::MOUSE_BUTTON_DOWN, Events::MOUSE_BUTTON_UP, Events::MOUSE_CURSOR, Events::MOUSE_SCROLL, Events::RESUME_KEY_INPUT, Events::SET_ACTIVE, Events::SET_ENTITY_ACTIVE, Events::SET_UNIFORM, Events::SPRITE_MOVE, Events::SUSPEND_KEY_INPUT, Events::TOGGLE_FREE_CAMERA, Events::TOGGLE_LAYER, Events::TOGGLE_LIGHTS, and Events::WINDOW_EXIT.
Referenced by onNotifyNow().
void Script::ScriptObject::loadSavedData | ( | Json::Value & | save_data | ) |
void Script::ScriptObject::onDestroy | ( | ) |
Calls onDestroy in the attached script object.
|
overridevirtual |
When receiving an event that is immediate, onNotifyNow is used. It acts as an interrupt to make sure the object is notified before another engine loop. This is pure virtual and is implemented on a case by case basis in derived classes.
[in] | event | The event |
Implements Events::Observer.
References handleQueuedEvent().
void Script::ScriptObject::onStart | ( | ) |
Calls onStart in the attached script object.
void Script::ScriptObject::onUpdate | ( | const float | delta | ) |
Calls onUpdate in the attached script object.
[in] | delta | The delta |
References Events::Observer::processEventQueue().
|
noexcept |
void Script::ScriptObject::setClassName | ( | const std::string & | name | ) |
Sets the class name on the scripting object.
[in] | name | The name |
Referenced by generated::getScriptObjectModule().
|
noexcept |
|
friend |