diff options
| author | troido <troido@protonmail.com> | 2020-04-09 15:04:54 +0200 |
|---|---|---|
| committer | troido <troido@protonmail.com> | 2020-04-09 15:04:54 +0200 |
| commit | e7b4ed0f044c3ada82155f81d3b61c0c5ce36583 (patch) | |
| tree | ebdf7c9b712c07fcb89a1b50fb2a653fa749932d /src | |
| parent | 8dbe1f51ff1705f97a191197b3ee7cb66b682584 (diff) | |
change interaction is now a combination of harvest and loot
Diffstat (limited to 'src')
| -rw-r--r-- | src/components/interactable.rs | 4 | ||||
| -rw-r--r-- | src/systems/interact.rs | 12 |
2 files changed, 3 insertions, 13 deletions
diff --git a/src/components/interactable.rs b/src/components/interactable.rs index 33e3a12..eafe977 100644 --- a/src/components/interactable.rs +++ b/src/components/interactable.rs @@ -6,7 +6,6 @@ use specs::{ HashMapStorage }; use crate::{ - Template, exchange::Exchange, ItemId }; @@ -15,7 +14,6 @@ use crate::{ #[storage(HashMapStorage)] pub enum Interactable { Harvest, - Change(Template), Say(String), Reply(String), Exchange(String, HashMap<String, Exchange>) @@ -29,7 +27,6 @@ impl Interactable { let arg = if val.is_string() {&Value::Null} else {val.get(1)?}; Some(match typ.as_str()? { "harvest" => Harvest, - "change" => Change(Template::from_json(arg).ok()?), "say" => Say(arg.as_str()?.to_string()), "reply" => Reply(arg.as_str()?.to_string()), "exchange" => Exchange( @@ -53,7 +50,6 @@ impl Interactable { pub fn accepts_arg(&self, arg: &Option<String>) -> bool { match self { Harvest => arg.is_none(), - Change(_) => arg.is_none(), Say(_) => arg.is_none(), Reply(_) => arg.is_some(), Exchange(prefix, _exchanges) => { diff --git a/src/systems/interact.rs b/src/systems/interact.rs index 43c355d..fb11488 100644 --- a/src/systems/interact.rs +++ b/src/systems/interact.rs @@ -17,7 +17,6 @@ use crate::{ ControlCooldown, Interactable, Dead, - Removed, Sound, Ear, Inventory @@ -36,13 +35,12 @@ impl <'a> System<'a> for Interact { WriteStorage<'a, ControlCooldown>, ReadStorage<'a, Interactable>, WriteStorage<'a, Dead>, - WriteStorage<'a, Removed>, Write<'a, NewEntities>, WriteStorage<'a, Ear>, WriteStorage<'a, Inventory> ); - fn run(&mut self, (entities, controllers, positions, ground, mut cooldowns, interactables, mut deads, mut removeds, mut new, mut ears, mut inventories): Self::SystemData) { + fn run(&mut self, (entities, controllers, positions, ground, mut cooldowns, interactables, mut deads, new, mut ears, mut inventories): Self::SystemData) { for (entity, controller, position) in (&entities, &controllers, &positions).join(){ let mut target = None; let ear = ears.get_mut(entity); @@ -53,7 +51,7 @@ impl <'a> System<'a> for Interact { for ent in ground.cells.get(&pos).unwrap_or(&HashSet::new()) { if let Some(interactable) = interactables.get(*ent) { if interactable.accepts_arg(arg){ - target = Some((*ent, interactable, pos, arg.clone())); + target = Some((*ent, interactable, arg.clone())); break 'targets; } } @@ -62,15 +60,11 @@ impl <'a> System<'a> for Interact { } _ => {} } - if let Some((ent, interactable, pos, arg)) = target { + if let Some((ent, interactable, arg)) = target { match interactable { Interactable::Harvest => { deads.insert(ent, Dead).unwrap(); } - Interactable::Change(into) => { - new.create(pos, into).unwrap(); - removeds.insert(ent, Removed).unwrap(); - } Interactable::Say(text) => { say(ear, text.clone()); } |
