diff --git a/src/inventory_system.rs b/src/inventory_system.rs index cc7b319..bb6bab8 100644 --- a/src/inventory_system.rs +++ b/src/inventory_system.rs @@ -1,5 +1,7 @@ use crate::components::*; +use crate::particle_system::ParticleBuilder; use crate::{game_log::GameLog, Map}; +use rltk::RGB; use specs::prelude::*; pub struct ItemCollectionSystem {} @@ -63,6 +65,8 @@ impl<'a> System<'a> for ItemUseSystem { ReadStorage<'a, Equippable>, WriteStorage<'a, Equipped>, WriteStorage<'a, InBackpack>, + WriteExpect<'a, ParticleBuilder>, + ReadStorage<'a, Position>, ); #[allow(clippy::cognitive_complexity)] @@ -84,6 +88,8 @@ impl<'a> System<'a> for ItemUseSystem { equippable, mut equipped, mut backpack, + mut particle_builder, + positions, ) = data; for (entity, useitem) in (&entities, &wants_use).join() { @@ -117,6 +123,15 @@ impl<'a> System<'a> for ItemUseSystem { for mob in map.tile_content[idx].iter() { targets.push(*mob); } + + particle_builder.request( + tile_idx.x, + tile_idx.y, + RGB::named(rltk::ORANGE), + RGB::named(rltk::BLACK), + rltk::to_cp437('░'), + 200.0, + ); } } } @@ -189,6 +204,18 @@ impl<'a> System<'a> for ItemUseSystem { } used_item = true; + + // Visually show healing + if let Some(pos) = positions.get(*target) { + particle_builder.request( + pos.x, + pos.y, + RGB::named(rltk::GREEN), + RGB::named(rltk::BLACK), + rltk::to_cp437('♥'), + 200.0, + ); + } } } } @@ -210,6 +237,17 @@ impl<'a> System<'a> for ItemUseSystem { "You use {} on {}, inflicting {} hp.", item_name.name, mob_name.name, damage.damage )); + + if let Some(pos) = positions.get(*mob) { + particle_builder.request( + pos.x, + pos.y, + RGB::named(rltk::RED), + RGB::named(rltk::BLACK), + rltk::to_cp437('‼'), + 200.0, + ); + } } used_item = true; @@ -236,6 +274,17 @@ impl<'a> System<'a> for ItemUseSystem { "You use {} on {}, confusing them.", item_name.name, mob_name.name )); + + if let Some(pos) = positions.get(*mob) { + particle_builder.request( + pos.x, + pos.y, + RGB::named(rltk::MAGENTA), + RGB::named(rltk::BLACK), + rltk::to_cp437('?'), + 200.0, + ); + } } } }