pub struct WorldEntityManager {
state: SyncRwLock<ManagerState>,
}Expand description
Central world entity manager.
Fields§
§state: SyncRwLock<ManagerState>Implementations§
Source§impl WorldEntityManager
impl WorldEntityManager
Sourcepub(crate) fn is_chunk_loaded(&self, pos: ChunkPos) -> bool
pub(crate) fn is_chunk_loaded(&self, pos: ChunkPos) -> bool
Returns whether runtime entity ownership for this chunk is loaded.
This is Vanilla’s separate areEntitiesLoaded gate used by block-entity
ticking; it is intentionally not the stricter entity-ticking visibility.
Sourcepub fn on_chunk_loaded(&self, pos: ChunkPos) -> ChunkEntityLoadResult
pub fn on_chunk_loaded(&self, pos: ChunkPos) -> ChunkEntityLoadResult
Marks a chunk as loaded and reactivates retained unloading entities.
Sourcepub fn update_chunk_visibility(
&self,
pos: ChunkPos,
visibility: EntityVisibility,
) -> EntityLifecycleChanges
pub fn update_chunk_visibility( &self, pos: ChunkPos, visibility: EntityVisibility, ) -> EntityLifecycleChanges
Updates the entity visibility for a chunk column.
fn push_unique_entity( entity: &SharedEntity, seen: &mut FxHashSet<i32>, entities: &mut Vec<SharedEntity>, )
Sourcepub fn begin_chunk_unload(&self, pos: ChunkPos) -> ChunkEntityUnloadStart
pub fn begin_chunk_unload(&self, pos: ChunkPos) -> ChunkEntityUnloadStart
Moves manager-owned root entities in pos out of live world membership while
retaining them for possible chunk recovery.
fn retain_unloading_entity_tree( state: &mut ManagerState, entity_id: i32, visited: &mut FxHashSet<i32>, retained: &mut Vec<EntityEntry>, retained_entities: &mut Vec<SharedEntity>, tracking_stopped_ids: &mut FxHashSet<i32>, tracking_stopped: &mut Vec<SharedEntity>, )
Sourcepub fn finalize_chunk_unload(&self, pos: ChunkPos)
pub fn finalize_chunk_unload(&self, pos: ChunkPos)
Finalizes an unloading chunk. Retained entities are detached and dropped.
Sourcepub fn add_live_entity(
&self,
entity: SharedEntity,
ownership: EntityOwnership,
) -> Result<EntityLifecycleChanges, AddEntityError>
pub fn add_live_entity( &self, entity: SharedEntity, ownership: EntityOwnership, ) -> Result<EntityLifecycleChanges, AddEntityError>
Registers a live runtime entity.
§Panics
Panics if an entity with the same session network ID is already present. Duplicate runtime IDs indicate corrupted manager ownership and cannot be recovered without losing identity.
Sourcepub fn add_live_entity_tree(
&self,
entities: &[SharedEntity],
ownership: EntityOwnership,
) -> Result<EntityLifecycleChanges, AddEntityError>
pub fn add_live_entity_tree( &self, entities: &[SharedEntity], ownership: EntityOwnership, ) -> Result<EntityLifecycleChanges, AddEntityError>
Adds a related group of live entities atomically.
Use this for persisted vehicle/passenger trees so registration either publishes the whole tree or leaves world indexes unchanged.
§Panics
Panics if the entity tree contains the same session network ID more than once. Duplicate runtime IDs indicate corrupted ownership.
fn checked_live_entry( entity: SharedEntity, ownership: EntityOwnership, ) -> Result<EntityEntry, AddEntityError>
fn validate_live_entries( state: &ManagerState, entries: &[EntityEntry], ownership: EntityOwnership, require_loaded_chunks: bool, ) -> Result<(), AddEntityError>
Sourcepub fn remove_live_entity(
&self,
entity_id: i32,
reason: RemovalReason,
) -> Option<SharedEntity>
pub fn remove_live_entity( &self, entity_id: i32, reason: RemovalReason, ) -> Option<SharedEntity>
Removes a live entity for an explicit entity removal reason.
Sourcepub fn on_chunk_saved(&self, chunk: ChunkPos, saved_entity_ids: &[i32])
pub fn on_chunk_saved(&self, chunk: ChunkPos, saved_entity_ids: &[i32])
Acknowledges that selected save-pending entities for chunk were persisted.
Sourcepub fn has_save_pending_for_chunk(&self, chunk: ChunkPos) -> bool
pub fn has_save_pending_for_chunk(&self, chunk: ChunkPos) -> bool
Returns whether chunk has removed runtime entities waiting for a save acknowledgement.
Sourcepub fn validate_move(
&self,
entity_id: i32,
new_pos: DVec3,
) -> Result<(), EntityMoveError>
pub fn validate_move( &self, entity_id: i32, new_pos: DVec3, ) -> Result<(), EntityMoveError>
Validates that a live entity can move to new_pos.
Sourcepub fn commit_move(
&self,
entity_id: i32,
new_pos: DVec3,
) -> Result<EntityMoveUpdate, EntityMoveError>
pub fn commit_move( &self, entity_id: i32, new_pos: DVec3, ) -> Result<EntityMoveUpdate, EntityMoveError>
Commits manager indexes after a live entity position change.
Sourcepub fn commit_bounding_box_change(&self, entity_id: i32)
pub fn commit_bounding_box_change(&self, entity_id: i32)
Commits a live entity bounding-box change to the spatial query index.
Reads the current bounds after acquiring the manager lock so concurrent callbacks may complete in either order without restoring stale bounds.
fn can_move_manager_owned_to_chunk( state: &ManagerState, entry: &EntityEntry, new_chunk: ChunkPos, ) -> bool
fn has_live_loaded_root_vehicle( state: &ManagerState, entity: &SharedEntity, ) -> bool
Sourcepub fn get_by_id(&self, entity_id: i32) -> Option<SharedEntity>
pub fn get_by_id(&self, entity_id: i32) -> Option<SharedEntity>
Gets a live entity by session network ID.
Sourcepub fn contains_live_or_unloading_entity(&self, entity: &SharedEntity) -> bool
pub fn contains_live_or_unloading_entity(&self, entity: &SharedEntity) -> bool
Returns true if this exact entity is live or retained for chunk-unload recovery.
Sourcepub fn get_accessible_by_id(&self, entity_id: i32) -> Option<SharedEntity>
pub fn get_accessible_by_id(&self, entity_id: i32) -> Option<SharedEntity>
Gets a live entity by session network ID if it is visible to vanilla gameplay lookups.
Sourcepub fn get_by_uuid(&self, uuid: &Uuid) -> Option<SharedEntity>
pub fn get_by_uuid(&self, uuid: &Uuid) -> Option<SharedEntity>
Gets a live entity by persistent UUID.
Sourcepub fn get_entities_in_aabb_matching(
&self,
aabb: &WorldAabb,
predicate: impl FnMut(&dyn Entity) -> bool,
) -> Vec<SharedEntity> ⓘ
pub fn get_entities_in_aabb_matching( &self, aabb: &WorldAabb, predicate: impl FnMut(&dyn Entity) -> bool, ) -> Vec<SharedEntity> ⓘ
Gets live entities whose bounding boxes intersect aabb and match predicate.
Sourcepub fn has_entity_in_aabb_matching(
&self,
aabb: &WorldAabb,
predicate: impl FnMut(&dyn Entity) -> bool,
) -> bool
pub fn has_entity_in_aabb_matching( &self, aabb: &WorldAabb, predicate: impl FnMut(&dyn Entity) -> bool, ) -> bool
Returns whether any live entity intersects aabb and matches predicate.
Sourcepub fn get_entity_bounding_boxes_in_aabb_matching(
&self,
aabb: &WorldAabb,
predicate: impl FnMut(&dyn Entity) -> bool,
) -> Vec<WorldAabb> ⓘ
pub fn get_entity_bounding_boxes_in_aabb_matching( &self, aabb: &WorldAabb, predicate: impl FnMut(&dyn Entity) -> bool, ) -> Vec<WorldAabb> ⓘ
Gets matching live entity bounding boxes that intersect aabb.
Sourcepub fn nearest_entity_in_aabb_matching(
&self,
aabb: &WorldAabb,
origin: DVec3,
predicate: impl FnMut(&dyn Entity) -> bool,
) -> Option<SharedEntity>
pub fn nearest_entity_in_aabb_matching( &self, aabb: &WorldAabb, origin: DVec3, predicate: impl FnMut(&dyn Entity) -> bool, ) -> Option<SharedEntity>
Gets the nearest live entity whose bounding box intersects aabb and matches predicate.
Sourcepub fn get_entities_in_aabb(&self, aabb: &WorldAabb) -> Vec<SharedEntity> ⓘ
pub fn get_entities_in_aabb(&self, aabb: &WorldAabb) -> Vec<SharedEntity> ⓘ
Gets live entities whose bounding boxes intersect aabb.
Sourcepub fn get_accessible_entities(&self) -> Vec<SharedEntity> ⓘ
pub fn get_accessible_entities(&self) -> Vec<SharedEntity> ⓘ
Gets all live entities visible to vanilla gameplay lookups.
fn entity_query_entries<'a>( state: &'a ManagerState, aabb: &WorldAabb, ) -> Vec<&'a EntityEntry>
fn entity_ids_in_chunk_order(state: &ManagerState, chunk: ChunkPos) -> Vec<i32>
Sourcepub fn saveable_entities_outside_chunks(
&self,
saved_chunks: &[ChunkPos],
) -> Vec<UnsavedEntityReport>
pub fn saveable_entities_outside_chunks( &self, saved_chunks: &[ChunkPos], ) -> Vec<UnsavedEntityReport>
Reports saveable entities whose chunks were not part of a chunk save pass.
Sourcepub fn get_saveable_entities_for_chunk(
&self,
chunk: ChunkPos,
) -> Vec<SharedEntity> ⓘ
pub fn get_saveable_entities_for_chunk( &self, chunk: ChunkPos, ) -> Vec<SharedEntity> ⓘ
Gets entities that should be serialized for chunk.
Sourcepub fn live_entities_in_chunk(&self, chunk: ChunkPos) -> Vec<SharedEntity> ⓘ
pub fn live_entities_in_chunk(&self, chunk: ChunkPos) -> Vec<SharedEntity> ⓘ
Gets live entities currently indexed in chunk.
Sourcepub fn tick_entities(
&self,
_tick_count: i32,
runs_normally: bool,
) -> FxHashSet<ChunkPos>
pub fn tick_entities( &self, _tick_count: i32, runs_normally: bool, ) -> FxHashSet<ChunkPos>
Ticks live entities currently in the ticking visibility set.
fn ticking_entities_snapshot(&self) -> Vec<SharedEntity> ⓘ
fn live_manager_owned_entity_chunk(&self, entity_id: i32) -> Option<ChunkPos>
fn chunk_visibility(state: &ManagerState, chunk: ChunkPos) -> EntityVisibility
fn effective_visibility( entry: &EntityEntry, chunk_visibility: EntityVisibility, ) -> EntityVisibility
fn lifecycle_visibility_for( entry: &EntityEntry, chunk_visibility: EntityVisibility, ) -> EntityVisibility
fn apply_entity_lifecycle_after_insert( state: &mut ManagerState, entity_id: i32, ) -> EntityLifecycleChanges
fn apply_chunk_visibility_change( state: &mut ManagerState, chunk: ChunkPos, previous: EntityVisibility, new: EntityVisibility, ) -> EntityLifecycleChanges
fn is_entity_frozen_by_tick_rate( entity: &dyn Entity, runs_normally: bool, ) -> bool
fn has_pending_world_change_in_vehicle_chain(entity: &SharedEntity) -> bool
fn is_accessible(state: &ManagerState, entry: &EntityEntry) -> bool
fn is_accessible_at( state: &ManagerState, ownership: EntityOwnership, chunk: ChunkPos, ) -> bool
fn is_valid_passenger_or_stop_riding(entity: &SharedEntity) -> bool
fn assert_acyclic_vehicle_chain(entity: &SharedEntity)
fn tick_non_passenger( &self, entity: &SharedEntity, ticked_entities: &mut FxHashSet<i32>, dirty_chunks: &mut FxHashSet<ChunkPos>, )
fn tick_vehicle_passengers_with_ticked( &self, vehicle: &dyn Entity, ticked_entities: &mut FxHashSet<i32>, dirty_chunks: &mut FxHashSet<ChunkPos>, )
fn mark_dirty_after_tick( &self, entity: &SharedEntity, dirty_chunks: &mut FxHashSet<ChunkPos>, )
fn can_tick_entity_now(&self, entity_id: i32) -> bool
fn insert_live_entry(state: &mut ManagerState, entry: EntityEntry)
fn contains_uuid(state: &ManagerState, uuid: Uuid) -> bool
fn contains_id(state: &ManagerState, entity_id: i32) -> bool
fn push_saveable_entity( result: &mut Vec<SharedEntity>, seen_ids: &mut FxHashSet<i32>, seen_uuids: &mut FxHashSet<Uuid>, entry: &EntityEntry, )
fn push_unsaved_entity_report( saved_chunks: &FxHashSet<ChunkPos>, seen: &mut FxHashSet<i32>, reports: &mut Vec<UnsavedEntityReport>, entry: &EntityEntry, )
fn remove_live_entry( state: &mut ManagerState, entity_id: i32, ) -> Option<EntityEntry>
fn next_section_order(state: &mut ManagerState) -> u64
fn insert_into_spatial_cells( state: &mut ManagerState, cells: &[EntitySpatialCell], entity_id: i32, query_order: EntityQueryOrder, )
fn remove_from_spatial_cells( state: &mut ManagerState, cells: &[EntitySpatialCell], entity_id: i32, )
fn remove_from_section( state: &mut ManagerState, section: SectionPos, entity_id: i32, )
fn remove_from_chunk(state: &mut ManagerState, chunk: ChunkPos, entity_id: i32)
Trait Implementations§
Source§impl Debug for WorldEntityManager
impl Debug for WorldEntityManager
Auto Trait Implementations§
impl !Freeze for WorldEntityManager
impl !RefUnwindSafe for WorldEntityManager
impl !UnwindSafe for WorldEntityManager
impl Send for WorldEntityManager
impl Sync for WorldEntityManager
impl Unpin for WorldEntityManager
impl UnsafeUnpin for WorldEntityManager
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<>>