Fixed site2 economies

This commit is contained in:
Joshua Barretto 2022-01-25 16:31:12 +00:00
parent 54d5a06a0d
commit 59ac3b1d4f
3 changed files with 15 additions and 4 deletions

View File

@ -776,13 +776,19 @@ impl Civs {
let mut nearby = self
.sites
.iter()
.filter(|(_, p)| matches!(p.kind, SiteKind::Settlement | SiteKind::Castle))
.filter(|(_, p)| {
matches!(
p.kind,
SiteKind::Refactor | SiteKind::Settlement | SiteKind::Castle
)
})
.map(|(id, p)| (id, (p.center.distance_squared(loc) as f32).sqrt()))
.filter(|(_, dist)| *dist < MAX_NEIGHBOR_DISTANCE)
.collect::<Vec<_>>();
nearby.sort_by_key(|(_, dist)| *dist as i32);
if let SiteKind::Settlement | SiteKind::Castle = self.sites[site].kind {
if let SiteKind::Refactor | SiteKind::Settlement | SiteKind::Castle = self.sites[site].kind
{
for (nearby, _) in nearby.into_iter().take(5) {
// Find a novel path
if let Some((path, cost)) = find_path(ctx, loc, self.sites.get(nearby).center) {

View File

@ -205,7 +205,7 @@ fn simulate_return(index: &mut Index, world: &mut WorldSim) -> Result<(), std::i
SiteKind::Settlement(_) => towns += site.economy.pop,
SiteKind::Castle(_) => castles += site.economy.pop,
SiteKind::Tree(_) => (),
SiteKind::Refactor(_) => (),
SiteKind::Refactor(_) => towns += site.economy.pop,
}
}
if towns.valid() {
@ -1225,6 +1225,9 @@ mod tests {
crate::site::SiteKind::Castle(_) => {
common::terrain::site::SitesKind::Castle
},
crate::site::SiteKind::Refactor(_) => {
common::terrain::site::SitesKind::Settlement
},
_ => common::terrain::site::SitesKind::Void,
},
};

View File

@ -181,5 +181,7 @@ impl Site {
}
}
pub fn do_economic_simulation(&self) -> bool { matches!(self.kind, SiteKind::Settlement(_)) }
pub fn do_economic_simulation(&self) -> bool {
matches!(self.kind, SiteKind::Refactor(_) | SiteKind::Settlement(_))
}
}