summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/components/interactable.rs14
-rw-r--r--src/components/mod.rs7
-rw-r--r--src/room.rs2
-rw-r--r--src/systems/interact.rs23
4 files changed, 39 insertions, 7 deletions
diff --git a/src/components/interactable.rs b/src/components/interactable.rs
index 1787a33..3432f33 100644
--- a/src/components/interactable.rs
+++ b/src/components/interactable.rs
@@ -8,7 +8,8 @@ use specs::{
use crate::{
exchange::Exchange,
ItemId,
- components::Trigger
+ components::Trigger,
+ RoomId
};
#[derive(Component, Debug, Clone, PartialEq)]
@@ -17,7 +18,8 @@ pub enum Interactable {
Trigger(Trigger),
Say(String),
Reply(String),
- Exchange(String, HashMap<String, Exchange>)
+ Exchange(String, HashMap<String, Exchange>),
+ Visit(RoomId)
}
use Interactable::*;
@@ -44,6 +46,7 @@ impl Interactable {
})
.collect::<Option<HashMap<String, Exchange>>>()?
),
+ "visit" => Visit(RoomId::from_str(arg.as_str()?)),
_ => None?
})
}
@@ -60,6 +63,13 @@ impl Interactable {
true
}
}
+ Visit(_) => {
+ if let Some(txt) = arg {
+ txt.starts_with("visit")
+ } else {
+ false
+ }
+ }
}
}
}
diff --git a/src/components/mod.rs b/src/components/mod.rs
index 6692445..ae50edc 100644
--- a/src/components/mod.rs
+++ b/src/components/mod.rs
@@ -29,6 +29,8 @@ pub use ear::{
Ear
};
+use std::collections::HashMap;
+
use specs::{
DenseVecStorage,
VecStorage,
@@ -225,6 +227,11 @@ pub struct Build {
pub obj: Template
}
+#[derive(Component, Debug, Clone)]
+pub struct Whitelist{
+ pub allowed: HashMap<String, PlayerId>
+}
+
diff --git a/src/room.rs b/src/room.rs
index dbdb46f..c9fb525 100644
--- a/src/room.rs
+++ b/src/room.rs
@@ -118,7 +118,7 @@ impl <'a, 'b>Room<'a, 'b> {
world.insert(NewEntities::new(encyclopedia));
register_insert!(
world,
- (Position, Visible, Controller, Movable, New, Removed, Moved, Player, Inventory, Health, Serialise, RoomExit, Entered, TriggerBox, Trap, Fighter, Healing, ControlCooldown, Autofight, MonsterAI, Home, AttackInbox, Item, Spawner, Clan, Faction, Interactable, Loot, Timer, Equipment, TimeOffset, Flags, Ear, Build),
+ (Position, Visible, Controller, Movable, New, Removed, Moved, Player, Inventory, Health, Serialise, RoomExit, Entered, TriggerBox, Trap, Fighter, Healing, ControlCooldown, Autofight, MonsterAI, Home, AttackInbox, Item, Spawner, Clan, Faction, Interactable, Loot, Timer, Equipment, TimeOffset, Flags, Ear, Build, Whitelist),
(Ground, Input, Output, Size, Spawn, Players, Emigration, Time)
);
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();
}