diff --git a/character_window/src/inventory/jewel_right_side.rs b/character_window/src/inventory/jewel_right_side.rs index 13e4c6c..b7f9bfe 100644 --- a/character_window/src/inventory/jewel_right_side.rs +++ b/character_window/src/inventory/jewel_right_side.rs @@ -328,7 +328,7 @@ impl JewelRightSide { } let item_settings = resources.get::(); - let item_system = resources.get::>(); + let item_system = resources.get::(); let inventory = entity.get_component_mut::()?; diff --git a/gavania-core/src/game/content/objects/hero.rs b/gavania-core/src/game/content/objects/hero.rs index 72e4bec..3bfedec 100644 --- a/gavania-core/src/game/content/objects/hero.rs +++ b/gavania-core/src/game/content/objects/hero.rs @@ -435,10 +435,10 @@ impl Hero { match hero_create_type { HeroCreateType::SaveGame(save_game) => { - AbilitySlots::load(game.item_system(), save_game) + AbilitySlots::load(&game.item_system(), save_game) } HeroCreateType::New(_) => { - let mut abilities = AbilitySlots::empty(game.item_system()); + let mut abilities = AbilitySlots::empty(); let book = game_handle.upgrade().item_system().ability_book( "Basic Attack", diff --git a/rpg_components/src/components/ability_slots.rs b/rpg_components/src/components/ability_slots.rs index 8a1d71d..0a78fff 100644 --- a/rpg_components/src/components/ability_slots.rs +++ b/rpg_components/src/components/ability_slots.rs @@ -6,7 +6,6 @@ use paste; use std::{ slice::{Iter, IterMut}, str::FromStr, - sync::Arc, }; use crate::config::save_game::SaveGame; @@ -14,12 +13,10 @@ use crate::items::{ability_addon::AbilityAddonTypes, ability_book::AbilityBook, use crate::{components::inventory::Storable, items::ItemSystem}; macro_rules! load { - ($me: ident, $save_game:ident, $($index:literal,)+) => { + ($me: ident, $item_system:ident, $save_game:ident, $($index:literal,)+) => { paste::expr! { $( if $save_game.[].used { - let item_system = &$me.item_system; - let ability = &$save_game.[]; let mut addons = Vec::new(); @@ -30,10 +27,10 @@ macro_rules! load { let rarity = Rarities::from_str(&split.nth(0).unwrap())?; let addon_type = AbilityAddonTypes::from_str(&split.nth(0).unwrap())?; - addons.push(Some(item_system.addon(rarity, addon_type))); + addons.push(Some($item_system.addon(rarity, addon_type))); } - let book = item_system.ability_book( + let book = $item_system.ability_book( &ability.name, ability.rarity, addons, @@ -71,8 +68,6 @@ macro_rules! store { } pub struct AbilitySlots { - item_system: Arc, - pub direction: Vector2, abilities: [Option; AbilitySlots::MAX_ABILITIES], @@ -82,20 +77,17 @@ impl AbilitySlots { // stupid workaround for serde Deserialize pub const MAX_ABILITIES: usize = 4; - pub fn empty(item_system: Arc) -> Self { + pub fn empty() -> Self { Self { - item_system, - direction: Vector2::zero(), - abilities: Default::default(), } } - pub fn load(item_system: Arc, save_game: &SaveGame) -> Result { - let mut me = Self::empty(item_system); + pub fn load(item_system: &ItemSystem, save_game: &SaveGame) -> Result { + let mut me = Self::empty(); - load!(me, save_game, 0, 1, 2, 3,); + load!(me, item_system, save_game, 0, 1, 2, 3,); Ok(me) } diff --git a/rpg_components/src/config/save_game.rs b/rpg_components/src/config/save_game.rs index 7eab1cd..2072953 100644 --- a/rpg_components/src/config/save_game.rs +++ b/rpg_components/src/config/save_game.rs @@ -10,7 +10,7 @@ use crate::{ items::{ItemAffix, ItemSystem, Rarities}, }; -use std::{env::var, sync::Arc}; +use std::env::var; use super::{attributes::AttributeSettings, experience::ExperienceSettings, items::ItemSettings}; @@ -365,7 +365,7 @@ impl SaveGame { let experience_settings = scene.resources.get::(); let attribute_settings = scene.resources.get::(); let item_settings = scene.resources.get::(); - let item_system = scene.resources.get::>(); + let item_system = scene.resources.get::(); let mut entity_object = engine.assets().empty_entity(); @@ -380,7 +380,7 @@ impl SaveGame { self.general.intelligence, ); let inventory = Inventory::load(&self, &item_system)?; - let abilities = AbilitySlots::load(item_system.clone(), &self)?; + let abilities = AbilitySlots::load(item_system, &self)?; let crafting_materials = CraftingMaterials::load(&self); let items = ItemSlotContainer::load(&self, &item_system)?; let mut statistics = Statistics::default();