I added two new Structure
s. The Assembler
and Splitter
.
Assembler
s can create new output Item
s from input Item
s. Which conversions are valid is defined via Recipe
s that can be assigned to Assembler
s.
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 Item
s:
pub struct Assembler {
pub input: BTreeMap<Item, usize>,
pub out: usize,
pub recipe: Option<&'static Recipe>,
pub cooldown: usize,
}
The Assembler
s Recipe
affects both which Item
s the Assembler
may accept and the Assembler
s 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 Belt
s.
It distributes Item
s from the input to the output Belt
s as evenly as possible.
+----------+
Belt --->---| |=-=>-=- Belt
| |
| Splitter |
| |
Belt ===>===| |-=->=-= Belt
+----------+