summaryrefslogtreecommitdiff
path: root/src/systems/interact.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/systems/interact.rs')
-rw-r--r--src/systems/interact.rs15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/systems/interact.rs b/src/systems/interact.rs
index b932fd5..4bf2e4c 100644
--- a/src/systems/interact.rs
+++ b/src/systems/interact.rs
@@ -45,20 +45,22 @@ impl <'a> System<'a> for Interact {
for (entity, controller, position) in (&entities, &controllers, &positions).join(){
let mut target = None;
match &controller.control {
- Control::Interact(directions) => {
+ Control::Interact(directions, arg) => {
'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(interactable) = interactables.get(*ent) {
- target = Some((*ent, interactable, pos));
- break 'targets;
+ if interactable.accepts_arg(arg){
+ target = Some((*ent, interactable, pos, arg.clone()));
+ break 'targets;
+ }
}
}
}
}
_ => {}
}
- if let Some((ent, interactable, pos)) = target {
+ if let Some((ent, interactable, pos, arg)) = target {
match interactable {
Interactable::Harvest => {
deads.insert(ent, Dead).unwrap();
@@ -72,6 +74,11 @@ impl <'a> System<'a> for Interact {
ear.sounds.push(Sound{source: None, text: text.clone()});
}
}
+ Interactable::Reply(text) => {
+ if let Some(ear) = ears.get_mut(entity) {
+ ear.sounds.push(Sound{source: None, text: text.replace("{}", &arg.unwrap())});
+ }
+ }
}
cooldowns.insert(entity, ControlCooldown{amount: 2}).unwrap();
}