savannah_pit

This commit is contained in:
flo 2022-10-22 19:48:50 +00:00 committed by Joshua Barretto
parent 938fd77b5a
commit 698a00bae3
9 changed files with 1786 additions and 57 deletions

View File

@ -18,8 +18,9 @@ pub enum DungeonKindMeta {
#[derive(Debug, Copy, Clone, Serialize, Deserialize, PartialEq, Eq)] #[derive(Debug, Copy, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub enum SettlementKindMeta { pub enum SettlementKindMeta {
Default, Default,
Cliff, CliffTown,
Desert, DesertCity,
SavannahPit,
} }
impl Default for SiteKindMeta { impl Default for SiteKindMeta {

View File

@ -116,8 +116,9 @@ impl ActivityUpdate {
Dungeon(Gnarling) => format!("Hunting Gnarlings in {chunk_name}"), Dungeon(Gnarling) => format!("Hunting Gnarlings in {chunk_name}"),
Cave => "In a Cave".to_string(), Cave => "In a Cave".to_string(),
Settlement(Default) => format!("Visiting {chunk_name}"), Settlement(Default) => format!("Visiting {chunk_name}"),
Settlement(Cliff) => format!("Climbing the towers of {chunk_name}"), Settlement(CliffTown) => format!("Climbing the towers of {chunk_name}"),
Settlement(Desert) => format!("Hiding from the sun in {chunk_name}"), Settlement(DesertCity) => format!("Hiding from the sun in {chunk_name}"),
Settlement(SavannahPit) => format!("Shop at the market down in {chunk_name}"),
_ => format!("In {chunk_name}"), _ => format!("In {chunk_name}"),
}; };

View File

@ -184,6 +184,7 @@ impl Civs {
SiteKind::Castle => (16i32, 5.0), SiteKind::Castle => (16i32, 5.0),
SiteKind::Refactor => (32i32, 10.0), SiteKind::Refactor => (32i32, 10.0),
SiteKind::CliffTown => (32i32, 10.0), SiteKind::CliffTown => (32i32, 10.0),
SiteKind::SavannahPit => (36i32, 20.0),
SiteKind::DesertCity => (64i32, 25.0), SiteKind::DesertCity => (64i32, 25.0),
SiteKind::ChapelSite => (36i32, 10.0), SiteKind::ChapelSite => (36i32, 10.0),
SiteKind::Tree => (12i32, 8.0), SiteKind::Tree => (12i32, 8.0),
@ -249,54 +250,60 @@ impl Civs {
}); });
let mut rng = ctx.reseed().rng; let mut rng = ctx.reseed().rng;
let site = let site = index.sites.insert(match &sim_site.kind {
index.sites.insert(match &sim_site.kind { SiteKind::Settlement => {
SiteKind::Settlement => { WorldSite::settlement(Settlement::generate(wpos, Some(ctx.sim), &mut rng))
WorldSite::settlement(Settlement::generate(wpos, Some(ctx.sim), &mut rng)) },
}, SiteKind::Dungeon => WorldSite::dungeon(site2::Site::generate_dungeon(
SiteKind::Dungeon => WorldSite::dungeon(site2::Site::generate_dungeon( &Land::from_sim(ctx.sim),
&Land::from_sim(ctx.sim), &mut rng,
&mut rng, wpos,
wpos, )),
)), SiteKind::Castle => {
SiteKind::Castle => { WorldSite::castle(Castle::generate(wpos, Some(ctx.sim), &mut rng))
WorldSite::castle(Castle::generate(wpos, Some(ctx.sim), &mut rng)) },
}, SiteKind::Refactor => WorldSite::refactor(site2::Site::generate_city(
SiteKind::Refactor => WorldSite::refactor(site2::Site::generate_city( &Land::from_sim(ctx.sim),
&Land::from_sim(ctx.sim), &mut rng,
&mut rng, wpos,
wpos, )),
)), SiteKind::CliffTown => WorldSite::cliff_town(site2::Site::generate_cliff_town(
SiteKind::CliffTown => WorldSite::cliff_town(site2::Site::generate_cliff_town( &Land::from_sim(ctx.sim),
&Land::from_sim(ctx.sim), &mut rng,
&mut rng, wpos,
wpos, )),
)), SiteKind::SavannahPit => WorldSite::savannah_pit(
SiteKind::DesertCity => WorldSite::desert_city( site2::Site::generate_savannah_pit(&Land::from_sim(ctx.sim), &mut rng, wpos),
site2::Site::generate_desert_city(&Land::from_sim(ctx.sim), &mut rng, wpos), ),
), SiteKind::DesertCity => WorldSite::desert_city(site2::Site::generate_desert_city(
SiteKind::Tree => { &Land::from_sim(ctx.sim),
WorldSite::tree(Tree::generate(wpos, &Land::from_sim(ctx.sim), &mut rng)) &mut rng,
}, wpos,
SiteKind::GiantTree => WorldSite::giant_tree(site2::Site::generate_giant_tree( )),
&Land::from_sim(ctx.sim), SiteKind::Tree => {
&mut rng, WorldSite::tree(Tree::generate(wpos, &Land::from_sim(ctx.sim), &mut rng))
wpos, },
)), SiteKind::GiantTree => WorldSite::giant_tree(site2::Site::generate_giant_tree(
SiteKind::Gnarling => WorldSite::gnarling(site2::Site::generate_gnarling( &Land::from_sim(ctx.sim),
&Land::from_sim(ctx.sim), &mut rng,
&mut rng, wpos,
wpos, )),
)), SiteKind::Gnarling => WorldSite::gnarling(site2::Site::generate_gnarling(
SiteKind::ChapelSite => WorldSite::chapel_site( &Land::from_sim(ctx.sim),
site2::Site::generate_chapel_site(&Land::from_sim(ctx.sim), &mut rng, wpos), &mut rng,
), wpos,
SiteKind::Citadel => WorldSite::gnarling(site2::Site::generate_citadel( )),
&Land::from_sim(ctx.sim), SiteKind::ChapelSite => WorldSite::chapel_site(site2::Site::generate_chapel_site(
&mut rng, &Land::from_sim(ctx.sim),
wpos, &mut rng,
)), wpos,
}); )),
SiteKind::Citadel => WorldSite::gnarling(site2::Site::generate_citadel(
&Land::from_sim(ctx.sim),
&mut rng,
wpos,
)),
});
sim_site.site_tmp = Some(site); sim_site.site_tmp = Some(site);
let site_ref = &index.sites[site]; let site_ref = &index.sites[site];
@ -580,6 +587,7 @@ impl Civs {
let kind = match ctx.rng.gen_range(0..64) { let kind = match ctx.rng.gen_range(0..64) {
0..=10 => SiteKind::CliffTown, 0..=10 => SiteKind::CliffTown,
11..=12 => SiteKind::DesertCity, 11..=12 => SiteKind::DesertCity,
13..=18 => SiteKind::SavannahPit,
_ => SiteKind::Refactor, _ => SiteKind::Refactor,
}; };
let site = attempt(100, || { let site = attempt(100, || {
@ -999,6 +1007,7 @@ impl Civs {
SiteKind::Refactor SiteKind::Refactor
| SiteKind::Settlement | SiteKind::Settlement
| SiteKind::CliffTown | SiteKind::CliffTown
| SiteKind::SavannahPit
| SiteKind::DesertCity | SiteKind::DesertCity
| SiteKind::Castle | SiteKind::Castle
) )
@ -1011,6 +1020,7 @@ impl Civs {
if let SiteKind::Refactor if let SiteKind::Refactor
| SiteKind::Settlement | SiteKind::Settlement
| SiteKind::CliffTown | SiteKind::CliffTown
| SiteKind::SavannahPit
| SiteKind::DesertCity | SiteKind::DesertCity
| SiteKind::Castle = self.sites[site].kind | SiteKind::Castle = self.sites[site].kind
{ {
@ -1248,6 +1258,7 @@ pub enum SiteKind {
Castle, Castle,
Refactor, Refactor,
CliffTown, CliffTown,
SavannahPit,
DesertCity, DesertCity,
ChapelSite, ChapelSite,
Tree, Tree,
@ -1393,6 +1404,12 @@ impl SiteKind {
&& chunk.near_cliffs() && chunk.near_cliffs()
&& suitable_for_town(4.0) && suitable_for_town(4.0)
}, },
SiteKind::SavannahPit => {
matches!(chunk.get_biome(), BiomeKind::Savannah)
&& !chunk.near_cliffs()
&& !chunk.river.near_water()
&& suitable_for_town(4.0)
},
SiteKind::DesertCity => { SiteKind::DesertCity => {
(0.9..1.0).contains(&chunk.temp) (0.9..1.0).contains(&chunk.temp)
&& !chunk.near_cliffs() && !chunk.near_cliffs()
@ -1452,7 +1469,11 @@ impl Site {
pub fn is_settlement(&self) -> bool { pub fn is_settlement(&self) -> bool {
matches!( matches!(
self.kind, self.kind,
SiteKind::Settlement | SiteKind::Refactor | SiteKind::CliffTown | SiteKind::DesertCity SiteKind::Settlement
| SiteKind::Refactor
| SiteKind::CliffTown
| SiteKind::DesertCity
| SiteKind::SavannahPit
) )
} }

View File

@ -144,7 +144,7 @@ impl World {
name: site.site_tmp.map(|id| index.sites[id].name().to_string()), name: site.site_tmp.map(|id| index.sites[id].name().to_string()),
// TODO: Probably unify these, at some point // TODO: Probably unify these, at some point
kind: match &site.kind { kind: match &site.kind {
civ::SiteKind::Settlement | civ::SiteKind::Refactor | civ::SiteKind::CliffTown | civ::SiteKind::DesertCity => world_msg::SiteKind::Town, civ::SiteKind::Settlement | civ::SiteKind::Refactor | civ::SiteKind::CliffTown | civ::SiteKind::SavannahPit | civ::SiteKind::DesertCity => world_msg::SiteKind::Town,
civ::SiteKind::Dungeon => world_msg::SiteKind::Dungeon { civ::SiteKind::Dungeon => world_msg::SiteKind::Dungeon {
difficulty: match site.site_tmp.map(|id| &index.sites[id].kind) { difficulty: match site.site_tmp.map(|id| &index.sites[id].kind) {
Some(SiteKind::Dungeon(d)) => d.dungeon_difficulty().unwrap_or(0), Some(SiteKind::Dungeon(d)) => d.dungeon_difficulty().unwrap_or(0),

View File

@ -122,6 +122,7 @@ impl Environment {
SiteKind::Settlement(_) SiteKind::Settlement(_)
| SiteKind::Refactor(_) | SiteKind::Refactor(_)
| SiteKind::CliffTown(_) | SiteKind::CliffTown(_)
| SiteKind::SavannahPit(_)
| SiteKind::DesertCity(_) => towns += site.economy.pop, | SiteKind::DesertCity(_) => towns += site.economy.pop,
SiteKind::Dungeon(_) => dungeons += site.economy.pop, SiteKind::Dungeon(_) => dungeons += site.economy.pop,
SiteKind::Castle(_) => castles += site.economy.pop, SiteKind::Castle(_) => castles += site.economy.pop,

View File

@ -67,6 +67,7 @@ pub enum SiteKind {
Castle(Castle), Castle(Castle),
Refactor(site2::Site), Refactor(site2::Site),
CliffTown(site2::Site), CliffTown(site2::Site),
SavannahPit(site2::Site),
Tree(Tree), Tree(Tree),
DesertCity(site2::Site), DesertCity(site2::Site),
ChapelSite(site2::Site), ChapelSite(site2::Site),
@ -117,6 +118,13 @@ impl Site {
} }
} }
pub fn savannah_pit(sp: site2::Site) -> Self {
Self {
kind: SiteKind::SavannahPit(sp),
economy: Economy::default(),
}
}
pub fn desert_city(dc: site2::Site) -> Self { pub fn desert_city(dc: site2::Site) -> Self {
Self { Self {
kind: SiteKind::DesertCity(dc), kind: SiteKind::DesertCity(dc),
@ -152,6 +160,7 @@ impl Site {
SiteKind::Castle(c) => c.radius(), SiteKind::Castle(c) => c.radius(),
SiteKind::Refactor(s) => s.radius(), SiteKind::Refactor(s) => s.radius(),
SiteKind::CliffTown(ct) => ct.radius(), SiteKind::CliffTown(ct) => ct.radius(),
SiteKind::SavannahPit(sp) => sp.radius(),
SiteKind::DesertCity(dc) => dc.radius(), SiteKind::DesertCity(dc) => dc.radius(),
SiteKind::ChapelSite(p) => p.radius(), SiteKind::ChapelSite(p) => p.radius(),
SiteKind::Tree(t) => t.radius(), SiteKind::Tree(t) => t.radius(),
@ -167,6 +176,7 @@ impl Site {
SiteKind::Castle(c) => c.get_origin(), SiteKind::Castle(c) => c.get_origin(),
SiteKind::Refactor(s) => s.origin, SiteKind::Refactor(s) => s.origin,
SiteKind::CliffTown(ct) => ct.origin, SiteKind::CliffTown(ct) => ct.origin,
SiteKind::SavannahPit(sp) => sp.origin,
SiteKind::DesertCity(dc) => dc.origin, SiteKind::DesertCity(dc) => dc.origin,
SiteKind::ChapelSite(p) => p.origin, SiteKind::ChapelSite(p) => p.origin,
SiteKind::Tree(t) => t.origin, SiteKind::Tree(t) => t.origin,
@ -182,6 +192,7 @@ impl Site {
SiteKind::Castle(c) => c.spawn_rules(wpos), SiteKind::Castle(c) => c.spawn_rules(wpos),
SiteKind::Refactor(s) => s.spawn_rules(wpos), SiteKind::Refactor(s) => s.spawn_rules(wpos),
SiteKind::CliffTown(ct) => ct.spawn_rules(wpos), SiteKind::CliffTown(ct) => ct.spawn_rules(wpos),
SiteKind::SavannahPit(sp) => sp.spawn_rules(wpos),
SiteKind::DesertCity(dc) => dc.spawn_rules(wpos), SiteKind::DesertCity(dc) => dc.spawn_rules(wpos),
SiteKind::ChapelSite(p) => p.spawn_rules(wpos), SiteKind::ChapelSite(p) => p.spawn_rules(wpos),
SiteKind::Tree(t) => t.spawn_rules(wpos), SiteKind::Tree(t) => t.spawn_rules(wpos),
@ -197,6 +208,7 @@ impl Site {
SiteKind::Castle(c) => c.name(), SiteKind::Castle(c) => c.name(),
SiteKind::Refactor(s) => s.name(), SiteKind::Refactor(s) => s.name(),
SiteKind::CliffTown(ct) => ct.name(), SiteKind::CliffTown(ct) => ct.name(),
SiteKind::SavannahPit(sp) => sp.name(),
SiteKind::DesertCity(dc) => dc.name(), SiteKind::DesertCity(dc) => dc.name(),
SiteKind::ChapelSite(p) => p.name(), SiteKind::ChapelSite(p) => p.name(),
SiteKind::Tree(_) => "Giant Tree", SiteKind::Tree(_) => "Giant Tree",
@ -213,6 +225,7 @@ impl Site {
SiteKind::Settlement(_) SiteKind::Settlement(_)
| SiteKind::Refactor(_) | SiteKind::Refactor(_)
| SiteKind::CliffTown(_) | SiteKind::CliffTown(_)
| SiteKind::SavannahPit(_)
| SiteKind::DesertCity(_) => Some(common::trade::SiteInformation { | SiteKind::DesertCity(_) => Some(common::trade::SiteInformation {
id: site_id, id: site_id,
unconsumed_stock: self.economy.get_available_stock(), unconsumed_stock: self.economy.get_available_stock(),
@ -230,6 +243,7 @@ impl Site {
SiteKind::Castle(c) => c.apply_to(canvas.index, canvas.wpos, get_col, canvas.chunk), SiteKind::Castle(c) => c.apply_to(canvas.index, canvas.wpos, get_col, canvas.chunk),
SiteKind::Refactor(s) => s.render(canvas, dynamic_rng), SiteKind::Refactor(s) => s.render(canvas, dynamic_rng),
SiteKind::CliffTown(ct) => ct.render(canvas, dynamic_rng), SiteKind::CliffTown(ct) => ct.render(canvas, dynamic_rng),
SiteKind::SavannahPit(sp) => sp.render(canvas, dynamic_rng),
SiteKind::DesertCity(dc) => dc.render(canvas, dynamic_rng), SiteKind::DesertCity(dc) => dc.render(canvas, dynamic_rng),
SiteKind::ChapelSite(p) => p.render(canvas, dynamic_rng), SiteKind::ChapelSite(p) => p.render(canvas, dynamic_rng),
SiteKind::Tree(t) => t.render(canvas, dynamic_rng), SiteKind::Tree(t) => t.render(canvas, dynamic_rng),
@ -258,6 +272,7 @@ impl Site {
SiteKind::Castle(c) => c.apply_supplement(dynamic_rng, wpos2d, get_column, supplement), SiteKind::Castle(c) => c.apply_supplement(dynamic_rng, wpos2d, get_column, supplement),
SiteKind::Refactor(_) => {}, SiteKind::Refactor(_) => {},
SiteKind::CliffTown(_) => {}, SiteKind::CliffTown(_) => {},
SiteKind::SavannahPit(_) => {},
SiteKind::DesertCity(_) => {}, SiteKind::DesertCity(_) => {},
SiteKind::ChapelSite(p) => p.apply_supplement(dynamic_rng, wpos2d, supplement), SiteKind::ChapelSite(p) => p.apply_supplement(dynamic_rng, wpos2d, supplement),
SiteKind::Tree(_) => {}, SiteKind::Tree(_) => {},
@ -271,6 +286,7 @@ impl Site {
self.kind, self.kind,
SiteKind::Refactor(_) SiteKind::Refactor(_)
| SiteKind::CliffTown(_) | SiteKind::CliffTown(_)
| SiteKind::SavannahPit(_)
| SiteKind::DesertCity(_) | SiteKind::DesertCity(_)
| SiteKind::Settlement(_) | SiteKind::Settlement(_)
) )
@ -283,8 +299,13 @@ impl SiteKind {
SiteKind::Refactor(_) | SiteKind::Settlement(_) => { SiteKind::Refactor(_) | SiteKind::Settlement(_) => {
Some(SiteKindMeta::Settlement(SettlementKindMeta::Default)) Some(SiteKindMeta::Settlement(SettlementKindMeta::Default))
}, },
SiteKind::CliffTown(_) => Some(SiteKindMeta::Settlement(SettlementKindMeta::Cliff)), SiteKind::CliffTown(_) => Some(SiteKindMeta::Settlement(SettlementKindMeta::CliffTown)),
SiteKind::DesertCity(_) => Some(SiteKindMeta::Settlement(SettlementKindMeta::Desert)), SiteKind::SavannahPit(_) => {
Some(SiteKindMeta::Settlement(SettlementKindMeta::SavannahPit))
},
SiteKind::DesertCity(_) => {
Some(SiteKindMeta::Settlement(SettlementKindMeta::DesertCity))
},
SiteKind::Dungeon(_) => Some(SiteKindMeta::Dungeon(DungeonKindMeta::Old)), SiteKind::Dungeon(_) => Some(SiteKindMeta::Dungeon(DungeonKindMeta::Old)),
SiteKind::Gnarling(_) => Some(SiteKindMeta::Dungeon(DungeonKindMeta::Gnarling)), SiteKind::Gnarling(_) => Some(SiteKindMeta::Dungeon(DungeonKindMeta::Gnarling)),
_ => None, _ => None,

View File

@ -817,6 +817,38 @@ impl Site {
site site
} }
pub fn generate_savannah_pit(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_savannah_custom(),
..Site::default()
};
let size = 11.0 as i32;
let aabr = Aabr {
min: Vec2::broadcast(-size),
max: Vec2::broadcast(size),
};
{
let savannah_pit =
plot::SavannahPit::generate(land, &mut reseed(&mut rng), &site, aabr);
let savannah_pit_alt = savannah_pit.alt;
let plot = site.create_plot(Plot {
kind: PlotKind::SavannahPit(savannah_pit),
root_tile: aabr.center(),
tiles: aabr_tiles(aabr).collect(),
seed: rng.gen(),
});
site.blit_aabr(aabr, Tile {
kind: TileKind::Building,
plot: Some(plot),
hard_alt: Some(savannah_pit_alt),
});
}
site
}
pub fn generate_desert_city(land: &Land, rng: &mut impl Rng, origin: Vec2<i32>) -> Self { pub fn generate_desert_city(land: &Land, rng: &mut impl Rng, origin: Vec2<i32>) -> Self {
let mut rng = reseed(rng); let mut rng = reseed(rng);
@ -1196,6 +1228,7 @@ impl Site {
PlotKind::Gnarling(gnarling) => gnarling.render_collect(self, canvas), PlotKind::Gnarling(gnarling) => gnarling.render_collect(self, canvas),
PlotKind::GiantTree(giant_tree) => giant_tree.render_collect(self, canvas), PlotKind::GiantTree(giant_tree) => giant_tree.render_collect(self, canvas),
PlotKind::CliffTower(cliff_tower) => cliff_tower.render_collect(self, canvas), PlotKind::CliffTower(cliff_tower) => cliff_tower.render_collect(self, canvas),
PlotKind::SavannahPit(savannah_pit) => savannah_pit.render_collect(self, canvas),
PlotKind::DesertCityMultiPlot(desert_city_multi_plot) => { PlotKind::DesertCityMultiPlot(desert_city_multi_plot) => {
desert_city_multi_plot.render_collect(self, canvas) desert_city_multi_plot.render_collect(self, canvas)
}, },

View File

@ -7,6 +7,7 @@ pub mod dungeon;
mod giant_tree; mod giant_tree;
mod gnarling; mod gnarling;
mod house; mod house;
mod savannah_pit;
mod sea_chapel; mod sea_chapel;
mod workshop; mod workshop;
@ -14,7 +15,7 @@ pub use self::{
castle::Castle, citadel::Citadel, cliff_tower::CliffTower, castle::Castle, citadel::Citadel, cliff_tower::CliffTower,
desert_city_multiplot::DesertCityMultiPlot, desert_city_temple::DesertCityTemple, desert_city_multiplot::DesertCityMultiPlot, desert_city_temple::DesertCityTemple,
dungeon::Dungeon, giant_tree::GiantTree, gnarling::GnarlingFortification, house::House, dungeon::Dungeon, giant_tree::GiantTree, gnarling::GnarlingFortification, house::House,
sea_chapel::SeaChapel, workshop::Workshop, savannah_pit::SavannahPit, sea_chapel::SeaChapel, workshop::Workshop,
}; };
use super::*; use super::*;
@ -64,4 +65,5 @@ pub enum PlotKind {
GiantTree(GiantTree), GiantTree(GiantTree),
CliffTower(CliffTower), CliffTower(CliffTower),
Citadel(Citadel), Citadel(Citadel),
SavannahPit(SavannahPit),
} }

File diff suppressed because it is too large Load Diff