Next fixes
This commit is contained in:
parent
abf0be7881
commit
93e98f5477
4 changed files with 35 additions and 34 deletions
|
@ -166,7 +166,8 @@ impl CharacterPage {
|
||||||
let level = entity.get_component::<Level>()?;
|
let level = entity.get_component::<Level>()?;
|
||||||
let attributes = entity.get_component::<Attributes>()?;
|
let attributes = entity.get_component::<Attributes>()?;
|
||||||
|
|
||||||
let gui_handler = resources.get::<GuiHandler>();
|
let (gui_handler, attribute_settings): (&mut GuiHandler, &mut AttributeSettings) =
|
||||||
|
resources.get_mut()?;
|
||||||
|
|
||||||
level_label.set_text(gui_handler, format!("Level: {}", level.level()))?;
|
level_label.set_text(gui_handler, format!("Level: {}", level.level()))?;
|
||||||
level_progress.set_text(
|
level_progress.set_text(
|
||||||
|
@ -178,11 +179,7 @@ impl CharacterPage {
|
||||||
gui_handler,
|
gui_handler,
|
||||||
format!(
|
format!(
|
||||||
"Attributes ({})",
|
"Attributes ({})",
|
||||||
Self::available_attribute_points(
|
Self::available_attribute_points(attribute_settings, attributes, level)
|
||||||
resources.get::<AttributeSettings>(),
|
|
||||||
attributes,
|
|
||||||
level
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
|
@ -222,15 +219,16 @@ impl CharacterPage {
|
||||||
let attribute_settings = resources.get::<AttributeSettings>();
|
let attribute_settings = resources.get::<AttributeSettings>();
|
||||||
let item_settings = resources.get::<ItemSettings>();
|
let item_settings = resources.get::<ItemSettings>();
|
||||||
|
|
||||||
let level = multi_mut.get::<Level>()?;
|
let (level, attributes, statistics, items): (
|
||||||
let attributes = multi_mut.get::<Attributes>()?;
|
&mut Level,
|
||||||
|
&mut Attributes,
|
||||||
|
&mut Statistics,
|
||||||
|
&mut ItemSlotContainer,
|
||||||
|
) = entity.get_components_mut()?;
|
||||||
|
|
||||||
if Self::available_attribute_points(attribute_settings, attributes, level) > 0 {
|
if Self::available_attribute_points(attribute_settings, attributes, level) > 0 {
|
||||||
upgrade(attributes);
|
upgrade(attributes);
|
||||||
|
|
||||||
let statistics = multi_mut.get::<Statistics>()?;
|
|
||||||
let items = multi_mut.get::<ItemSlotContainer>()?;
|
|
||||||
|
|
||||||
statistics.update(attributes, attribute_settings, (&*items, item_settings));
|
statistics.update(attributes, attribute_settings, (&*items, item_settings));
|
||||||
|
|
||||||
upgraded = true;
|
upgraded = true;
|
||||||
|
|
|
@ -67,21 +67,22 @@ impl<A: Ability + 'static> Content<A, Item> {
|
||||||
fn equip_item(world: &mut World, hero: Entity, item_index: usize) -> Result<()> {
|
fn equip_item(world: &mut World, hero: Entity, item_index: usize) -> Result<()> {
|
||||||
let (entity, resources) = world.entity_resources(hero)?;
|
let (entity, resources) = world.entity_resources(hero)?;
|
||||||
|
|
||||||
let hero_items = multi_mut.get::<ItemSlotContainer>()?;
|
let (hero_items, inventory, attributes, statistics): (
|
||||||
let inventory = multi_mut.get::<Inventory<A>>()?;
|
&mut ItemSlotContainer,
|
||||||
let attributes = multi_mut.get::<Attributes>()?;
|
&mut Inventory<A>,
|
||||||
|
&mut Attributes,
|
||||||
|
&mut Statistics,
|
||||||
|
) = entity.get_components_mut()?;
|
||||||
|
|
||||||
// remove item from inventory
|
// remove item from inventory
|
||||||
let item = inventory.remove_item(item_index);
|
let item = inventory.remove_item(item_index);
|
||||||
|
|
||||||
// add or swap items with equipment
|
// add or swap items with equipment
|
||||||
if let Some(old_item) = hero_items.insert(item.clone(), attributes, &mut multi_mut)? {
|
if let Some(old_item) = hero_items.insert(item.clone(), attributes, entity)? {
|
||||||
inventory.insert_item(old_item, item_index);
|
inventory.insert_item(old_item, item_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
// update hero stats
|
// update hero stats
|
||||||
let statistics = multi_mut.get::<Statistics>()?;
|
|
||||||
|
|
||||||
statistics.update(
|
statistics.update(
|
||||||
attributes,
|
attributes,
|
||||||
resources.get::<AttributeSettings>(),
|
resources.get::<AttributeSettings>(),
|
||||||
|
|
|
@ -232,15 +232,19 @@ impl JewelRightSide {
|
||||||
pub fn combine<A: Ability + 'static>(world: &mut World, hero: Entity) -> Result<bool> {
|
pub fn combine<A: Ability + 'static>(world: &mut World, hero: Entity) -> Result<bool> {
|
||||||
let (entity, resources) = world.entity_resources(hero)?;
|
let (entity, resources) = world.entity_resources(hero)?;
|
||||||
|
|
||||||
let reference_info = resources.get::<Option<ReferenceObject>>();
|
let (reference_info, lower_info, item_system, attribute_settings, item_settings): (
|
||||||
|
&mut ReferenceObject,
|
||||||
|
&mut LowerJewels,
|
||||||
|
&mut ItemSystem<A>,
|
||||||
|
&mut AttributeSettings,
|
||||||
|
&mut ItemSettings,
|
||||||
|
) = resources.get_mut()?;
|
||||||
|
|
||||||
if reference_info.is_none() {
|
if reference_info.some().is_none() {
|
||||||
return Ok(false);
|
return Ok(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
let lower_info = resources.get::<LowerJewels>();
|
if let Some(upper_info) = reference_info.some() {
|
||||||
|
|
||||||
if let Some(upper_info) = reference_info {
|
|
||||||
match upper_info {
|
match upper_info {
|
||||||
ReferenceObject::Item { item, source } => {
|
ReferenceObject::Item { item, source } => {
|
||||||
// check that is there something in lower
|
// check that is there something in lower
|
||||||
|
@ -278,11 +282,12 @@ impl JewelRightSide {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ReferenceItemSource::Slots(opt_index) => {
|
ReferenceItemSource::Slots(opt_index) => {
|
||||||
let attribute_settings = resources.get::<AttributeSettings>();
|
let (inventory, item_slots, statistics, attributes): (
|
||||||
let item_settings = resources.get::<ItemSettings>();
|
&mut Inventory<A>,
|
||||||
|
&mut ItemSlotContainer,
|
||||||
let inventory = multi_mut.get::<Inventory<A>>()?;
|
&mut Statistics,
|
||||||
let item_slots = multi_mut.get::<ItemSlotContainer>()?;
|
&mut Attributes,
|
||||||
|
) = entity.get_components_mut()?;
|
||||||
|
|
||||||
let slot = item.slot;
|
let slot = item.slot;
|
||||||
let item = item_slots.item_mut(slot, *opt_index).as_mut().unwrap();
|
let item = item_slots.item_mut(slot, *opt_index).as_mut().unwrap();
|
||||||
|
@ -309,9 +314,6 @@ impl JewelRightSide {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let statistics = multi_mut.get::<Statistics>()?;
|
|
||||||
let attributes = multi_mut.get::<Attributes>()?;
|
|
||||||
|
|
||||||
statistics.update(
|
statistics.update(
|
||||||
attributes,
|
attributes,
|
||||||
attribute_settings,
|
attribute_settings,
|
||||||
|
@ -332,9 +334,6 @@ impl JewelRightSide {
|
||||||
return Ok(false);
|
return Ok(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
let item_settings = resources.get::<ItemSettings>();
|
|
||||||
let item_system = resources.get::<ItemSystem<A>>();
|
|
||||||
|
|
||||||
let inventory = entity.get_component_mut::<Inventory<A>>()?;
|
let inventory = entity.get_component_mut::<Inventory<A>>()?;
|
||||||
|
|
||||||
let upper_jewel = inventory.jewel_mut_at(*index);
|
let upper_jewel = inventory.jewel_mut_at(*index);
|
||||||
|
@ -362,6 +361,8 @@ impl JewelRightSide {
|
||||||
debug_assert_eq!(*jewel, inventory.remove_jewel(*i))
|
debug_assert_eq!(*jewel, inventory.remove_jewel(*i))
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ReferenceObject::Empty => unreachable!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ use std::marker::PhantomData;
|
||||||
use std::sync::{Arc, Weak};
|
use std::sync::{Arc, Weak};
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
|
use ecs::*;
|
||||||
use engine::prelude::*;
|
use engine::prelude::*;
|
||||||
use rpg_components::components::inventory::Inventory;
|
use rpg_components::components::inventory::Inventory;
|
||||||
use rpg_components::items::ability_book::Ability;
|
use rpg_components::items::ability_book::Ability;
|
||||||
|
@ -42,7 +43,7 @@ impl<A: Ability + 'static> InventoryPage<A> {
|
||||||
reference: Weak<CharacterWindow>,
|
reference: Weak<CharacterWindow>,
|
||||||
close: &Arc<Button>,
|
close: &Arc<Button>,
|
||||||
) -> Result<Self> {
|
) -> Result<Self> {
|
||||||
let gui_handler = world.resources.get_mut()?;
|
let gui_handler: &mut GuiHandler = world.resources.get_mut()?;
|
||||||
let grid = Grid::new(gui_handler, 2, 1, false)?;
|
let grid = Grid::new(gui_handler, 2, 1, false)?;
|
||||||
|
|
||||||
let left_base = GuiSnippet::from_str(
|
let left_base = GuiSnippet::from_str(
|
||||||
|
|
Loading…
Reference in a new issue