Skip to main content

EntityHandle Struct

A versioned handle for referencing entities in an EntityPool. More...

Declaration

struct helios::engine::ecs::EntityHandle { ... }

Public Operators Index

booloperator== (const EntityHandle &) const =default

Compares two handles for equality. More...

constexpr booloperator< (const EntityHandle &entityHandle) const noexcept

Compares two handles by entity ID (less-than). More...

constexpr booloperator> (const EntityHandle &entityHandle) const noexcept

Compares two handles by entity ID (greater-than). More...

Public Member Functions Index

boolisValid () const noexcept

Checks if this handle is potentially valid. More...

Public Member Attributes Index

helios::engine::ecs::types::EntityIdentityId

The unique identifier for the entity within the pool. More...

helios::engine::common::types::VersionIdversionId

The version number for stale handle detection. More...

Description

A versioned handle for referencing entities in an EntityPool.

`EntityHandle` combines an entity ID with a version number to provide safe references to pooled entities. The version ensures that handles to removed entities are detected as stale.

See Also

EntityPool

Definition at line 27 of file EntityHandle.ixx.

Public Operators

operator<()

bool helios::engine::ecs::EntityHandle::operator< (const EntityHandle & entityHandle)
inline constexpr noexcept

Compares two handles by entity ID (less-than).

Parameters
entityHandle

The handle to compare against.

Returns

True if this handle's entity ID is less than the other.

Definition at line 53 of file EntityHandle.ixx.

53 constexpr bool operator<(const EntityHandle& entityHandle) const noexcept {
54 return entityId < entityHandle.entityId;
55 }

Reference entityId.

operator==()

bool helios::engine::ecs::EntityHandle::operator== (const EntityHandle &)
default

Compares two handles for equality.

Definition at line 44 of file EntityHandle.ixx.

operator>()

bool helios::engine::ecs::EntityHandle::operator> (const EntityHandle & entityHandle)
inline constexpr noexcept

Compares two handles by entity ID (greater-than).

Parameters
entityHandle

The handle to compare against.

Returns

True if this handle's entity ID is greater than the other.

Definition at line 64 of file EntityHandle.ixx.

64 constexpr bool operator>(const EntityHandle& entityHandle) const noexcept {
65 return entityId > entityHandle.entityId;
66 }

Reference entityId.

Public Member Functions

isValid()

bool helios::engine::ecs::EntityHandle::isValid ()
inline nodiscard noexcept

Checks if this handle is potentially valid.

Returns

True if the version is at least 1 (initial version).

Definition at line 73 of file EntityHandle.ixx.

73 [[nodiscard]] bool isValid() const noexcept {
74 return versionId >= 1;
75 }

Reference versionId.

Referenced by helios::engine::runtime::pooling::GameObjectPool::addInactive, helios::engine::runtime::pooling::GameObjectPool::release, helios::engine::runtime::pooling::GameObjectPool::releaseAndRemove and helios::engine::builder::gameObject::builders::configs::ChaseConfig::target.

Public Member Attributes

entityId

versionId

helios::engine::common::types::VersionId helios::engine::ecs::EntityHandle::versionId

The documentation for this struct was generated from the following file:


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.