JungleRuin

This commit is contained in:
flo 2023-08-16 12:35:27 +00:00
parent 21bf0a5572
commit fdea283f98
76 changed files with 850 additions and 24 deletions

View File

@ -0,0 +1,292 @@
#![enable(unwrap_newtypes)]
[
(
specifier: "world.structure.jungle_ruin.0",
center: (10, 10, 2)
),
(
specifier: "world.structure.jungle_ruin.1",
center: (10, 10, 2)
),
(
specifier: "world.structure.jungle_ruin.3",
center: (10, 10, 2)
),
(
specifier: "world.structure.jungle_ruin.4",
center: (10, 10, 2)
),
(
specifier: "world.structure.jungle_ruin.5",
center: (10, 10, 2)
),
(
specifier: "world.structure.jungle_ruin.6",
center: (10, 10, 2)
),
(
specifier: "world.structure.jungle_ruin.6",
center: (10, 10, 2)
),
(
specifier: "world.structure.jungle_ruin.8",
center: (10, 10, 2)
),
(
specifier: "world.structure.jungle_ruin.9",
center: (10, 10, 2)
),
(
specifier: "world.structure.jungle_ruin.10",
center: (10, 10, 2)
),
(
specifier: "world.structure.jungle_ruin.11",
center: (10, 10, 2)
),
(
specifier: "world.structure.jungle_ruin.12",
center: (10, 10, 2)
),
(
specifier: "world.structure.jungle_ruin.13",
center: (10, 10, 2)
),
(
specifier: "world.structure.jungle_ruin.14",
center: (10, 10, 2)
),
(
specifier: "world.structure.jungle_ruin.15",
center: (10, 10, 2)
),
(
specifier: "world.structure.jungle_ruin.16",
center: (10, 10, 2)
),
(
specifier: "world.structure.jungle_ruin.17",
center: (10, 10, 2)
),
(
specifier: "world.structure.jungle_ruin.18",
center: (10, 10, 2)
),
(
specifier: "world.structure.jungle_ruin.19",
center: (10, 10, 2)
),
(
specifier: "world.structure.jungle_ruin.20",
center: (10, 10, 2)
),
(
specifier: "world.structure.jungle_ruin.21",
center: (10, 10, 2)
),
(
specifier: "world.structure.jungle_ruin.22",
center: (10, 10, 2)
),
(
specifier: "world.structure.jungle_ruin.23",
center: (10, 10, 2)
),
(
specifier: "world.structure.jungle_ruin.24",
center: (10, 10, 2)
),
(
specifier: "world.structure.jungle_ruin.25",
center: (10, 10, 2)
),
(
specifier: "world.structure.jungle_ruin.26",
center: (10, 10, 2)
),
(
specifier: "world.structure.jungle_ruin.27",
center: (10, 10, 2)
),
(
specifier: "world.structure.jungle_ruin.28",
center: (10, 10, 2)
),
(
specifier: "world.structure.jungle_ruin.29",
center: (10, 10, 2)
),
(
specifier: "world.structure.jungle_ruin.30",
center: (10, 10, 2)
),
(
specifier: "world.structure.jungle_ruin.31",
center: (10, 10, 2)
),
(
specifier: "world.structure.jungle_ruin.32",
center: (10, 10, 2)
),
(
specifier: "world.structure.jungle_ruin.33",
center: (10, 10, 2)
),
(
specifier: "world.structure.jungle_ruin.34",
center: (10, 10, 2)
),
(
specifier: "world.structure.jungle_ruin.35",
center: (10, 10, 2)
),
(
specifier: "world.structure.jungle_ruin.36",
center: (10, 10, 2)
),
(
specifier: "world.structure.jungle_ruin.37",
center: (10, 10, 2)
),
(
specifier: "world.structure.jungle_ruin.38",
center: (10, 10, 2)
),
(
specifier: "world.structure.jungle_ruin.39",
center: (10, 10, 2)
),
(
specifier: "world.structure.jungle_ruin.40",
center: (10, 10, 2)
),
(
specifier: "world.structure.jungle_ruin.41",
center: (10, 10, 2)
),
(
specifier: "world.structure.jungle_ruin.42",
center: (10, 10, 2)
),
(
specifier: "world.structure.jungle_ruin.43",
center: (10, 10, 2)
),
(
specifier: "world.structure.jungle_ruin.44",
center: (10, 10, 2)
),
(
specifier: "world.structure.jungle_ruin.45",
center: (10, 10, 2)
),
(
specifier: "world.structure.jungle_ruin.46",
center: (10, 10, 2)
),
(
specifier: "world.structure.jungle_ruin.47",
center: (10, 10, 2)
),
(
specifier: "world.structure.jungle_ruin.48",
center: (10, 10, 2)
),
(
specifier: "world.structure.jungle_ruin.49",
center: (10, 10, 2)
),
(
specifier: "world.structure.jungle_ruin.50",
center: (10, 10, 2)
),
(
specifier: "world.structure.jungle_ruin.51",
center: (10, 10, 2)
),
(
specifier: "world.structure.jungle_ruin.52",
center: (10, 10, 2)
),
(
specifier: "world.structure.jungle_ruin.53",
center: (10, 10, 2)
),
(
specifier: "world.structure.jungle_ruin.54",
center: (10, 10, 2)
),
(
specifier: "world.structure.jungle_ruin.55",
center: (10, 10, 2)
),
(
specifier: "world.structure.jungle_ruin.56",
center: (10, 10, 2)
),
(
specifier: "world.structure.jungle_ruin.57",
center: (10, 10, 2)
),
(
specifier: "world.structure.jungle_ruin.58",
center: (10, 10, 2)
),
(
specifier: "world.structure.jungle_ruin.59",
center: (10, 10, 2)
),
(
specifier: "world.structure.jungle_ruin.60",
center: (10, 10, 2)
),
(
specifier: "world.structure.jungle_ruin.61",
center: (10, 10, 2)
),
(
specifier: "world.structure.jungle_ruin.62",
center: (10, 10, 2)
),
(
specifier: "world.structure.jungle_ruin.63",
center: (10, 10, 2)
),
(
specifier: "world.structure.jungle_ruin.64",
center: (10, 10, 2)
),
(
specifier: "world.structure.jungle_ruin.65",
center: (10, 10, 2)
),
(
specifier: "world.structure.jungle_ruin.66",
center: (10, 10, 2)
),
]

