Start more complex cases
This commit is contained in:
parent
93e98f5477
commit
071b4dc408
3 changed files with 31 additions and 23 deletions
|
@ -292,14 +292,14 @@ impl<A: Ability + 'static> Content<A, Jewel> {
|
|||
let jewel = inventory.jewel_at(jewel_index).clone();
|
||||
|
||||
// remove from reference if placed there
|
||||
let socket_object = world.resources.get_mut::<Option<ReferenceObject>>();
|
||||
if let Some(ReferenceObject::Jewel { index, .. }) = socket_object {
|
||||
let socket_object: &mut ReferenceObject = world.resources.get_mut()?;
|
||||
if let Some(ReferenceObject::Jewel { index, .. }) = socket_object.some() {
|
||||
if *index == jewel_index {
|
||||
*socket_object = None;
|
||||
*socket_object = ReferenceObject::Empty;
|
||||
}
|
||||
}
|
||||
|
||||
let lower_jewels = world.resources.get_mut::<LowerJewels>();
|
||||
let lower_jewels: &mut LowerJewels = world.resources.get_mut()?;
|
||||
|
||||
// check if that jewel is already added
|
||||
if !lower_jewels.jewels.iter().any(|content| match content {
|
||||
|
|
|
@ -230,8 +230,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>]() {
|
||||
inventory.add_item($item.clone());
|
||||
|
@ -239,10 +250,7 @@ mod macros {
|
|||
}
|
||||
|
||||
if found_item {
|
||||
items.[<unset_ $item>](&mut multi_mut)?;
|
||||
|
||||
let statistics = multi_mut.get::<Statistics>()?;
|
||||
let attributes = multi_mut.get::<Attributes>()?;
|
||||
items.[<unset_ $item>](entity)?;
|
||||
|
||||
statistics.update(
|
||||
attributes,
|
||||
|
@ -250,8 +258,6 @@ mod macros {
|
|||
(&*items, resources.get::<ItemSettings>())
|
||||
);
|
||||
|
||||
let status = multi_mut.get::<CharacterStatus>()?;
|
||||
|
||||
if status.current_health > statistics.health {
|
||||
status.current_health = statistics.health.clone();
|
||||
}
|
||||
|
|
|
@ -374,15 +374,19 @@ impl RightSide for JewelRightSide {
|
|||
fn refresh(&mut self, world: &mut World, _hero: Entity) -> Result<()> {
|
||||
let (reference, lower) = self.elements()?;
|
||||
|
||||
let gui_handler = resources.get::<GuiHandler>();
|
||||
let reference_info = resources.get::<Option<ReferenceObject>>();
|
||||
let lower_info = resources.get::<LowerJewels>();
|
||||
let (gui_handler, reference_info, lower_info): (
|
||||
&mut GuiHandler,
|
||||
&mut ReferenceObject,
|
||||
&mut LowerJewels,
|
||||
) = world.resources.get_mut()?;
|
||||
|
||||
match reference_info.as_ref() {
|
||||
match reference_info.some() {
|
||||
Some(reference_info) => {
|
||||
let icon = match reference_info {
|
||||
ReferenceObject::Item { item, .. } => item.icon(),
|
||||
ReferenceObject::Jewel { jewel, .. } => jewel.icon(),
|
||||
|
||||
ReferenceObject::Empty => unreachable!(),
|
||||
};
|
||||
|
||||
reference.set_icon(gui_handler, &icon)?;
|
||||
|
@ -401,13 +405,11 @@ impl RightSide for JewelRightSide {
|
|||
}
|
||||
|
||||
fn disable(&mut self, world: &mut World, _hero: Entity) -> Result<()> {
|
||||
*world.resources.get_mut::<Option<ReferenceObject>>() = None;
|
||||
world
|
||||
.resources
|
||||
.get_mut::<LowerJewels>()
|
||||
.jewels
|
||||
.iter_mut()
|
||||
.for_each(|j| *j = None);
|
||||
let reference_object: &mut ReferenceObject = world.resources.get_mut()?;
|
||||
*reference_object = ReferenceObject::Empty;
|
||||
|
||||
let lower_jewels: &mut LowerJewels = world.resources.get_mut()?;
|
||||
lower_jewels.jewels.iter_mut().for_each(|j| *j = None);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue