From cab87658a3d4b1251cc02dce48e9f9a5230b857a Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 10 Feb 2022 14:40:23 -0500 Subject: [PATCH] Placement tweaks --- world/src/civ/mod.rs | 4 ++-- world/src/site2/plot/gnarling.rs | 30 ++++++++++++++++++------------ 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/world/src/civ/mod.rs b/world/src/civ/mod.rs index cd76ef3b56..948e24ffdb 100644 --- a/world/src/civ/mod.rs +++ b/world/src/civ/mod.rs @@ -15,7 +15,7 @@ use common::{ path::Path, spiral::Spiral2d, store::{Id, Store}, - terrain::{uniform_idx_as_vec2, BiomeKind, MapSizeLg, TerrainChunkSize}, + terrain::{uniform_idx_as_vec2, MapSizeLg, TerrainChunkSize}, vol::RectVolSize, }; use core::{fmt, hash::BuildHasherDefault, ops::Range}; @@ -1120,7 +1120,7 @@ pub enum SiteKind { impl SiteKind { pub fn is_suitable_loc(&self, chunk: &SimChunk) -> bool { match self { - SiteKind::Gnarling => matches!(chunk.get_biome(), BiomeKind::Forest), + SiteKind::Gnarling => (-0.3..0.4).contains(&chunk.temp) && chunk.tree_density > 0.75, _ => true, } } diff --git a/world/src/site2/plot/gnarling.rs b/world/src/site2/plot/gnarling.rs index 04037d8751..b5da8f7bc3 100644 --- a/world/src/site2/plot/gnarling.rs +++ b/world/src/site2/plot/gnarling.rs @@ -9,7 +9,6 @@ use common::{ generation::{ChunkSupplement, EntityInfo}, terrain::{Structure as PrefabStructure, StructuresGroup}, }; -use inline_tweak::tweak; use kiddo::{distance::squared_euclidean, KdTree}; use lazy_static::lazy_static; use rand::prelude::*; @@ -49,17 +48,24 @@ enum GnarlingStructure { impl GnarlingStructure { fn required_separation(&self, other: &Self) -> i32 { - match (self, other) { - (Self::Hut, Self::Hut) => 13, - (_, Self::VeloriteHut) | (Self::VeloriteHut, _) => 25, - (_, Self::Banner) | (Self::Banner, _) => 15, + let radius = |structure: &Self| match structure { + Self::Hut => 7, + Self::VeloriteHut => 15, + Self::Banner => 6, + Self::Totem => 6, + // Generated in different pass that doesn't use distance check + Self::WatchTower => 0, + Self::ChieftainHut => 0, + }; - (Self::Hut, Self::Totem) | (Self::Totem, Self::Hut) => 20, + let additional_padding = match (self, other) { + (Self::Banner, Self::Banner) => 50, (Self::Totem, Self::Totem) => 50, - // Chieftain hut and watch tower generated in separate pass without distance check - (Self::ChieftainHut | Self::WatchTower, _) - | (_, Self::ChieftainHut | Self::WatchTower) => 0, - } + (Self::VeloriteHut, Self::VeloriteHut) => 50, + _ => 0, + }; + + radius(self) + radius(other) + additional_padding } } @@ -183,7 +189,7 @@ impl GnarlingFortification { let desired_structures = wall_radius.pow(2) / 100; let mut structure_locations = Vec::<(GnarlingStructure, Vec3, Ori)>::new(); for _ in 0..desired_structures { - if let Some((hut_loc, kind)) = attempt(16, || { + if let Some((hut_loc, kind)) = attempt(50, || { // Choose structure kind let structure_kind = match rng.gen_range(0..10) { 0 => GnarlingStructure::Totem, @@ -208,7 +214,7 @@ impl GnarlingFortification { (outer_wall_corners[0], 0) }; - let center_weight: f32 = rng.gen_range(0.2..0.6); + let center_weight: f32 = rng.gen_range(0.15..0.7); // Forbidden and restricted indices are near walls, so don't spawn structures // too close to avoid overlap with wall