mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Move armor types to a new location, use a const for the moving cutoff in voxygen anims
This commit is contained in:
parent
8fd774f21a
commit
f551c4a2c5
@ -1,6 +1,7 @@
|
||||
use crate::{
|
||||
comp::{
|
||||
Body, CharacterState, EnergySource, Gravity, Item, LightEmitter, Projectile, StateUpdate,
|
||||
item::Item, Body, CharacterState, EnergySource, Gravity, LightEmitter, Projectile,
|
||||
StateUpdate,
|
||||
},
|
||||
states::*,
|
||||
sys::character_behavior::JoinData,
|
||||
|
@ -471,180 +471,6 @@ pub enum BodyType {
|
||||
}
|
||||
pub const ALL_BODY_TYPES: [BodyType; 2] = [BodyType::Female, BodyType::Male];
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
#[repr(u32)]
|
||||
pub enum Chest {
|
||||
None = 0,
|
||||
Blue = 1,
|
||||
Brown = 2,
|
||||
Dark = 3,
|
||||
Green = 4,
|
||||
Orange = 5,
|
||||
Midnight = 6,
|
||||
Kimono = 7,
|
||||
Assassin = 8,
|
||||
PlateGreen0 = 9,
|
||||
Leather0 = 10,
|
||||
ClothPurple0 = 11,
|
||||
ClothBlue0 = 12,
|
||||
ClothGreen0 = 13,
|
||||
}
|
||||
pub const ALL_CHESTS: [Chest; 14] = [
|
||||
Chest::None,
|
||||
Chest::Blue,
|
||||
Chest::Brown,
|
||||
Chest::Dark,
|
||||
Chest::Green,
|
||||
Chest::Orange,
|
||||
Chest::Midnight,
|
||||
Chest::Kimono,
|
||||
Chest::Assassin,
|
||||
Chest::PlateGreen0,
|
||||
Chest::Leather0,
|
||||
Chest::ClothPurple0,
|
||||
Chest::ClothBlue0,
|
||||
Chest::ClothGreen0,
|
||||
];
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
#[repr(u32)]
|
||||
pub enum Belt {
|
||||
None = 0,
|
||||
Dark = 1,
|
||||
TurqCloth = 2,
|
||||
BloodCloth = 3,
|
||||
BlackCloth = 4,
|
||||
Assassin = 5,
|
||||
Plate0 = 6,
|
||||
Leather0 = 7,
|
||||
ClothPurple0 = 8,
|
||||
ClothBlue0 = 9,
|
||||
ClothGreen0 = 10,
|
||||
}
|
||||
pub const ALL_BELTS: [Belt; 11] = [
|
||||
Belt::None,
|
||||
Belt::Dark,
|
||||
Belt::TurqCloth,
|
||||
Belt::BloodCloth,
|
||||
Belt::BlackCloth,
|
||||
Belt::Assassin,
|
||||
Belt::Plate0,
|
||||
Belt::Leather0,
|
||||
Belt::ClothPurple0,
|
||||
Belt::ClothBlue0,
|
||||
Belt::ClothGreen0,
|
||||
];
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
#[repr(u32)]
|
||||
pub enum Pants {
|
||||
None = 0,
|
||||
Blue = 1,
|
||||
Brown = 2,
|
||||
Dark = 3,
|
||||
Green = 4,
|
||||
Orange = 5,
|
||||
Kimono = 6,
|
||||
Assassin = 7,
|
||||
PlateGreen0 = 8,
|
||||
Leather0 = 9,
|
||||
ClothPurple0 = 10,
|
||||
ClothBlue0 = 11,
|
||||
ClothGreen0 = 12,
|
||||
}
|
||||
pub const ALL_PANTS: [Pants; 13] = [
|
||||
Pants::None,
|
||||
Pants::Blue,
|
||||
Pants::Brown,
|
||||
Pants::Dark,
|
||||
Pants::Green,
|
||||
Pants::Orange,
|
||||
Pants::Kimono,
|
||||
Pants::Assassin,
|
||||
Pants::PlateGreen0,
|
||||
Pants::Leather0,
|
||||
Pants::ClothPurple0,
|
||||
Pants::ClothBlue0,
|
||||
Pants::ClothGreen0,
|
||||
];
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
#[repr(u32)]
|
||||
pub enum Hand {
|
||||
Bare = 0,
|
||||
Cloth = 1,
|
||||
Assassin = 2,
|
||||
Plate0 = 3,
|
||||
Leather0 = 4,
|
||||
ClothPurple0 = 5,
|
||||
ClothBlue0 = 6,
|
||||
ClothGreen0 = 7,
|
||||
}
|
||||
pub const ALL_HANDS: [Hand; 8] = [
|
||||
Hand::Bare,
|
||||
Hand::Cloth,
|
||||
Hand::Assassin,
|
||||
Hand::Plate0,
|
||||
Hand::Leather0,
|
||||
Hand::ClothPurple0,
|
||||
Hand::ClothBlue0,
|
||||
Hand::ClothGreen0,
|
||||
];
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
#[repr(u32)]
|
||||
pub enum Foot {
|
||||
Bare = 0,
|
||||
Dark = 1,
|
||||
Sandal = 2,
|
||||
Jester = 3,
|
||||
Assassin = 4,
|
||||
Plate0 = 5,
|
||||
Leather0 = 6,
|
||||
ClothPurple0 = 7,
|
||||
ClothBlue0 = 8,
|
||||
ClothGreen0 = 9,
|
||||
}
|
||||
pub const ALL_FEET: [Foot; 10] = [
|
||||
Foot::Bare,
|
||||
Foot::Dark,
|
||||
Foot::Sandal,
|
||||
Foot::Jester,
|
||||
Foot::Assassin,
|
||||
Foot::Plate0,
|
||||
Foot::Leather0,
|
||||
Foot::ClothPurple0,
|
||||
Foot::ClothBlue0,
|
||||
Foot::ClothGreen0,
|
||||
];
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
#[repr(u32)]
|
||||
pub enum Shoulder {
|
||||
None = 0,
|
||||
Brown1 = 1,
|
||||
Chain = 2,
|
||||
Assassin = 3,
|
||||
Plate0 = 4,
|
||||
Leather0 = 5,
|
||||
Leather1 = 6,
|
||||
ClothPurple0 = 7,
|
||||
ClothBlue0 = 8,
|
||||
ClothGreen0 = 9,
|
||||
}
|
||||
pub const ALL_SHOULDERS: [Shoulder; 10] = [
|
||||
Shoulder::None,
|
||||
Shoulder::Brown1,
|
||||
Shoulder::Chain,
|
||||
Shoulder::Assassin,
|
||||
Shoulder::Plate0,
|
||||
Shoulder::Leather0,
|
||||
Shoulder::Leather1,
|
||||
Shoulder::ClothPurple0,
|
||||
Shoulder::ClothBlue0,
|
||||
Shoulder::ClothGreen0,
|
||||
];
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
#[repr(u32)]
|
||||
pub enum Eyebrows {
|
||||
|
186
common/src/comp/inventory/item/armor.rs
Normal file
186
common/src/comp/inventory/item/armor.rs
Normal file
@ -0,0 +1,186 @@
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
#[repr(u32)]
|
||||
pub enum Chest {
|
||||
None = 0,
|
||||
Blue = 1,
|
||||
Brown = 2,
|
||||
Dark = 3,
|
||||
Green = 4,
|
||||
Orange = 5,
|
||||
Midnight = 6,
|
||||
Kimono = 7,
|
||||
Assassin = 8,
|
||||
PlateGreen0 = 9,
|
||||
Leather0 = 10,
|
||||
ClothPurple0 = 11,
|
||||
ClothBlue0 = 12,
|
||||
ClothGreen0 = 13,
|
||||
}
|
||||
pub const ALL_CHESTS: [Chest; 14] = [
|
||||
Chest::None,
|
||||
Chest::Blue,
|
||||
Chest::Brown,
|
||||
Chest::Dark,
|
||||
Chest::Green,
|
||||
Chest::Orange,
|
||||
Chest::Midnight,
|
||||
Chest::Kimono,
|
||||
Chest::Assassin,
|
||||
Chest::PlateGreen0,
|
||||
Chest::Leather0,
|
||||
Chest::ClothPurple0,
|
||||
Chest::ClothBlue0,
|
||||
Chest::ClothGreen0,
|
||||
];
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
#[repr(u32)]
|
||||
pub enum Belt {
|
||||
None = 0,
|
||||
Dark = 1,
|
||||
TurqCloth = 2,
|
||||
BloodCloth = 3,
|
||||
BlackCloth = 4,
|
||||
Assassin = 5,
|
||||
Plate0 = 6,
|
||||
Leather0 = 7,
|
||||
ClothPurple0 = 8,
|
||||
ClothBlue0 = 9,
|
||||
ClothGreen0 = 10,
|
||||
}
|
||||
pub const ALL_BELTS: [Belt; 11] = [
|
||||
Belt::None,
|
||||
Belt::Dark,
|
||||
Belt::TurqCloth,
|
||||
Belt::BloodCloth,
|
||||
Belt::BlackCloth,
|
||||
Belt::Assassin,
|
||||
Belt::Plate0,
|
||||
Belt::Leather0,
|
||||
Belt::ClothPurple0,
|
||||
Belt::ClothBlue0,
|
||||
Belt::ClothGreen0,
|
||||
];
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
#[repr(u32)]
|
||||
pub enum Pants {
|
||||
None = 0,
|
||||
Blue = 1,
|
||||
Brown = 2,
|
||||
Dark = 3,
|
||||
Green = 4,
|
||||
Orange = 5,
|
||||
Kimono = 6,
|
||||
Assassin = 7,
|
||||
PlateGreen0 = 8,
|
||||
Leather0 = 9,
|
||||
ClothPurple0 = 10,
|
||||
ClothBlue0 = 11,
|
||||
ClothGreen0 = 12,
|
||||
}
|
||||
pub const ALL_PANTS: [Pants; 13] = [
|
||||
Pants::None,
|
||||
Pants::Blue,
|
||||
Pants::Brown,
|
||||
Pants::Dark,
|
||||
Pants::Green,
|
||||
Pants::Orange,
|
||||
Pants::Kimono,
|
||||
Pants::Assassin,
|
||||
Pants::PlateGreen0,
|
||||
Pants::Leather0,
|
||||
Pants::ClothPurple0,
|
||||
Pants::ClothBlue0,
|
||||
Pants::ClothGreen0,
|
||||
];
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
#[repr(u32)]
|
||||
pub enum Hand {
|
||||
Bare = 0,
|
||||
Cloth = 1,
|
||||
Assassin = 2,
|
||||
Plate0 = 3,
|
||||
Leather0 = 4,
|
||||
ClothPurple0 = 5,
|
||||
ClothBlue0 = 6,
|
||||
ClothGreen0 = 7,
|
||||
}
|
||||
pub const ALL_HANDS: [Hand; 8] = [
|
||||
Hand::Bare,
|
||||
Hand::Cloth,
|
||||
Hand::Assassin,
|
||||
Hand::Plate0,
|
||||
Hand::Leather0,
|
||||
Hand::ClothPurple0,
|
||||
Hand::ClothBlue0,
|
||||
Hand::ClothGreen0,
|
||||
];
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
#[repr(u32)]
|
||||
pub enum Foot {
|
||||
Bare = 0,
|
||||
Dark = 1,
|
||||
Sandal = 2,
|
||||
Jester = 3,
|
||||
Assassin = 4,
|
||||
Plate0 = 5,
|
||||
Leather0 = 6,
|
||||
ClothPurple0 = 7,
|
||||
ClothBlue0 = 8,
|
||||
ClothGreen0 = 9,
|
||||
}
|
||||
pub const ALL_FEET: [Foot; 10] = [
|
||||
Foot::Bare,
|
||||
Foot::Dark,
|
||||
Foot::Sandal,
|
||||
Foot::Jester,
|
||||
Foot::Assassin,
|
||||
Foot::Plate0,
|
||||
Foot::Leather0,
|
||||
Foot::ClothPurple0,
|
||||
Foot::ClothBlue0,
|
||||
Foot::ClothGreen0,
|
||||
];
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
#[repr(u32)]
|
||||
pub enum Shoulder {
|
||||
None = 0,
|
||||
Brown1 = 1,
|
||||
Chain = 2,
|
||||
Assassin = 3,
|
||||
Plate0 = 4,
|
||||
Leather0 = 5,
|
||||
Leather1 = 6,
|
||||
ClothPurple0 = 7,
|
||||
ClothBlue0 = 8,
|
||||
ClothGreen0 = 9,
|
||||
}
|
||||
pub const ALL_SHOULDERS: [Shoulder; 10] = [
|
||||
Shoulder::None,
|
||||
Shoulder::Brown1,
|
||||
Shoulder::Chain,
|
||||
Shoulder::Assassin,
|
||||
Shoulder::Plate0,
|
||||
Shoulder::Leather0,
|
||||
Shoulder::Leather1,
|
||||
Shoulder::ClothPurple0,
|
||||
Shoulder::ClothBlue0,
|
||||
Shoulder::ClothGreen0,
|
||||
];
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
pub enum Armor {
|
||||
Shoulder(Shoulder),
|
||||
Chest(Chest),
|
||||
Belt(Belt),
|
||||
Hand(Hand),
|
||||
Pants(Pants),
|
||||
Foot(Foot),
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
pub struct Stats(pub u32);
|
176
common/src/comp/inventory/item/mod.rs
Normal file
176
common/src/comp/inventory/item/mod.rs
Normal file
@ -0,0 +1,176 @@
|
||||
pub mod armor;
|
||||
pub mod tool;
|
||||
|
||||
// Reexports
|
||||
pub use tool::{DebugKind, SwordKind, Tool, ToolKind};
|
||||
|
||||
use crate::{
|
||||
assets::{self, Asset},
|
||||
effect::Effect,
|
||||
terrain::{Block, BlockKind},
|
||||
};
|
||||
use rand::seq::SliceRandom;
|
||||
use specs::{Component, FlaggedStorage};
|
||||
use specs_idvs::IDVStorage;
|
||||
use std::{fs::File, io::BufReader};
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
pub enum Consumable {
|
||||
Apple,
|
||||
Cheese,
|
||||
Potion,
|
||||
Mushroom,
|
||||
Velorite,
|
||||
VeloriteFrag,
|
||||
PotionMinor,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
pub enum Utility {
|
||||
Collar,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
pub enum Ingredient {
|
||||
Flower,
|
||||
Grass,
|
||||
}
|
||||
|
||||
fn default_amount() -> u32 { 1 }
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
pub enum ItemKind {
|
||||
/// Something wieldable
|
||||
Tool(tool::Tool),
|
||||
Armor {
|
||||
kind: armor::Armor,
|
||||
stats: armor::Stats,
|
||||
},
|
||||
Consumable {
|
||||
kind: Consumable,
|
||||
effect: Effect,
|
||||
#[serde(default = "default_amount")]
|
||||
amount: u32,
|
||||
},
|
||||
Utility {
|
||||
kind: Utility,
|
||||
#[serde(default = "default_amount")]
|
||||
amount: u32,
|
||||
},
|
||||
Ingredient {
|
||||
kind: Ingredient,
|
||||
#[serde(default = "default_amount")]
|
||||
amount: u32,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
pub struct Item {
|
||||
name: String,
|
||||
description: String,
|
||||
pub kind: ItemKind,
|
||||
}
|
||||
|
||||
impl Asset for Item {
|
||||
const ENDINGS: &'static [&'static str] = &["ron"];
|
||||
|
||||
fn parse(buf_reader: BufReader<File>) -> Result<Self, assets::Error> {
|
||||
Ok(ron::de::from_reader(buf_reader).unwrap())
|
||||
}
|
||||
}
|
||||
|
||||
impl Item {
|
||||
pub fn empty() -> Self {
|
||||
Self {
|
||||
name: "Empty Item".to_owned(),
|
||||
description: "This item may grant abilities, but is invisible".to_owned(),
|
||||
kind: ItemKind::Tool(Tool::empty()),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn name(&self) -> &str { &self.name }
|
||||
|
||||
pub fn description(&self) -> &str { &self.description }
|
||||
|
||||
pub fn try_reclaim_from_block(block: Block) -> Option<Self> {
|
||||
match block.kind() {
|
||||
BlockKind::Apple => Some(assets::load_expect_cloned("common.items.apple")),
|
||||
BlockKind::Mushroom => Some(assets::load_expect_cloned("common.items.mushroom")),
|
||||
BlockKind::Velorite => Some(assets::load_expect_cloned("common.items.velorite")),
|
||||
BlockKind::BlueFlower => Some(assets::load_expect_cloned("common.items.flowers.blue")),
|
||||
BlockKind::PinkFlower => Some(assets::load_expect_cloned("common.items.flowers.pink")),
|
||||
BlockKind::PurpleFlower => {
|
||||
Some(assets::load_expect_cloned("common.items.flowers.purple"))
|
||||
},
|
||||
BlockKind::RedFlower => Some(assets::load_expect_cloned("common.items.flowers.red")),
|
||||
BlockKind::WhiteFlower => {
|
||||
Some(assets::load_expect_cloned("common.items.flowers.white"))
|
||||
},
|
||||
BlockKind::YellowFlower => {
|
||||
Some(assets::load_expect_cloned("common.items.flowers.yellow"))
|
||||
},
|
||||
BlockKind::Sunflower => Some(assets::load_expect_cloned("common.items.flowers.sun")),
|
||||
BlockKind::LongGrass => Some(assets::load_expect_cloned("common.items.grasses.long")),
|
||||
BlockKind::MediumGrass => {
|
||||
Some(assets::load_expect_cloned("common.items.grasses.medium"))
|
||||
},
|
||||
BlockKind::ShortGrass => Some(assets::load_expect_cloned("common.items.grasses.short")),
|
||||
BlockKind::Chest => Some(assets::load_expect_cloned(
|
||||
[
|
||||
"common.items.apple",
|
||||
"common.items.velorite",
|
||||
"common.items.veloritefrag",
|
||||
"common.items.cheese",
|
||||
"common.items.potion_minor",
|
||||
"common.items.collar",
|
||||
"common.items.weapons.starter_sword",
|
||||
"common.items.weapons.starter_axe",
|
||||
"common.items.weapons.staff_nature",
|
||||
"common.items.weapons.starter_hammer",
|
||||
"common.items.weapons.starter_bow",
|
||||
"common.items.weapons.starter_staff",
|
||||
"common.items.armor.belt.plate_0",
|
||||
"common.items.armor.belt.leather_0",
|
||||
"common.items.armor.chest.plate_green_0",
|
||||
"common.items.armor.chest.leather_0",
|
||||
"common.items.armor.foot.plate_0",
|
||||
"common.items.armor.foot.leather_0",
|
||||
"common.items.armor.pants.plate_green_0",
|
||||
"common.items.armor.belt.leather_0",
|
||||
"common.items.armor.shoulder.plate_0",
|
||||
"common.items.armor.shoulder.leather_1",
|
||||
"common.items.armor.shoulder.leather_0",
|
||||
"common.items.armor.hand.leather_0",
|
||||
"common.items.armor.hand.plate_0",
|
||||
"common.items.weapons.wood_sword",
|
||||
"common.items.weapons.short_sword_0",
|
||||
"common.items.armor.belt.cloth_blue_0",
|
||||
"common.items.armor.chest.cloth_blue_0",
|
||||
"common.items.armor.foot.cloth_blue_0",
|
||||
"common.items.armor.pants.cloth_blue_0",
|
||||
"common.items.armor.shoulder.cloth_blue_0",
|
||||
"common.items.armor.hand.cloth_blue_0",
|
||||
"common.items.armor.belt.cloth_green_0",
|
||||
"common.items.armor.chest.cloth_green_0",
|
||||
"common.items.armor.foot.cloth_green_0",
|
||||
"common.items.armor.pants.cloth_green_0",
|
||||
"common.items.armor.shoulder.cloth_green_0",
|
||||
"common.items.armor.hand.cloth_green_0",
|
||||
"common.items.armor.belt.cloth_purple_0",
|
||||
"common.items.armor.chest.cloth_purple_0",
|
||||
"common.items.armor.foot.cloth_purple_0",
|
||||
"common.items.armor.pants.cloth_purple_0",
|
||||
"common.items.armor.shoulder.cloth_purple_0",
|
||||
"common.items.armor.hand.cloth_purple_0",
|
||||
]
|
||||
.choose(&mut rand::thread_rng())
|
||||
.unwrap(), // Can't fail
|
||||
)),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Component for Item {
|
||||
type Storage = FlaggedStorage<Self, IDVStorage<Self>>;
|
||||
}
|
@ -1,17 +1,8 @@
|
||||
use crate::{
|
||||
assets::{self, Asset},
|
||||
comp::{
|
||||
body::{humanoid, object},
|
||||
projectile, Body, CharacterAbility, Gravity, HealthChange, HealthSource, LightEmitter,
|
||||
Projectile,
|
||||
},
|
||||
effect::Effect,
|
||||
terrain::{Block, BlockKind},
|
||||
use crate::comp::{
|
||||
body::object, projectile, Body, CharacterAbility, Gravity, HealthChange, HealthSource,
|
||||
LightEmitter, Projectile,
|
||||
};
|
||||
use rand::seq::SliceRandom;
|
||||
use specs::{Component, FlaggedStorage};
|
||||
use specs_idvs::IDVStorage;
|
||||
use std::{fs::File, io::BufReader, time::Duration};
|
||||
use std::time::Duration;
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
pub enum SwordKind {
|
||||
@ -47,6 +38,12 @@ pub enum ShieldKind {
|
||||
BasicShield,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
pub enum DebugKind {
|
||||
Boost,
|
||||
Possess,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
pub enum ToolKind {
|
||||
Sword(SwordKind),
|
||||
@ -61,8 +58,22 @@ pub enum ToolKind {
|
||||
Empty,
|
||||
}
|
||||
|
||||
impl ToolData {
|
||||
pub fn equip_time(&self) -> Duration { Duration::from_millis(self.equip_time_millis) }
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
pub struct Tool {
|
||||
pub kind: ToolKind,
|
||||
equip_time_millis: u32,
|
||||
// TODO: item specific abilities
|
||||
}
|
||||
|
||||
impl Tool {
|
||||
pub fn empty() -> Self {
|
||||
Self {
|
||||
kind: ToolKind::Empty,
|
||||
equip_time_millis: 0,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn equip_time(&self) -> Duration { Duration::from_millis(self.equip_time_millis as u64) }
|
||||
|
||||
pub fn get_abilities(&self) -> Vec<CharacterAbility> {
|
||||
use CharacterAbility::*;
|
||||
@ -254,192 +265,3 @@ impl ToolData {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
pub enum DebugKind {
|
||||
Boost,
|
||||
Possess,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
pub enum Armor {
|
||||
Shoulder(humanoid::Shoulder),
|
||||
Chest(humanoid::Chest),
|
||||
Belt(humanoid::Belt),
|
||||
Hand(humanoid::Hand),
|
||||
Pants(humanoid::Pants),
|
||||
Foot(humanoid::Foot),
|
||||
}
|
||||
|
||||
pub type ArmorStats = u32;
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
pub enum Consumable {
|
||||
Apple,
|
||||
Cheese,
|
||||
Potion,
|
||||
Mushroom,
|
||||
Velorite,
|
||||
VeloriteFrag,
|
||||
PotionMinor,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
pub enum Utility {
|
||||
Collar,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
pub enum Ingredient {
|
||||
Flower,
|
||||
Grass,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
pub struct ToolData {
|
||||
pub kind: ToolKind,
|
||||
equip_time_millis: u64,
|
||||
// TODO: item specific abilities
|
||||
}
|
||||
|
||||
fn default_amount() -> u32 { 1 }
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
pub enum ItemKind {
|
||||
/// Something wieldable
|
||||
Tool(ToolData),
|
||||
Armor {
|
||||
kind: Armor,
|
||||
stats: ArmorStats,
|
||||
},
|
||||
Consumable {
|
||||
kind: Consumable,
|
||||
effect: Effect,
|
||||
#[serde(default = "default_amount")]
|
||||
amount: u32,
|
||||
},
|
||||
Utility {
|
||||
kind: Utility,
|
||||
#[serde(default = "default_amount")]
|
||||
amount: u32,
|
||||
},
|
||||
Ingredient {
|
||||
kind: Ingredient,
|
||||
#[serde(default = "default_amount")]
|
||||
amount: u32,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
pub struct Item {
|
||||
name: String,
|
||||
description: String,
|
||||
pub kind: ItemKind,
|
||||
}
|
||||
|
||||
impl Asset for Item {
|
||||
const ENDINGS: &'static [&'static str] = &["ron"];
|
||||
|
||||
fn parse(buf_reader: BufReader<File>) -> Result<Self, assets::Error> {
|
||||
Ok(ron::de::from_reader(buf_reader).unwrap())
|
||||
}
|
||||
}
|
||||
|
||||
impl Item {
|
||||
pub fn empty() -> Self {
|
||||
Self {
|
||||
name: "Empty Item".to_owned(),
|
||||
description: "This item may grant abilities, but is invisible".to_owned(),
|
||||
kind: ItemKind::Tool(ToolData {
|
||||
kind: ToolKind::Empty,
|
||||
equip_time_millis: 0,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn name(&self) -> &str { &self.name }
|
||||
|
||||
pub fn description(&self) -> &str { &self.description }
|
||||
|
||||
pub fn try_reclaim_from_block(block: Block) -> Option<Self> {
|
||||
match block.kind() {
|
||||
BlockKind::Apple => Some(assets::load_expect_cloned("common.items.apple")),
|
||||
BlockKind::Mushroom => Some(assets::load_expect_cloned("common.items.mushroom")),
|
||||
BlockKind::Velorite => Some(assets::load_expect_cloned("common.items.velorite")),
|
||||
BlockKind::BlueFlower => Some(assets::load_expect_cloned("common.items.flowers.blue")),
|
||||
BlockKind::PinkFlower => Some(assets::load_expect_cloned("common.items.flowers.pink")),
|
||||
BlockKind::PurpleFlower => {
|
||||
Some(assets::load_expect_cloned("common.items.flowers.purple"))
|
||||
},
|
||||
BlockKind::RedFlower => Some(assets::load_expect_cloned("common.items.flowers.red")),
|
||||
BlockKind::WhiteFlower => {
|
||||
Some(assets::load_expect_cloned("common.items.flowers.white"))
|
||||
},
|
||||
BlockKind::YellowFlower => {
|
||||
Some(assets::load_expect_cloned("common.items.flowers.yellow"))
|
||||
},
|
||||
BlockKind::Sunflower => Some(assets::load_expect_cloned("common.items.flowers.sun")),
|
||||
BlockKind::LongGrass => Some(assets::load_expect_cloned("common.items.grasses.long")),
|
||||
BlockKind::MediumGrass => {
|
||||
Some(assets::load_expect_cloned("common.items.grasses.medium"))
|
||||
},
|
||||
BlockKind::ShortGrass => Some(assets::load_expect_cloned("common.items.grasses.short")),
|
||||
BlockKind::Chest => Some(assets::load_expect_cloned(
|
||||
[
|
||||
"common.items.apple",
|
||||
"common.items.velorite",
|
||||
"common.items.veloritefrag",
|
||||
"common.items.cheese",
|
||||
"common.items.potion_minor",
|
||||
"common.items.collar",
|
||||
"common.items.weapons.starter_sword",
|
||||
"common.items.weapons.starter_axe",
|
||||
"common.items.weapons.staff_nature",
|
||||
"common.items.weapons.starter_hammer",
|
||||
"common.items.weapons.starter_bow",
|
||||
"common.items.weapons.starter_staff",
|
||||
"common.items.armor.belt.plate_0",
|
||||
"common.items.armor.belt.leather_0",
|
||||
"common.items.armor.chest.plate_green_0",
|
||||
"common.items.armor.chest.leather_0",
|
||||
"common.items.armor.foot.plate_0",
|
||||
"common.items.armor.foot.leather_0",
|
||||
"common.items.armor.pants.plate_green_0",
|
||||
"common.items.armor.belt.leather_0",
|
||||
"common.items.armor.shoulder.plate_0",
|
||||
"common.items.armor.shoulder.leather_1",
|
||||
"common.items.armor.shoulder.leather_0",
|
||||
"common.items.armor.hand.leather_0",
|
||||
"common.items.armor.hand.plate_0",
|
||||
"common.items.weapons.wood_sword",
|
||||
"common.items.weapons.short_sword_0",
|
||||
"common.items.armor.belt.cloth_blue_0",
|
||||
"common.items.armor.chest.cloth_blue_0",
|
||||
"common.items.armor.foot.cloth_blue_0",
|
||||
"common.items.armor.pants.cloth_blue_0",
|
||||
"common.items.armor.shoulder.cloth_blue_0",
|
||||
"common.items.armor.hand.cloth_blue_0",
|
||||
"common.items.armor.belt.cloth_green_0",
|
||||
"common.items.armor.chest.cloth_green_0",
|
||||
"common.items.armor.foot.cloth_green_0",
|
||||
"common.items.armor.pants.cloth_green_0",
|
||||
"common.items.armor.shoulder.cloth_green_0",
|
||||
"common.items.armor.hand.cloth_green_0",
|
||||
"common.items.armor.belt.cloth_purple_0",
|
||||
"common.items.armor.chest.cloth_purple_0",
|
||||
"common.items.armor.foot.cloth_purple_0",
|
||||
"common.items.armor.pants.cloth_purple_0",
|
||||
"common.items.armor.shoulder.cloth_purple_0",
|
||||
"common.items.armor.hand.cloth_purple_0",
|
||||
]
|
||||
.choose(&mut rand::thread_rng())
|
||||
.unwrap(), // Can't fail
|
||||
)),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Component for Item {
|
||||
type Storage = FlaggedStorage<Self, IDVStorage<Self>>;
|
||||
}
|
@ -1,9 +1,7 @@
|
||||
pub mod item;
|
||||
|
||||
// Reexports
|
||||
pub use item::{Consumable, DebugKind, Item, ItemKind, SwordKind, ToolData, ToolKind};
|
||||
|
||||
use crate::assets;
|
||||
use item::{Consumable, Item, ItemKind};
|
||||
use specs::{Component, FlaggedStorage, HashMapStorage};
|
||||
use specs_idvs::IDVStorage;
|
||||
use std::ops::Not;
|
||||
|
@ -31,8 +31,7 @@ pub use controller::{
|
||||
pub use energy::{Energy, EnergySource};
|
||||
pub use inputs::CanBuild;
|
||||
pub use inventory::{
|
||||
item, Inventory, InventoryUpdate, InventoryUpdateEvent, Item, ItemKind, SwordKind, ToolData,
|
||||
ToolKind, MAX_PICKUP_RANGE_SQR,
|
||||
item, item::Item, Inventory, InventoryUpdate, InventoryUpdateEvent, MAX_PICKUP_RANGE_SQR,
|
||||
};
|
||||
pub use last::Last;
|
||||
pub use location::{Waypoint, WaypointArea};
|
||||
|
@ -1,5 +1,8 @@
|
||||
use crate::{
|
||||
comp::{CharacterState, ItemKind::Tool, StateUpdate, ToolData},
|
||||
comp::{
|
||||
item::{ItemKind, Tool},
|
||||
CharacterState, StateUpdate,
|
||||
},
|
||||
event::LocalEvent,
|
||||
states::*,
|
||||
sys::{character_behavior::JoinData, phys::GRAVITY},
|
||||
@ -108,7 +111,7 @@ pub fn handle_primary_wield(data: &JoinData, update: &mut StateUpdate) {
|
||||
|
||||
/// If a tool is equipped, goes into Equipping state, otherwise goes to Idle
|
||||
pub fn attempt_wield(data: &JoinData, update: &mut StateUpdate) {
|
||||
if let Some(Tool(tool)) = data.loadout.active_item.as_ref().map(|i| &i.item.kind) {
|
||||
if let Some(ItemKind::Tool(tool)) = data.loadout.active_item.as_ref().map(|i| &i.item.kind) {
|
||||
update.character = CharacterState::Equipping(equipping::Data {
|
||||
time_left: tool.equip_time(),
|
||||
});
|
||||
@ -237,8 +240,8 @@ pub fn handle_dodge_input(data: &JoinData, update: &mut StateUpdate) {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn unwrap_tool_data<'a>(data: &'a JoinData) -> Option<&'a ToolData> {
|
||||
if let Some(Tool(tool)) = data.loadout.active_item.as_ref().map(|i| &i.item.kind) {
|
||||
pub fn unwrap_tool_data<'a>(data: &'a JoinData) -> Option<&'a Tool> {
|
||||
if let Some(ItemKind::Tool(tool)) = data.loadout.active_item.as_ref().map(|i| &i.item.kind) {
|
||||
Some(tool)
|
||||
} else {
|
||||
None
|
||||
|
@ -3,7 +3,8 @@ use crate::{
|
||||
Server,
|
||||
};
|
||||
use common::{
|
||||
assets, comp,
|
||||
assets,
|
||||
comp::{self, item},
|
||||
msg::ServerMsg,
|
||||
sync::{Uid, WorldSyncExt},
|
||||
};
|
||||
@ -85,7 +86,7 @@ pub fn handle_possess(server: &Server, possessor_uid: Uid, possesse_uid: Uid) {
|
||||
.or_insert(comp::Loadout::default());
|
||||
|
||||
let item = assets::load_expect_cloned::<comp::Item>("common.items.debug.possess");
|
||||
if let comp::ItemKind::Tool(tool) = item.kind {
|
||||
if let item::ItemKind::Tool(tool) = item.kind {
|
||||
let mut abilities = tool.get_abilities();
|
||||
let mut ability_drain = abilities.drain(..);
|
||||
loadout.active_item = Some(comp::ItemConfig {
|
||||
|
@ -1,6 +1,6 @@
|
||||
use crate::{Server, StateExt};
|
||||
use common::{
|
||||
comp::{self, Pos, MAX_PICKUP_RANGE_SQR},
|
||||
comp::{self, item, Pos, MAX_PICKUP_RANGE_SQR},
|
||||
sync::WorldSyncExt,
|
||||
terrain::block::Block,
|
||||
vol::{ReadVol, Vox},
|
||||
@ -94,7 +94,7 @@ pub fn handle_inventory(server: &mut Server, entity: EcsEntity, manip: comp::Inv
|
||||
|
||||
if let Some(item) = item_opt {
|
||||
match &item.kind {
|
||||
comp::ItemKind::Tool(tool) => {
|
||||
item::ItemKind::Tool(tool) => {
|
||||
if let Some(loadout) =
|
||||
state.ecs().write_storage::<comp::Loadout>().get_mut(entity)
|
||||
{
|
||||
@ -121,16 +121,16 @@ pub fn handle_inventory(server: &mut Server, entity: EcsEntity, manip: comp::Inv
|
||||
}
|
||||
},
|
||||
|
||||
comp::ItemKind::Consumable { kind, effect, .. } => {
|
||||
item::ItemKind::Consumable { kind, effect, .. } => {
|
||||
event = comp::InventoryUpdateEvent::Consumed(*kind);
|
||||
state.apply_effect(entity, *effect);
|
||||
},
|
||||
|
||||
comp::ItemKind::Armor { kind, .. } => {
|
||||
item::ItemKind::Armor { kind, .. } => {
|
||||
if let Some(loadout) =
|
||||
state.ecs().write_storage::<comp::Loadout>().get_mut(entity)
|
||||
{
|
||||
use comp::item::Armor::*;
|
||||
use comp::item::armor::Armor::*;
|
||||
let slot = match kind.clone() {
|
||||
Shoulder(_) => &mut loadout.shoulder,
|
||||
Chest(_) => &mut loadout.chest,
|
||||
@ -153,7 +153,7 @@ pub fn handle_inventory(server: &mut Server, entity: EcsEntity, manip: comp::Inv
|
||||
}
|
||||
},
|
||||
|
||||
comp::ItemKind::Utility { kind, .. } => match kind {
|
||||
item::ItemKind::Utility { kind, .. } => match kind {
|
||||
comp::item::Utility::Collar => {
|
||||
let reinsert = if let Some(pos) =
|
||||
state.read_storage::<comp::Pos>().get(entity)
|
||||
|
@ -1,6 +1,7 @@
|
||||
use crate::{client::Client, settings::ServerSettings, sys::sentinel::DeletedEntities, SpawnPoint};
|
||||
use common::{
|
||||
assets, comp,
|
||||
assets,
|
||||
comp::{self, item},
|
||||
effect::Effect,
|
||||
msg::{ClientState, ServerMsg},
|
||||
state::State,
|
||||
@ -164,7 +165,7 @@ impl StateExt for State {
|
||||
|
||||
self.write_component(
|
||||
entity,
|
||||
if let Some(comp::ItemKind::Tool(tool)) = main.as_ref().map(|i| &i.kind) {
|
||||
if let Some(item::ItemKind::Tool(tool)) = main.as_ref().map(|i| &i.kind) {
|
||||
let mut abilities = tool.get_abilities();
|
||||
let mut ability_drain = abilities.drain(..);
|
||||
comp::Loadout {
|
||||
|
@ -2,7 +2,7 @@ use super::SysTimer;
|
||||
use crate::{chunk_generator::ChunkGenerator, client::Client, Tick};
|
||||
use common::{
|
||||
assets,
|
||||
comp::{self, CharacterAbility, Item, ItemConfig, Player, Pos},
|
||||
comp::{self, item, CharacterAbility, Item, ItemConfig, Player, Pos},
|
||||
event::{EventBus, ServerEvent},
|
||||
generation::EntityKind,
|
||||
msg::ServerMsg,
|
||||
@ -190,7 +190,7 @@ impl<'a> System<'a> for Sys {
|
||||
let mut stats = comp::Stats::new(name, body);
|
||||
|
||||
let active_item =
|
||||
if let Some(comp::ItemKind::Tool(tool)) = main.as_ref().map(|i| &i.kind) {
|
||||
if let Some(item::ItemKind::Tool(tool)) = main.as_ref().map(|i| &i.kind) {
|
||||
let mut abilities = tool.get_abilities();
|
||||
let mut ability_drain = abilities.drain(..);
|
||||
|
||||
|
@ -12,7 +12,7 @@ pub mod quadruped_medium;
|
||||
pub mod quadruped_small;
|
||||
|
||||
use crate::render::FigureBoneData;
|
||||
use common::comp::{self, ToolKind};
|
||||
use common::comp::{self, item::tool::ToolKind};
|
||||
use vek::*;
|
||||
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
|
@ -9,7 +9,7 @@ use crate::{
|
||||
ui::{fonts::ConrodVoxygenFonts, ImageFrame, Tooltip, TooltipManager, Tooltipable},
|
||||
};
|
||||
use client::Client;
|
||||
use common::comp::{ItemKind, Stats};
|
||||
use common::comp::{item::ItemKind, Stats};
|
||||
use conrod_core::{
|
||||
color, image,
|
||||
widget::{self, Button, Image, Rectangle, Text},
|
||||
|
@ -1,7 +1,11 @@
|
||||
use crate::ui::{Graphic, SampleStrat, Transform, Ui};
|
||||
use common::{
|
||||
assets::{self, watch::ReloadIndicator, Asset},
|
||||
comp::item::{Armor, Consumable, Ingredient, Item, ItemKind, ToolData, ToolKind, Utility},
|
||||
comp::item::{
|
||||
armor::Armor,
|
||||
tool::{Tool, ToolKind},
|
||||
Consumable, Ingredient, Item, ItemKind, Utility,
|
||||
},
|
||||
};
|
||||
use conrod_core::image::Id;
|
||||
use dot_vox::DotVoxData;
|
||||
@ -24,7 +28,7 @@ pub enum ItemKey {
|
||||
impl From<&Item> for ItemKey {
|
||||
fn from(item: &Item) -> Self {
|
||||
match &item.kind {
|
||||
ItemKind::Tool(ToolData { kind, .. }) => ItemKey::Tool(kind.clone()),
|
||||
ItemKind::Tool(Tool { kind, .. }) => ItemKey::Tool(kind.clone()),
|
||||
ItemKind::Armor { kind, .. } => ItemKey::Armor(kind.clone()),
|
||||
ItemKind::Utility { kind, .. } => ItemKey::Utility(kind.clone()),
|
||||
ItemKind::Consumable { kind, .. } => ItemKey::Consumable(kind.clone()),
|
||||
|
@ -10,8 +10,11 @@ use crate::{
|
||||
use common::{
|
||||
assets::load_expect,
|
||||
comp::{
|
||||
item::{DebugKind, StaffKind, ToolData, ToolKind},
|
||||
CharacterState, ControllerInputs, Energy, ItemKind, Loadout, Stats,
|
||||
item::{
|
||||
tool::{DebugKind, StaffKind, Tool, ToolKind},
|
||||
ItemKind,
|
||||
},
|
||||
CharacterState, ControllerInputs, Energy, Loadout, Stats,
|
||||
},
|
||||
};
|
||||
use conrod_core::{
|
||||
@ -590,7 +593,7 @@ impl<'a> Widget for Skillbar<'a> {
|
||||
.w_h(38.0 * scale, 38.0 * scale)
|
||||
.color(
|
||||
match self.loadout.active_item.as_ref().map(|i| &i.item.kind) {
|
||||
Some(ItemKind::Tool(ToolData { kind, .. })) => match kind {
|
||||
Some(ItemKind::Tool(Tool { kind, .. })) => match kind {
|
||||
ToolKind::Bow(_) => Some(BG_COLOR_2),
|
||||
ToolKind::Staff(_) => Some(BG_COLOR_2),
|
||||
_ => Some(BG_COLOR_2),
|
||||
@ -602,7 +605,7 @@ impl<'a> Widget for Skillbar<'a> {
|
||||
.set(state.ids.m1_slot_bg, ui);
|
||||
Button::image(
|
||||
match self.loadout.active_item.as_ref().map(|i| &i.item.kind) {
|
||||
Some(ItemKind::Tool(ToolData { kind, .. })) => match kind {
|
||||
Some(ItemKind::Tool(Tool { kind, .. })) => match kind {
|
||||
ToolKind::Sword(_) => self.imgs.twohsword_m1,
|
||||
ToolKind::Hammer(_) => self.imgs.twohhammer_m1,
|
||||
ToolKind::Axe(_) => self.imgs.twohaxe_m1,
|
||||
@ -616,7 +619,7 @@ impl<'a> Widget for Skillbar<'a> {
|
||||
) // Insert Icon here
|
||||
.w(
|
||||
match self.loadout.active_item.as_ref().map(|i| &i.item.kind) {
|
||||
Some(ItemKind::Tool(ToolData { kind, .. })) => match kind {
|
||||
Some(ItemKind::Tool(Tool { kind, .. })) => match kind {
|
||||
ToolKind::Bow(_) => 30.0 * scale,
|
||||
ToolKind::Staff(_) => 32.0 * scale,
|
||||
_ => 38.0 * scale,
|
||||
@ -626,7 +629,7 @@ impl<'a> Widget for Skillbar<'a> {
|
||||
)
|
||||
.h(
|
||||
match self.loadout.active_item.as_ref().map(|i| &i.item.kind) {
|
||||
Some(ItemKind::Tool(ToolData { kind, .. })) => match kind {
|
||||
Some(ItemKind::Tool(Tool { kind, .. })) => match kind {
|
||||
ToolKind::Bow(_) => 30.0 * scale,
|
||||
ToolKind::Staff(_) => 32.0 * scale,
|
||||
_ => 38.0 * scale,
|
||||
@ -691,7 +694,7 @@ impl<'a> Widget for Skillbar<'a> {
|
||||
.w_h(38.0 * scale, 38.0 * scale)
|
||||
.color(
|
||||
match self.loadout.active_item.as_ref().map(|i| &i.item.kind) {
|
||||
Some(ItemKind::Tool(ToolData { kind, .. })) => match kind {
|
||||
Some(ItemKind::Tool(Tool { kind, .. })) => match kind {
|
||||
ToolKind::Bow(_) => Some(BG_COLOR_2),
|
||||
ToolKind::Staff(_) => Some(BG_COLOR_2),
|
||||
_ => Some(BG_COLOR_2),
|
||||
@ -703,7 +706,7 @@ impl<'a> Widget for Skillbar<'a> {
|
||||
.set(state.ids.m2_slot_bg, ui);
|
||||
Button::image(
|
||||
match self.loadout.active_item.as_ref().map(|i| &i.item.kind) {
|
||||
Some(ItemKind::Tool(ToolData { kind, .. })) => match kind {
|
||||
Some(ItemKind::Tool(Tool { kind, .. })) => match kind {
|
||||
ToolKind::Sword(_) => self.imgs.charge,
|
||||
ToolKind::Hammer(_) => self.imgs.nothing,
|
||||
ToolKind::Axe(_) => self.imgs.nothing,
|
||||
@ -718,7 +721,7 @@ impl<'a> Widget for Skillbar<'a> {
|
||||
) // Insert Icon here
|
||||
.w(
|
||||
match self.loadout.active_item.as_ref().map(|i| &i.item.kind) {
|
||||
Some(ItemKind::Tool(ToolData { kind, .. })) => match kind {
|
||||
Some(ItemKind::Tool(Tool { kind, .. })) => match kind {
|
||||
ToolKind::Staff(_) => 30.0 * scale,
|
||||
_ => 38.0 * scale,
|
||||
},
|
||||
@ -727,7 +730,7 @@ impl<'a> Widget for Skillbar<'a> {
|
||||
)
|
||||
.h(
|
||||
match self.loadout.active_item.as_ref().map(|i| &i.item.kind) {
|
||||
Some(ItemKind::Tool(ToolData { kind, .. })) => match kind {
|
||||
Some(ItemKind::Tool(Tool { kind, .. })) => match kind {
|
||||
ToolKind::Staff(_) => 30.0 * scale,
|
||||
_ => 38.0 * scale,
|
||||
},
|
||||
@ -737,7 +740,7 @@ impl<'a> Widget for Skillbar<'a> {
|
||||
.middle_of(state.ids.m2_slot_bg)
|
||||
.image_color(
|
||||
match self.loadout.active_item.as_ref().map(|i| &i.item.kind) {
|
||||
Some(ItemKind::Tool(ToolData { kind, .. })) => match kind {
|
||||
Some(ItemKind::Tool(Tool { kind, .. })) => match kind {
|
||||
ToolKind::Sword(_) => {
|
||||
if self.energy.current() as f64 >= 200.0 {
|
||||
Color::Rgba(1.0, 1.0, 1.0, 1.0)
|
||||
@ -832,7 +835,7 @@ impl<'a> Widget for Skillbar<'a> {
|
||||
.w_h(19.5 * scale, 19.5 * scale)
|
||||
.color(
|
||||
match self.loadout.active_item.as_ref().map(|i| &i.item.kind) {
|
||||
Some(ItemKind::Tool(ToolData { kind, .. })) => match kind {
|
||||
Some(ItemKind::Tool(Tool { kind, .. })) => match kind {
|
||||
ToolKind::Staff(StaffKind::BasicStaff) => Some(BLACK),
|
||||
_ => Some(BG_COLOR),
|
||||
},
|
||||
@ -843,7 +846,7 @@ impl<'a> Widget for Skillbar<'a> {
|
||||
.set(state.ids.slot1_bg, ui);
|
||||
// TODO: Changeable slot image
|
||||
match self.loadout.active_item.as_ref().map(|i| &i.item.kind) {
|
||||
Some(ItemKind::Tool(ToolData { kind, .. })) => match kind {
|
||||
Some(ItemKind::Tool(Tool { kind, .. })) => match kind {
|
||||
ToolKind::Staff(StaffKind::BasicStaff) => {
|
||||
Image::new(self.imgs.fire_spell_1)
|
||||
.w_h(18.0 * scale, 18.0 * scale)
|
||||
|
@ -6,7 +6,10 @@ use crate::{
|
||||
};
|
||||
use common::{
|
||||
assets::watch::ReloadIndicator,
|
||||
comp::{Body, CharacterState, Item, ItemKind, Loadout, ToolKind},
|
||||
comp::{
|
||||
item::{tool::ToolKind, ItemKind},
|
||||
Body, CharacterState, Item, Loadout,
|
||||
},
|
||||
};
|
||||
use hashbrown::{hash_map::Entry, HashMap};
|
||||
use std::{
|
||||
|
@ -10,15 +10,16 @@ use common::{
|
||||
bird_small,
|
||||
critter::{BodyType as CBodyType, Species as CSpecies},
|
||||
dragon, fish_medium, fish_small,
|
||||
humanoid::{
|
||||
Belt, Body, BodyType, Chest, EyeColor, Eyebrows, Foot, Hand, Pants, Race, Shoulder,
|
||||
Skin,
|
||||
humanoid::{Body, BodyType, EyeColor, Eyebrows, Race, Skin},
|
||||
item::{
|
||||
armor::{Armor, Belt, Chest, Foot, Hand, Pants, Shoulder},
|
||||
tool::{Tool, ToolKind},
|
||||
ItemKind,
|
||||
},
|
||||
item::{Armor, ToolData, ToolKind},
|
||||
object,
|
||||
quadruped_medium::{BodyType as QMBodyType, Species as QMSpecies},
|
||||
quadruped_small::{BodyType as QSBodyType, Species as QSSpecies},
|
||||
ItemKind, Loadout,
|
||||
Loadout,
|
||||
},
|
||||
figure::{DynaUnionizer, MatSegment, Material, Segment},
|
||||
};
|
||||
@ -609,7 +610,7 @@ impl HumMainWeaponSpec {
|
||||
}
|
||||
|
||||
pub fn mesh_main_weapon(&self, item_kind: Option<&ItemKind>) -> Mesh<FigurePipeline> {
|
||||
let tool_kind = if let Some(ItemKind::Tool(ToolData { kind, .. })) = item_kind {
|
||||
let tool_kind = if let Some(ItemKind::Tool(Tool { kind, .. })) = item_kind {
|
||||
kind
|
||||
} else {
|
||||
return Mesh::new();
|
||||
|
@ -21,7 +21,8 @@ use crate::{
|
||||
};
|
||||
use common::{
|
||||
comp::{
|
||||
Body, CharacterState, ItemKind, Last, Loadout, Ori, PhysicsState, Pos, Scale, Stats, Vel,
|
||||
item::ItemKind, Body, CharacterState, Last, Loadout, Ori, PhysicsState, Pos, Scale, Stats,
|
||||
Vel,
|
||||
},
|
||||
state::State,
|
||||
states::triple_strike,
|
||||
@ -35,6 +36,8 @@ use treeculler::{BVol, BoundingSphere};
|
||||
use vek::*;
|
||||
|
||||
const DAMAGE_FADE_COEFFICIENT: f64 = 5.0;
|
||||
const MOVING_THRESHOLD: f32 = 0.7;
|
||||
const MOVING_THRESHOLD_SQR: f32 = MOVING_THRESHOLD * MOVING_THRESHOLD;
|
||||
|
||||
pub struct FigureMgr {
|
||||
model_cache: FigureModelCache,
|
||||
@ -425,8 +428,8 @@ impl FigureMgr {
|
||||
|
||||
let target_base = match (
|
||||
physics.on_ground,
|
||||
vel.0.magnitude_squared() > 0.5, // Moving
|
||||
physics.in_fluid, // In water
|
||||
vel.0.magnitude_squared() > MOVING_THRESHOLD_SQR, // Moving
|
||||
physics.in_fluid, // In water
|
||||
) {
|
||||
// Standing
|
||||
(true, false, _) => anim::character::StandAnimation::update_skeleton(
|
||||
@ -673,8 +676,8 @@ impl FigureMgr {
|
||||
|
||||
let target_base = match (
|
||||
physics.on_ground,
|
||||
vel.0.magnitude_squared() > 0.5, // Moving
|
||||
physics.in_fluid, // In water
|
||||
vel.0.magnitude_squared() > MOVING_THRESHOLD_SQR, // Moving
|
||||
physics.in_fluid, // In water
|
||||
) {
|
||||
// Standing
|
||||
(true, false, false) => {
|
||||
@ -753,8 +756,8 @@ impl FigureMgr {
|
||||
|
||||
let target_base = match (
|
||||
physics.on_ground,
|
||||
vel.0.magnitude_squared() > 0.5, // Moving
|
||||
physics.in_fluid, // In water
|
||||
vel.0.magnitude_squared() > MOVING_THRESHOLD_SQR, // Moving
|
||||
physics.in_fluid, // In water
|
||||
) {
|
||||
// Standing
|
||||
(true, false, false) => {
|
||||
@ -833,8 +836,8 @@ impl FigureMgr {
|
||||
|
||||
let target_base = match (
|
||||
physics.on_ground,
|
||||
vel.0.magnitude_squared() > 0.5, // Moving
|
||||
physics.in_fluid, // In water
|
||||
vel.0.magnitude_squared() > MOVING_THRESHOLD_SQR, // Moving
|
||||
physics.in_fluid, // In water
|
||||
) {
|
||||
// Standing
|
||||
(true, false, false) => anim::bird_medium::IdleAnimation::update_skeleton(
|
||||
@ -907,8 +910,8 @@ impl FigureMgr {
|
||||
|
||||
let target_base = match (
|
||||
physics.on_ground,
|
||||
vel.0.magnitude_squared() > 0.5, // Moving
|
||||
physics.in_fluid, // In water
|
||||
vel.0.magnitude_squared() > MOVING_THRESHOLD_SQR, // Moving
|
||||
physics.in_fluid, // In water
|
||||
) {
|
||||
// Standing
|
||||
(true, false, false) => anim::fish_medium::IdleAnimation::update_skeleton(
|
||||
@ -981,8 +984,8 @@ impl FigureMgr {
|
||||
|
||||
let target_base = match (
|
||||
physics.on_ground,
|
||||
vel.0.magnitude_squared() > 0.5, // Moving
|
||||
physics.in_fluid, // In water
|
||||
vel.0.magnitude_squared() > MOVING_THRESHOLD_SQR, // Moving
|
||||
physics.in_fluid, // In water
|
||||
) {
|
||||
// Standing
|
||||
(true, false, false) => anim::dragon::IdleAnimation::update_skeleton(
|
||||
@ -1055,8 +1058,8 @@ impl FigureMgr {
|
||||
|
||||
let target_base = match (
|
||||
physics.on_ground,
|
||||
vel.0.magnitude_squared() > 0.5, // Moving
|
||||
physics.in_fluid, // In water
|
||||
vel.0.magnitude_squared() > MOVING_THRESHOLD_SQR, // Moving
|
||||
physics.in_fluid, // In water
|
||||
) {
|
||||
// Standing
|
||||
(true, false, false) => anim::critter::IdleAnimation::update_skeleton(
|
||||
@ -1129,8 +1132,8 @@ impl FigureMgr {
|
||||
|
||||
let target_base = match (
|
||||
physics.on_ground,
|
||||
vel.0.magnitude_squared() > 0.5, // Moving
|
||||
physics.in_fluid, // In water
|
||||
vel.0.magnitude_squared() > MOVING_THRESHOLD_SQR, // Moving
|
||||
physics.in_fluid, // In water
|
||||
) {
|
||||
// Standing
|
||||
(true, false, false) => anim::bird_small::IdleAnimation::update_skeleton(
|
||||
@ -1203,8 +1206,8 @@ impl FigureMgr {
|
||||
|
||||
let target_base = match (
|
||||
physics.on_ground,
|
||||
vel.0.magnitude_squared() > 0.5, // Moving
|
||||
physics.in_fluid, // In water
|
||||
vel.0.magnitude_squared() > MOVING_THRESHOLD_SQR, // Moving
|
||||
physics.in_fluid, // In water
|
||||
) {
|
||||
// Standing
|
||||
(true, false, false) => anim::fish_small::IdleAnimation::update_skeleton(
|
||||
@ -1277,8 +1280,8 @@ impl FigureMgr {
|
||||
|
||||
let target_base = match (
|
||||
physics.on_ground,
|
||||
vel.0.magnitude_squared() > 0.5, // Moving
|
||||
physics.in_fluid, // In water
|
||||
vel.0.magnitude_squared() > MOVING_THRESHOLD_SQR, // Moving
|
||||
physics.in_fluid, // In water
|
||||
) {
|
||||
// Standing
|
||||
(true, false, false) => anim::biped_large::IdleAnimation::update_skeleton(
|
||||
|
Loading…
Reference in New Issue
Block a user