Crimson Engine 1.0.0
A high-performance C++20 game engine prototype showcasing a custom ECS, Vulkan renderer, and ImGui editor.
Loading...
Searching...
No Matches
Entity.hpp
Go to the documentation of this file.
1#pragma once
2#include <cstdint>
3#include <bitset>
4#include <limits>
5#include <functional>
6
11class Entity {
12public:
14 using IdType = std::uint32_t;
16 static constexpr IdType INVALID_ENTITY = std::numeric_limits<IdType>::max();
17
26 explicit Entity(IdType i) : id(i) {}
27
32 IdType getId() const { return id; }
33
39 bool operator==(const Entity& other) const { return id == other.id; }
45 bool operator!=(const Entity& other) const { return id != other.id; }
46
47private:
50};
51
53constexpr std::size_t MAX_COMPONENTS = 64;
55using ComponentMask = std::bitset<MAX_COMPONENTS>;
constexpr std::size_t MAX_COMPONENTS
Maximum number of supported component types in the ECS.
Definition Entity.hpp:53
std::bitset< MAX_COMPONENTS > ComponentMask
Bitmask representing component registration status.
Definition Entity.hpp:55
IdType id
Unique numeric identifier.
Definition Entity.hpp:49
static constexpr IdType INVALID_ENTITY
Constant representing a null or invalid entity.
Definition Entity.hpp:16
IdType getId() const
Retrieve the raw identifier of the entity.
Definition Entity.hpp:32
Entity(IdType i)
Construct a new Entity object with a given ID.
Definition Entity.hpp:26
Entity()
Construct a new, invalid Entity object.
Definition Entity.hpp:21
std::uint32_t IdType
Numeric type of the entity identifier.
Definition Entity.hpp:14
bool operator==(const Entity &other) const
Check equality with another entity.
Definition Entity.hpp:39
bool operator!=(const Entity &other) const
Check inequality with another entity.
Definition Entity.hpp:45