Skip to main content

Storage

Struct Storage 

Source
pub struct Storage {
    pub capacity: i32,
    pub accepts: u32,
    pub items: Vec<Item>,
}
Expand description

A storage: its capacity and the goods in it, with their reservations.

Fields§

§capacity: i32

The capacity.

§accepts: u32

The flags of the goods it accepts.

§items: Vec<Item>

The goods in it.

Implementations§

Source§

impl Storage

Source

pub fn used(&self, materials: &[RawMaterial]) -> i32

Weighted occupancy (includes reserved goods).

Original: FUN_1401323e0.

Source

pub fn fits( &self, materials: &[RawMaterial], material: usize, count: i32, ) -> bool

Whether count units of a material fit in the storage.

Original: FUN_140132250, FUN_140131a30.

Source

pub fn entry(&self, material: usize) -> Option<&Item>

The entry of a material.

Source

pub fn available(&self, material: usize) -> i32

Quantity available for another task.

Original: FUN_14011bc90.

Source

pub fn add(&mut self, material: usize, count: i32)

Merge in place, otherwise append with no reservation.

Original: FUN_1401324d0.

Source

pub fn remove(&mut self, material: usize, count: i32)

Subtract, erase exactly-zero entries preserving order; no clamp.

Original: FUN_140132620.

Source

pub fn reserve(&mut self, material: usize, count: i32)

Reserve when building a task, not on arrival.

Original: FUN_1400cb980, FUN_1400cf700.

Source

pub fn unreserve(&mut self, material: usize, count: i32)

Release a reservation, when a task is cancelled or before the goods are used or moved.

Original: FUN_1400cb300, FUN_1400cf140 (cancel).

Source

pub fn find_item( &self, materials: &[RawMaterial], category: u32, rng: &mut Random, ) -> Option<usize>

Search category 0 food, 1 fuel, 2 tool, 3 herb, 4 clothing. Even a single eligible unpreferred material draws Rand(1).

Original: FUN_140094410.

Trait Implementations§

Source§

impl Clone for Storage

Source§

fn clone(&self) -> Storage

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Storage

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Storage

Source§

fn default() -> Storage

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.