ComponentId
ComponentId
- usize
Description
A value which uniquely identifies the type of a [
Component
] or [Resource
] within a [World
].Each time a new
Component
type is registered within aWorld
using e.g. [World::register_component
] or [World::register_component_with_descriptor
] or a Resource with e.g. [World::init_resource
], a correspondingComponentId
is created to track it.While the distinction between
ComponentId
and [TypeId
] may seem superficial, breaking them into two separate but related concepts allows components to exist outside of Rust's type system. Each Rust type registered as aComponent
will have a correspondingComponentId
, but additionalComponentId
s may exist in aWorld
to track components which cannot be represented as Rust types for scripting or other advanced use-cases.A
ComponentId
is tightly coupled to its parentWorld
. Attempting to use aComponentId
from oneWorld
to access the metadata of aComponent
in a differentWorld
is undefined behavior and must not be attempted.Given a type
T
which implements [Component
], theComponentId
forT
can be retrieved from aWorld
using [World::component_id()
] or via [Components::component_id()
]. Access to theComponentId
for a [Resource
] is available via [Components::resource_id()
].
Functions
Function | Summary |
---|---|
assert_receiver_is_total_eq(_self) | No Documentation 🚧 |
clone(_self) | No Documentation 🚧 |
eq(_self, other) | No Documentation 🚧 |
index(_self) | Returns the index of the current component. |
new(index) | Creates a new [`ComponentId`]. The `index` is a unique value associated with each type of component in a given world. Usually, this value is taken from a counter incremented for each type of component registered with the world. |