Fix everything but item slots
This commit is contained in:
parent
071b4dc408
commit
60ba92aa76
1 changed files with 20 additions and 13 deletions
|
@ -1,5 +1,6 @@
|
|||
use anyhow::Result;
|
||||
use assetpath::AssetPath;
|
||||
use ecs::*;
|
||||
use rpg_components::{
|
||||
components::{
|
||||
attributes::Attributes, character_status::CharacterStatus, inventory::Inventory,
|
||||
|
@ -293,12 +294,12 @@ mod macros {
|
|||
false
|
||||
}
|
||||
}) {
|
||||
let socket_object = world.resources.get_mut::<Option<ReferenceObject>>();
|
||||
let socket_object: &mut ReferenceObject = world.resources.get_mut()?;
|
||||
|
||||
*socket_object = Some(ReferenceObject::Item {
|
||||
*socket_object = ReferenceObject::Item {
|
||||
item,
|
||||
source: ReferenceItemSource::Slots(None),
|
||||
});
|
||||
};
|
||||
|
||||
empty_affixes_found = true;
|
||||
}
|
||||
|
@ -370,8 +371,19 @@ mod macros {
|
|||
|
||||
let (entity, resources) = world.entity_resources($hero)?;
|
||||
|
||||
let items = multi_mut.get::<ItemSlotContainer>()?;
|
||||
let inventory = multi_mut.get::<Inventory<A>>()?;
|
||||
let (
|
||||
items,
|
||||
inventory,
|
||||
statistics,
|
||||
attributes,
|
||||
status
|
||||
): (
|
||||
&mut ItemSlotContainer,
|
||||
&mut Inventory<A>,
|
||||
&mut Statistics,
|
||||
&mut Attributes,
|
||||
&mut CharacterStatus
|
||||
) = entity.get_components_mut()?;
|
||||
|
||||
if let Some($item) = items.[<$item>]($index) {
|
||||
inventory.add_item($item.clone());
|
||||
|
@ -381,17 +393,12 @@ mod macros {
|
|||
if found_item {
|
||||
items.[<unset_ $item>]($index)?;
|
||||
|
||||
let statistics = multi_mut.get::<Statistics>()?;
|
||||
let attributes = multi_mut.get::<Attributes>()?;
|
||||
|
||||
statistics.update(
|
||||
attributes,
|
||||
resources.get::<AttributeSettings>(),
|
||||
(&*items, resources.get::<ItemSettings>())
|
||||
);
|
||||
|
||||
let status = multi_mut.get::<CharacterStatus>()?;
|
||||
|
||||
if status.current_health > statistics.health {
|
||||
status.current_health = statistics.health.clone();
|
||||
}
|
||||
|
@ -427,12 +434,12 @@ mod macros {
|
|||
false
|
||||
}
|
||||
}) {
|
||||
let socket_object = world.resources.get_mut::<Option<ReferenceObject>>();
|
||||
let socket_object: &mut ReferenceObject = world.resources.get_mut()?;
|
||||
|
||||
*socket_object = Some(ReferenceObject::Item {
|
||||
*socket_object = ReferenceObject::Item {
|
||||
item,
|
||||
source: ReferenceItemSource::Slots(Some($index)),
|
||||
});
|
||||
};
|
||||
|
||||
empty_affixes_found = true;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue