GPR5100 - Rollback
Loading...
Searching...
No Matches
entity.h
Go to the documentation of this file.
1
4#pragma once
5
6#include <cstdint>
7#include <vector>
8#include <limits>
9
10
11namespace core
12{
17using Entity = std::uint32_t;
22using EntityMask = std::uint32_t;
26constexpr Entity INVALID_ENTITY = std::numeric_limits<Entity>::max();
35{
36public:
38 EntityManager(std::size_t reservedSize);
52 void DestroyEntity(Entity entity);
59 void AddComponent(Entity entity, EntityMask mask);
65 void RemoveComponent(Entity entity, EntityMask mask);
72 [[nodiscard]] bool HasComponent(Entity entity, EntityMask mask) const;
78 [[nodiscard]] bool EntityExists(Entity entity) const;
83 [[nodiscard]] std::size_t GetEntitiesSize() const;
84
85
86private:
87 std::vector<EntityMask> entityMasks_;
88};
89
90} // namespace core
Manages the entities in an array using bitwise operations to know if it has components.
Definition: entity.h:35
void DestroyEntity(Entity entity)
DestroyEntity is a method that will erase all Component from the EntityMask. It means that EntityExis...
Definition: entity.cpp:44
std::size_t GetEntitiesSize() const
GetEntitiesSize is a method that returns the size of the EntityMask array.
Definition: entity.cpp:69
Entity CreateEntity()
CreateEntity is a method that will return the next available Entity index. It will look at the intern...
Definition: entity.cpp:19
void AddComponent(Entity entity, EntityMask mask)
AddComponent is a method that adds the bitwise entity mask to the entity mask. It is normally called ...
Definition: entity.cpp:50
bool EntityExists(Entity entity) const
EntityExists is a method that check if a certain Entity has any Component and thus do exist.
Definition: entity.cpp:63
void RemoveComponent(Entity entity, EntityMask mask)
RemoveComponent is a method that removes the bitwise entity mask to the entity mask.
Definition: entity.cpp:56
bool HasComponent(Entity entity, EntityMask mask) const
HasComponent is a method that check if a certain Entity has a EntityMask on.
Definition: entity.cpp:74
std::uint32_t EntityMask
EntityMask is the type used to define the bitwise mask of an Entity. It is used to know what Componen...
Definition: entity.h:22
constexpr Entity INVALID_ENTITY
INVALID_ENTITY is a constant that define an invalid Entity.
Definition: entity.h:26
constexpr EntityMask INVALID_ENTITY_MASK
INVALID_ENTITY_MASK is a constant that define an invalid or empty entity mask.
Definition: entity.h:30
std::uint32_t Entity
Entity is the type used to define an game world entity. An Entity is just an index,...
Definition: entity.h:17