pub struct PlacementBuilder<'p, 'a> {
grid: &'p mut GridPlacer<'a>,
rect: Rect,
container: ContainerRef,
mapping: SlotMapping,
kind: SectionKind,
}Fields§
§grid: &'p mut GridPlacer<'a>§rect: Rect§container: ContainerRef§mapping: SlotMapping§kind: SectionKindImplementations§
Source§impl PlacementBuilder<'_, '_>
impl PlacementBuilder<'_, '_>
Sourcepub fn start_at(self, slot: usize) -> Self
pub fn start_at(self, slot: usize) -> Self
Maps the rect’s first cell to container slot slot instead of 0.
Sourcepub fn at_indices(self, indices: impl IntoIterator<Item = usize>) -> Self
pub fn at_indices(self, indices: impl IntoIterator<Item = usize>) -> Self
Maps the rect’s cells (row-major) to these container slots, in the
given order. Replaces start_at.
The committing call panics if the count differs from the rect’s cell count.
Sourcepub fn kind(self, kind: impl Into<SectionKind>) -> Self
pub fn kind(self, kind: impl Into<SectionKind>) -> Self
Lowers the cells through kind, e.g. a SectionKind::Custom factory.
The generalization of restrict, guard
and display.
Sourcepub fn restrict(
self,
may_place: impl Fn(usize, &ItemStack) -> bool + Send + Sync + 'static,
) -> Self
pub fn restrict( self, may_place: impl Fn(usize, &ItemStack) -> bool + Send + Sync + 'static, ) -> Self
Only accepts items passing may_place. Pickup stays allowed.
Sourcepub fn guard(
self,
may_place: impl Fn(usize, &ItemStack) -> bool + Send + Sync + 'static,
may_pickup: impl Fn(usize, &ItemStack, &ContainerLockGuard, &Player) -> bool + Send + Sync + 'static,
) -> Self
pub fn guard( self, may_place: impl Fn(usize, &ItemStack) -> bool + Send + Sync + 'static, may_pickup: impl Fn(usize, &ItemStack, &ContainerLockGuard, &Player) -> bool + Send + Sync + 'static, ) -> Self
Guards both placement and pickup.
Sourcepub fn display(self) -> Self
pub fn display(self) -> Self
Locks the cells as display slots. Clicks are rejected and handled in MenuKind::on_slot_clicked.
Sourcepub fn section(self) -> Section
pub fn section(self) -> Section
Commits the placement and returns its single contiguous Section.
Shorthand for region() followed by
Region::single; use region() when the rect may lower to multiple
slot ranges.
§Panics
Panics if the placement lowers to more than one contiguous slot range. Single-cell and single-row rects can never trip this.
Sourcepub fn result(self, handler: impl ResultHandler + 'static) -> Section
pub fn result(self, handler: impl ResultHandler + 'static) -> Section
Commits a single fake result slot driven by handler, ignoring start_at and guards.
§Panics
If the rect is not a single cell, or the placement container differs
from ResultHandler::result_container.
Auto Trait Implementations§
impl<'p, 'a> !RefUnwindSafe for PlacementBuilder<'p, 'a>
impl<'p, 'a> !UnwindSafe for PlacementBuilder<'p, 'a>
impl<'p, 'a> Freeze for PlacementBuilder<'p, 'a>
impl<'p, 'a> Send for PlacementBuilder<'p, 'a>
impl<'p, 'a> Sync for PlacementBuilder<'p, 'a>
impl<'p, 'a> Unpin for PlacementBuilder<'p, 'a>
impl<'p, 'a> UnsafeUnpin for PlacementBuilder<'p, 'a>
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<>>