pub struct PointOfInterestStorage {
columns: FxHashMap<ChunkPos, FxHashMap<i32, PointOfInterestSet>>,
}Expand description
World-level storage for all points of interest.
Organized as a two-level map: ChunkPos -> section_y -> PointOfInterestSet.
This structure mirrors chunk lifecycle (load/unload per column) and provides
efficient spatial queries by narrowing to relevant columns first.
Fields§
§columns: FxHashMap<ChunkPos, FxHashMap<i32, PointOfInterestSet>>Implementations§
Source§impl PointOfInterestStorage
impl PointOfInterestStorage
fn get_or_create_set( &mut self, chunk_pos: ChunkPos, section_y: i32, ) -> &mut PointOfInterestSet
Sourcepub fn add(&mut self, pos: BlockPos, poi_type_id: usize, max_tickets: u32)
pub fn add(&mut self, pos: BlockPos, poi_type_id: usize, max_tickets: u32)
Adds a POI at the given block position.
Sourcepub fn get_type(&self, pos: BlockPos) -> Option<usize>
pub fn get_type(&self, pos: BlockPos) -> Option<usize>
Returns the POI type ID at the given position, if any.
Sourcepub fn is_occupied(&self, pos: BlockPos) -> bool
pub fn is_occupied(&self, pos: BlockPos) -> bool
Returns true if the POI at the given position has all tickets reserved.
Sourcepub fn reserve_ticket(&mut self, pos: BlockPos) -> bool
pub fn reserve_ticket(&mut self, pos: BlockPos) -> bool
Reserves a ticket at the given position. Returns true if successful.
Sourcepub fn release_ticket(&mut self, pos: BlockPos) -> bool
pub fn release_ticket(&mut self, pos: BlockPos) -> bool
Releases a ticket at the given position. Returns true if successful.
Sourcepub fn get_in_chunk(
&self,
type_predicate: &impl Fn(usize) -> bool,
chunk_x: i32,
chunk_z: i32,
status: OccupationStatus,
) -> Vec<(BlockPos, usize)>
pub fn get_in_chunk( &self, type_predicate: &impl Fn(usize) -> bool, chunk_x: i32, chunk_z: i32, status: OccupationStatus, ) -> Vec<(BlockPos, usize)>
Returns all matching POIs in a specific chunk column.
Sourcepub fn get_in_square(
&self,
type_predicate: &impl Fn(usize) -> bool,
center: BlockPos,
radius: i32,
status: OccupationStatus,
) -> Vec<(BlockPos, usize)>
pub fn get_in_square( &self, type_predicate: &impl Fn(usize) -> bool, center: BlockPos, radius: i32, status: OccupationStatus, ) -> Vec<(BlockPos, usize)>
Returns all matching POIs within a cubic region centered on center.
Sourcepub fn get_in_horizontal_square(
&self,
type_predicate: &impl Fn(usize) -> bool,
center: BlockPos,
radius: i32,
status: OccupationStatus,
) -> Vec<(BlockPos, usize)>
pub fn get_in_horizontal_square( &self, type_predicate: &impl Fn(usize) -> bool, center: BlockPos, radius: i32, status: OccupationStatus, ) -> Vec<(BlockPos, usize)>
Returns all matching POIs within a vanilla horizontal square centered on center.
Mirrors PoiManager.getInSquare: X/Z are constrained by radius, while Y is not.
Sourcepub fn count(
&self,
type_predicate: &impl Fn(usize) -> bool,
pos: BlockPos,
radius: i32,
status: OccupationStatus,
) -> usize
pub fn count( &self, type_predicate: &impl Fn(usize) -> bool, pos: BlockPos, radius: i32, status: OccupationStatus, ) -> usize
Counts matching POIs within a spherical region.
Sourcefn count_in_square(
&self,
type_predicate: &impl Fn(usize) -> bool,
center: BlockPos,
radius: i32,
status: OccupationStatus,
filter: &impl Fn(BlockPos) -> bool,
) -> usize
fn count_in_square( &self, type_predicate: &impl Fn(usize) -> bool, center: BlockPos, radius: i32, status: OccupationStatus, filter: &impl Fn(BlockPos) -> bool, ) -> usize
Counts matching POIs within a cubic region, filtered by an additional predicate.
Sourcepub fn scan_and_populate(
&mut self,
section: &ChunkSection,
section_pos: SectionPos,
)
pub fn scan_and_populate( &mut self, section: &ChunkSection, section_pos: SectionPos, )
Scans a chunk section for POI block states and populates the storage.
§Panics
Panics if the POI type registry contains an inconsistent state-to-type mapping.
Sourcepub fn on_block_state_change(
&mut self,
pos: BlockPos,
old_state: BlockStateId,
new_state: BlockStateId,
)
pub fn on_block_state_change( &mut self, pos: BlockPos, old_state: BlockStateId, new_state: BlockStateId, )
Updates POI storage when a block state changes.
§Panics
Panics if the POI type registry contains an inconsistent state-to-type mapping.
Sourcepub fn collect_for_chunk(&self, chunk_pos: ChunkPos) -> Vec<(BlockPos, u32)>
pub fn collect_for_chunk(&self, chunk_pos: ChunkPos) -> Vec<(BlockPos, u32)>
Collects all POI data in a chunk column for persistence.
Returns (BlockPos, free_tickets) for each POI.
Sourcepub fn restore_tickets(
&mut self,
chunk_pos: ChunkPos,
tickets: &[(BlockPos, u32)],
)
pub fn restore_tickets( &mut self, chunk_pos: ChunkPos, tickets: &[(BlockPos, u32)], )
Restores ticket state for POIs after loading from disk.
Called after scan_and_populate has created fresh POIs from block states.
Applies saved free_tickets values to matching positions.
Sourcepub fn remove_chunk(&mut self, chunk_pos: ChunkPos)
pub fn remove_chunk(&mut self, chunk_pos: ChunkPos)
Removes all POI data for a chunk column. Called during chunk unload.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for PointOfInterestStorage
impl RefUnwindSafe for PointOfInterestStorage
impl Send for PointOfInterestStorage
impl Sync for PointOfInterestStorage
impl Unpin for PointOfInterestStorage
impl UnsafeUnpin for PointOfInterestStorage
impl UnwindSafe for PointOfInterestStorage
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<>>