diff --git a/assets/world/manifests/dungeon_entrances.ron b/assets/world/manifests/dungeon_entrances/grassland.ron similarity index 87% rename from assets/world/manifests/dungeon_entrances.ron rename to assets/world/manifests/dungeon_entrances/grassland.ron index bf24627572..54576d09d1 100644 --- a/assets/world/manifests/dungeon_entrances.ron +++ b/assets/world/manifests/dungeon_entrances/grassland.ron @@ -1,48 +1,44 @@ -#![enable(unwrap_newtypes)] - -[ - ( - specifier: "world.structure.dungeon.jungle_temple.entrance.1", - center: (50, 40, 10) - ), - ( - specifier: "world.structure.dungeon.pillar_entrance.round.1", - center: (21, 17, 28) - ), - ( - specifier: "world.structure.dungeon.pillar_entrance.round.2", - center: (20, 28, 15) - ), - ( - specifier: "world.structure.dungeon.pillar_entrance.1", - center: (18, 16, 17) - ), - ( - specifier: "world.structure.dungeon.pillar_entrance.2", - center: (18, 16, 17) - ), - ( - specifier: "world.structure.dungeon.pillar_entrance.3", - center: (18, 16, 17) - ), - ( - specifier: "world.structure.dungeon.pillar_entrance.4", - center: (18, 16, 17) - ), - ( - specifier: "world.structure.dungeon.pillar_entrance.5", - center: (18, 16, 17) - ), - ( - specifier: "world.structure.dungeon.pillar_entrance.6", - center: (18, 16, 17) - ), - ( - specifier: "world.structure.dungeon.temperate_entrance.ruins_4", - center: (13, 11, 14) - ), - ( - specifier: "world.structure.dungeon.misc_entrance.tower-ruin", - center: (13, 16, 9) - ), -] +#![enable(unwrap_newtypes)] + +[ + ( + specifier: "world.structure.dungeon.pillar_entrance.round.1", + center: (21, 17, 28) + ), + ( + specifier: "world.structure.dungeon.pillar_entrance.round.2", + center: (20, 28, 15) + ), + ( + specifier: "world.structure.dungeon.pillar_entrance.1", + center: (18, 16, 17) + ), + ( + specifier: "world.structure.dungeon.pillar_entrance.2", + center: (18, 16, 17) + ), + ( + specifier: "world.structure.dungeon.pillar_entrance.3", + center: (18, 16, 17) + ), + ( + specifier: "world.structure.dungeon.pillar_entrance.4", + center: (18, 16, 17) + ), + ( + specifier: "world.structure.dungeon.pillar_entrance.5", + center: (18, 16, 17) + ), + ( + specifier: "world.structure.dungeon.pillar_entrance.6", + center: (18, 16, 17) + ), + ( + specifier: "world.structure.dungeon.temperate_entrance.ruins_4", + center: (13, 11, 14) + ), + ( + specifier: "world.structure.dungeon.misc_entrance.tower-ruin", + center: (13, 16, 9) + ), +] diff --git a/assets/world/manifests/dungeon_entrances/jungle.ron b/assets/world/manifests/dungeon_entrances/jungle.ron new file mode 100644 index 0000000000..1f4bb2f5c3 --- /dev/null +++ b/assets/world/manifests/dungeon_entrances/jungle.ron @@ -0,0 +1,8 @@ +#![enable(unwrap_newtypes)] + +[ + ( + specifier: "world.structure.dungeon.jungle_temple.entrance.1", + center: (50, 40, 10) + ), +] diff --git a/assets/world/manifests/acacias.ron b/assets/world/manifests/trees/acacias.ron similarity index 100% rename from assets/world/manifests/acacias.ron rename to assets/world/manifests/trees/acacias.ron diff --git a/assets/world/manifests/baobabs.ron b/assets/world/manifests/trees/baobabs.ron similarity index 100% rename from assets/world/manifests/baobabs.ron rename to assets/world/manifests/trees/baobabs.ron diff --git a/assets/world/manifests/birch.ron b/assets/world/manifests/trees/birch.ron similarity index 100% rename from assets/world/manifests/birch.ron rename to assets/world/manifests/trees/birch.ron diff --git a/assets/world/manifests/fruit_trees.ron b/assets/world/manifests/trees/fruit_trees.ron similarity index 100% rename from assets/world/manifests/fruit_trees.ron rename to assets/world/manifests/trees/fruit_trees.ron diff --git a/assets/world/manifests/mangrove_trees.ron b/assets/world/manifests/trees/mangrove_trees.ron similarity index 100% rename from assets/world/manifests/mangrove_trees.ron rename to assets/world/manifests/trees/mangrove_trees.ron diff --git a/assets/world/manifests/oak_stumps.ron b/assets/world/manifests/trees/oak_stumps.ron similarity index 100% rename from assets/world/manifests/oak_stumps.ron rename to assets/world/manifests/trees/oak_stumps.ron diff --git a/assets/world/manifests/oaks.ron b/assets/world/manifests/trees/oaks.ron similarity index 100% rename from assets/world/manifests/oaks.ron rename to assets/world/manifests/trees/oaks.ron diff --git a/assets/world/manifests/palms.ron b/assets/world/manifests/trees/palms.ron similarity index 100% rename from assets/world/manifests/palms.ron rename to assets/world/manifests/trees/palms.ron diff --git a/assets/world/manifests/pines.ron b/assets/world/manifests/trees/pines.ron similarity index 100% rename from assets/world/manifests/pines.ron rename to assets/world/manifests/trees/pines.ron diff --git a/assets/world/manifests/quirky.ron b/assets/world/manifests/trees/quirky.ron similarity index 100% rename from assets/world/manifests/quirky.ron rename to assets/world/manifests/trees/quirky.ron diff --git a/assets/world/manifests/quirky_dry.ron b/assets/world/manifests/trees/quirky_dry.ron similarity index 100% rename from assets/world/manifests/quirky_dry.ron rename to assets/world/manifests/trees/quirky_dry.ron diff --git a/assets/world/manifests/swamp_trees.ron b/assets/world/manifests/trees/swamp_trees.ron similarity index 100% rename from assets/world/manifests/swamp_trees.ron rename to assets/world/manifests/trees/swamp_trees.ron diff --git a/world/examples/dungeon_voxel_export.rs b/world/examples/dungeon_voxel_export.rs index e0971c351b..2f8b157b81 100644 --- a/world/examples/dungeon_voxel_export.rs +++ b/world/examples/dungeon_voxel_export.rs @@ -43,7 +43,7 @@ fn main() -> Result { CanvasInfo::with_mock_canvas_info(index.as_index_ref(), world.sim(), |canvas| { for plot in site.plots() { if let PlotKind::Dungeon(dungeon) = plot.kind() { - let (prim_tree, fills) = dungeon.render_collect(&site); + let (prim_tree, fills) = dungeon.render_collect(&site, &canvas.land()); for (prim, fill) in fills { let aabb = fill.get_bounds(&prim_tree, prim); diff --git a/world/src/layer/tree.rs b/world/src/layer/tree.rs index 27fdf48dfa..baad42868d 100644 --- a/world/src/layer/tree.rs +++ b/world/src/layer/tree.rs @@ -20,19 +20,21 @@ use std::{f32, ops::Range}; use vek::*; lazy_static! { - static ref OAKS: AssetHandle = Structure::load_group("oaks"); - static ref OAK_STUMPS: AssetHandle = Structure::load_group("oak_stumps"); - static ref PINES: AssetHandle = Structure::load_group("pines"); - static ref PALMS: AssetHandle = Structure::load_group("palms"); - static ref ACACIAS: AssetHandle = Structure::load_group("acacias"); - static ref BAOBABS: AssetHandle = Structure::load_group("baobabs"); - static ref FRUIT_TREES: AssetHandle = Structure::load_group("fruit_trees"); - static ref BIRCHES: AssetHandle = Structure::load_group("birch"); + static ref OAKS: AssetHandle = Structure::load_group("trees.oaks"); + static ref OAK_STUMPS: AssetHandle = Structure::load_group("trees.oak_stumps"); + static ref PINES: AssetHandle = Structure::load_group("trees.pines"); + static ref PALMS: AssetHandle = Structure::load_group("trees.palms"); + static ref ACACIAS: AssetHandle = Structure::load_group("trees.acacias"); + static ref BAOBABS: AssetHandle = Structure::load_group("trees.baobabs"); + static ref FRUIT_TREES: AssetHandle = + Structure::load_group("trees.fruit_trees"); + static ref BIRCHES: AssetHandle = Structure::load_group("trees.birch"); static ref MANGROVE_TREES: AssetHandle = - Structure::load_group("mangrove_trees"); - static ref QUIRKY: AssetHandle = Structure::load_group("quirky"); - static ref QUIRKY_DRY: AssetHandle = Structure::load_group("quirky_dry"); - static ref SWAMP_TREES: AssetHandle = Structure::load_group("swamp_trees"); + Structure::load_group("trees.mangrove_trees"); + static ref QUIRKY: AssetHandle = Structure::load_group("trees.quirky"); + static ref QUIRKY_DRY: AssetHandle = Structure::load_group("trees.quirky_dry"); + static ref SWAMP_TREES: AssetHandle = + Structure::load_group("trees.swamp_trees"); } static MODEL_RAND: RandomPerm = RandomPerm::new(0xDB21C052); diff --git a/world/src/site2/gen.rs b/world/src/site2/gen.rs index 036db08171..9e1fd2379d 100644 --- a/world/src/site2/gen.rs +++ b/world/src/site2/gen.rs @@ -270,15 +270,20 @@ pub trait Structure { fn render Id, G: FnMut(Id, Fill)>( &self, site: &Site, + land: &Land, prim: F, fill: G, ); // Generate a primitive tree and fills for this structure - fn render_collect(&self, site: &Site) -> (Store, Vec<(Id, Fill)>) { + fn render_collect( + &self, + site: &Site, + land: &Land, + ) -> (Store, Vec<(Id, Fill)>) { let mut tree = Store::default(); let mut fills = Vec::new(); - self.render(site, |p| tree.insert(p), |p, f| fills.push((p, f))); + self.render(site, land, |p| tree.insert(p), |p, f| fills.push((p, f))); (tree, fills) } } diff --git a/world/src/site2/mod.rs b/world/src/site2/mod.rs index 5a5490e2ac..38dde808b2 100644 --- a/world/src/site2/mod.rs +++ b/world/src/site2/mod.rs @@ -758,9 +758,9 @@ impl Site { for plot in plots_to_render { let (prim_tree, fills) = match &self.plots[plot].kind { - PlotKind::House(house) => house.render_collect(self), - PlotKind::Castle(castle) => castle.render_collect(self), - PlotKind::Dungeon(dungeon) => dungeon.render_collect(self), + PlotKind::House(house) => house.render_collect(self, &canvas.land()), + PlotKind::Castle(castle) => castle.render_collect(self, &canvas.land()), + PlotKind::Dungeon(dungeon) => dungeon.render_collect(self, &canvas.land()), _ => continue, }; diff --git a/world/src/site2/plot/castle.rs b/world/src/site2/plot/castle.rs index e4459bda6f..038903f6d9 100644 --- a/world/src/site2/plot/castle.rs +++ b/world/src/site2/plot/castle.rs @@ -46,6 +46,7 @@ impl Structure for Castle { fn render Id, G: FnMut(Id, Fill)>( &self, site: &Site, + _land: &Land, mut prim: F, mut fill: G, ) { diff --git a/world/src/site2/plot/dungeon.rs b/world/src/site2/plot/dungeon.rs index 2b6a0126fe..29dfc77744 100644 --- a/world/src/site2/plot/dungeon.rs +++ b/world/src/site2/plot/dungeon.rs @@ -12,7 +12,9 @@ use common::{ comp::{self}, generation::{ChunkSupplement, EntityInfo}, store::{Id, Store}, - terrain::{Block, BlockKind, SpriteKind, Structure, StructuresGroup, TerrainChunkSize}, + terrain::{ + BiomeKind, Block, BlockKind, SpriteKind, Structure, StructuresGroup, TerrainChunkSize, + }, vol::RectVolSize, }; use core::{f32, hash::BuildHasherDefault}; @@ -1364,17 +1366,27 @@ impl SiteStructure for Dungeon { fn render Id, G: FnMut(Id, Fill)>( &self, _site: &site2::Site, + land: &Land, mut prim: F, mut fill: G, ) { let origin = (self.origin + Vec2::broadcast(TILE_SIZE / 2)).with_z(self.alt + ALT_OFFSET); lazy_static! { - pub static ref ENTRANCES: AssetHandle = - Structure::load_group("dungeon_entrances"); + pub static ref JUNGLE: AssetHandle = + Structure::load_group("dungeon_entrances.jungle"); + pub static ref GRASSLAND: AssetHandle = + Structure::load_group("dungeon_entrances.grassland"); } - let entrances = ENTRANCES.read(); + let biome = land + .get_chunk_at(self.origin) + .map_or(BiomeKind::Void, |c| c.get_biome()); + let entrances = match biome { + BiomeKind::Jungle => *JUNGLE, + _ => *GRASSLAND, + }; + let entrances = entrances.read(); let entrance = entrances[self.seed as usize % entrances.len()].clone(); let entrance_prim = prim(Primitive::Prefab(entrance.clone())); diff --git a/world/src/site2/plot/house.rs b/world/src/site2/plot/house.rs index 7bc85fc8c0..a04fca267f 100644 --- a/world/src/site2/plot/house.rs +++ b/world/src/site2/plot/house.rs @@ -50,6 +50,7 @@ impl Structure for House { fn render Id, G: FnMut(Id, Fill)>( &self, site: &Site, + _land: &Land, mut prim: F, mut fill: G, ) {