diff --git a/server/src/rtsim/entity.rs b/server/src/rtsim/entity.rs index d61d70d38d..ab6401afba 100644 --- a/server/src/rtsim/entity.rs +++ b/server/src/rtsim/entity.rs @@ -104,8 +104,6 @@ impl Entity { // is not used for RtSim as of now. pub fn get_adhoc_loadout( &self, - world: &World, - index: &world::IndexOwned, ) -> fn(LoadoutBuilder, Option<&trade::SiteInformation>) -> LoadoutBuilder { let body = self.get_body(); let kind = self.kind; diff --git a/server/src/rtsim/tick.rs b/server/src/rtsim/tick.rs index 3102166dc1..9c111b0543 100644 --- a/server/src/rtsim/tick.rs +++ b/server/src/rtsim/tick.rs @@ -129,16 +129,31 @@ impl<'a> System<'a> for Sys { } else { let entity_config_path = entity.get_entity_config(); let mut loadout_rng = entity.loadout_rng(); - let ad_hoc_loadout = entity.get_adhoc_loadout(&world, &index); + let ad_hoc_loadout = entity.get_adhoc_loadout(); // Body is rewritten so that body parameters // are consistent between reifications let entity_config = EntityConfig::from_asset_expect(entity_config_path) .with_body(BodyBuilder::Exact(body)); - let entity_info = EntityInfo::at(pos.0) + let mut entity_info = EntityInfo::at(pos.0) .with_entity_config(entity_config, Some(entity_config_path)) .with_lazy_loadout(ad_hoc_loadout) .with_health_scaling(10); + // Merchants can be traded with + if let Some(economy) = matches!(entity.kind, RtSimEntityKind::Merchant) + .then(|| { + entity + .brain + .begin_site() + .and_then(|home| world.civs().sites[home].site_tmp) + .and_then(|site| index.sites[site].trade_information(site.id())) + }) + .flatten() + { + entity_info = entity_info + .with_agent_mark(comp::agent::Mark::Merchant) + .with_economy(&economy); + } match NpcData::from_entity_info(entity_info, &mut loadout_rng) { NpcData::Data { pos, diff --git a/world/src/site/mod.rs b/world/src/site/mod.rs index c855b298a1..8e15a8db56 100644 --- a/world/src/site/mod.rs +++ b/world/src/site/mod.rs @@ -131,15 +131,17 @@ impl Site { site_id: common::trade::SiteId, ) -> Option { match &self.kind { - SiteKind::Settlement(s) => Some(common::trade::SiteInformation { - id: site_id, - unconsumed_stock: self - .economy - .unconsumed_stock - .iter() - .map(|(g, a)| (g.into(), *a)) - .collect(), - }), + SiteKind::Settlement(_) | SiteKind::Refactor(_) => { + Some(common::trade::SiteInformation { + id: site_id, + unconsumed_stock: self + .economy + .unconsumed_stock + .iter() + .map(|(g, a)| (g.into(), *a)) + .collect(), + }) + }, _ => None, } } diff --git a/world/src/site/settlement/mod.rs b/world/src/site/settlement/mod.rs index 6ddaae9051..9c568b6c50 100644 --- a/world/src/site/settlement/mod.rs +++ b/world/src/site/settlement/mod.rs @@ -1125,7 +1125,7 @@ fn ingredient_backpack(economy: Option<&trade::SiteInformation>, rng: &mut impl // `to_skip` is ideologicaly boolean flag either to start from 0-th or 1-th slot let mut to_skip = 0; - if let Some(coins) = coins { + if let Some(coins) = coins.filter(|c| *c > 0) { let mut coin_item = Item::new_from_asset_expect("common.items.utility.coins"); coin_item .set_amount(coins)