Finality Engine
Loading...
Searching...
No Matches
Entity.h
Go to the documentation of this file.
1
11#pragma once
12
13#include <Core/Core.h>
14#include "Scene.h"
15
16#include <entt.hpp>
17#include <Utils/UUID.h>
18
19namespace FINALITY
20{
22 struct ScriptStorage;
23
33 class FAPI Entity
34 {
35 private:
36 Entity(entt::entity handle, Scene* scene);
37
38 public:
40 Entity(const Entity&);
41 Entity(Entity&&) noexcept;
42 Entity& operator=(const Entity&);
43 Entity& operator=(Entity&&) noexcept;
44 ~Entity();
45
46 template<typename T, typename... Args>
47 T& AddScript(Args&&... args);
48
49 template<typename T, typename... Args>
50 T& AddComponent(Args&&... args);
51
52 template<typename T>
54
55 template<typename T>
56 bool HasComponent() const;
57
58 template<typename T>
60
61 entt::entity GetHandle() const { return m_EntityHandle; }
67 bool IsValid() const { return !m_Lifetime.expired() && m_CurrentScene && m_CurrentScene->GetRegistry().valid(m_EntityHandle); }
68
69 void SetParent(Entity parent);
70
71 private:
72 entt::entity m_EntityHandle{ entt::null };
73 Scene* m_CurrentScene = nullptr;
74 std::weak_ptr<void> m_Lifetime;
75
76 friend class Scene;
77 friend class SceneSerializer;
78 friend class ScriptableComponent;
79 };
80
81 // For entity to have children entity (need to frame this sentence correctly)
84 {
85 entt::entity Parent = entt::null;
86 entt::entity FirstChild = entt::null;
87 entt::entity NextSibling = entt::null;
88 entt::entity PrevSibling = entt::null;
89 };
90}
91
92#include "Entity.inl"
#define FAPI
Definition Core.h:22
Owns entities and dispatches script simulation.
friend class Scene
Definition Entity.h:76
bool HasComponent() const
friend class SceneSerializer
Definition Entity.h:77
entt::entity GetHandle() const
Definition Entity.h:61
void RemoveComponent()
Entity(const Entity &)
T & AddComponent(Args &&... args)
T & AddScript(Args &&... args)
void SetParent(Entity parent)
Entity(Entity &&) noexcept
friend class ScriptableComponent
Definition Entity.h:78
bool IsValid() const
Checks that the scene still exists and the entity handle is valid.
Definition Entity.h:67
Owns entities and dispatches script simulation.
Definition Scene.h:36
Intrusive hierarchy links using EnTT handles; entt::null denotes a missing link.
Definition Entity.h:84
Attached native script instances and their authored property values for one entity.