With this change Structure
s can’t be placed for free anymore.
I introduced an Inventory
type which is roughly implemented like this:
pub struct Inventory {
items: BTreeMap<Item, usize>,
}
impl Inventory {
pub fn add(&mut self, item: Item, count: usize) {
...
}
pub fn try_take(&mut self, item: &Item, count: usize) -> Option<usize> {
...
}
pub fn n_available(&self, item: &Item) -> usize {
...
}
pub fn starter_inventory() -> Self {
...
}
}
I also updated Planet
to have its own Inventory
. Only Item
s available in it can be placed on the Planet
and will be removed from that Inventory
. When removed from the Planet
, they are added back to the Inventory
.
To then fill up the Planet
‘s Inventory
, Influence
s got their own Inventory
. They now accept any Structure
which is then added to the Influence
‘s Inventory
.
On every tick, the inventories of all Incluence
s are merged into the Planet
‘s.
This way it’s possible to craft structures with your factory that are then available for placement.
The available counts are now displayed in the Structure
overview:
Many Structure
s were only accepting Material
instead of the more generic Item
type which made it impossible to transport Structure
s within the factory. I updated them accordingly.