Merge branch 'snowram/dungeon-entraces-biomes' into 'master'

Spawn dungeon entrances depending on the Site origin biome

See merge request veloren/veloren!2554
This commit is contained in:
Samuel Keiffer 2021-07-07 02:47:34 +00:00
commit 2d7a4d6bee
21 changed files with 95 additions and 70 deletions

View File

@ -1,48 +1,44 @@
#![enable(unwrap_newtypes)] #![enable(unwrap_newtypes)]
[ [
( (
specifier: "world.structure.dungeon.jungle_temple.entrance.1", specifier: "world.structure.dungeon.pillar_entrance.round.1",
center: (50, 40, 10) center: (21, 17, 28)
), ),
( (
specifier: "world.structure.dungeon.pillar_entrance.round.1", specifier: "world.structure.dungeon.pillar_entrance.round.2",
center: (21, 17, 28) center: (20, 28, 15)
), ),
( (
specifier: "world.structure.dungeon.pillar_entrance.round.2", specifier: "world.structure.dungeon.pillar_entrance.1",
center: (20, 28, 15) center: (18, 16, 17)
), ),
( (
specifier: "world.structure.dungeon.pillar_entrance.1", specifier: "world.structure.dungeon.pillar_entrance.2",
center: (18, 16, 17) center: (18, 16, 17)
), ),
( (
specifier: "world.structure.dungeon.pillar_entrance.2", specifier: "world.structure.dungeon.pillar_entrance.3",
center: (18, 16, 17) center: (18, 16, 17)
), ),
( (
specifier: "world.structure.dungeon.pillar_entrance.3", specifier: "world.structure.dungeon.pillar_entrance.4",
center: (18, 16, 17) center: (18, 16, 17)
), ),
( (
specifier: "world.structure.dungeon.pillar_entrance.4", specifier: "world.structure.dungeon.pillar_entrance.5",
center: (18, 16, 17) center: (18, 16, 17)
), ),
( (
specifier: "world.structure.dungeon.pillar_entrance.5", specifier: "world.structure.dungeon.pillar_entrance.6",
center: (18, 16, 17) center: (18, 16, 17)
), ),
( (
specifier: "world.structure.dungeon.pillar_entrance.6", specifier: "world.structure.dungeon.temperate_entrance.ruins_4",
center: (18, 16, 17) center: (13, 11, 14)
), ),
( (
specifier: "world.structure.dungeon.temperate_entrance.ruins_4", specifier: "world.structure.dungeon.misc_entrance.tower-ruin",
center: (13, 11, 14) center: (13, 16, 9)
), ),
( ]
specifier: "world.structure.dungeon.misc_entrance.tower-ruin",
center: (13, 16, 9)
),
]

View File

@ -0,0 +1,8 @@
#![enable(unwrap_newtypes)]
[
(
specifier: "world.structure.dungeon.jungle_temple.entrance.1",
center: (50, 40, 10)
),
]

View File

