#[repr(C)]pub struct Entity(/* private fields */);
Expand description
An entity index.
They are created using the Entities
struct. They are used as indices with Components
structs.
Entities are conceptual “things” which possess attributes (Components). As an exemple, a Car (Entity) has a Color (Component), a Position (Component) and a Speed (Component).
Implementations§
source§impl Entity
impl Entity
sourcepub fn new(index: u32, generation: u32) -> Entity
pub fn new(index: u32, generation: u32) -> Entity
Creates a new Entity
from the provided index and generation.
⚠️ Warning: It is not generally recommended to manually create
Entity
s unless you know exactly what you are doing. This can be useful in certain advanced or unusual use-cases, but usually you should useEntities::create()
to spawn entities.
sourcepub fn index(&self) -> u32
pub fn index(&self) -> u32
Returns the index of this Entity
.
In most cases, you do not want to use this directly. However, it can be useful to create caches to improve performances.
sourcepub fn generation(&self) -> u32
pub fn generation(&self) -> u32
Returns the generation of this Entity
.
In most cases, you do not want to use this directly. However, it can be useful to create caches to improve performances.
Trait Implementations§
source§impl HasSchema for Entity
impl HasSchema for Entity
§fn register_schema()
fn register_schema()
§fn cast<T>(this: &Self) -> &Twhere
T: HasSchema,
fn cast<T>(this: &Self) -> &Twhere
T: HasSchema,
§fn try_cast<T>(this: &Self) -> Result<&T, SchemaMismatchError>where
T: HasSchema,
fn try_cast<T>(this: &Self) -> Result<&T, SchemaMismatchError>where
T: HasSchema,
§fn cast_mut<T>(this: &mut Self) -> &mut Twhere
T: HasSchema,
fn cast_mut<T>(this: &mut Self) -> &mut Twhere
T: HasSchema,
§fn try_cast_mut<T>(this: &mut Self) -> Result<&mut T, SchemaMismatchError>where
T: HasSchema,
fn try_cast_mut<T>(this: &mut Self) -> Result<&mut T, SchemaMismatchError>where
T: HasSchema,
§fn as_schema_ref(&self) -> SchemaRef<'_>where
Self: Sized,
fn as_schema_ref(&self) -> SchemaRef<'_>where
Self: Sized,
T
to a SchemaRef
§fn as_schema_mut(&mut self) -> SchemaRefMut<'_>where
Self: Sized,
fn as_schema_mut(&mut self) -> SchemaRefMut<'_>where
Self: Sized,
T
to a SchemaRefMut
source§impl Ord for Entity
impl Ord for Entity
source§impl PartialEq for Entity
impl PartialEq for Entity
source§impl PartialOrd for Entity
impl PartialOrd for Entity
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moreimpl Copy for Entity
impl Eq for Entity
impl StructuralPartialEq for Entity
Auto Trait Implementations§
impl Freeze for Entity
impl RefUnwindSafe for Entity
impl Send for Entity
impl Sync for Entity
impl Unpin for Entity
impl UnwindSafe for Entity
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
source§impl<T> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere
T: Default,
source§fn from_world(_world: &World) -> T
fn from_world(_world: &World) -> T
Self
using data from the given World
.