Entity

Entity

Mojo struct

Entity

@register_passable_trivial
struct Entity

Entity identifier. Holds an entity ID and it’s generation for recycling.

Entities are only created via the World, using World.add_entity.

⚠️ Important: Entities are intended to be stored and passed around via copy, not via pointers! The zero value should be used to indicate “nil”, and can be checked with Entity.is_zero.

Implemented traits

AnyType, CollectionElement, Copyable, EqualityComparable, Hashable, Movable, Stringable, UnknownDestructibility

Methods

__bool__

__bool__(self) -> Bool

Args:

  • self (Self)

Returns:

Bool

__eq__

__eq__(self, other: Self) -> Bool

Args:

  • self (Self)
  • other (Self)

Returns:

Bool

__ne__

__ne__(self, other: Self) -> Bool

Args:

  • self (Self)
  • other (Self)

Returns:

Bool

__str__

__str__(self) -> String

Args:

  • self (Self)

Returns:

String

__hash__

__hash__(self) -> UInt

Returns a unique hash.

Args:

  • self (Self)

Returns:

UInt

get_id

get_id(self) -> SIMD[uint32, 1]

Returns the entity’s ID.

Args:

  • self (Self)

Returns:

SIMD[uint32, 1]

get_gen

get_gen(self) -> SIMD[uint32, 1]

Returns the entity’s Generation.

Args:

  • self (Self)

Returns:

SIMD[uint32, 1]

is_zero

is_zero(self) -> Bool

Returns whether this entity is the reserved zero entity.

Args:

  • self (Self)

Returns:

Bool