@ -43,7 +43,7 @@ fn main() -> Result {
CanvasInfo::with_mock_canvas_info(index.as_index_ref(), world.sim(), |canvas| { CanvasInfo::with_mock_canvas_info(index.as_index_ref(), world.sim(), |canvas| {
for plot in site.plots() { for plot in site.plots() {
if let PlotKind::Dungeon(dungeon) = plot.kind() { 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 { for (prim, fill) in fills {
let aabb = fill.get_bounds(&prim_tree, prim); let aabb = fill.get_bounds(&prim_tree, prim);

View File

@ -20,19 +20,21 @@ use std::{f32, ops::Range};
use vek::*; use vek::*;
lazy_static! { lazy_static! {
static ref OAKS: AssetHandle<StructuresGroup> = Structure::load_group("oaks"); static ref OAKS: AssetHandle<StructuresGroup> = Structure::load_group("trees.oaks");
static ref OAK_STUMPS: AssetHandle<StructuresGroup> = Structure::load_group("oak_stumps"); static ref OAK_STUMPS: AssetHandle<StructuresGroup> = Structure::load_group("trees.oak_stumps");
static ref PINES: AssetHandle<StructuresGroup> = Structure::load_group("pines"); static ref PINES: AssetHandle<StructuresGroup> = Structure::load_group("trees.pines");
static ref PALMS: AssetHandle<StructuresGroup> = Structure::load_group("palms"); static ref PALMS: AssetHandle<StructuresGroup> = Structure::load_group("trees.palms");
static ref ACACIAS: AssetHandle<StructuresGroup> = Structure::load_group("acacias"); static ref ACACIAS: AssetHandle<StructuresGroup> = Structure::load_group("trees.acacias");
static ref BAOBABS: AssetHandle<StructuresGroup> = Structure::load_group("baobabs"); static ref BAOBABS: AssetHandle<StructuresGroup> = Structure::load_group("trees.baobabs");
static ref FRUIT_TREES: AssetHandle<StructuresGroup> = Structure::load_group("fruit_trees"); static ref FRUIT_TREES: AssetHandle<StructuresGroup> =
static ref BIRCHES: AssetHandle<StructuresGroup> = Structure::load_group("birch"); Structure::load_group("trees.fruit_trees");
static ref BIRCHES: AssetHandle<StructuresGroup> = Structure::load_group("trees.birch");
static ref MANGROVE_TREES: AssetHandle<StructuresGroup> = static ref MANGROVE_TREES: AssetHandle<StructuresGroup> =
Structure::load_group("mangrove_trees"); Structure::load_group("trees.mangrove_trees");
static ref QUIRKY: AssetHandle<StructuresGroup> = Structure::load_group("quirky"); static ref QUIRKY: AssetHandle<StructuresGroup> = Structure::load_group("trees.quirky");
static ref QUIRKY_DRY: AssetHandle<StructuresGroup> = Structure::load_group("quirky_dry"); static ref QUIRKY_DRY: AssetHandle<StructuresGroup> = Structure::load_group("trees.quirky_dry");
static ref SWAMP_TREES: AssetHandle<StructuresGroup> = Structure::load_group("swamp_trees"); static ref SWAMP_TREES: AssetHandle<StructuresGroup> =
Structure::load_group("trees.swamp_trees");
} }
static MODEL_RAND: RandomPerm = RandomPerm::new(0xDB21C052); static MODEL_RAND: RandomPerm = RandomPerm::new(0xDB21C052);

View File

@ -270,15 +270,20 @@ pub trait Structure {
fn render<F: FnMut(Primitive) -> Id<Primitive>, G: FnMut(Id<Primitive>, Fill)>( fn render<F: FnMut(Primitive) -> Id<Primitive>, G: FnMut(Id<Primitive>, Fill)>(
&self, &self,
site: &Site, site: &Site,
land: &Land,
prim: F, prim: F,
fill: G, fill: G,
); );
// Generate a primitive tree and fills for this structure // Generate a primitive tree and fills for this structure
fn render_collect(&self, site: &Site) -> (Store<Primitive>, Vec<(Id<Primitive>, Fill)>) { fn render_collect(
&self,
site: &Site,
land: &Land,
) -> (Store<Primitive>, Vec<(Id<Primitive>, Fill)>) {
let mut tree = Store::default(); let mut tree = Store::default();
let mut fills = Vec::new(); 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) (tree, fills)
} }
} }

View File

@ -758,9 +758,9 @@ impl Site {
for plot in plots_to_render { for plot in plots_to_render {
let (prim_tree, fills) = match &self.plots[plot].kind { let (prim_tree, fills) = match &self.plots[plot].kind {
PlotKind::House(house) => house.render_collect(self), PlotKind::House(house) => house.render_collect(self, &canvas.land()),
PlotKind::Castle(castle) => castle.render_collect(self), PlotKind::Castle(castle) => castle.render_collect(self, &canvas.land()),
PlotKind::Dungeon(dungeon) => dungeon.render_collect(self), PlotKind::Dungeon(dungeon) => dungeon.render_collect(self, &canvas.land()),
_ => continue, _ => continue,
}; };

View File

@ -46,6 +46,7 @@ impl Structure for Castle {
fn render<F: FnMut(Primitive) -> Id<Primitive>, G: FnMut(Id<Primitive>, Fill)>( fn render<F: FnMut(Primitive) -> Id<Primitive>, G: FnMut(Id<Primitive>, Fill)>(
&self, &self,
site: &Site, site: &Site,
_land: &Land,
mut prim: F, mut prim: F,
mut fill: G, mut fill: G,
) { ) {

View File

@ -12,7 +12,9 @@ use common::{
comp::{self}, comp::{self},
generation::{ChunkSupplement, EntityInfo}, generation::{ChunkSupplement, EntityInfo},
store::{Id, Store}, store::{Id, Store},
terrain::{Block, BlockKind, SpriteKind, Structure, StructuresGroup, TerrainChunkSize}, terrain::{
BiomeKind, Block, BlockKind, SpriteKind, Structure, StructuresGroup, TerrainChunkSize,
},
vol::RectVolSize, vol::RectVolSize,
}; };
use core::{f32, hash::BuildHasherDefault}; use core::{f32, hash::BuildHasherDefault};
@ -1364,17 +1366,27 @@ impl SiteStructure for Dungeon {
fn render<F: FnMut(Primitive) -> Id<Primitive>, G: FnMut(Id<Primitive>, Fill)>( fn render<F: FnMut(Primitive) -> Id<Primitive>, G: FnMut(Id<Primitive>, Fill)>(
&self, &self,
_site: &site2::Site, _site: &site2::Site,
land: &Land,
mut prim: F, mut prim: F,
mut fill: G, mut fill: G,
) { ) {
let origin = (self.origin + Vec2::broadcast(TILE_SIZE / 2)).with_z(self.alt + ALT_OFFSET); let origin = (self.origin + Vec2::broadcast(TILE_SIZE / 2)).with_z(self.alt + ALT_OFFSET);
lazy_static! { lazy_static! {
pub static ref ENTRANCES: AssetHandle<StructuresGroup> = pub static ref JUNGLE: AssetHandle<StructuresGroup> =
Structure::load_group("dungeon_entrances"); Structure::load_group("dungeon_entrances.jungle");
pub static ref GRASSLAND: AssetHandle<StructuresGroup> =
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 = entrances[self.seed as usize % entrances.len()].clone();
let entrance_prim = prim(Primitive::Prefab(entrance.clone())); let entrance_prim = prim(Primitive::Prefab(entrance.clone()));

View File

@ -50,6 +50,7 @@ impl Structure for House {
fn render<F: FnMut(Primitive) -> Id<Primitive>, G: FnMut(Id<Primitive>, Fill)>( fn render<F: FnMut(Primitive) -> Id<Primitive>, G: FnMut(Id<Primitive>, Fill)>(
&self, &self,
site: &Site, site: &Site,
_land: &Land,
mut prim: F, mut prim: F,
mut fill: G, mut fill: G,
) { ) {