90#pragma region big_6_functions
129#pragma region abstract functions
146 virtual auto
update(
float dt) ->
void;
175 virtual auto
render() ->
void;
202 virtual auto
destroy() ->
void;
259#pragma region parent_functions
278 [[nodiscard(
"Parenting may fail")]] virtual auto
parentTo(
GameObject* newParent) ->
bool;
294#pragma region child_functions
305 [[nodiscard(
"adding child may fail")]]
306 virtual auto addChild(std::unique_ptr<GameObject> newChild) -> bool;
316 [[nodiscard]]
virtual auto getKey() const -> Key;
318 [[nodiscard]] auto
destroyed() const ->
bool;
320 [[nodiscard]] auto
isUUID(
gobj::UUID compareUUID) const ->
bool;
325 [[nodiscard]] auto
getName() const -> const std::
string&;
330 [[nodiscard]] auto
getNickname() const -> const std::
string&;
344 [[nodiscard]] auto
nameEquals(const std::
string& compareString) const ->
bool;
352 [[nodiscard]] auto
isType(
gobj::Type otherType) const ->
bool;
364 auto
setNickname(const std::
string& newNickname) ->
void;
369 [[nodiscard]] auto
updates() const ->
bool;
374 [[nodiscard]] auto
renders() const ->
bool;
384 [[nodiscard]] auto
isActive() const ->
bool;
408 auto
setActive(
bool shouldBeActive) ->
void;
sys::Json Stream
Definition AudioObject.h:20
auto operator<(const GameObject::Key &lhs, const GameObject::Key &rhs) -> bool
Definition GameObject.cpp:440
unsigned int RenderLayer
Definition GameObject.h:65
static unsigned int ObjectCount
Definition GameObject.h:69
nlohmann::json json
Definition Json.cpp:19
A container for child objects.
Definition ChildrenHandeler.h:42
Definition Component.h:28
a Key class to be used as a key when holding GameObjects (or unique pointers to game objects) in <key...
Definition GameObject.h:415
auto getType() const -> gobj::Type
Definition GameObject.cpp:329
gobj::UUID uuid
the UUID of the GameObject the Key was generated from
Definition GameObject.h:436
auto getSubtype() const -> unsigned short
Definition GameObject.cpp:334
gobj::Type type
the type of the GameObject the Key was generated from
Definition GameObject.h:441
Key(gobj::UUID uuid, gobj::Type type, unsigned short subtype)
Definition GameObject.cpp:317
unsigned short subtype
Definition GameObject.h:447
the base class for the engine, most things inherit from this.
Definition GameObject.h:77
std::string formattedName
the combined name of the GameObject.
Definition GameObject.h:555
virtual auto setShouldReceiveMessages(bool _shouldReceiveMessages) -> void
set whether the GameObject should Receive Messags, and whether all of it's children should receive me...
Definition GameObject.cpp:302
virtual auto onSceneStart(const std::string &sceneName) -> void
Hook that is called before the first frame a scene is run, but after the entire scene is loaded into ...
Definition GameObject.h:229
auto getUUID() const -> gobj::UUID
Definition GameObject.cpp:208
virtual auto onUpdate(float dt) -> void=0
called once every frame.
auto receivesMessages() const -> bool
Definition GameObject.cpp:280
auto getObjectType() const -> gobj::Type
gets the internal type of the GameObject, as an enum
Definition GameObject.cpp:265
virtual auto onRender() -> void=0
called every frame after update has been called for every object.
virtual auto onSceneExit(const std::string &sceneName) -> void
Hook that is called right before a scene is unloaded To receive the hook, simply override the functio...
Definition GameObject.h:238
virtual auto getParent() const -> GameObject *
Gets the parent of a GameObject.
Definition GameObject.cpp:173
gobj::Type parentType
Definition GameObject.h:503
auto isType(gobj::Type otherType) const -> bool
check whether the GameObject is the same as a given type.
Definition GameObject.cpp:260
auto setGameObjectJson(const json &stream) -> void
used for deserializing GameObjects
Definition GameObject.cpp:360
virtual auto update(float dt) -> void
called once every frame.
Definition GameObject.cpp:125
bool isDestroyed
whether the GameObject has been destroyed, and if it should be deleted at the end of the frame.
Definition GameObject.h:497
virtual auto onEnterEngine() -> void
hook that is called when a GameObject enters the Engine tree.
Definition GameObject.h:220
auto getInternalParent() const -> GameObject *
returns the actual owning parent of the GameObject
Definition GameObject.cpp:339
friend Entity
Definition GameObject.h:84
auto getGameObjectJson() const -> json
Used for serializing GameObjects.
Definition GameObject.cpp:344
auto updates() const -> bool
Definition GameObject.cpp:270
virtual auto load(const Stream &stream) -> void=0
Implementations will load the state of a GameObject from a th::Json Object.
std::string typeName
the typeName of a GameObject.
Definition GameObject.h:545
GameObject * internalParent
The GameObject that owns and manages this GameObject.
Definition GameObject.h:512
auto getNickname() const -> const std::string &
Gets the nickname (custom, writable name) of a GameObject.
Definition GameObject.cpp:230
friend ChildrenHandeler
Definition GameObject.h:87
auto getFormattedName() const -> const std::string &
combines a GameObjects Type, Nickname, and UUID into one string, for use with logging.
Definition GameObject.cpp:240
bool shouldRender
whether the GameObject and it's children render
Definition GameObject.h:526
auto getName() const -> const std::string &
Gets the type of the object as a string.
Definition GameObject.cpp:225
friend Node
Definition GameObject.h:86
auto setActive(bool shouldBeActive) -> void
set the GameObject should update, render, and receive messages
Definition GameObject.cpp:310
const gobj::UUID uuid
a unique ID for each GameObject
Definition GameObject.h:493
auto setNickname(const std::string &newNickname) -> void
sets the GameObjects nickname.
Definition GameObject.cpp:249
auto checkAddToSceneHook() -> void
Determine if the GameObject was recently added to the engine, and if it was, call onEngineEnter.
Definition GameObject.cpp:385
virtual auto showMenu() -> void
Called before update each frame, for calling ImGui editor code relevant to the gameObject.
Definition GameObject.h:211
auto calculateFormattedName() const -> void
helper function for updating the formatted name, called when we set a nickname, or lazily when we req...
Definition GameObject.cpp:235
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
auto isActive() const -> bool
Definition GameObject.cpp:285
auto isUUID(gobj::UUID compareUUID) const -> bool
Definition GameObject.cpp:214
virtual auto destroy() -> void
Marks an GameObject to be destroyed.
Definition GameObject.cpp:157
friend Engine
Definition GameObject.h:88
virtual auto getChildren() const -> std::shared_ptr< std::vector< GameObject * > >
gets a vector of a GameObjects public (i.e.
Definition GameObject.cpp:380
virtual auto clone() const -> std::unique_ptr< GameObject >=0
makes a copy a GameObject even if it's held polymorphically
virtual auto parentTo(GameObject *newParent) -> bool
Sets the GameObject as a child of another GameObject.
Definition GameObject.cpp:184
virtual auto render() -> void
called every frame after update has been called for every object.
Definition GameObject.cpp:139
auto nameEquals(const std::string &compareString) const -> bool
check whether a GameObjects typeName is equivilent to a given string.
Definition GameObject.cpp:255
RenderLayer renderLayer
Currently unused, the z layer an GameObject will be drawn on.
Definition GameObject.h:516
auto operator=(const GameObject &other) -> GameObject &
copy assignment operator
Definition GameObject.cpp:56
virtual auto setShouldUpdate(bool _shouldUpdate) -> void
set whether the GameObject should update every frame, and whether all of it's children should update ...
Definition GameObject.cpp:290
bool shouldReceiveMessages
whether the GameObject and it's children receive messages
Definition GameObject.h:531
std::string nickname
the nickname of a GameObject is used to identify in the editor.
Definition GameObject.h:550
auto setInternalParent(GameObject *parent) -> bool
sets the internal parent of a GameObject directly, avoiding abstractions provided by ParentTo().
Definition GameObject.cpp:400
virtual ~GameObject()
destructor for GameObject.
Definition GameObject.cpp:34
virtual auto for_each(std::function< void(GameObject &)> func) -> void
applies a function to every child.
Definition GameObject.cpp:163
auto renders() const -> bool
Definition GameObject.cpp:275
bool inEngine
whether the GameObject is current in the Engine, underneath SceneManager Used for making sure the Gam...
Definition GameObject.h:537
virtual auto endWindow() -> void=0
currently unused, but intended to but was assumed to be necessary for a proper ImGui editor
virtual auto save(Stream &stream) const -> void=0
Implementations will load the state of a GameObject to a th::Json object.
auto destroyed() const -> bool
Definition GameObject.cpp:202
virtual auto setShouldRender(bool _shouldRender) -> void
set whether the GameObject should render every frame, and whether all of it's children should render ...
Definition GameObject.cpp:296
virtual auto addChild(std::unique_ptr< GameObject > newChild) -> bool
Adds a child to a GameObject.
Definition GameObject.cpp:190
virtual auto getKey() const -> Key
Generates a unique Key that corresponds to the GameObject.
Definition GameObject.cpp:219
bool shouldUpdate
whether the GameObject and it's children updates
Definition GameObject.h:521
Manages the heirarchical structure between Systems and Entities.
Definition Node.h:41
Definition SceneManager.h:57
namespace for things relating to GameObject, other than GameObject itself
Definition Entity.h:309
Type
Definition GameObject.h:45
@ no_parent_type
Definition GameObject.h:47
@ null_obj_type
Definition GameObject.h:46
@ ChildrenHandler
Definition GameObject.h:51
unsigned int UUID
Definition GameObject.h:62
the type of elements in a basic_json container
Definition GameObject.h:32
internal type for computing Paths
Definition PathNode.h:37