ecs
Loading...
Searching...
No Matches
Entity.hpp
Go to the documentation of this file.
1
8#ifndef ENTITY_HPP
9#define ENTITY_HPP
10
11//local
12
13//global
14#include <cstddef>
15#include <type_traits>
16
17namespace ecs {
18
19 class Registry;
21
26 class Entity {
27 public:
28
29 friend Registry;
30
31 public:
32
36 Entity() = delete;
37
42 ~Entity() = default;
43
50 template <typename... Component, typename = std::enable_if_t<(sizeof...(Component) >= 1)>>
51 void addComponent(Component&& ... c);
52
58 template <typename... Component, typename = std::enable_if_t<(sizeof...(Component) >= 1)>>
59 void removeComponent();
60
61 private:
62
69 explicit Entity(size_t idx, RegistryRef ecs);
70
71 private:
72
73 size_t _idx;
74 RegistryRef _ecs;
75 };
76}
77
78#endif // ENTITY_HPP
Component is a template define in Registry. (not a class)
Entity class from ECS.
Definition Entity.hpp:26
Entity()=delete
Deleted default constructor, use Registry::createEntity() instead.
void addComponent(Component &&... c)
add a component to the entity using the registryRef method addComponent
Definition Entity_impl.hpp:24
void removeComponent()
remove a component from the entity using the registryRef method removeComponent
Definition Entity_impl.hpp:29
~Entity()=default
Destroy the Entity object.
friend Registry
Definition Entity.hpp:29
define the Registry class
Definition Registry.hpp:44
Entity Component System.