Skip to main content

Assembler

Struct Assembler 

Source
pub struct Assembler<R: AssemblerRecipe>(/* private fields */);
Expand description

The assembler can craft most items in the game.

To use, first build the assembler using Assembler::build, providing the desired recipe and the required resources. Then, add inputs using inputs, for example assembler.inputs(&tick).0.add(bundle). The assembler will automatically process the inputs over time, which can be advanced using the Tick. Outputs can be extracted using outputs, for example assembler.outputs(&tick).0.bundle::<1>(). If you want to change the recipe, use change_recipe, but ensure the assembler is empty first.

See the implementors of the AssemblerRecipe trait for recipes that can be used in the assembler.

Implementations§

Source§

impl<R: AssemblerRecipe> Assembler<R>

Source

pub fn build( tick: &Tick, recipe: R, copper_wires: Bundle<CopperWire, 12>, iron: Bundle<Iron, 6>, ) -> Self

Builds an assembler. Costs 12 copper wires and 6 iron.

Source

pub fn change_recipe<R2: AssemblerRecipe>( self, recipe: R2, ) -> Result<Assembler<R2>, MachineNotEmptyError<Self>>

Changes the Recipe of the assembler. Returns the original assembler if the the input and output buffers are not empty.

Source

pub fn inputs(&mut self, tick: &Tick) -> &mut <R as Recipe>::Inputs

Update internal state and access input buffers.

Source

pub const fn input_amounts(&self) -> <R as Recipe>::InputAmountsType

Amount of each input resource needed for one recipe cycle

Source

pub fn outputs(&mut self, tick: &Tick) -> &mut <R as Recipe>::Outputs

Update internal state and access output buffers.

Source

pub const fn output_amounts(&self) -> <R as Recipe>::OutputAmountsType

Amount of each output resource created per recipe cycle

Trait Implementations§

Source§

impl<R: Debug + AssemblerRecipe> Debug for Assembler<R>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<R> Freeze for Assembler<R>
where <R as Recipe>::Inputs: Freeze, <R as Recipe>::Outputs: Freeze,

§

impl<R> RefUnwindSafe for Assembler<R>

§

impl<R> Send for Assembler<R>
where <R as Recipe>::Inputs: Send, <R as Recipe>::Outputs: Send,

§

impl<R> Sync for Assembler<R>
where <R as Recipe>::Inputs: Sync, <R as Recipe>::Outputs: Sync,

§

impl<R> Unpin for Assembler<R>
where <R as Recipe>::Inputs: Unpin, <R as Recipe>::Outputs: Unpin,

§

impl<R> UnwindSafe for Assembler<R>
where <R as Recipe>::Inputs: UnwindSafe, <R as Recipe>::Outputs: UnwindSafe,

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> 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, 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.