ecs
Entity-Component-System
Loading...
Searching...
No Matches
Entity.hpp
Go to the documentation of this file.
1
11#ifndef ENTITY_HPP
12#define ENTITY_HPP
13
14//local
15
16//global
17#include <cstddef>
18#include <type_traits>
19
20namespace ecs {
21
22 class Registry;
24
29 class Entity {
30 public:
31
32 friend Registry;
33
34 public:
35
39 Entity() = delete;
40
45 ~Entity() = default;
46
53 template <typename... Component, typename = std::enable_if_t<(sizeof...(Component) >= 1)>>
54 void addComponent(Component&& ... c);
55
61 template <typename... Component, typename = std::enable_if_t<(sizeof...(Component) >= 1)>>
62 void removeComponent();
63
64 private:
65
72 explicit Entity(size_t idx, RegistryRef ecs);
73
74 private:
75
76 size_t _idx;
77 RegistryRef _ecs;
78 };
79}
80
83#endif // ENTITY_HPP
Component is a template define in Registry. (not a class)
Entity class from ECS.
Definition Entity.hpp:29
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:27
void removeComponent()
remove a component from the entity using the registryRef method removeComponent
Definition Entity_impl.hpp:32
~Entity()=default
Destroy the Entity object.
friend Registry
Definition Entity.hpp:32
define the Registry class
Definition Registry.hpp:47
Entity Component System.