2
3
4
5
10#include "World/Components/UUIDComponent.h"
11#include "World/World.h"
16
17
18
24
25
29
30
31
32
33
34
41
42
46
47
48
49
50
51
52 template<
typename T,
typename... Args>
55 if (HasComponent<T>())
58 ss <<
"Entity: " << (
int)m_EntityHandle <<
" already has such component.";
60 SPICES_CORE_WARN(ss.str())
61 return GetComponent<T>();
64 T& component = m_World->AddComponent<T>(m_EntityHandle, std::forward<Args>(args)...);
65 m_World->OnComponentAdded<T>(
this, component);
70
71
72
73
77 return m_World->GetComponent<T>(m_EntityHandle);
81
82
83
87 m_World->RemoveComponent<T>(m_EntityHandle);
91
92
99
100
107
108
109
110
114 return m_World->HasComponent<T>(m_EntityHandle);
118
119
120
124
125
126
127 operator bool()
const {
return m_EntityHandle != entt::null; }
130
131
132
133 operator uint32_t()
const {
return static_cast<uint32_t>(m_EntityHandle); }
136
137
138
142
143
144
145
152
153
154
155
164
165
169
170
#define SPICES_PROFILE_ZONE
virtual void OnPreActivate() override
This interface define the specific world behave before on activated.
virtual void OnDeactivate() override
This interface defines the specific world behave after on activated.
virtual void OnActivate(TimeStep &ts) override
This interface define the specific world behave on activated.
EditorWorld Class. This class defines the specific behave of EditorWorld.
T & AddComponent(Args &&... args)
Template Function. Used for add specific component to entity.
T & GetComponent() const
Get Component owned by this entity.
void RemoveComponent() const
Remove Component owned from this entity.
Entity()=default
Constructor Function.
void AddToRoot()
Add a entity to this world root.
World * m_World
A specific world Pointer.
const UUID GetUUID()
Get UUID form UUIDComponent.
Entity(entt::entity handle, World *world)
Constructor Function. Init class variable. Usually call it.
void RemoveFromRoot()
Remove a entity from this world root.
operator bool() const
Empty Operation.
virtual ~Entity()=default
Destructor Function.
bool HasComponent() const
If Component is owned by this entity or not.
operator uint32_t() const
Empty Operation.
Entity Class. This class defines the specific behaves of Entity.
Wrapper of Gltf file data.
This Class handles our engine time step during frames. Global Unique.
UUIDComponent Class. This class defines the specific behaves of UUIDComponent.
This class helps to generate a uuid for one resource.
virtual void OnDeactivate() override
This interface defines the specific world behave after on activated.
virtual void OnActivate(TimeStep &ts) override
This interface define the specific world behave on activated.
virtual void OnPreActivate() override
This interface define the specific world behave before on activated.
void RemoveFromRoot(Entity &entity)
Remove a entity from this world root.
void AddToRoot(Entity &entity)
Add a entity to this world root.
World Class. This class defines the basic behaves of World. When we create an new world,...