41using u8 = std::uint8_t;
43using u16 = std::uint16_t;
45using u32 = std::uint32_t;
47using u64 = std::uint64_t;
50using i8 = std::int8_t;
52using i16 = std::int16_t;
54using i32 = std::int32_t;
56using i64 = std::int64_t;
89using Weak = std::weak_ptr<T>;
98template<
typename T,
typename... Args>
100 return std::make_unique<T>(std::forward<Args>(args)...);
110template<
typename T,
typename... Args>
112 return std::make_shared<T>(std::forward<Args>(args)...);
147 explicit constexpr operator u32()
const {
return raw; }
171static_assert(
sizeof(Entity) ==
sizeof(
u32),
"Entity must be 4 bytes for FFI and dense array performance");
201 template<
typename Domain>
203 static std::atomic<TypeId> counter{0};
207 template<
typename Domain,
typename T>
253 return std::hash<esengine::u32>{}(e.raw);
Single source of truth for index+generation bit-packing.
std::ostream & operator<<(std::ostream &os, esengine::Entity e)
std::atomic< TypeId > & typeIdCounter()
One independent TypeId counter per Domain tag.
constexpr Unique< T > makeUnique(Args &&... args)
Creates a Unique pointer with the given arguments.
std::int32_t i32
Signed 32-bit integer.
TypeId componentTypeId()
Dense 0-based runtime id for a component type (ECS pool index + mask bit).
std::uint64_t u64
Unsigned 64-bit integer.
constexpr u32 INVALID_DENSE_INDEX
Sentinel for empty sparse set slots.
std::size_t usize
Size type for indexing and sizes.
std::weak_ptr< T > Weak
Weak reference smart pointer.
constexpr Entity INVALID_ENTITY
Invalid entity sentinel value.
std::shared_ptr< T > Shared
Shared ownership smart pointer.
std::int16_t i16
Signed 16-bit integer.
TypeId serviceTypeId()
Dense 0-based runtime id for a service type (ServiceRegistry key).
std::span< const T > ConstSpan
std::unique_ptr< T > Unique
Unique ownership smart pointer.
std::int8_t i8
Signed 8-bit integer.
std::uint32_t u32
Unsigned 32-bit integer.
std::uint8_t u8
Unsigned 8-bit integer.
std::int64_t i64
Signed 64-bit integer.
std::uint16_t u16
Unsigned 16-bit integer.
double f64
64-bit floating point
u32 TypeId
Runtime type identifier.
constexpr Shared< T > makeShared(Args &&... args)
Creates a Shared pointer with the given arguments.
float f32
32-bit floating point
Domain tags — each yields an independent, dense, 0-based TypeId sequence. Use the typed helpers below...
Entity identifier with packed index + generation.
PackedId< 22, 10 > Layout
static constexpr u32 INVALID_RAW
static constexpr u32 GEN_BITS
constexpr bool operator!=(Entity other) const
constexpr u32 id() const
Returns the raw packed value for FFI serialization.
static constexpr u32 GEN_MASK
static constexpr Entity fromRaw(u32 v)
Reconstructs an Entity from a raw packed value.
constexpr bool operator==(Entity other) const
static constexpr Entity make(u32 idx, u32 gen)
Creates an Entity from index and generation.
constexpr bool isValid() const
Checks if this is not the invalid sentinel.
static constexpr u32 INDEX_MASK
static constexpr u32 INDEX_BITS
constexpr u32 generation() const
Gets the generation number.
constexpr u32 index() const
Gets the entity index.
Index+generation packing into a u32, parameterized by the bit split.
static constexpr std::uint32_t generationOf(std::uint32_t raw)
static constexpr std::uint32_t INDEX_MASK
static constexpr std::uint32_t pack(std::uint32_t index, std::uint32_t generation)
static constexpr std::uint32_t INDEX_BITS
static constexpr std::uint32_t indexOf(std::uint32_t raw)
static constexpr std::uint32_t GEN_BITS
static constexpr std::uint32_t GEN_MASK
std::size_t operator()(esengine::Entity e) const noexcept