From 60f0505e8ac91115d616a89b6f9ce8b67a6b6fec Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 3 Jun 2022 19:26:26 -0400 Subject: [PATCH] Initial tannery and animal pen --- world/src/site2/plot/adlet.rs | 51 +++++++++++++++++++++++++++++++++-- 1 file changed, 49 insertions(+), 2 deletions(-) diff --git a/world/src/site2/plot/adlet.rs b/world/src/site2/plot/adlet.rs index 1d872e42d3..bfa9a79240 100644 --- a/world/src/site2/plot/adlet.rs +++ b/world/src/site2/plot/adlet.rs @@ -41,6 +41,7 @@ pub struct AdletStronghold { cavern_structures: Vec<(AdletStructure, Vec2, Dir)>, } +#[derive(Copy, Clone)] enum AdletStructure { Igloo(u8), TunnelEntrance, @@ -49,9 +50,9 @@ enum AdletStructure { YetiPit, Tannery, AnimalPen, + CookFire, RockHut, BoneHut, - CookFire, } impl AdletStructure { @@ -64,9 +65,9 @@ impl AdletStructure { Self::YetiPit => 20, Self::Tannery => 10, Self::AnimalPen => 16, + Self::CookFire => 3, Self::RockHut => 6, Self::BoneHut => 8, - Self::CookFire => 3, }; let additional_padding = match (self, other) { @@ -319,6 +320,30 @@ impl AdletStronghold { cavern_structures.push((AdletStructure::YetiPit, rpos, Dir::X)); } + // Attempt to place some general structures somewhat near the center + let desired_structures = cavern_radius.pow(2) / 500; + for _ in 0..desired_structures { + if let Some((structure, rpos)) = attempt(25, || { + let rpos = { + let theta = rng.gen_range(0.0..TAU); + // sqrt biases radius away from center, leading to even distribution in circle + let radius = rng.gen::().sqrt() * cavern_radius as f32 * 0.6; + Vec2::new(theta.cos() * radius, theta.sin() * radius).as_() + }; + let structure = match rng.gen_range(0..2) { + 0 => AdletStructure::Tannery, + _ => AdletStructure::AnimalPen, + }; + + valid_cavern_struct_pos(&cavern_structures, structure, rpos) + .then_some((structure, rpos)) + }) { + // Direction facing the central bonfire + let dir = Dir::from_vector(rpos).opposite(); + cavern_structures.push((structure, rpos, dir)); + } + } + Self { name, seed, @@ -673,6 +698,28 @@ impl Structure for AdletStronghold { }) .clear(); }, + AdletStructure::Tannery => { + painter + .aabb(Aabb { + min: wpos.map(|x| x - 5).with_z(alt as i32), + max: wpos.with_z(alt as i32).map(|x| x + 5), + }) + .fill(bone_fill.clone()); + }, + AdletStructure::AnimalPen => { + painter + .aabb(Aabb { + min: wpos.map(|x| x - 5).with_z(alt as i32), + max: wpos.with_z(alt as i32).map(|x| x + 5), + }) + .fill(bone_fill.clone()); + painter + .aabb(Aabb { + min: wpos.map(|x| x - 4).with_z(alt as i32), + max: wpos.with_z(alt as i32 + 1).map(|x| x + 4), + }) + .clear(); + }, _ => panic!(), } }