pub struct Entity(/* private fields */);Expand description
ECS Entity tanımlayıcısı — Packed u64 temsili.
Alt 32 bit = entity ID (slot index), üst 32 bit = generation (yeniden kullanım sayacı). Generation, aynı slot’a (ID’ye) yeni bir entity atandığında artırılır ve eski referansların (dangling entity) güvenli şekilde tespit edilmesini sağlar.
§Layout
┌──────────────────────────────────────────────────────────────────┐
│ 63 ───────────── 32 │ 31 ───────────── 0 │
│ generation (u32) │ id (u32) │
└──────────────────────────────────────────────────────────────────┘Implementations§
Source§impl Entity
impl Entity
Sourcepub const INVALID: Entity
pub const INVALID: Entity
Geçersiz / null entity sentinel değeri.
Option<Entity> yerine kullanılabilir (ergonomi ve cache dostu).
Sourcepub fn new(id: u32, generation: u32) -> Entity
pub fn new(id: u32, generation: u32) -> Entity
Builds an Entity handle from an explicit id + generation.
FOOTGUN: if you only have a raw id (e.g. from the UI, a script, or a saved
reference) do NOT fabricate Entity::new(id, 0) to call a generation-checked API
(World::is_alive/entity_component_types/get_entity, queries): once the id slot
has been recycled (despawn→spawn bumps the generation) that gen-0 handle is stale
and silently misses / mis-targets. Use World::entity(id),
which reconstructs the CURRENT generation. new is for deserialization and tests
where the generation is known, or for purely id-keyed internal addressing.
Sourcepub fn generation(self) -> u32
pub fn generation(self) -> u32
Entity’nin generation (nesil) sayacını döndürür.
Sourcepub fn is_valid(self) -> bool
pub fn is_valid(self) -> bool
Bu entity’nin geçerli (INVALID olmayan) olup olmadığını kontrol eder.
Trait Implementations§
impl Copy for Entity
Source§impl<'de> Deserialize<'de> for Entity
impl<'de> Deserialize<'de> for Entity
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Entity, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Entity, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
impl Eq for Entity
Source§impl<'b, 'a> From<EntityBuilder<'b, 'a>> for Entity
impl<'b, 'a> From<EntityBuilder<'b, 'a>> for Entity
Source§fn from(b: EntityBuilder<'b, 'a>) -> Entity
fn from(b: EntityBuilder<'b, 'a>) -> Entity
Source§impl Serialize for Entity
impl Serialize for Entity
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
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 UnsafeUnpin 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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more