diff options
| author | troido <troido@protonmail.com> | 2020-04-15 12:23:06 +0200 |
|---|---|---|
| committer | troido <troido@protonmail.com> | 2020-04-15 12:23:06 +0200 |
| commit | 43bde225ebbadd0b917ca87f3164a50455a2b588 (patch) | |
| tree | c9c2bb0c6839af01a02acba1c338b2d8c59cfcb5 /src/systems | |
| parent | 30a5688010bf07a9e0807ed0c2dc7c51f0e9dae4 (diff) | |
visit other players
Diffstat (limited to 'src/systems')
| -rw-r--r-- | src/systems/interact.rs | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/src/systems/interact.rs b/src/systems/interact.rs index 6df0066..c3cd0d2 100644 --- a/src/systems/interact.rs +++ b/src/systems/interact.rs @@ -20,10 +20,13 @@ use crate::{ Notification, Ear, Inventory, - Visible + Visible, + Player }, controls::{Control}, - resources::{Ground, NewEntities} + resources::{Ground, NewEntities, Emigration}, + hashmap, + playerstate::RoomPos }; pub struct Interact; @@ -39,10 +42,12 @@ impl <'a> System<'a> for Interact { Write<'a, NewEntities>, WriteStorage<'a, Ear>, WriteStorage<'a, Inventory>, - ReadStorage<'a, Visible> + ReadStorage<'a, Visible>, + ReadStorage<'a, Player>, + Write<'a, Emigration> ); - fn run(&mut self, (entities, controllers, positions, ground, mut cooldowns, interactables, mut triggerbox, new, mut ears, mut inventories, visibles): Self::SystemData) { + fn run(&mut self, (entities, controllers, positions, ground, mut cooldowns, interactables, mut triggerbox, new, mut ears, mut inventories, visibles, players, mut emigration): Self::SystemData) { for (entity, controller, position) in (&entities, &controllers, &positions).join(){ let mut target = None; let ear = ears.get_mut(entity); @@ -101,6 +106,16 @@ impl <'a> System<'a> for Interact { ); } } + Interactable::Visit(dest) => { + if let Some(player) = players.get(entity){ + let argument = arg.unwrap(); + if argument.starts_with("visit") { + let playername = argument.split_at("visit ".len()).1; + let destination = dest.format(hashmap!("{player}" => playername)); + emigration.emigrants.push((player.id.clone(), destination, RoomPos::Unknown)); + } + } + } } cooldowns.insert(entity, ControlCooldown{amount: 2}).unwrap(); } |
