Dynamic and Cooldowns

<
>
December 15, 2020

Up until now there was no cooldown for Structures. Belts and Arms would move an Item as soon as it’s given to them.
I introduced a trait for types that change over time.

pub trait Dynamic {
    fn tick(&mut self);
}

The updated Furnace code for example now looks like this:

impl Dynamic for Furnace {
    fn tick(&mut self) {
        self.cooldown = self.cooldown.saturating_sub(1);
        if self.cooldown == 0 {
            self.cooldown = 500;
            match (self.product, &self.coal, self.ore) {
                (None, Some(Material::Coal), Some(ore)) => {
                    self.coal = None;
                    self.ore = None;
                    self.product = Some(ore.smelted());
                }
                _ => (),
            }
        }
    }
}