BIN
assets/world/structure/jungle_ruin/0.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/world/structure/jungle_ruin/1.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/world/structure/jungle_ruin/10.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/world/structure/jungle_ruin/11.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/world/structure/jungle_ruin/12.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/world/structure/jungle_ruin/13.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/world/structure/jungle_ruin/14.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/world/structure/jungle_ruin/15.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/world/structure/jungle_ruin/16.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/world/structure/jungle_ruin/17.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/world/structure/jungle_ruin/18.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/world/structure/jungle_ruin/19.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/world/structure/jungle_ruin/2.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/world/structure/jungle_ruin/20.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/world/structure/jungle_ruin/21.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/world/structure/jungle_ruin/22.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/world/structure/jungle_ruin/23.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/world/structure/jungle_ruin/24.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/world/structure/jungle_ruin/25.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/world/structure/jungle_ruin/26.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/world/structure/jungle_ruin/27.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/world/structure/jungle_ruin/28.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/world/structure/jungle_ruin/29.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/world/structure/jungle_ruin/3.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/world/structure/jungle_ruin/30.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/world/structure/jungle_ruin/31.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/world/structure/jungle_ruin/32.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/world/structure/jungle_ruin/33.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/world/structure/jungle_ruin/34.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/world/structure/jungle_ruin/35.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/world/structure/jungle_ruin/36.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/world/structure/jungle_ruin/37.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/world/structure/jungle_ruin/38.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/world/structure/jungle_ruin/39.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/world/structure/jungle_ruin/4.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/world/structure/jungle_ruin/40.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/world/structure/jungle_ruin/41.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/world/structure/jungle_ruin/42.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/world/structure/jungle_ruin/43.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/world/structure/jungle_ruin/44.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/world/structure/jungle_ruin/45.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/world/structure/jungle_ruin/46.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/world/structure/jungle_ruin/47.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/world/structure/jungle_ruin/48.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/world/structure/jungle_ruin/49.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/world/structure/jungle_ruin/5.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/world/structure/jungle_ruin/50.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/world/structure/jungle_ruin/51.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/world/structure/jungle_ruin/52.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/world/structure/jungle_ruin/53.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/world/structure/jungle_ruin/54.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/world/structure/jungle_ruin/55.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/world/structure/jungle_ruin/56.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/world/structure/jungle_ruin/57.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/world/structure/jungle_ruin/58.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/world/structure/jungle_ruin/59.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/world/structure/jungle_ruin/6.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/world/structure/jungle_ruin/60.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/world/structure/jungle_ruin/61.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/world/structure/jungle_ruin/62.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/world/structure/jungle_ruin/63.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/world/structure/jungle_ruin/64.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/world/structure/jungle_ruin/65.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/world/structure/jungle_ruin/66.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/world/structure/jungle_ruin/7.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/world/structure/jungle_ruin/8.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/world/structure/jungle_ruin/9.vox (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -32,6 +32,7 @@ impl Site {
| SiteKind::ChapelSite(_)
| SiteKind::Gnarling(_)
| SiteKind::PirateHideout(_)
| SiteKind::JungleRuin(_)
| SiteKind::Adlet(_) => Some(false),
SiteKind::DwarvenMine(_) => Some(false),
// Neutral

View File

@ -259,7 +259,7 @@ impl Civs {
let world_dims = ctx.sim.get_aabr();
for _ in 0..initial_civ_count * 3 {
attempt(5, || {
let (loc, kind) = match ctx.rng.gen_range(0..78) {
let (loc, kind) = match ctx.rng.gen_range(0..84) {
0..=5 => (
find_site_loc(
&mut ctx,
@ -347,6 +347,16 @@ impl Civs {
)?,
SiteKind::PirateHideout,
),
69..=75 => (
find_site_loc(
&mut ctx,
&ProximityRequirementsBuilder::new()
.avoid_all_of(this.jungle_ruin_enemies(), 40)
.finalize(&world_dims),
&SiteKind::JungleRuin,
)?,
SiteKind::JungleRuin,
),
_ => (
find_site_loc(
&mut ctx,
@ -384,6 +394,7 @@ impl Civs {
SiteKind::CliffTown => (64i32, 25.0),
SiteKind::SavannahPit => (48i32, 25.0),
SiteKind::CoastalTown => (64i32, 35.0),
SiteKind::JungleRuin => (8i32, 3.0),
SiteKind::DesertCity => (64i32, 25.0),
SiteKind::ChapelSite => (36i32, 10.0),
SiteKind::Tree => (12i32, 8.0),
@ -508,6 +519,9 @@ impl Civs {
wpos,
))
},
SiteKind::JungleRuin => WorldSite::jungle_ruin(
site2::Site::generate_jungle_ruin(&Land::from_sim(ctx.sim), &mut rng, wpos),
),
SiteKind::DesertCity => WorldSite::desert_city(
site2::Site::generate_desert_city(&Land::from_sim(ctx.sim), &mut rng, wpos),
),
@ -1448,6 +1462,13 @@ impl Civs {
})
}
fn jungle_ruin_enemies(&self) -> impl Iterator<Item = Vec2<i32>> + '_ {
self.sites().filter_map(|s| match s.kind {
SiteKind::Tree | SiteKind::GiantTree => None,
_ => Some(s.center),
})
}
fn town_enemies(&self) -> impl Iterator<Item = Vec2<i32>> + '_ {
self.sites().filter_map(|s| match s.kind {
SiteKind::Castle | SiteKind::Citadel => None,
@ -1802,6 +1823,7 @@ pub enum SiteKind {
Adlet,
PirateHideout,
//DwarvenMine,
JungleRuin,
}
impl SiteKind {
@ -1859,7 +1881,10 @@ impl SiteKind {
},
SiteKind::Citadel => true,
SiteKind::CliffTown => {
(-0.6..0.4).contains(&chunk.temp) && chunk.near_cliffs() && suitable_for_town()
(-0.6..0.4).contains(&chunk.temp)
&& chunk.near_cliffs()
&& !chunk.river.near_water()
&& suitable_for_town()
},
SiteKind::SavannahPit => {
matches!(chunk.get_biome(), BiomeKind::Savannah)
@ -1874,6 +1899,9 @@ impl SiteKind {
SiteKind::PirateHideout => {
(0.5..3.5).contains(&(chunk.water_alt - CONFIG.sea_level))
},
SiteKind::JungleRuin => {
matches!(chunk.get_biome(), BiomeKind::Jungle)
},
SiteKind::DesertCity => {
(0.9..1.0).contains(&chunk.temp) && !chunk.near_cliffs() && suitable_for_town()
},

View File

@ -157,14 +157,14 @@ impl World {
.civs()
.sites
.iter()
.filter(|(_, site)| !matches!(&site.kind, civ::SiteKind::PirateHideout))
.filter(|(_, site)| !matches!(&site.kind, civ::SiteKind::PirateHideout | civ::SiteKind::JungleRuin))
.map(|(_, site)| {
world_msg::SiteInfo {
id: site.site_tmp.map(|i| i.id()).unwrap_or_default(),
name: site.site_tmp.map(|id| index.sites[id].name().to_string()),
// TODO: Probably unify these, at some point
kind: match &site.kind {
civ::SiteKind::Settlement | civ::SiteKind::Refactor | civ::SiteKind::CliffTown | civ::SiteKind::SavannahPit | civ::SiteKind::CoastalTown | civ::SiteKind::DesertCity | civ::SiteKind::PirateHideout => world_msg::SiteKind::Town,
civ::SiteKind::Settlement | civ::SiteKind::Refactor | civ::SiteKind::CliffTown | civ::SiteKind::SavannahPit | civ::SiteKind::CoastalTown | civ::SiteKind::DesertCity | civ::SiteKind::PirateHideout | civ::SiteKind::JungleRuin => world_msg::SiteKind::Town,
civ::SiteKind::Dungeon => world_msg::SiteKind::Dungeon {
difficulty: match site.site_tmp.map(|id| &index.sites[id].kind) {
Some(SiteKind::Dungeon(d)) => d.dungeon_difficulty().unwrap_or(0),

View File

@ -131,6 +131,7 @@ impl Environment {
SiteKind::GiantTree(_) => (),
SiteKind::Gnarling(_) => {},
SiteKind::Adlet(_) => {},
SiteKind::JungleRuin(_) => {},
SiteKind::ChapelSite(_) => {},
SiteKind::DwarvenMine(_) => {},
SiteKind::Bridge(_) => {},

View File

@ -78,6 +78,7 @@ pub enum SiteKind {
Bridge(site2::Site),
Adlet(site2::Site),
PirateHideout(site2::Site),
JungleRuin(site2::Site),
}
impl Site {
@ -102,9 +103,9 @@ impl Site {
}
}
pub fn adlet(g: site2::Site) -> Self {
pub fn adlet(ad: site2::Site) -> Self {
Self {
kind: SiteKind::Adlet(g),
kind: SiteKind::Adlet(ad),
economy: Economy::default(),
}
}
@ -151,6 +152,13 @@ impl Site {
}
}
pub fn jungle_ruin(jr: site2::Site) -> Self {
Self {
kind: SiteKind::JungleRuin(jr),
economy: Economy::default(),
}
}
pub fn desert_city(dc: site2::Site) -> Self {
Self {
kind: SiteKind::DesertCity(dc),
@ -165,9 +173,9 @@ impl Site {
}
}
pub fn dwarven_mine(p: site2::Site) -> Self {
pub fn dwarven_mine(dm: site2::Site) -> Self {
Self {
kind: SiteKind::DwarvenMine(p),
kind: SiteKind::DwarvenMine(dm),
economy: Economy::default(),
}
}
@ -203,14 +211,15 @@ impl Site {
SiteKind::SavannahPit(sp) => sp.radius(),
SiteKind::CoastalTown(ct) => ct.radius(),
SiteKind::PirateHideout(ph) => ph.radius(),
SiteKind::JungleRuin(jr) => jr.radius(),
SiteKind::DesertCity(dc) => dc.radius(),
SiteKind::ChapelSite(p) => p.radius(),
SiteKind::DwarvenMine(p) => p.radius(),
SiteKind::DwarvenMine(dm) => dm.radius(),
SiteKind::Tree(t) => t.radius(),
SiteKind::GiantTree(gt) => gt.radius(),
SiteKind::Gnarling(g) => g.radius(),
SiteKind::Bridge(b) => b.radius(),
SiteKind::Adlet(g) => g.radius(),
SiteKind::Adlet(ad) => ad.radius(),
}
}
@ -224,14 +233,15 @@ impl Site {
SiteKind::SavannahPit(sp) => sp.origin,
SiteKind::CoastalTown(ct) => ct.origin,
SiteKind::PirateHideout(ph) => ph.origin,
SiteKind::JungleRuin(jr) => jr.origin,
SiteKind::DesertCity(dc) => dc.origin,
SiteKind::ChapelSite(p) => p.origin,
SiteKind::DwarvenMine(p) => p.origin,
SiteKind::DwarvenMine(dm) => dm.origin,
SiteKind::Tree(t) => t.origin,
SiteKind::GiantTree(gt) => gt.origin,
SiteKind::Gnarling(g) => g.origin,
SiteKind::Bridge(b) => b.origin,
SiteKind::Adlet(g) => g.origin,
SiteKind::Adlet(ad) => ad.origin,
}
}
@ -245,14 +255,15 @@ impl Site {
SiteKind::SavannahPit(sp) => sp.spawn_rules(wpos),
SiteKind::CoastalTown(ct) => ct.spawn_rules(wpos),
SiteKind::PirateHideout(ph) => ph.spawn_rules(wpos),
SiteKind::JungleRuin(jr) => jr.spawn_rules(wpos),
SiteKind::DesertCity(dc) => dc.spawn_rules(wpos),
SiteKind::ChapelSite(p) => p.spawn_rules(wpos),
SiteKind::DwarvenMine(p) => p.spawn_rules(wpos),
SiteKind::DwarvenMine(dm) => dm.spawn_rules(wpos),
SiteKind::Tree(t) => t.spawn_rules(wpos),
SiteKind::GiantTree(gt) => gt.spawn_rules(wpos),
SiteKind::Gnarling(g) => g.spawn_rules(wpos),
SiteKind::Bridge(b) => b.spawn_rules(wpos),
SiteKind::Adlet(g) => g.spawn_rules(wpos),
SiteKind::Adlet(ad) => ad.spawn_rules(wpos),
}
}
@ -266,14 +277,15 @@ impl Site {
SiteKind::SavannahPit(sp) => sp.name(),
SiteKind::CoastalTown(ct) => ct.name(),
SiteKind::PirateHideout(ph) => ph.name(),
SiteKind::JungleRuin(jr) => jr.name(),
SiteKind::DesertCity(dc) => dc.name(),
SiteKind::ChapelSite(p) => p.name(),
SiteKind::DwarvenMine(p) => p.name(),
SiteKind::DwarvenMine(dm) => dm.name(),
SiteKind::Tree(_) => "Giant Tree",
SiteKind::GiantTree(gt) => gt.name(),
SiteKind::Gnarling(g) => g.name(),
SiteKind::Bridge(b) => b.name(),
SiteKind::Adlet(g) => g.name(),
SiteKind::Adlet(ad) => ad.name(),
}
}
@ -287,7 +299,6 @@ impl Site {
| SiteKind::CliffTown(_)
| SiteKind::SavannahPit(_)
| SiteKind::CoastalTown(_)
| SiteKind::PirateHideout(_)
| SiteKind::DesertCity(_) => Some(common::trade::SiteInformation {
id: site_id,
unconsumed_stock: self.economy.get_available_stock(),
@ -308,14 +319,15 @@ impl Site {
SiteKind::SavannahPit(sp) => sp.render(canvas, dynamic_rng),
SiteKind::CoastalTown(ct) => ct.render(canvas, dynamic_rng),
SiteKind::PirateHideout(ph) => ph.render(canvas, dynamic_rng),
SiteKind::JungleRuin(jr) => jr.render(canvas, dynamic_rng),
SiteKind::DesertCity(dc) => dc.render(canvas, dynamic_rng),
SiteKind::ChapelSite(p) => p.render(canvas, dynamic_rng),
SiteKind::DwarvenMine(p) => p.render(canvas, dynamic_rng),
SiteKind::DwarvenMine(dm) => dm.render(canvas, dynamic_rng),
SiteKind::Tree(t) => t.render(canvas, dynamic_rng),
SiteKind::GiantTree(gt) => gt.render(canvas, dynamic_rng),
SiteKind::Gnarling(g) => g.render(canvas, dynamic_rng),
SiteKind::Bridge(b) => b.render(canvas, dynamic_rng),
SiteKind::Adlet(g) => g.render(canvas, dynamic_rng),
SiteKind::Adlet(ad) => ad.render(canvas, dynamic_rng),
}
}
@ -342,14 +354,15 @@ impl Site {
SiteKind::SavannahPit(_) => {},
SiteKind::CoastalTown(_) => {},
SiteKind::PirateHideout(_) => {},
SiteKind::JungleRuin(_) => {},
SiteKind::DesertCity(_) => {},
SiteKind::ChapelSite(p) => p.apply_supplement(dynamic_rng, wpos2d, supplement),
SiteKind::DwarvenMine(p) => p.apply_supplement(dynamic_rng, wpos2d, supplement),
SiteKind::DwarvenMine(dm) => dm.apply_supplement(dynamic_rng, wpos2d, supplement),
SiteKind::Tree(_) => {},
SiteKind::GiantTree(gt) => gt.apply_supplement(dynamic_rng, wpos2d, supplement),
SiteKind::Gnarling(g) => g.apply_supplement(dynamic_rng, wpos2d, supplement),
SiteKind::Bridge(b) => b.apply_supplement(dynamic_rng, wpos2d, supplement),
SiteKind::Adlet(g) => g.apply_supplement(dynamic_rng, wpos2d, supplement),
SiteKind::Adlet(ad) => ad.apply_supplement(dynamic_rng, wpos2d, supplement),
}
}
@ -378,6 +391,7 @@ impl Site {
SiteKind::SavannahPit(site2) => Some(site2),
SiteKind::CoastalTown(site2) => Some(site2),
SiteKind::PirateHideout(site2) => Some(site2),
SiteKind::JungleRuin(site2) => Some(site2),
SiteKind::Tree(_) => None,
SiteKind::DesertCity(site2) => Some(site2),
SiteKind::ChapelSite(site2) => Some(site2),

View File

@ -1293,6 +1293,37 @@ impl Site {
site
}
pub fn generate_jungle_ruin(land: &Land, rng: &mut impl Rng, origin: Vec2<i32>) -> Self {
let mut rng = reseed(rng);
let mut site = Site {
origin,
name: "".to_string(),
..Site::default()
};
let size = 8.0 as i32;
let aabr = Aabr {
min: Vec2::broadcast(-size),
max: Vec2::broadcast(size),
};
{
let jungle_ruin = plot::JungleRuin::generate(land, &mut reseed(&mut rng), &site, aabr);
let jungle_ruin_alt = jungle_ruin.alt;
let plot = site.create_plot(Plot {
kind: PlotKind::JungleRuin(jungle_ruin),
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(jungle_ruin_alt),
});
}
site
}
pub fn generate_bridge(
land: &Land,
index: IndexRef,
@ -1622,6 +1653,7 @@ impl Site {
PlotKind::CoastalWorkshop(coastal_workshop) => {
coastal_workshop.render_collect(self, canvas)
},
PlotKind::JungleRuin(jungle_ruin) => jungle_ruin.render_collect(self, canvas),
PlotKind::Workshop(workshop) => workshop.render_collect(self, canvas),
PlotKind::Castle(castle) => castle.render_collect(self, canvas),
PlotKind::SeaChapel(sea_chapel) => sea_chapel.render_collect(self, canvas),

View File

@ -12,6 +12,7 @@ mod dwarven_mine;
mod giant_tree;
mod gnarling;
mod house;
mod jungle_ruin;
mod pirate_hideout;
mod savannah_hut;
mod savannah_pit;
@ -24,9 +25,9 @@ pub use self::{
cliff_tower::CliffTower, coastal_house::CoastalHouse, coastal_workshop::CoastalWorkshop,
desert_city_multiplot::DesertCityMultiPlot, desert_city_temple::DesertCityTemple,
dungeon::Dungeon, dwarven_mine::DwarvenMine, giant_tree::GiantTree,
gnarling::GnarlingFortification, house::House, pirate_hideout::PirateHideout,
savannah_hut::SavannahHut, savannah_pit::SavannahPit, savannah_workshop::SavannahWorkshop,
sea_chapel::SeaChapel, workshop::Workshop,
gnarling::GnarlingFortification, house::House, jungle_ruin::JungleRuin,
pirate_hideout::PirateHideout, savannah_hut::SavannahHut, savannah_pit::SavannahPit,
savannah_workshop::SavannahWorkshop, sea_chapel::SeaChapel, workshop::Workshop,
};
use super::*;
@ -74,6 +75,7 @@ pub enum PlotKind {
DesertCityMultiPlot(DesertCityMultiPlot),
DesertCityTemple(DesertCityTemple),
SeaChapel(SeaChapel),
JungleRuin(JungleRuin),
Plaza,
Castle(Castle),
Road(Path<Vec2<i32>>),

View File

@ -0,0 +1,255 @@
use super::*;
use crate::{
assets::AssetHandle,
site2::gen::PrimitiveTransform,
util::{sampler::Sampler, RandomField},
Land,
};
use common::{
generation::EntityInfo,
terrain::{SpriteKind, Structure as PrefabStructure, StructuresGroup},
};
use lazy_static::lazy_static;
use rand::prelude::*;
use std::{f32::consts::TAU, sync::Arc};
use vek::*;
pub struct JungleRuin {
bounds: Aabr<i32>,
pub(crate) alt: i32,
}
impl JungleRuin {
pub fn generate(land: &Land, _rng: &mut impl Rng, site: &Site, tile_aabr: Aabr<i32>) -> Self {
let bounds = Aabr {
min: site.tile_wpos(tile_aabr.min),
max: site.tile_wpos(tile_aabr.max),
};
Self {
bounds,
alt: land.get_alt_approx(site.tile_center_wpos((tile_aabr.max - tile_aabr.min) / 2))
as i32
+ 2,
}
}
}
impl Structure for JungleRuin {
#[cfg(feature = "use-dyn-lib")]
const UPDATE_FN: &'static [u8] = b"render_jungleruin\0";
#[cfg_attr(feature = "be-dyn-lib", export_name = "render_jungleruin")]
fn render_inner(&self, _site: &Site, land: &Land, painter: &Painter) {
let center = self.bounds.center();
let plot_base = land.get_alt_approx(center) as i32;
let mut thread_rng = thread_rng();
let stone = Fill::Sampling(Arc::new(|center| {
Some(match (RandomField::new(0).get(center)) % 52 {
0..=8 => Block::new(BlockKind::Rock, Rgb::new(92, 99, 86)),
9..=17 => Block::new(BlockKind::Rock, Rgb::new(83, 89, 78)),
18..=26 => Block::new(BlockKind::Rock, Rgb::new(75, 89, 66)),
27..=35 => Block::new(BlockKind::Rock, Rgb::new(79, 83, 73)),
36..=44 => Block::new(BlockKind::Rock, Rgb::new(66, 80, 59)),
_ => Block::new(BlockKind::Rock, Rgb::new(88, 94, 83)),
})
}));
let stone_broken = Fill::Sampling(Arc::new(|center| {
Some(match (RandomField::new(0).get(center)) % 56 {
0..=8 => Block::new(BlockKind::Rock, Rgb::new(92, 99, 86)),
9..=17 => Block::new(BlockKind::Rock, Rgb::new(83, 89, 78)),
18..=26 => Block::new(BlockKind::Rock, Rgb::new(75, 89, 66)),
27..=35 => Block::new(BlockKind::Rock, Rgb::new(79, 83, 73)),
36..=44 => Block::new(BlockKind::Rock, Rgb::new(66, 80, 59)),
45..=49 => Block::new(BlockKind::Air, Rgb::new(0, 0, 0)),
_ => Block::new(BlockKind::Rock, Rgb::new(88, 94, 83)),
})
}));
let grass_fill = Fill::Sampling(Arc::new(|wpos| {
Some(match (RandomField::new(0).get(wpos)) % 30 {
1..=2 => Block::air(SpriteKind::ShortGrass),
3..=7 => Block::air(SpriteKind::LongGrass),
8 => Block::air(SpriteKind::JungleFern),
_ => Block::new(BlockKind::Air, Rgb::new(0, 0, 0)),
})
}));
let mut ruin_positions = vec![];
let pos_var = RandomField::new(0).get(center.with_z(plot_base)) % 10;
let radius = 25 + pos_var;
let ruins = 12.0 + pos_var as f32;
let phi = TAU / ruins;
for n in 1..=ruins as i32 {
let pos = Vec2::new(
center.x + (radius as f32 * ((n as f32 * phi).cos())) as i32,
center.y + (radius as f32 * ((n as f32 * phi).sin())) as i32,
);
let base = land.get_alt_approx(pos) as i32;
let ground_sink = RandomField::new(0).get(pos.with_z(base)) as i32 % 4;
let ruin_pos = pos.with_z(base - 8 - ground_sink);
ruin_positions.push(ruin_pos);
}
let underground_chamber = pos_var < 7;
// center ruin and underground chest chamber
let room_size = 10;
let height_handle = 10;
if underground_chamber {
// room
painter
.aabb(Aabb {
min: (center - room_size - 1).with_z(plot_base - height_handle - room_size - 1),
max: (center + room_size + 1).with_z(plot_base - height_handle + room_size + 1),
})
.fill(stone.clone());
painter
.aabb(Aabb {
min: (center - room_size).with_z(plot_base - height_handle - room_size),
max: (center + room_size).with_z(plot_base - height_handle + room_size + 2),
})
.fill(stone_broken.clone());
// platform
painter
.aabb(Aabb {
min: (center - room_size + 1).with_z(plot_base - height_handle + room_size + 1),
max: (center + room_size - 1).with_z(plot_base - height_handle + room_size + 2),
})
.clear();
let center_ruin_pos = center.with_z(plot_base - 1);
ruin_positions.push(center_ruin_pos);
// room decor
for d in 0..=5 {
painter
.line(
Vec2::new(center.x, center.y - room_size + 1)
.with_z(plot_base - height_handle - (room_size / 3) + 3),
Vec2::new(center.x, center.y + room_size - 1)
.with_z(plot_base - height_handle - (room_size / 3) + 3),
(room_size - (2 * d)) as f32,
)
.fill(stone_broken.clone());
painter
.line(
Vec2::new(center.x, center.y - room_size + 1)
.with_z(plot_base - height_handle - (room_size / 3) + 3),
Vec2::new(center.x, center.y + room_size - 1)
.with_z(plot_base - height_handle - (room_size / 3) + 3),
(room_size - 1 - (2 * d)) as f32,
)
.clear();
painter
.line(
Vec2::new(center.x - room_size + 1, center.y)
.with_z(plot_base - height_handle - (room_size / 3) + 3),
Vec2::new(center.x + room_size - 1, center.y)
.with_z(plot_base - height_handle - (room_size / 3) + 3),
(room_size - (2 * d)) as f32,
)
.fill(stone_broken.clone());
painter
.line(
Vec2::new(center.x - room_size + 1, center.y)
.with_z(plot_base - height_handle - (room_size / 3) + 3),
Vec2::new(center.x + room_size - 1, center.y)
.with_z(plot_base - height_handle - (room_size / 3) + 3),
(room_size - 1 - (2 * d)) as f32,
)
.clear();
}
// clear room
painter
.aabb(Aabb {
min: (center - room_size).with_z(plot_base - height_handle - room_size),
max: (center + room_size).with_z(plot_base - height_handle + room_size - 1),
})
.clear();
painter
.aabb(Aabb {
min: (center - room_size).with_z(plot_base - height_handle - room_size),
max: (center + room_size).with_z(plot_base - height_handle - room_size + 1),
})
.fill(stone);
painter
.aabb(Aabb {
min: (center - room_size).with_z(plot_base - height_handle - room_size + 1),
max: (center + room_size).with_z(plot_base - height_handle - room_size + 2),
})
.fill(grass_fill);
}
for ruin_pos in ruin_positions {
// ruin models
lazy_static! {
pub static ref RUIN: AssetHandle<StructuresGroup> =
PrefabStructure::load_group("site_structures.jungle_ruin.jungle_ruin");
}
let rng = RandomField::new(0).get(ruin_pos) % 62;
let ruin = RUIN.read();
let ruin = ruin[rng as usize % ruin.len()].clone();
painter
.prim(Primitive::Prefab(Box::new(ruin.clone())))
.translate(ruin_pos)
.fill(Fill::Prefab(Box::new(ruin), ruin_pos, rng));
}
if underground_chamber {
// entry
painter
.aabb(Aabb {
min: Vec2::new(center.x - 9, center.y - 3)
.with_z(plot_base - height_handle - room_size + 1),
max: Vec2::new(center.x - 3, center.y + 3).with_z(plot_base + 30),
})
.clear();
// stairs
painter
.ramp(
Aabb {
min: Vec2::new(center.x - room_size, center.y - 3)
.with_z(plot_base - height_handle - room_size + 1),
max: Vec2::new(center.x, center.y + 3).with_z(plot_base),
},
Dir::NegX,
)
.fill(stone_broken);
let chest_pos = Vec2::new(center.x + room_size - 2, center.y - 3)
.with_z(plot_base - height_handle - room_size + 1);
painter.sprite(chest_pos, SpriteKind::DungeonChest0);
} else {
let chest_radius = radius / 2;
for n in 1..=(ruins / 4.0) as i32 {
let chest_pos = Vec2::new(
center.x + (chest_radius as f32 * ((n as f32 * phi).cos())) as i32,
center.y + (chest_radius as f32 * ((n as f32 * phi).sin())) as i32,
);
if RandomField::new(0).get(chest_pos.with_z(plot_base)) % 2 > 0 {
painter.sprite(chest_pos.with_z(plot_base - 1), SpriteKind::ChestBuried);
}
}
}
// npcs
let npc_radius = radius / 4;
for n in 1..=(ruins / 4.0) as i32 {
let npc_pos = Vec2::new(
center.x + (npc_radius as f32 * ((n as f32 * phi).cos())) as i32,
center.y + (npc_radius as f32 * ((n as f32 * phi).sin())) as i32,
);
match RandomField::new(0).get(center.with_z(plot_base)) % 6 {
// grave robbers
0 => painter.spawn(
EntityInfo::at(npc_pos.with_z(plot_base).as_()).with_asset_expect(
"common.entity.spot.dwarf_grave_robber",
&mut thread_rng,
),
),
// sauroks
1 => painter.spawn(
EntityInfo::at(npc_pos.with_z(plot_base).as_())
.with_asset_expect("common.entity.spot.saurok", &mut thread_rng),
),
// grim salvager
2 => painter.spawn(
EntityInfo::at(npc_pos.with_z(plot_base).as_())
.with_asset_expect("common.entity.spot.grim_salvager", &mut thread_rng),
),
_ => {},
}
}
}
}