add campfires to clifftown and desertcity

This commit is contained in:
flo 2022-08-14 20:22:30 +00:00 committed by Isse
parent 3e5f04cb40
commit 4c49cb933e
3 changed files with 27 additions and 4 deletions

View File

@ -744,17 +744,17 @@ impl Site {
pub fn generate_cliff_town(land: &Land, rng: &mut impl Rng, origin: Vec2<i32>) -> Self {
let mut rng = reseed(rng);
let mut site = Site {
origin,
name: NameGen::location(&mut rng).generate_arabic(),
..Site::default()
};
let mut campfires = 0;
site.make_plaza(land, &mut rng);
for _ in 0..30 {
// CliffTower
let size = (6.0 + rng.gen::<f32>().powf(5.0) * 1.0).round() as u32;
let campfire = campfires < 4;
if let Some((aabr, door_tile, door_dir)) = attempt(32, || {
site.find_roadside_aabr(&mut rng, 6..(size + 1).pow(2), Extent2::broadcast(size))
}) {
@ -765,6 +765,7 @@ impl Site {
door_tile,
door_dir,
aabr,
campfire,
);
let cliff_tower_alt = cliff_tower.alt;
let plot = site.create_plot(Plot {
@ -779,6 +780,7 @@ impl Site {
plot: Some(plot),
hard_alt: Some(cliff_tower_alt),
});
campfires += 1;
} else {
site.make_plaza(land, &mut rng);
}
@ -803,12 +805,14 @@ impl Site {
let build_chance = Lottery::from(vec![(20.0, 1), (10.0, 2)]);
let mut temples = 0;
let mut campfires = 0;
for _ in 0..30 {
match *build_chance.choose_seeded(rng.gen()) {
// DesertCityMultiplot
1 => {
let size = (9.0 + rng.gen::<f32>().powf(5.0) * 1.5).round() as u32;
let campfire = campfires < 4;
if let Some((aabr, door_tile, door_dir)) = attempt(32, || {
site.find_roadside_aabr(
&mut rng,
@ -823,6 +827,7 @@ impl Site {
door_tile,
door_dir,
aabr,
campfire,
);
let desert_city_multi_plot_alt = desert_city_multi_plot.alt;
let plot = site.create_plot(Plot {
@ -837,6 +842,7 @@ impl Site {
plot: Some(plot),
hard_alt: Some(desert_city_multi_plot_alt),
});
campfires += 1;
} else {
site.make_plaza(land, &mut rng);
}

View File

@ -17,6 +17,7 @@ pub struct CliffTower {
bounds: Aabr<i32>,
/// Approximate altitude of the door tile
pub(crate) alt: i32,
campfire: bool,
}
impl CliffTower {
@ -27,6 +28,7 @@ impl CliffTower {
door_tile: Vec2<i32>,
door_dir: Vec2<i32>,
tile_aabr: Aabr<i32>,
campfire: bool,
) -> Self {
let bounds = Aabr {
min: site.tile_wpos(tile_aabr.min),
@ -35,6 +37,7 @@ impl CliffTower {
Self {
bounds,
alt: land.get_alt_approx(site.tile_center_wpos(door_tile + door_dir)) as i32,
campfire,
}
}
}
@ -894,5 +897,10 @@ impl Structure for CliffTower {
mem::swap(&mut length, &mut width);
mem::swap(&mut stair_pos1, &mut stair_pos2);
}
// spawn campfire next to some clifftowers
if self.campfire {
let campfire_pos = (center - 20).with_z(self.alt + 18);
painter.spawn(EntityInfo::at(campfire_pos.map(|e| e as f32)).into_waypoint());
}
}
}

View File

@ -5,8 +5,9 @@ use crate::{
util::{RandomField, Sampler, DIAGONALS, NEIGHBORS},
Land,
};
use common::terrain::{
Block, BlockKind, SpriteKind, Structure as PrefabStructure, StructuresGroup,
use common::{
generation::EntityInfo,
terrain::{Block, BlockKind, SpriteKind, Structure as PrefabStructure, StructuresGroup},
};
use lazy_static::lazy_static;
use rand::prelude::*;
@ -44,6 +45,7 @@ pub struct DesertCityMultiPlot {
pub(crate) alt: i32,
diameter: i32,
plot_kind: PlotKind,
campfire: bool,
}
impl DesertCityMultiPlot {
@ -54,6 +56,7 @@ impl DesertCityMultiPlot {
door_tile: Vec2<i32>,
door_dir: Vec2<i32>,
tile_aabr: Aabr<i32>,
campfire: bool,
) -> Self {
let bounds = Aabr {
min: site.tile_wpos(tile_aabr.min),
@ -120,6 +123,7 @@ impl DesertCityMultiPlot {
alt: land.get_alt_approx(site.tile_center_wpos(door_tile + door_dir)) as i32,
diameter,
plot_kind,
campfire,
}
}
}
@ -2407,6 +2411,11 @@ impl Structure for DesertCityMultiPlot {
},
}
}
// spawn campfire in some multiplots that are not markethall
let campfire_pos = (center).with_z(base + 1);
if self.campfire {
painter.spawn(EntityInfo::at(campfire_pos.map(|e| e as f32)).into_waypoint())
}
},
}
}