add the missing files outside of world from shredded_economy4

This commit is contained in:
Christof Petig 2022-06-01 23:41:46 +02:00
parent db85d2a146
commit 39fafe646c
2 changed files with 2 additions and 43 deletions

View File

@ -1,5 +1,4 @@
use crate::{client::Client, Server};
use common::trade::Good;
use common_net::msg::{world_msg::EconomyInfo, ServerGeneral};
use specs::{Entity as EcsEntity, WorldExt};
use std::collections::HashMap;
@ -30,47 +29,7 @@ pub fn handle_site_info(server: &Server, entity: EcsEntity, id: u64) {
let site_id = server.index.sites.recreate_id(id);
let info = if let Some(site_id) = site_id {
let site = server.index.sites.get(site_id);
EconomyInfo {
id,
population: site.economy.pop.floor() as u32,
stock: site
.economy
.stocks
.iter()
.map(|(g, a)| (Good::from(g), *a))
.collect(),
labor_values: site
.economy
.labor_values
.iter()
.filter_map(|(g, a)| a.map(|a| (Good::from(g), a)))
.collect(),
values: site
.economy
.values
.iter()
.filter_map(|(g, a)| a.map(|a| (Good::from(g), a)))
.collect(),
labors: site.economy.labors.iter().map(|(_, a)| (*a)).collect(),
last_exports: site
.economy
.last_exports
.iter()
.map(|(g, a)| (Good::from(g), *a))
.collect(),
resources: site
.economy
.natural_resources
.chunks_per_resource
.iter()
.map(|(g, a)| {
(
Good::from(g),
((*a) as f32) * site.economy.natural_resources.average_yield_per_chunk[g],
)
})
.collect(),
}
site.economy.get_information(site_id)
} else {
EconomyInfo {
id,

View File

@ -208,7 +208,7 @@ pub fn init(
},
SiteKind::Refactor(site2) => {
// villagers
for _ in 0..site.economy.pop.min(site2.plots().len() as f32) as usize {
for _ in 0..site.economy.population().min(site2.plots().len() as f32) as usize {
rtsim.entities.insert(Entity {
is_loaded: false,
pos: site2