43#pragma region Ctors dtors and assignments
49 explicit Node(std::unique_ptr<GameObject> gamobj);
60#pragma region overloaded functions
65 auto
update(
float dt) ->
void override;
66 auto
onUpdate(
float dt) ->
void override;
71 auto render() ->
void override;
74 auto onSceneStart(
const std::string& sceneName) ->
void override;
75 auto onSceneExit(
const std::string& sceneName) ->
void override;
78 auto load(
const Stream& stream) ->
void override;
79 auto save(
Stream& stream)
const ->
void override;
135#pragma region node_functions
143 template <
typename type>
146 assert(
data->isType(typeId));
147 return static_cast<type*
>(&(*data));
157 template <
typename type>
160 assert(
data->isType(typeId));
161 return std::unique_ptr<type>(
dynamic_cast<type*
>(
data.release()));
176 auto
add(std::unique_ptr<
Node> child) ->
bool;
212 auto
pop() -> std::unique_ptr<
Node>;
225#pragma region GetItrFunctions
226 template <
typename T>
237#pragma region NodeIterator
238#define NodeIteratorImplemented 0
239#if NodeIteratorImplemented
246 static_assert(std::bidirectional_iterator<Itr>);
sys::Json Stream
Definition AudioObject.h:20
The class containing Json implemenation for building components.
the base class for the engine, most things inherit from this.
nlohmann::json json
Definition Json.cpp:19
the base class for the engine, most things inherit from this.
Definition GameObject.h:77
friend ChildrenHandeler
Definition GameObject.h:87
friend Node
Definition GameObject.h:86
GameObject(std::string typeName, gobj::Type parentType, gobj::Type type)
constructor for gameobject.
Definition GameObject.cpp:23
gobj::Type type
What type this GameObject is, for type checking, and safe casts.
Definition GameObject.h:507
Manages the heirarchical structure between Systems and Entities.
Definition Node.h:41
auto deRegisterRecursively() const -> void
Tell Messaging to remove all messages to this Node, it's data, and all of it's children,...
Definition Node.cpp:484
auto getParent() const -> Node *override
Definition Node.cpp:360
auto GetData(gobj::Type typeId) const -> type *
Gets a pointer to the data held by a node.
Definition Node.h:144
auto setShouldReceiveMessages(bool _shouldReceiveMessages) -> void override
set whether the Node, its data, and its children should receiveMessages
Definition Node.cpp:396
Node(Node &&other) noexcept=delete
auto onEnterEngine() -> void override
hook that is called when a GameObject enters the Engine tree.
Definition Node.cpp:316
auto onUpdate(float dt) -> void override
called once every frame.
Definition Node.cpp:299
auto moveParent() -> void
Holds the ImGui functionality for moving a node to a different parent in the Engine tree.
Definition Node.cpp:246
auto findDirect(const std::function< bool(GameObject &)> &predicate) -> GameObject *
Finds a GameObject somewhere in the nodes direct children.
Definition Node.cpp:466
std::unique_ptr< GameObject > data
Definition Node.h:272
auto setShouldUpdate(bool _shouldUpdate) -> void override
set whether the Node, its data, and its children should update every frame
Definition Node.cpp:378
auto onRender() -> void override
called every frame after update has been called for every object.
Definition Node.cpp:312
auto showMenu() -> void override
Called before update each frame, for calling ImGui editor code relevant to the gameObject.
Definition Node.cpp:102
friend auto from_json(const json &j, Node &n) -> void
Definition Node.cpp:528
auto add(std::unique_ptr< Node > child) -> bool
Gives a node a new Child node.
Definition Node.cpp:410
auto for_each(std::function< void(GameObject &)> func) -> void override
applies a function to every child.
Definition Node.cpp:337
auto addChild(std::unique_ptr< GameObject > newChild) -> bool override
Adds a child to a Node.
Definition Node.cpp:366
auto GetChildren() const
Definition Node.cpp:550
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 ...
Definition Node.cpp:322
ChildrenHandeler< Node > children
Definition Node.h:273
auto pop() -> std::unique_ptr< Node >
removes this Node from its parent, handing ownership to the caller
Definition Node.cpp:507
auto ExtractData(gobj::Type typeId) -> std::unique_ptr< type >
removes the data from the node, and relenquishes ownership of it.
Definition Node.h:158
auto dragTarget() -> void
Definition Node.cpp:184
auto dataItr() -> GameObject *
Definition Node.h:227
auto operator=(const Node &other) -> Node &
Definition Node.cpp:45
auto getChildren() const -> std::shared_ptr< std::vector< GameObject * > > override
gets a vector of a GameObjects public (i.e.
Definition Node.cpp:537
auto isDescendantOf(const Node *potentialParent) const -> bool
helper function to determine if a node is a descendant of another node.
Definition Node.cpp:229
auto save(Stream &stream) const -> void override
Implementations will load the state of a GameObject to a th::Json object.
Definition Node.cpp:355
auto dragAndDrop() -> void
wrapper function around the drag and drop source functionality in ImGui.
Definition Node.cpp:211
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 functio...
Definition Node.cpp:329
auto setShouldRender(bool _shouldRender) -> void override
set whether the Node, its data, and its children should render every frame
Definition Node.cpp:387
auto endWindow() -> void override
currently unused, but intended to but was assumed to be necessary for a proper ImGui editor
Definition Node.h:68
Node(std::unique_ptr< GameObject > gamobj)
Definition Node.cpp:27
auto dataType() const -> gobj::Type
Definition Node.cpp:421
auto update(float dt) -> void override
called once every frame.
Definition Node.cpp:285
auto render() -> void override
called every frame after update has been called for every object.
Definition Node.cpp:303
auto clone() const -> std::unique_ptr< GameObject > override
makes a copy a GameObject even if it's held polymorphically
Definition Node.cpp:97
auto load(const Stream &stream) -> void override
Implementations will load the state of a GameObject from a th::Json Object.
Definition Node.cpp:347
auto deleteDestroyedChildren() -> void
delete all the children of the node that are destroyed
Definition Node.cpp:512
auto getDataAsGameObj() const -> GameObject *
gives a GameObject* to the data held by the node.
Definition Node.cpp:405
friend auto to_json(json &j, const Node &n) -> void
Definition Node.cpp:517
auto find(const std::function< bool(GameObject &)> &predicate) -> GameObject *
Finds a GameObject somewhere in the nodes lower (children, grandchildren, etc.) than the node.
Definition Node.cpp:430
auto operator=(Node &&other) noexcept -> Node &=delete
namespace for things relating to GameObject, other than GameObject itself
Definition Entity.h:309
Type
Definition GameObject.h:45