Finality Engine
Toggle main menu visibility
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
19
namespace
FINALITY
20
{
21
class
ScriptableComponent
;
22
struct
ScriptStorage
;
23
33
class
FAPI
Entity
34
{
35
private
:
36
Entity(entt::entity handle,
Scene
* scene);
37
38
public
:
39
Entity
();
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>
53
T&
GetComponent
();
54
55
template<typename T>
56
bool
HasComponent
() const;
57
58
template<typename T>
59
void
RemoveComponent
();
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)
83
struct
RelationshipComponent
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"
Core.h
FAPI
#define FAPI
Definition
Core.h:22
Scene.h
Owns entities and dispatches script simulation.
UUID.h
FINALITY::Entity::Scene
friend class Scene
Definition
Entity.h:76
FINALITY::Entity::HasComponent
bool HasComponent() const
FINALITY::Entity::Entity
Entity()
FINALITY::Entity::SceneSerializer
friend class SceneSerializer
Definition
Entity.h:77
FINALITY::Entity::GetHandle
entt::entity GetHandle() const
Definition
Entity.h:61
FINALITY::Entity::RemoveComponent
void RemoveComponent()
FINALITY::Entity::Entity
Entity(const Entity &)
FINALITY::Entity::AddComponent
T & AddComponent(Args &&... args)
FINALITY::Entity::AddScript
T & AddScript(Args &&... args)
FINALITY::Entity::SetParent
void SetParent(Entity parent)
FINALITY::Entity::GetComponent
T & GetComponent()
FINALITY::Entity::Entity
Entity(Entity &&) noexcept
FINALITY::Entity::ScriptableComponent
friend class ScriptableComponent
Definition
Entity.h:78
FINALITY::Entity::IsValid
bool IsValid() const
Checks that the scene still exists and the entity handle is valid.
Definition
Entity.h:67
FINALITY::Scene
Owns entities and dispatches script simulation.
Definition
Scene.h:36
FINALITY::ScriptableComponent
Definition
ScriptableComponent.h:96
FINALITY
Definition
Asset.h:12
FINALITY::RelationshipComponent
Intrusive hierarchy links using EnTT handles; entt::null denotes a missing link.
Definition
Entity.h:84
FINALITY::RelationshipComponent::Parent
entt::entity Parent
Definition
Entity.h:85
FINALITY::RelationshipComponent::PrevSibling
entt::entity PrevSibling
Definition
Entity.h:88
FINALITY::RelationshipComponent::NextSibling
entt::entity NextSibling
Definition
Entity.h:87
FINALITY::RelationshipComponent::FirstChild
entt::entity FirstChild
Definition
Entity.h:86
FINALITY::ScriptStorage
Attached native script instances and their authored property values for one entity.
Definition
ScriptableComponent.h:59
FinalityEngine
src
Scene
Entity.h
Generated by
1.18.0