Carpenter Engine
A C++ game engine with a build once run anywhere solution
Loading...
Searching...
No Matches
Node.hpp
1/*
2 * This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at https://mozilla.org/MPL/2.0/.
5 */
6
7#ifndef ENGINE_NODE
8#define ENGINE_NODE
9
10#include "Utils.hpp"
11#include <vector>
12#include <string>
13
14namespace Engine {
15
43 class Node{
44 private:
45
46 bool m_enabled;
47 std::vector<Node*> m_children;
48
49 protected:
50
51 Node* m_parent;
52
53 public:
54
55 const char* m_nodeType;
56 std::string m_name;
57
61 Node(std::string name);
62
66 virtual ~Node();
67
75 size_t AddChild(Node* child);
76
83 Node* GetChild(size_t index);
84
91 Success RemoveChild(size_t index);
92
102 Success SetEnabled(bool enabled = true);
103
109 virtual void OnEnable();
110
116 virtual void OnDisable();
117
118 // Behaviour Methods //
119
120 virtual void Init();
121
127 virtual void Draw();
128
134 virtual void Update(float dt);
135 };
136
140 typedef Node Scene;
141}
142
143#endif
A collection of utilities for the game engine code.
Success
A generic success type.
Definition Utils.hpp:29
A single node in a game scene.
Definition Node.hpp:43
size_t AddChild(Node *child)
Adds a child to the node and assigns itself as the parent of the new node.
Definition Node.cpp:22
Success RemoveChild(size_t index)
Removes the child at the specified index.
Definition Node.cpp:33
virtual void OnDisable()
Overridable disable method for the node.
Definition Node.cpp:60
virtual void Draw()
Overridable draw method for the node.
Definition Node.cpp:67
Node * GetChild(size_t index)
Returns a reference to the child at the specified index.
Definition Node.cpp:29
Success SetEnabled(bool enabled=true)
Toggles the state of the node.
Definition Node.cpp:41
virtual void OnEnable()
Overridable enable method for the node.
Definition Node.cpp:55
virtual void Update(float dt)
Overridable update method for the node.
Definition Node.cpp:75
virtual ~Node()
Default destructor.
Definition Node.cpp:16