diff options
| author | troido <troido@protonmail.com> | 2020-04-16 22:11:00 +0200 |
|---|---|---|
| committer | troido <troido@protonmail.com> | 2020-04-16 22:11:00 +0200 |
| commit | 608918af8174e9afb761cdd2ad46e489b21c5f4e (patch) | |
| tree | d4ebfc375b1a4af5211f2aa332c1d8698151da45 /src | |
| parent | 4e144009aad9255af1e83970fc16fdafe3e79e83 (diff) | |
don't spread stones dropped from destroyed walls
Diffstat (limited to 'src')
| -rw-r--r-- | src/components/mod.rs | 1 | ||||
| -rw-r--r-- | src/componentwrapper.rs | 4 | ||||
| -rw-r--r-- | src/systems/droploot.rs | 4 |
3 files changed, 6 insertions, 3 deletions
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(); } } |
