NoJobEngine 2.0.7
Loading...
Searching...
No Matches
Entity.h
Go to the documentation of this file.
1
6#pragma once
7#include <cstdint>
8#include <type_traits>
9
10namespace NoJob
11{
12 class Scene;
13 class PrefabSerializer;
14
15 class Entity
16 {
17 public:
18 Entity() = default;
19 Entity(std::uint32_t handle, Scene* scene)
20 : m_Handle(handle), m_Scene(scene)
21 {
22 }
23
24 template<typename T, typename... Args>
25 T& AddComponent(Args&&... args);
26
27 template<typename T>
28 void RemoveComponent();
29
30 template<typename T>
31 T& GetComponent();
32
33 template<typename T>
34 const T& GetComponent() const;
35
36 template<typename T>
37 bool HasComponent() const;
38
39 explicit operator bool() const;
40
41 std::uint32_t GetHandle() const { return m_Handle; }
42 Scene* GetScene() const { return m_Scene; }
43
44 bool operator==(const Entity& other) const
45 {
46 return m_Handle == other.m_Handle && m_Scene == other.m_Scene;
47 }
48
49 bool operator!=(const Entity& other) const
50 {
51 return !(*this == other);
52 }
53
54 private:
55 std::uint32_t m_Handle = 0;
56 Scene* m_Scene = nullptr;
57
58 friend class Scene;
59 friend class PrefabSerializer;
60 };
61}
friend class Scene
Definition Entity.h:58
Entity()=default
friend class PrefabSerializer
Definition Entity.h:59
std::uint32_t GetHandle() const
Definition Entity.h:41
void RemoveComponent()
Definition Scene.h:844
T & GetComponent()
Definition Scene.h:851
bool operator==(const Entity &other) const
Definition Entity.h:44
Entity(std::uint32_t handle, Scene *scene)
Definition Entity.h:19
T & AddComponent(Args &&... args)
Definition Scene.h:836
bool HasComponent() const
Definition Scene.h:865
bool operator!=(const Entity &other) const
Definition Entity.h:49
Scene * GetScene() const
Definition Entity.h:42