mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Made merchants work in new sites
This commit is contained in:
parent
4b8bf94320
commit
0cb88139c9
@ -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;
|
||||
|
@ -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,
|
||||
|
@ -131,15 +131,17 @@ impl Site {
|
||||
site_id: common::trade::SiteId,
|
||||
) -> Option<common::trade::SiteInformation> {
|
||||
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,
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user