From 5b65b1659460c7020c5c383eb942896770bc4ffd Mon Sep 17 00:00:00 2001 From: S Handley Date: Wed, 8 Jan 2020 12:48:00 +0000 Subject: [PATCH] Prevent NPCs from spawnign underwater This should be set until there are underwater NPC types. --- world/src/lib.rs | 5 ++++- world/src/sim/mod.rs | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/world/src/lib.rs b/world/src/lib.rs index 75c6a2e69c..745515cd54 100644 --- a/world/src/lib.rs +++ b/world/src/lib.rs @@ -148,7 +148,10 @@ impl World { const SPAWN_RATE: f32 = 0.1; const BOSS_RATE: f32 = 0.03; let supplement = ChunkSupplement { - npcs: if rand::thread_rng().gen::() < SPAWN_RATE && sim_chunk.chaos < 0.5 { + npcs: if rand::thread_rng().gen::() < SPAWN_RATE + && sim_chunk.chaos < 0.5 + && !sim_chunk.is_underwater + { vec![NpcInfo { pos: gen_entity_pos(), boss: rand::thread_rng().gen::() < BOSS_RATE, diff --git a/world/src/sim/mod.rs b/world/src/sim/mod.rs index ce7a484676..8735ad135b 100644 --- a/world/src/sim/mod.rs +++ b/world/src/sim/mod.rs @@ -970,6 +970,7 @@ pub struct SimChunk { pub spawn_rate: f32, pub location: Option, pub river: RiverData, + pub is_underwater: bool, pub structures: Structures, } @@ -1146,6 +1147,7 @@ impl SimChunk { } else { 0.0 }, + is_underwater, is_cliffs: cliff > 0.5 && !is_underwater, near_cliffs: cliff > 0.2, tree_density,