pub struct EntityReference {
uuid: Uuid,
cached: Arc<SyncMutex<Option<WeakEntity>>>,
}Expand description
A UUID reference that re-resolves removed entities within the same domain.
Its cache is weak to avoid entity ownership cycles.
Fields§
§uuid: Uuid§cached: Arc<SyncMutex<Option<WeakEntity>>>Implementations§
Source§impl EntityReference
impl EntityReference
Sourcepub fn from_entity(entity: &SharedEntity) -> Self
pub fn from_entity(entity: &SharedEntity) -> Self
Creates a reference with a weak cache of a live entity.
Sourcepub fn read(nbt: &BorrowedNbtCompoundView<'_, '_>, key: &str) -> Option<Self>
pub fn read(nbt: &BorrowedNbtCompoundView<'_, '_>, key: &str) -> Option<Self>
Reads a UUID reference; absent or malformed values have no reference.
Sourcepub fn cache_entity(&self, entity: &SharedEntity)
pub fn cache_entity(&self, entity: &SharedEntity)
Caches an entity only when its UUID matches this reference.
Sourcepub fn get_entity(&self, world: &World) -> Option<SharedEntity>
pub fn get_entity(&self, world: &World) -> Option<SharedEntity>
Resolves a live cache, then the UUID in any loaded world in this domain.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for EntityReference
impl !UnwindSafe for EntityReference
impl Freeze for EntityReference
impl Send for EntityReference
impl Sync for EntityReference
impl Unpin for EntityReference
impl UnsafeUnpin for EntityReference
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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> ⓘ
Converts
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> ⓘ
Converts
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 moreWraps this value in an
Arc<SyncMutex<>>