From 608918af8174e9afb761cdd2ad46e489b21c5f4e Mon Sep 17 00:00:00 2001 From: troido Date: Thu, 16 Apr 2020 22:11:00 +0200 Subject: don't spread stones dropped from destroyed walls --- src/components/mod.rs | 1 + src/componentwrapper.rs | 4 ++-- src/systems/droploot.rs | 4 +++- 3 files changed, 6 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/components/mod.rs b/src/components/mod.rs index 176f97a..64fa717 100644 --- a/src/components/mod.rs +++ b/src/components/mod.rs @@ -197,6 +197,7 @@ pub struct Clan { #[derive(Component, Debug, Clone)] #[storage(HashMapStorage)] pub struct Loot { + pub spread: bool, pub loot: Vec<(Template, f64)> } diff --git a/src/componentwrapper.rs b/src/componentwrapper.rs index d677cb2..ecc8227 100644 --- a/src/componentwrapper.rs +++ b/src/componentwrapper.rs @@ -182,8 +182,8 @@ components!(all: Home (home: Pos); Faction (faction: String) {Faction::from_str(faction.as_str()).ok_or(aerr!("invalid faction name"))?}; Interactable (action: Interaction) {action}; - Loot (loot: List) { - Loot { loot: + Loot (loot: List, spread: Bool) { + Loot {spread, loot: loot .iter() .map(|param| {match param { diff --git a/src/systems/droploot.rs b/src/systems/droploot.rs index fcd104b..604f29f 100644 --- a/src/systems/droploot.rs +++ b/src/systems/droploot.rs @@ -39,8 +39,10 @@ impl <'a> System<'a> for DropLoot{ if triggerbox.has_message(&[Trigger::Die, Trigger::Loot]) { for (template, chance) in &loot.loot { if *chance > rand::thread_rng().gen_range(0.0, 1.0) { + let pos = if loot.spread { + pick_position(position.pos, &ground, &flags) + } else {position.pos}; // todo: better error handling - let pos = pick_position(position.pos, &ground, &flags); new.create(pos, &template).unwrap(); } } -- cgit