From 0fbe6a67f2fb0f9219e80ddd248c34513a45cca4 Mon Sep 17 00:00:00 2001 From: Tormod Gjeitnes Hellen Date: Wed, 15 Feb 2023 22:01:35 +0100 Subject: [PATCH] Make castles appear close to towns. --- CHANGELOG.md | 1 + world/src/civ/mod.rs | 11 +++++------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 74c8e85f23..9cce50bd8e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Bats move slower and use a simple proportional controller to maintain altitude - Bats now have less health - Climbing no longer requires having 10 energy +- Castles will now be placed close to towns ### Removed diff --git a/world/src/civ/mod.rs b/world/src/civ/mod.rs index d2042a1ef8..dd43147286 100644 --- a/world/src/civ/mod.rs +++ b/world/src/civ/mod.rs @@ -113,11 +113,8 @@ struct ProximityRequirements { impl ProximityRequirements { pub fn satisfied_by(&self, site: Vec2) -> bool { let all_of_compliance = self.all_of.iter().all(|spec| spec.satisfied_by(site)); - let any_of_compliance = if self.any_of.is_empty() { - true - } else { - self.any_of.iter().any(|spec| spec.satisfied_by(site)) - }; + let any_of_compliance = + self.any_of.is_empty() || self.any_of.iter().any(|spec| spec.satisfied_by(site)); all_of_compliance && any_of_compliance } @@ -193,7 +190,9 @@ impl Civs { 0..=5 => ( find_site_loc( &mut ctx, - &ProximityRequirements::new().avoid_all_of(this.castle_enemies(), 40), + &ProximityRequirements::new() + .avoid_all_of(this.castle_enemies(), 40) + .close_to_one_of(this.towns(), 20), SiteKind::Castle, )?, SiteKind::Castle,