vkmEngine 1.0.0
A C++ game engine · vkmengine.com
Loading...
Searching...
No Matches
entity.h
1#pragma once
2
3#include <cstdint>
4
5#include "core/memory/types.h"
6
7namespace Vkm::Engine {
8
23struct EntityId {
24 StorageIndex key = {};
25
27 constexpr explicit operator bool() const noexcept { return bool(key); }
28
29 constexpr bool operator==(const EntityId& other) const noexcept {
30 return key == other.key;
31 }
32 constexpr bool operator!=(const EntityId& other) const noexcept {
33 return key != other.key;
34 }
35
36 constexpr uint32_t slot() const noexcept { return key.index; }
37
38 constexpr uint32_t generation() const noexcept { return key.generation; }
39};
40
41static_assert(sizeof(EntityId) == 8, "EntityId must be 8 bytes");
42
43} // namespace Vkm::Engine
Names one entity of one Scene, for as long as that slot holds it.
Definition entity.h:23
Opaque handle pairing a sparse-array index with a generation counter.
Definition types.h:14
uint32_t index
Sparse slot index; 0 is null.
Definition types.h:15