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