LeviLamina
Loading...
Searching...
No Matches
EntityId.h
1#pragma once
2
3#include "mc/_HeaderOutputPredefine.h"
4
5#include "mc/deps/ecs/EntityIdTraits.h"
6
7// entt v4 constrains `entt::entt_traits` with the `entity_like` concept, which is
8// only satisfied when `entt::internal::entt_traits` is defined for the type. It is
9// also the traits the generic `entt::entt_traits` is built from, so specializing it
10// makes `entt::entt_traits<EntityId>` resolve to `basic_entt_traits<EntityIdTraits>`.
11namespace entt::internal {
12template <>
13struct entt_traits<EntityId> : EntityIdTraits {};
14} // namespace entt::internal
15
16namespace entt {
17
18template <>
19struct entt_traits<EntityId> : basic_entt_traits<EntityIdTraits> {
20 using base_type = basic_entt_traits<EntityIdTraits>;
21
22 static constexpr std::size_t page_size = 2048;
23};
24
25} // namespace entt
26
27class EntityId : public entt::entt_traits<EntityId> {
28public:
29 entity_type mRawId{entt::null};
30
31 [[nodiscard]] constexpr EntityId() = default;
32
33 [[nodiscard]] constexpr EntityId(entity_type rawId) : mRawId(rawId) {}
34
35 [[nodiscard]] constexpr bool isNull() const { return *this == entt::null; }
36
37 [[nodiscard]] constexpr operator entity_type() const { return mRawId; }
38};
Definition EntityId.h:27
Definition EntityIdTraits.h:7