|
Brunot
|
#include <Script.h>
Public Member Functions | |
| Script (const std::filesystem::path &path) | |
| Script () | |
| Constructs a NULL script, which represents a script that does not exist Once constructed as a NULL script, scripts cannot be turned into a real script. | |
| Script (const Script &other) | |
| Script (Script &&other) noexcept | |
| auto | operator= (const Script &other) -> Script & |
| auto | operator= (Script &&other) noexcept -> Script & |
| operator bool () const | |
| auto | showMenu () -> void override |
| Called before update each frame, for calling ImGui editor code relevant to the gameObject. | |
| auto | clone () const -> std::unique_ptr< GameObject > override |
| makes a copy a GameObject even if it's held polymorphically | |
| auto | endWindow () -> void override |
| currently unused, but intended to but was assumed to be necessary for a proper ImGui editor | |
| auto | onEnterEngine () -> void override |
| hook that is called when a GameObject enters the Engine tree. | |
| auto | onSceneStart (const std::string &sceneName) -> void override |
| Hook that is called before the first frame a scene is run, but after the entire scene is loaded into the engine To receive the hook, simply override the function in your class. | |
| auto | onSceneExit (const std::string &sceneName) -> void override |
| Hook that is called right before a scene is unloaded To receive the hook, simply override the function in your class. | |
| auto | load (const Stream &stream) -> void override |
| Implementations will load the state of a GameObject from a th::Json Object. | |
| auto | save (Stream &stream) const -> void override |
| Implementations will load the state of a GameObject to a th::Json object. | |
| auto | parentTo (GameObject *newParent) -> bool override |
| override of parentTo because a ScriptHolder parent is the Entity above it, not the ScriptHolder component | |
| template<typename... Args> | |
| auto | callIfFunction (const std::string &functionName, Args &&... args) -> sol::optional< sol::protected_function_result > |
| checks if a member function of the script exists, and then calls it if it does, otherwise returns an empty optional | |
| template<typename... Args> | |
| auto | callFunction (const std::string &functionName, Args &&... args) -> sol::protected_function_result |
| calls a lua function that is a member of the Script | |
| __forceinline auto | getVariable (const std::string &name) -> sol::table_proxy< sol::basic_table_core< false, sol::basic_reference<> > &, std::tuple< const char(&)[5], const std::string & > > |
| Gets a reference to public variable from the script. | |
| __forceinline auto | operator[] (const std::string &name) -> sol::table_proxy< sol::basic_table_core< false, sol::basic_reference<> > &, std::tuple< const char(&)[5], const std::string & > > |
| Gets a reference to public variable from the script. | |
| auto | loadDataFromJson (const nlohmann::json &j) -> void |
| helper to de-serialize a json into a script | |
| auto | getDataAsJson () const -> nlohmann::json |
| helper to serialize a script into a json | |
| auto | reloadScript () -> void |
| loads a script from the file it is constructed from | |
| Public Member Functions inherited from GameObject | |
| GameObject (std::string typeName, gobj::Type parentType, gobj::Type type) | |
| constructor for gameobject. | |
| virtual | ~GameObject () |
| destructor for GameObject. | |
| GameObject (const GameObject &other) | |
| Copy Constructor. | |
| auto | operator= (const GameObject &other) -> GameObject & |
| copy assignment operator | |
| GameObject (GameObject &&other) noexcept | |
| Move constructor. | |
| auto | operator= (GameObject &&other) noexcept -> GameObject & |
| Move assignment operator. | |
| virtual auto | update (float dt) -> void |
| called once every frame. | |
| virtual auto | render () -> void |
| called every frame after update has been called for every object. | |
| virtual auto | destroy () -> void |
| Marks an GameObject to be destroyed. | |
| virtual auto | for_each (std::function< void(GameObject &)> func) -> void |
| applies a function to every child. | |
| virtual auto | for_each (std::function< void(const GameObject &)> func) const -> void |
| applies a const function to every child. | |
| virtual auto | getParent () const -> GameObject * |
| Gets the parent of a GameObject. | |
| auto | getInternalParent () const -> GameObject * |
| returns the actual owning parent of the GameObject | |
| virtual auto | addChild (std::unique_ptr< GameObject > newChild) -> bool |
| Adds a child to a GameObject. | |
| auto | addChildLua (std::unique_ptr< GameObject > &newChild) -> bool |
| for lua | |
| virtual auto | getKey () const -> Key |
| Generates a unique Key that corresponds to the GameObject. | |
| auto | destroyed () const -> bool |
| auto | getUUID () const -> gobj::UUID |
| auto | coolerGetUUID () const -> unsigned int |
| auto | isUUID (gobj::UUID compareUUID) const -> bool |
| auto | getName () const -> const std::string & |
| Gets the type of the object as a string. | |
| auto | getNickname () const -> const std::string & |
| Gets the nickname (custom, writable name) of a GameObject. | |
| auto | getFormattedName () const -> const std::string & |
| combines a GameObjects Type, Nickname, and UUID into one string, for use with logging. | |
| auto | nameEquals (const std::string &compareString) const -> bool |
| check whether a GameObjects typeName is equivilent to a given string. | |
| auto | isType (gobj::Type otherType) const -> bool |
| check whether the GameObject is the same as a given type. | |
| auto | getObjectType () const -> gobj::Type |
| gets the internal type of the GameObject, as an enum | |
| auto | setNickname (const std::string &newNickname) -> void |
| sets the GameObjects nickname. | |
| auto | updates () const -> bool |
| auto | renders () const -> bool |
| auto | receivesMessages () const -> bool |
| auto | isActive () const -> bool |
| virtual auto | setShouldUpdate (bool _shouldUpdate) -> void |
| set whether the GameObject should update every frame, and whether all of it's children should update every frame | |
| virtual auto | setShouldRender (bool _shouldRender) -> void |
| set whether the GameObject should render every frame, and whether all of it's children should render every frame | |
| virtual auto | setShouldReceiveMessages (bool _shouldReceiveMessages) -> void |
| set whether the GameObject should Receive Messags, and whether all of it's children should receive messages | |
| auto | setActive (bool shouldBeActive) -> void |
| set the GameObject should update, render, and receive messages | |
| auto | getGameObjectJson () const -> json |
| Used for serializing GameObjects. | |
| auto | setGameObjectJson (const json &stream) -> void |
| used for deserializing GameObjects | |
Public Attributes | |
| friend | ScriptHolder |
| std::filesystem::path | scriptPath |
| the path of the script | |
| std::string | scriptName |
| the name of the script | |
| sol::table | luaObject |
| the data for the script in lua | |
| const bool | isNull = false |
| whether the script is null (not constructed with a script path) | |
| Public Attributes inherited from GameObject | |
| friend | Entity |
| friend | Node |
| friend | Engine |
Private Member Functions | |
| auto | onUpdate (float dt) -> void override |
| called once every frame. | |
| auto | onRender () -> void override |
| called every frame after update has been called for every object. | |
| auto | updateOtherComponentBindings () -> void |
| Helper function that may be used later should link other components on the entity to the script object as table fields. | |
| auto | receiveComponentAdded (const Message *) -> Message |
| message recieving function that is currently unused, but might be used later | |
| auto | setParentInLua (GameObject *newParent) -> void |
| helper function to set a pointer to entity parent of the script in lua | |
| void | deepCopyTable (sol::table table, const sol::table &otherTable) |
Static Private Member Functions | |
| static auto | tableToJson (const sol::table &table) -> nlohmann::json |
| helper function that serializes a lua table to a json this works on: numbers (convert to double), string, bool, and table | |
| static auto | jsonToTable (const nlohmann::json &j, sol::table table) -> void |
| helper function that de-serializes a json into a lua table | |
| static auto | tableShowMenu (sol::table table) -> void |
| for all the values in a lua table, create editor fields for them in imgui | |
Additional Inherited Members | |
| Protected Member Functions inherited from GameObject | |
| auto | setInternalParent (GameObject *parent) -> bool |
| sets the internal parent of a GameObject directly, avoiding abstractions provided by ParentTo(). | |
| virtual auto | getChildren () const -> std::shared_ptr< std::vector< GameObject * > > |
| gets a vector of a GameObjects public (i.e. | |
| auto | checkAddToSceneHook () -> void |
| Determine if the GameObject was recently added to the engine, and if it was, call onEngineEnter. | |
|
explicit |
| Script::Script | ( | ) |
Constructs a NULL script, which represents a script that does not exist Once constructed as a NULL script, scripts cannot be turned into a real script.
| Script::Script | ( | const Script & | other | ) |
|
noexcept |
|
inline |
calls a lua function that is a member of the Script
| Args | Arguments for lua function |
| functionName | name of lua function |
| args | Arguments for lua function |
|
inline |
checks if a member function of the script exists, and then calls it if it does, otherwise returns an empty optional
| Args | args to be passed into the lua function |
| functionName | the name of the function to call |
| args | args to be passed into the lua function |
|
overridevirtual |
makes a copy a GameObject even if it's held polymorphically
Implements GameObject.
|
private |
|
overridevirtual |
currently unused, but intended to but was assumed to be necessary for a proper ImGui editor
Implements GameObject.
| auto Script::getDataAsJson | ( | ) | const->nlohmann::json |
helper to serialize a script into a json
|
inline |
Gets a reference to public variable from the script.
| name | the name of the variable to get |
|
staticprivate |
helper function that de-serializes a json into a lua table
| j | json to de-serialize |
| table | the lua table to load the json into |
|
overridevirtual |
Implementations will load the state of a GameObject from a th::Json Object.
Unimplemented in GameObject
| stream | th::Json Object |
Implements GameObject.
| auto Script::loadDataFromJson | ( | const nlohmann::json & | j | ) | ->void |
helper to de-serialize a json into a script
| j | json |
|
overridevirtual |
hook that is called when a GameObject enters the Engine tree.
The hook is called immediately after a GameObject's parent is called. Functionality may not be correct if an object was removed from the engine then re-added. To receive the hook, simply override the function in your class
Reimplemented from GameObject.
|
overrideprivatevirtual |
called every frame after update has been called for every object.
Generally used for rendering an object to the screen, when applicable. Unimplemented in GameObject
Implements GameObject.
|
overridevirtual |
Hook that is called right before a scene is unloaded To receive the hook, simply override the function in your class.
| sceneName | the name of the root node of the old scene |
Reimplemented from GameObject.
|
overridevirtual |
Hook that is called before the first frame a scene is run, but after the entire scene is loaded into the engine To receive the hook, simply override the function in your class.
| sceneName | the name of the root node of the new scene |
Reimplemented from GameObject.
|
overrideprivatevirtual |
called once every frame.
Generally used for timers, movement, condition checks, etc. Unimplemented in GameObject
| dt | the time in seconds that has elapsed |
Implements GameObject.
|
inlineexplicit |
|
inline |
Gets a reference to public variable from the script.
| name | the name of the variable to get |
|
nodiscardoverridevirtual |
override of parentTo because a ScriptHolder parent is the Entity above it, not the ScriptHolder component
| newParent | the parent entity |
Reimplemented from GameObject.
message recieving function that is currently unused, but might be used later
| auto Script::reloadScript | ( | ) | ->void |
loads a script from the file it is constructed from
TODO: don't use getstate here
|
overridevirtual |
Implementations will load the state of a GameObject to a th::Json object.
Unimplemented in GameObject
| stream | th::Json Object |
Implements GameObject.
|
private |
helper function to set a pointer to entity parent of the script in lua
| newParent | pointer to entity parent |
|
overridevirtual |
Called before update each frame, for calling ImGui editor code relevant to the gameObject.
virtual because we might need to destroy other things too, like parent node for entity Has a empty definition in GameObject, so it may be overriden, but doesn't have to be.
Reimplemented from GameObject.
|
staticprivate |
for all the values in a lua table, create editor fields for them in imgui
| table | the table to show in imgui |
|
staticprivate |
helper function that serializes a lua table to a json this works on: numbers (convert to double), string, bool, and table
| table | reference to the table to serialize |
|
private |
Helper function that may be used later should link other components on the entity to the script object as table fields.
| const bool Script::isNull = false |
whether the script is null (not constructed with a script path)
| sol::table Script::luaObject |
the data for the script in lua
| friend Script::ScriptHolder |
| std::string Script::scriptName |
the name of the script
| std::filesystem::path Script::scriptPath |
the path of the script