Planet Structures and Resources

<
>
August 2, 2021

It’s now possible to place Structures also on the Planet. Here they are then simulated and ticked just as if they were part of a Blueprint. It’s also ensured that they can’t be placed on Water tiles.

I then added resource fields that spawn depending on their position’s noise value similar to how Tiles are chosen.

    pub fn material_at(&self, pos: &Pos) -> Option<Material> {
        if let Some(tile) = self.tile_at(pos) {
            if tile.can_hold_resources() {
                ...
                if self.ng.get([x, y, z_copper]) > min {
                    Some(Material::Ore(Ore::Copper))
                } else if self.ng.get([x, y, z_iron]) > min {
                    Some(Material::Ore(Ore::Iron))
                } else if self.ng.get([x, y, z_coal]) > min {
                    Some(Material::Coal)
                } else {
                    None
                }
                ...
    }

Since there’s now resource fields I also added a Structure that can harvest them: The Miner.
Depending on whether there’s resources on the Tile it was placed on its content will be set after the cooldown has passed.