First fixes
This commit is contained in:
parent
5346559e61
commit
af8ef272ff
10 changed files with 54 additions and 35 deletions
|
@ -1,3 +1,6 @@
|
|||
use crate::config::save_game::SaveGame;
|
||||
use crate::items::Rarities;
|
||||
use crate::items::{ability_addon::AbilityAddonTypes, ability_book::AbilityBook};
|
||||
use anyhow::Result;
|
||||
use cgmath::{Vector2, Zero};
|
||||
use engine::prelude::*;
|
||||
|
@ -102,8 +105,6 @@ macro_rules! store {
|
|||
}
|
||||
|
||||
pub struct AbilitySlots {
|
||||
game_handle: GameHandle,
|
||||
|
||||
pub direction: Vector2<f32>,
|
||||
|
||||
abilities: [Option<AbilityBook>; AbilitySlots::MAX_ABILITIES],
|
||||
|
@ -113,36 +114,22 @@ impl AbilitySlots {
|
|||
// stupid workaround for serde Deserialize
|
||||
pub const MAX_ABILITIES: usize = 4;
|
||||
|
||||
pub fn empty(game_handle: GameHandle) -> Self {
|
||||
pub fn empty() -> Self {
|
||||
Self {
|
||||
direction: Vector2::zero(),
|
||||
|
||||
abilities: Default::default(),
|
||||
|
||||
game_handle,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn load(save_game: &SaveGame, game: GameHandle) -> Result<Self> {
|
||||
let mut me = Self::empty(game);
|
||||
pub fn load(save_game: &SaveGame) -> Result<Self> {
|
||||
let mut me = Self::empty();
|
||||
|
||||
load!(me, save_game, 0, 1, 2, 3,);
|
||||
|
||||
Ok(me)
|
||||
}
|
||||
|
||||
pub fn load_for_npc(
|
||||
npc_level: u32,
|
||||
npc_settings: &NPCSettings,
|
||||
game: GameHandle,
|
||||
) -> Result<Self> {
|
||||
let mut me = Self::empty(game);
|
||||
|
||||
load_npc!(me, npc_settings, npc_level, 0, 1, 2, 3,);
|
||||
|
||||
Ok(me)
|
||||
}
|
||||
|
||||
pub fn store(&self, save_game: &mut SaveGame) {
|
||||
store!(self, save_game, 0, 1, 2, 3,);
|
||||
}
|
||||
|
|
|
@ -3,6 +3,11 @@ use engine::prelude::{image::RgbaImage, *};
|
|||
|
||||
use std::{cmp::Ordering, slice::Iter, str::FromStr};
|
||||
|
||||
use crate::{
|
||||
config::attributes::{AttributeColorSettings, StartingAttributes},
|
||||
items::ItemSystem,
|
||||
};
|
||||
|
||||
generate_stat!(Agility, u32, "Agility");
|
||||
generate_stat!(Intelligence, u32, "Intelligence");
|
||||
generate_stat!(Strength, u32, "Strength");
|
||||
|
|
|
@ -2,6 +2,8 @@ use engine::prelude::*;
|
|||
|
||||
use paste::paste;
|
||||
|
||||
use crate::{config::save_game::SaveGame, items::Rarities};
|
||||
|
||||
macro_rules! check_consume {
|
||||
($self: ident, $var: ident, $amount: ident) => {
|
||||
paste! {
|
||||
|
|
|
@ -3,6 +3,14 @@ use engine::prelude::*;
|
|||
use std::slice::Iter;
|
||||
use std::sync::Arc;
|
||||
|
||||
use crate::{
|
||||
config::save_game::SaveGame,
|
||||
items::{
|
||||
ability_addon::AbilityAddon, ability_book::AbilityBook, Item, ItemSystem, Jewel, MapItem,
|
||||
Rarities,
|
||||
},
|
||||
};
|
||||
|
||||
pub trait Storable {
|
||||
fn rarity(&self) -> Rarities;
|
||||
fn icon(&self) -> Arc<Image>;
|
||||
|
|
|
@ -4,6 +4,16 @@ use paste;
|
|||
|
||||
use std::{collections::HashMap, sync::Arc};
|
||||
|
||||
use crate::{
|
||||
config::{items::ItemSettings, save_game::SaveGame},
|
||||
items::{Item, ItemAffix, ItemSlots, ItemSystem, Rarities},
|
||||
};
|
||||
|
||||
use super::{
|
||||
attributes::{Agility, Attribute, Attributes, Intelligence, Strength},
|
||||
statistic_types::StatisticType,
|
||||
};
|
||||
|
||||
macro_rules! load_item {
|
||||
($me:ident, $var_name:ident, $slot:ident, $save_game:ident, $item_system:ident) => {
|
||||
if $save_game.$var_name.used {
|
||||
|
@ -152,7 +162,7 @@ pub struct ItemSlotContainer {
|
|||
}
|
||||
|
||||
impl ItemSlotContainer {
|
||||
fn new(game_handle: GameHandle, draw: &Draw, query_meshes: bool) -> Result<Self> {
|
||||
fn new(item_settings: ItemSettings, draw: &Draw, query_meshes: bool) -> Result<Self> {
|
||||
Ok(Self {
|
||||
helmet: None,
|
||||
chest_plate: None,
|
||||
|
@ -171,11 +181,12 @@ impl ItemSlotContainer {
|
|||
item_meshes: if query_meshes {
|
||||
Arc::new(
|
||||
Self::find_items(draw)
|
||||
.map(|item_meshes| {
|
||||
Self::create_rarity_color_items(
|
||||
item_meshes,
|
||||
&game_handle.upgrade().item_system().item_settings,
|
||||
)
|
||||
.map({
|
||||
let item_settings = item_settings.clone();
|
||||
|
||||
move |item_meshes| {
|
||||
Self::create_rarity_color_items(item_meshes, &item_settings)
|
||||
}
|
||||
})
|
||||
.transpose()?
|
||||
.unwrap_or_default(),
|
||||
|
@ -184,22 +195,22 @@ impl ItemSlotContainer {
|
|||
Default::default()
|
||||
},
|
||||
|
||||
item_settings: game_handle.upgrade().item_system().item_settings.clone(),
|
||||
item_settings,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn empty(game_handle: GameHandle, draw: &Draw) -> Result<Self> {
|
||||
Self::new(game_handle, draw, true)
|
||||
pub fn empty(item_settings: ItemSettings, draw: &Draw) -> Result<Self> {
|
||||
Self::new(item_settings, draw, true)
|
||||
}
|
||||
|
||||
pub fn load(
|
||||
save_game: &SaveGame,
|
||||
game_handle: GameHandle,
|
||||
item_settings: ItemSettings,
|
||||
draw: &Draw,
|
||||
item_meshes: Arc<HashMap<ItemSlots, HashMap<Rarities, AssetMesh>>>,
|
||||
item_system: &ItemSystem,
|
||||
) -> Result<Self> {
|
||||
let item_system = game_handle.upgrade().item_system();
|
||||
let mut me = Self::new(game_handle, draw, false)?;
|
||||
let mut me = Self::new(item_settings, draw, false)?;
|
||||
|
||||
if me.item_meshes.is_empty() {
|
||||
me.item_meshes = item_meshes;
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
use anyhow::Result;
|
||||
use engine::prelude::*;
|
||||
|
||||
use crate::config::experience::ExperienceSettings;
|
||||
|
||||
pub struct LevelUpEvent;
|
||||
|
||||
pub struct Level {
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
#[macro_use]
|
||||
pub mod macros;
|
||||
|
||||
pub mod ability_slots;
|
||||
pub mod attributes;
|
||||
pub mod character_status;
|
||||
|
@ -7,6 +10,3 @@ pub mod item_slots;
|
|||
pub mod level;
|
||||
pub mod statistic_types;
|
||||
pub mod statistics;
|
||||
|
||||
#[macro_use]
|
||||
pub mod macros;
|
||||
|
|
|
@ -3,6 +3,8 @@ use engine::prelude::*;
|
|||
|
||||
use std::fmt;
|
||||
|
||||
use super::statistics::*;
|
||||
|
||||
macro_rules! apply {
|
||||
(
|
||||
$self:ident, $attrib:ident,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use engine::prelude::*;
|
||||
|
||||
use crate::game::content::prelude::*;
|
||||
use crate::items::{ItemAffix, Rarities};
|
||||
|
||||
use std::env::var;
|
||||
|
||||
|
|
|
@ -2,6 +2,8 @@ use std::sync::Arc;
|
|||
|
||||
use engine::prelude::*;
|
||||
|
||||
use crate::components::inventory::Storable;
|
||||
|
||||
use super::{ItemSystem, Rarities};
|
||||
|
||||
#[derive(Clone)]
|
||||
|
|
Loading…
Reference in a new issue