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