entity_remap
| Type | Class |
| Namespace | conjure::ecs |
| Include File Path | engine/include/conjure/ecs/entity.h |
| Source File Path | N/A |
| API ↗ | Entities and components |
Syntax
Constructors
| Access | Signature | Description |
|---|---|---|
| public | entity_remap() = default; | |
| public | explicit entity_remap(
std::vector<entity> targets); | Takes ownership of a local -> real table. |
| public | entity_remap(
const entity_remap &) = default; | |
| public | entity_remap(
entity_remap &&) noexcept = default; |
Destructors
| Access | Signature | Description |
|---|---|---|
| public | ~entity_remap() = default; |
Variables
| Access | Name | Type | Default | Description |
|---|---|---|---|---|
| private | mIndex | std:: | {} | |
| private | mTargets | std::vector<entity> | {} |
Functions
Public
clear
clearvoid clear() noexcept;Empties the table and its index.
index_targets
index_targetsvoid index_targets();Optional: builds a sorted index of the targets so remap() turns a real entity into its local index by binary search instead of a linear scan. Worth calling once the table is complete and many real -> local lookups follow (entity_archive::capture does). A target listed twice maps to its first local index, as the linear scan does. set(), resize() and clear() drop the index, after which remap() scans again until the next call.
remap
remapResolves one reference in whichever direction the value needs: an archive-local value becomes its real entity (as resolve), a real entity that is one of the targets becomes the archive-local index of that target, and every other value is returned unchanged. The same table therefore serves entity_archive::capture (real -> local, targets = the captured entities) and world::instantiate (local -> real): a live world never holds archive-local ids and an archive never holds a real id that is also one of its own targets. A real value is found by binary search after index_targets(), by a linear scan otherwise.
resize
resizevoid resize(
u32 count);Resizes the table; new entries are NULL_ENTITY. Drops the index_targets() index.
resolve
resolveResolves one reference: an archive-local value becomes its real entity (NULL_ENTITY when the local index is out of range); every other value, real or null, is returned unchanged.
set
setSets the real entity of a local index, growing the table when needed. Drops the index_targets() index.
target
targetThe real entity of a local index, or NULL_ENTITY when out of range.
Operator Overloads
Public
operator=
operator=entity_remap &operator=(
const entity_remap &) = default;entity_remap &operator=(
entity_remap &&) noexcept = default;