overhaul: data-driven architecture
This commit is contained in:
parent
062d36f640
commit
f53b767376
19 changed files with 680 additions and 727 deletions
|
|
@ -238,12 +238,13 @@ impl<'a> System<'a> for ItemUseSystem {
|
|||
for (item_entity, already_equipped, _name) in (&entities, &equipped, &names).join() {
|
||||
if already_equipped.owner == target && already_equipped.slot == target_slot {
|
||||
to_unequip.push(item_entity);
|
||||
if target == *player_entity {
|
||||
/*if target == *player_entity {
|
||||
gamelog::Logger::new()
|
||||
.append("You unequip the")
|
||||
.item_name_n(&item_being_used.name)
|
||||
.period();
|
||||
}
|
||||
.period()
|
||||
.log();
|
||||
}*/
|
||||
}
|
||||
}
|
||||
for item in to_unequip.iter() {
|
||||
|
|
@ -458,14 +459,25 @@ pub struct ItemRemoveSystem {}
|
|||
|
||||
impl<'a> System<'a> for ItemRemoveSystem {
|
||||
#[allow(clippy::type_complexity)]
|
||||
type SystemData =
|
||||
(Entities<'a>, WriteStorage<'a, WantsToRemoveItem>, WriteStorage<'a, Equipped>, WriteStorage<'a, InBackpack>);
|
||||
type SystemData = (
|
||||
Entities<'a>,
|
||||
ReadExpect<'a, Entity>,
|
||||
ReadStorage<'a, Name>,
|
||||
WriteStorage<'a, WantsToRemoveItem>,
|
||||
WriteStorage<'a, Equipped>,
|
||||
WriteStorage<'a, InBackpack>,
|
||||
);
|
||||
|
||||
fn run(&mut self, data: Self::SystemData) {
|
||||
let (entities, mut wants_remove, mut equipped, mut backpack) = data;
|
||||
let (entities, player_entity, names, mut wants_remove, mut equipped, mut backpack) = 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 entity == *player_entity {
|
||||
gamelog::Logger::new().append("You unequip the").item_name_n(&name.name).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