Assembler and Splitter

<
>
July 4, 2021

I added two new Structures. The Assembler and Splitter.
Assemblers can create new output Items from input Items. Which conversions are valid is defined via Recipes that can be assigned to Assemblers.

pub struct Recipe {
    pub cost: &'static [(usize, Item)],
    pub out: (usize, Item),
}

A concrete Recipe might look like this:

pub const REC_WIRE: Recipe = Recipe {
    cost: &[(1, Item::Material(Material::Plate(Plate::Copper)))],
    out: (1, Item::Material(Material::Wire)),
};

Below part of the new Assembler’s definition. It has an optional reference to a Recipe and keeps track of its input and output Items:

pub struct Assembler {
    pub input: BTreeMap<Item, usize>,
    pub out: usize,
    pub recipe: Option<&'static Recipe>,
    pub cooldown: usize,
}

The Assemblers Recipe affects both which Items the Assembler may accept and the Assemblers behavior in case of a tick() where the input might be converted to output.

The newly added Splitter can be connected to up to two input and two output Belts.
It distributes Items from the input to the output Belts as evenly as possible.

            +----------+
Belt --->---|          |=-=>-=- Belt
            |          |
            | Splitter |
            |          |
Belt ===>===|          |-=->=-= Belt
            +----------+