#[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 StructuralEq for Entity
impl StructuralPartialEq for Entity
Auto Trait Implementations§
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
§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§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
.