pub struct PositionedCraftingInput {
pub input: CraftingInput,
pub left: usize,
pub top: usize,
}Expand description
A crafting input with position information.
This represents a trimmed crafting grid (containing only the bounding box of non-empty items) along with the offset from the original grid origin. This is used when consuming ingredients to correctly map recipe slots back to the original crafting grid slots.
Fields§
§input: CraftingInputThe trimmed crafting input.
left: usizeThe X offset from the original grid origin.
top: usizeThe Y offset from the original grid origin.
Implementations§
Source§impl PositionedCraftingInput
impl PositionedCraftingInput
Sourcepub const EMPTY: PositionedCraftingInput
pub const EMPTY: PositionedCraftingInput
An empty positioned crafting input.
Sourcepub fn to_grid_slot(&self, x: usize, y: usize, grid_width: usize) -> usize
pub fn to_grid_slot(&self, x: usize, y: usize, grid_width: usize) -> usize
Converts a position in the trimmed input back to the original grid slot index.
§Arguments
x- X position in the trimmed input (0 to input.width-1)y- Y position in the trimmed input (0 to input.height-1)grid_width- Width of the original crafting grid
§Returns
The slot index in the original crafting grid.
Trait Implementations§
Source§impl Clone for PositionedCraftingInput
impl Clone for PositionedCraftingInput
Source§fn clone(&self) -> PositionedCraftingInput
fn clone(&self) -> PositionedCraftingInput
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for PositionedCraftingInput
impl RefUnwindSafe for PositionedCraftingInput
impl Send for PositionedCraftingInput
impl Sync for PositionedCraftingInput
impl Unpin for PositionedCraftingInput
impl UnsafeUnpin for PositionedCraftingInput
impl UnwindSafe for PositionedCraftingInput
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