atomising item use: ItemEquipSystem{} and remove system tweak
This commit is contained in:
parent
e02fa27ae4
commit
55202b241b
6 changed files with 150 additions and 55 deletions
|
|
@ -1,4 +1,5 @@
|
|||
use super::{gamelog, Equipped, InBackpack, Name, WantsToRemoveItem};
|
||||
use super::{gamelog, Equipped, InBackpack, MagicItem, MasterDungeonMap, Name, ObfuscatedName, WantsToRemoveItem};
|
||||
use crate::gui::{item_colour_u8, obfuscate_name};
|
||||
use specs::prelude::*;
|
||||
|
||||
pub struct ItemRemoveSystem {}
|
||||
|
|
@ -12,16 +13,34 @@ impl<'a> System<'a> for ItemRemoveSystem {
|
|||
WriteStorage<'a, WantsToRemoveItem>,
|
||||
WriteStorage<'a, Equipped>,
|
||||
WriteStorage<'a, InBackpack>,
|
||||
ReadStorage<'a, MagicItem>,
|
||||
ReadStorage<'a, ObfuscatedName>,
|
||||
ReadExpect<'a, MasterDungeonMap>,
|
||||
);
|
||||
|
||||
fn run(&mut self, data: Self::SystemData) {
|
||||
let (entities, player_entity, names, mut wants_remove, mut equipped, mut backpack) = data;
|
||||
let (
|
||||
entities,
|
||||
player_entity,
|
||||
names,
|
||||
mut wants_remove,
|
||||
mut equipped,
|
||||
mut backpack,
|
||||
magic_items,
|
||||
obfuscated_names,
|
||||
dm,
|
||||
) = data;
|
||||
|
||||
for (entity, to_remove) in (&entities, &wants_remove).join() {
|
||||
equipped.remove(to_remove.item);
|
||||
if let Some(name) = names.get(to_remove.item) {
|
||||
if let Some(_) = names.get(to_remove.item) {
|
||||
if entity == *player_entity {
|
||||
gamelog::Logger::new().append("You unequip the").item_name_n(&name.name).period().log();
|
||||
gamelog::Logger::new()
|
||||
.append("You unequip the")
|
||||
.append_n(obfuscate_name(to_remove.item, &names, &magic_items, &obfuscated_names, &dm, None).0)
|
||||
.colour(item_colour_u8(to_remove.item, &names, &magic_items, &dm))
|
||||
.period()
|
||||
.log();
|
||||
}
|
||||
}
|
||||
backpack.insert(to_remove.item, InBackpack { owner: entity }).expect("Unable to insert backpack");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue