10#include <entt/entt.hpp>
22 template<
typename Component,
typename ...Args>
24 template<
typename Component,
typename ...Args>
26 template<
typename Component>
28 template<
typename Component>
30 template<
typename Component>
32 template<
typename Component>
34 template<
typename Component,
typename ...Args>
38 const std::string&
getTag()
const;
44 operator bool() {
return m_handle != entt::null; }
45 operator void*() {
return reinterpret_cast<void*
>(m_handle); }
47 entt::entity m_handle{ entt::null };
48 Scene* m_sceneRef{
nullptr };
53 template<
typename Component,
typename ...Args>
56 JNG_CORE_ASSERT(!hasComponent<Component>(),
"Entity can't have more that one component of the same type!");
57 return m_sceneRef->m_registry.emplace<Component>(m_handle, std::forward<Args>(args)...);
60 template<
typename Component,
typename ...Args>
63 return m_sceneRef->m_registry.emplace_or_replace<Component>(m_handle, std::forward<Args>(args)...);
66 template<
typename Component>
69 m_sceneRef->m_registry.remove<Component>(m_handle);
72 template<
typename Component>
75 return m_sceneRef->m_registry.all_of<Component>(m_handle);
78 template<
typename Component>
81 JNG_CORE_ASSERT(hasComponent<Component>(),
"Entity doesn't have component of that type!");
82 return m_sceneRef->m_registry.get<Component>(m_handle);
85 template<
typename Component>
88 JNG_CORE_ASSERT(hasComponent<Component>(),
"Entity doesn't have component of that type!");
89 return m_sceneRef->m_registry.get<Component>(m_handle);
92 template<
typename Component,
typename ...Args>
95 return m_sceneRef->m_registry.get_or_emplace<Component>(m_handle, std::forward<Args>(args)...);
#define JNG_CORE_ASSERT(x,...)
Definition: assert.hpp:24
Definition: entity.hpp:17
void removeComponent()
Definition: entity.hpp:67
friend class Scene
Definition: entity.hpp:50
bool operator!=(const Entity &other) const
Definition: entity.hpp:43
bool operator==(const Entity &other) const
Definition: entity.hpp:42
const std::string & getTag() const
Definition: entity.cpp:23
GUID getGUID() const
Definition: entity.cpp:18
Scene * getScene()
Definition: entity.hpp:40
Component & addOrReplaceComponent(Args &&...args)
Definition: entity.hpp:61
Component & getOrAddComponent(Args &&...args)
Definition: entity.hpp:93
Component & getComponent()
Definition: entity.hpp:79
bool hasComponent() const
Definition: entity.hpp:73
Component & addComponent(Args &&...args)
Definition: entity.hpp:54