pub struct EntityRegistry {
entries: Vec<EntityEntry>,
}Expand description
Registry for entity factories.
Maps EntityType to factory functions that can create entity instances.
This is used when loading entities from disk or when entities are spawned.
Fields§
§entries: Vec<EntityEntry>Implementations§
Source§impl EntityRegistry
impl EntityRegistry
Sourcefn finish_registered_load(entity: &SharedEntity, nbt: &BorrowedNbtCompound<'_>)
fn finish_registered_load(entity: &SharedEntity, nbt: &BorrowedNbtCompound<'_>)
Completes the registered-entity portion of vanilla Entity.load after
the load factory has reconstructed the entity’s base state.
Sourcepub fn register(
&mut self,
entity_type: EntityTypeRef,
factory: fn(EntityTypeRef, i32, DVec3, Weak<World>) -> SharedEntity,
)
pub fn register( &mut self, entity_type: EntityTypeRef, factory: fn(EntityTypeRef, i32, DVec3, Weak<World>) -> SharedEntity, )
Registers a factory function for an entity type.
§Panics
Panics if a factory is already registered for the entity type.
Sourcepub fn register_load(
&mut self,
entity_type: EntityTypeRef,
factory: fn(EntityTypeRef, EntityBaseLoad) -> SharedEntity,
)
pub fn register_load( &mut self, entity_type: EntityTypeRef, factory: fn(EntityTypeRef, EntityBaseLoad) -> SharedEntity, )
Registers a load factory function for an entity type.
The load factory is used when loading entities from disk.
§Panics
Panics if a load factory is already registered for the entity type.
Sourcepub fn create(
&self,
entity_type: EntityTypeRef,
entity_id: i32,
pos: DVec3,
world: Weak<World>,
) -> Option<SharedEntity>
pub fn create( &self, entity_type: EntityTypeRef, entity_id: i32, pos: DVec3, world: Weak<World>, ) -> Option<SharedEntity>
Creates a new entity instance.
Returns None if no factory is registered for the given type.
Sourcepub fn create_and_load_or_raw(
&self,
request: EntityLoadRequest,
nbt: &BorrowedNbtCompound<'_>,
) -> SharedEntity
pub fn create_and_load_or_raw( &self, request: EntityLoadRequest, nbt: &BorrowedNbtCompound<'_>, ) -> SharedEntity
Creates an entity from persisted data, falling back to raw NBT preservation.
Sourcepub fn has_factory(&self, entity_type: EntityTypeRef) -> bool
pub fn has_factory(&self, entity_type: EntityTypeRef) -> bool
Returns whether a factory is registered for the given type.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for EntityRegistry
impl RefUnwindSafe for EntityRegistry
impl Send for EntityRegistry
impl Sync for EntityRegistry
impl Unpin for EntityRegistry
impl UnsafeUnpin for EntityRegistry
impl UnwindSafe for EntityRegistry
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<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> ⓘ
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 moreArc<SyncMutex<>>