summaryrefslogtreecommitdiff
path: root/src/systems/talk.rs
diff options
context:
space:
mode:
authortroido <troido@protonmail.com>2020-05-21 15:26:12 +0200
committertroido <troido@protonmail.com>2020-06-05 22:27:54 +0200
commit1899b27b791734a6b72e28cfb1420536c6035ee4 (patch)
treecbb908f05c1daa1c9fb996d474a34f0b6f4aba76 /src/systems/talk.rs
parentf47034bdf86e7ddc831ecb8f50689b9b07a0f6ca (diff)
added exchanger as seperate component/system; refactored other interactions; parameter parsing returns result instead of option
Diffstat (limited to 'src/systems/talk.rs')
-rw-r--r--src/systems/talk.rs14
1 files changed, 4 insertions, 10 deletions
diff --git a/src/systems/talk.rs b/src/systems/talk.rs
index 4bb898a..50e491f 100644
--- a/src/systems/talk.rs
+++ b/src/systems/talk.rs
@@ -1,5 +1,4 @@
-use std::collections::HashSet;
use specs::{
ReadStorage,
@@ -37,15 +36,10 @@ impl <'a> System<'a> for Talk {
for (controller, position, ear) in (&controllers, &positions, &mut ears).join(){
match &controller.control {
Control::Interact(directions, None) => {
- 'targets: for direction in directions {
- let pos = position.pos + direction.to_position();
- for ent in ground.cells.get(&pos).unwrap_or(&HashSet::new()) {
- if let Some(Talkable{text}) = talkables.get(*ent) {
- let name = visibles.get(*ent).map(|v| v.name.clone());
- ear.sounds.push(Notification::Sound{text: text.clone(), source: name});
- break 'targets;
- }
- }
+ for (ent, Talkable{text}) in ground.components_near(position.pos, directions, &talkables) {
+ let name = visibles.get(ent).map(|v| v.name.clone());
+ ear.sounds.push(Notification::Sound{text: text.clone(), source: name});
+ break;
}
}
_ => {}