diff options
| author | troido <troido@protonmail.com> | 2020-09-21 02:33:09 +0200 |
|---|---|---|
| committer | troido <troido@protonmail.com> | 2020-09-21 02:33:09 +0200 |
| commit | 455867294cc849bff2c0829a7464e71e79a0dcae (patch) | |
| tree | 0aebadca7d693f53efa87446222394c9d1387bc1 /src | |
| parent | e2281d8c6293b311ccc187e3503093a1120e6215 (diff) | |
removed unused systems for talk and exchange
Diffstat (limited to 'src')
| -rw-r--r-- | src/systems/exchange.rs | 82 | ||||
| -rw-r--r-- | src/systems/talk.rs | 50 |
2 files changed, 0 insertions, 132 deletions
diff --git a/src/systems/exchange.rs b/src/systems/exchange.rs deleted file mode 100644 index 9931bdd..0000000 --- a/src/systems/exchange.rs +++ /dev/null @@ -1,82 +0,0 @@ - -use specs::{ - Entities, - ReadStorage, - WriteStorage, - System, - Join, - Read, - Write -}; - -use crate::{ - components::{ - Controller, - Position, - Exchanger, - Notification, - Ear, - Inventory, - Visible - }, - controls::{Control}, - resources::{Ground, NewEntities}, - util::strip_prefix -}; - -pub struct Exchange; -impl <'a> System<'a> for Exchange { - type SystemData = ( - Entities<'a>, - ReadStorage<'a, Controller>, - ReadStorage<'a, Position>, - Read<'a, Ground>, - ReadStorage<'a, Exchanger>, - Write<'a, NewEntities>, - WriteStorage<'a, Ear>, - WriteStorage<'a, Inventory>, - ReadStorage<'a, Visible> - ); - - fn run(&mut self, (entities, controllers, positions, ground, exchangers, new, mut ears, mut inventories, visibles): Self::SystemData) { - for (actor, controller, position) in (&entities, &controllers, &positions).join(){ - let ear = ears.get_mut(actor); - match &controller.control { - Control::Interact(directions, arg) => { - for (ent, exchanger) in ground.components_near(position.pos, directions, &exchangers) { - let prefix = exchanger.prefix.as_str(); - let name = visibles.get(ent).map(|v| v.name.as_str()); - if let Some(txt) = arg { - if let (Some(inventory), Some(action)) = (inventories.get_mut(actor), strip_prefix(&txt, prefix)) { - if let Some(exchange) = exchanger.exchanges.get(action) { - if exchange.can_trade(inventory){ - exchange.trade(inventory, &new.encyclopedia); - say(ear, format!("Success! '{}' ({})", txt, exchange.show()), name); - } else { - say(ear, format!("You do not have the required items or inventory space for '{}' ({})", txt, exchange.show()), name); - } - } else { - say(ear, format!("Invalid option: {}", action), name); - } - break; - } - } else if let Some(ear) = ear { - ear.sounds.push(Notification::Options{ - description: "".to_string(), - options: exchanger.exchanges.iter().map(|(id, exchange)| (format!("{}{}", prefix, id), exchange.show())).collect() - }); - break; - } - } - } - _ => {} - } - } - } -} - -fn say(maybe_ear: Option<&mut Ear>, text: String, source: Option<&str>){ - if let Some(ear) = maybe_ear { - ear.sounds.push(Notification::Sound{text, source: source.map(|s| s.to_string())}); - } -} diff --git a/src/systems/talk.rs b/src/systems/talk.rs deleted file mode 100644 index 50e491f..0000000 --- a/src/systems/talk.rs +++ /dev/null @@ -1,50 +0,0 @@ - - -use specs::{ - ReadStorage, - WriteStorage, - System, - Join, - Read -}; - -use crate::{ - components::{ - Controller, - Position, - Talkable, - Notification, - Ear, - Visible - }, - controls::{Control}, - resources::{Ground}, -}; - -pub struct Talk; -impl <'a> System<'a> for Talk { - type SystemData = ( - ReadStorage<'a, Controller>, - ReadStorage<'a, Position>, - Read<'a, Ground>, - ReadStorage<'a, Talkable>, - WriteStorage<'a, Ear>, - ReadStorage<'a, Visible> - ); - - fn run(&mut self, (controllers, positions, ground, talkables, mut ears, visibles): Self::SystemData) { - for (controller, position, ear) in (&controllers, &positions, &mut ears).join(){ - match &controller.control { - Control::Interact(directions, None) => { - 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; - } - } - _ => {} - } - } - } -} - |
