21#include <sol/forward.hpp>
27#include "framework/Script.h"
32#pragma region static_functions
48#pragma region overriden_functions
52 return std::make_unique<ScriptHolder>(*
this);
55 [[nodiscard(
"Parenting may fail")]]
auto parentTo(
GameObject* newParent) ->
bool override;
59 auto onUpdate(
float dt) ->
void override;
66 auto load(
const Stream& stream) ->
void override;
67 auto save(
Stream& stream)
const ->
void override;
77#pragma region ScriptHolder_functions
84 auto contains(
const std::string& script)
const -> bool;
100 auto addScript(
const std::filesystem::path& selectedLuaFilePath,
const std::string& selectedLuaFileName) -> void;
104#pragma region messaging_functions
112#pragma region member_variables
117 std::unordered_map<std::string, Script>
scripts;
121#pragma region helper_functions
131#pragma region static_variables
sys::Json Stream
Definition AudioObject.h:20
The base class for components, holding all of their shared All components should inherit from this.
nlohmann::json json
Definition Json.cpp:19
system for managing lua, and how the lua state interacts with scripts
ComponentTypeEnum
This enum lists out every type of component we have.
Definition Component.h:39
Component(ComponentTypeEnum type, const char *typeName)
Definition Component.cpp:72
the base class for the engine, most things inherit from this.
Definition GameObject.h:83
GameObject(std::string typeName, gobj::Type parentType, gobj::Type type)
constructor for gameobject.
Definition GameObject.cpp:24
Definition ScriptHolder.h:30
auto addScript(const std::filesystem::path &selectedLuaFilePath, const std::string &selectedLuaFileName) -> void
helper function to add a script exposed as public b/c we build cards programatically,...
Definition ScriptHolder.cpp:305
static auto bindLuaTypes(sol::state &lua) -> void
Definition ScriptHolder.h:37
ScriptHolder()
Definition ScriptHolder.cpp:32
auto onUpdate(float dt) -> void override
called once every frame.
Definition ScriptHolder.cpp:225
std::unordered_map< std::string, Script > scripts
map of scripts, ordered by script name
Definition ScriptHolder.h:117
friend auto from_json(const json &j, ScriptHolder &n) -> void
Definition ScriptHolder.cpp:269
friend auto to_json(json &j, const ScriptHolder &n) -> void
Definition ScriptHolder.cpp:260
auto operator=(ScriptHolder &&other) noexcept -> ScriptHolder &=default
auto onEnterEngine() -> void override
hook that is called when a GameObject enters the Engine tree.
Definition ScriptHolder.cpp:252
auto onRender() -> void override
called every frame after update has been called for every object.
Definition ScriptHolder.cpp:234
auto endWindow() -> void override
currently unused, but intended to but was assumed to be necessary for a proper ImGui editor
Definition ScriptHolder.h:63
auto getScript(const std::string &script) -> Script &
get a reference to a specific script held
Definition ScriptHolder.cpp:296
static auto getEnum() -> ComponentTypeEnum
Definition ScriptHolder.h:33
auto parentTo(GameObject *newParent) -> bool override
Sets the GameObject as a child of another GameObject.
Definition ScriptHolder.cpp:63
auto clone() const -> std::unique_ptr< GameObject > override
makes a copy a GameObject even if it's held polymorphically
Definition ScriptHolder.h:50
auto save(Stream &stream) const -> void override
Implementations will load the state of a GameObject to a th::Json object.
Definition ScriptHolder.cpp:247
auto linkMessages() -> void
Definition ScriptHolder.cpp:315
auto load(const Stream &stream) -> void override
Implementations will load the state of a GameObject from a th::Json Object.
Definition ScriptHolder.cpp:242
~ScriptHolder() override=default
auto componentShowMenu() -> void override
Definition ScriptHolder.cpp:75
auto reloadScripts() -> void
tell all the scripts to reload themselves
Definition ScriptHolder.cpp:324
auto contains(const std::string &script) const -> bool
checks if this ScriptHolder holds a particular script
Definition ScriptHolder.cpp:291
auto operator=(const ScriptHolder &) -> ScriptHolder &
Definition ScriptHolder.cpp:45