Dehardcoded LanternKind, Consumable and Ingredient, fixed Sceptre hotbar

Also fixed two wrong asset references and did some .ron formatting
This commit is contained in:
BottledByte 2020-08-05 01:21:42 +02:00
parent a717276d81
commit ab1c43be84
50 changed files with 122 additions and 169 deletions

View File

@ -78,6 +78,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Updated windowing library (winit 0.19 -> 0.22)
- Bow M2 is now a charged attack that scales the longer it's held
- Fixed window resizing on Mac OS X.
- Dehardcoded many item variants
### Removed

View File

@ -3,7 +3,7 @@ Item(
description: "Used by city guards.",
kind: Lantern(
(
kind: Black0,
kind: "Black0",
color: (r: 255, g: 190, b: 75),
strength_thousandths: 3000,
flicker_thousandths: 300,

View File

@ -2,7 +2,7 @@ Item(
name: "Flask of Velorite Dusk",
description: "Increases Exp by 250\n\nTake with plenty of water\n\n<Right-Click to use>",
kind: Consumable(
kind: PotionExp,
kind: "PotionExp",
effect: Xp(250),
),
)

View File

@ -3,7 +3,7 @@ Item(
description: "Illuminates even the darkest dungeon\nA great monster was slain for this item",
kind: Lantern(
(
kind: Blue0,
kind: "Blue0",
color: (r: 220, g: 220, b: 255),
strength_thousandths: 6500,
flicker_thousandths: 300,

View File

@ -2,7 +2,7 @@ Item(
name: "Potent Potion",
description: "A potent healing potion.\n\nRestores 100 health on use.\n\n<Right-Click to use>",
kind: Consumable(
kind: Potion,
kind: "Potion",
effect: Health((
amount: 1000,
cause: Item,

View File

@ -2,7 +2,7 @@ Item(
name: "Potion of Skill",
description: "Provides 250 XP to the drinker\n\n<Right-Click to use>",
kind: Consumable(
kind: Potion,
kind: "Potion",
effect: Xp(250),
),
)

View File

@ -2,7 +2,7 @@ Item(
name: "Large Potion",
description: "Restores 100 Health\n\n<Right-Click to use>",
kind: Consumable(
kind: PotionLarge,
kind: "PotionLarge",
effect: Health((
amount: 1000,
cause: Item,

View File

@ -2,7 +2,7 @@ Item(
name: "Medium Potion",
description: "Restores 70 Health\n\n<Right-Click to use>",
kind: Consumable(
kind: PotionMed,
kind: "PotionMed",
effect: Health((
amount: 700,
cause: Item,

View File

@ -2,7 +2,7 @@ Item(
name: "Minor Potion",
description: "Restores 50 Health\n\n<Right-Click to use>",
kind: Consumable(
kind: PotionMinor,
kind: "PotionMinor",
effect: Health((
amount: 500,
cause: Item,

View File

@ -2,6 +2,6 @@ Item(
name: "Empty Vial",
description: "Can be filled with fluids.",
kind: Ingredient(
kind: EmptyVial,
kind: "EmptyVial",
)
)

View File

@ -2,6 +2,6 @@ Item(
name: "Leather Scraps",
description: "Used to craft various items.",
kind: Ingredient(
kind: LeatherScraps,
kind: "LeatherScraps",
)
)

View File

@ -2,6 +2,6 @@ Item(
name: "Shiny Gem",
description: "It's so shiny!",
kind: Ingredient(
kind: ShinyGem,
kind: "ShinyGem",
)
)

View File

@ -2,6 +2,6 @@ Item(
name: "Stones",
description: "Pebbles from the ground.",
kind: Ingredient(
kind: Stones,
kind: "Stones",
)
)

View File

@ -2,6 +2,6 @@ Item(
name: "Twigs",
description: "Dry.",
kind: Ingredient(
kind: Twigs,
kind: "Twigs",
)
)

View File

@ -2,6 +2,6 @@ Item(
name: "Craftsman Hammer",
description: "Used to craft various items.",
kind: Ingredient(
kind: CraftsmanHammer,
kind: "CraftsmanHammer",
)
)

View File

@ -2,6 +2,6 @@ Item(
name: "Mortar and Pestle",
description: "Crushes and grinds things into\na fine powder or paste.\nUsed to craft various items.",
kind: Ingredient(
kind: MortarPestle,
kind: "MortarPestle",
)
)

View File

@ -2,6 +2,6 @@ Item(
name: "Blue Flower",
description: "Matches the color of the sky.",
kind: Ingredient(
kind: Flower,
kind: "Flower",
)
)

View File

@ -2,6 +2,6 @@ Item(
name: "Pink Flower",
description: "Looks like a lollipop.",
kind: Ingredient(
kind: Flower,
kind: "Flower",
)
)

View File

@ -2,6 +2,6 @@ Item(
name: "Red Flower",
description: "Roses are red...",
kind: Ingredient(
kind: Flower,
kind: "Flower",
)
)

View File

@ -2,6 +2,6 @@ Item(
name: "Sunflower",
description: "Smells like summer.",
kind: Ingredient(
kind: Flower,
kind: "Flower",
)
)

View File

@ -2,6 +2,6 @@ Item(
name: "White flower",
description: "Pure and precious.",
kind: Ingredient(
kind: Flower,
kind: "Flower",
)
)

View File

@ -2,6 +2,6 @@ Item(
name: "Yellow Flower",
description: "Glows like the sun.",
kind: Ingredient(
kind: Flower,
kind: "Flower",
)
)

View File

@ -2,7 +2,7 @@ Item(
name: "Apple",
description: "Restores 20 Health\n\nRed and juicy\n\n<Right-Click to use>",
kind: Consumable(
kind: Apple,
kind: "Apple",
effect: Health((
amount: 200,
cause: Item,

View File

@ -2,7 +2,7 @@ Item(
name: "Mushroom Curry",
description: "Restores 120 Health\n\nWho could say no to that?\n\n<Right-Click to use>",
kind: Consumable(
kind: AppleShroomCurry,
kind: "AppleShroomCurry",
effect: Health((
amount: 1200,
cause: Item,

View File

@ -2,7 +2,7 @@ Item(
name: "Apple Stick",
description: "Restores 60 Health\n\n<Right-Click to use>",
kind: Consumable(
kind: AppleStick,
kind: "AppleStick",
effect: Health((
amount: 600,
cause: Item,

View File

@ -2,7 +2,7 @@ Item(
name: "Dwarven Cheese",
description: "Restores 15 Health\n\nAromatic and nutritious\n\n<Right-Click to use>",
kind: Consumable(
kind: Cheese,
kind: "Cheese",
effect: Health((
amount: 150,
cause: Item,

View File

@ -2,7 +2,7 @@ Item(
name: "Coconut",
description: "Restores 30 health\n\nReliable source of water and fat\n\n<Right-Click to use>",
kind: Consumable(
kind: Coconut,
kind: "Coconut",
effect: Health((
amount: 300,
cause: Item,

View File

@ -2,7 +2,7 @@ Item(
name: "Mushroom",
description: "Restores 10 Health\n\nHopefully this one is not poisonous\n\n<Right-Click to use>",
kind: Consumable(
kind: Mushroom,
kind: "Mushroom",
effect: Health((
amount: 100,
cause: Item,

View File

@ -2,7 +2,7 @@ Item(
name: "Mushroom Stick",
description: "Restores 50 Health\n\n<Right-Click to use>",
kind: Consumable(
kind: MushroomStick,
kind: "MushroomStick",
effect: Health((
amount: 500,
cause: Item,

View File

@ -2,6 +2,6 @@ Item(
name: "Long Grass",
description: "Greener than an orc's snout.",
kind: Ingredient(
kind: Grass,
kind: "Grass",
)
)

View File

@ -2,6 +2,6 @@ Item(
name: "Medium Grass",
description: "Greener than an orc's snout.",
kind: Ingredient(
kind: Grass,
kind: "Grass",
)
)

View File

@ -2,6 +2,6 @@ Item(
name: "Short Grass",
description: "Greener than an orc's snout.",
kind: Ingredient(
kind: Grass,
kind: "Grass",
)
)

View File

@ -3,7 +3,7 @@ Item(
description: "Used by city guards.",
kind: Lantern(
(
kind: Black0,
kind: "Black0",
color: (r: 255, g: 190, b: 75),
strength_thousandths: 3000,
flicker_thousandths: 300,

View File

@ -3,7 +3,7 @@ Item(
description: "This lantern is surprisingly cold when lit.",
kind: Lantern(
(
kind: Blue0,
kind: "Blue0",
color: (r: 64, g: 127, b: 153),
strength_thousandths: 4000,
flicker_thousandths: 250,

View File

@ -3,7 +3,7 @@ Item(
description: "It has an opening that could fit a ring...",
kind: Lantern(
(
kind: Green0,
kind: "Green0",
color: (r: 192, g: 255, b: 76),
strength_thousandths: 4000,
flicker_thousandths: 500,

View File

@ -3,7 +3,7 @@ Item(
description: "Caution: contents hot",
kind: Lantern(
(
kind: Red0,
kind: "Red0",
color: (r: 255, g: 127, b: 51),
strength_thousandths: 3500,
flicker_thousandths: 1000,

View File

@ -2,7 +2,7 @@ Item(
name: "Velorite",
description: "Increases Exp by 20\n\nJust a slight touch makes you feel the knowledge of ancient times\n\n<Right-Click to use>",
kind: Consumable(
kind: Velorite,
kind: "Velorite",
effect: Xp(20),
),
)

View File

@ -2,7 +2,7 @@ Item(
name: "Velorite Fragment",
description: "Increases Exp by 10\n\nSmall runes sparkle on its surface\n\n<Right-Click to use>",
kind: Consumable(
kind: VeloriteFrag,
kind: "VeloriteFrag",
effect: Xp(10),
),
)

View File

@ -77,31 +77,31 @@
],
threshold: 0.3,
),
Inventory(Consumed(Potion)): (
Inventory(Consumed("Potion")): (
files: [
"voxygen.audio.sfx.inventory.consumable.liquid",
],
threshold: 0.3,
),
Inventory(Consumed(PotionMinor)): (
Inventory(Consumed("PotionMinor")): (
files: [
"voxygen.audio.sfx.inventory.consumable.liquid",
],
threshold: 0.3,
),
Inventory(Consumed(Apple)): (
Inventory(Consumed("Apple")): (
files: [
"voxygen.audio.sfx.inventory.consumable.apple",
],
threshold: 0.3,
),
Inventory(Consumed(Mushroom)): (
Inventory(Consumed("Mushroom")): (
files: [
"voxygen.audio.sfx.inventory.consumable.food",
],
threshold: 0.3,
),
Inventory(Consumed(Cheese)): (
Inventory(Consumed("Cheese")): (
files: [
"voxygen.audio.sfx.inventory.consumable.food",
],

View File

@ -461,11 +461,11 @@
(2.0, -1.0, 0.0), (-135.0, 90.0, 0.0), 1.1,
),
Tool(Hammer("CobaltHammer0")): VoxTrans(
"voxel.weapon.hammer.2hhammer_Cobalt-0",
"voxel.weapon.hammer.2hhammer_cobalt-0",
(2.0, -1.0, 0.0), (-135.0, 90.0, 0.0), 1.1,
),
Tool(Hammer("CobaltHammer1")): VoxTrans(
"voxel.weapon.hammer.2hhammer_Cobalt-1",
"voxel.weapon.hammer.2hhammer_cobalt-1",
(2.0, -1.0, 0.0), (-135.0, 90.0, 0.0), 1.1,
),
Tool(Hammer("RunicHammer")): VoxTrans(
@ -508,16 +508,16 @@
(0.0, 0.0, 0.0), (-90.0, 90.0, 0.0), 2.4,
),
// Lanterns
Lantern(Black0): Png(
Lantern("Black0"): Png(
"element.icons.lantern_black-0",
),
Lantern(Green0): Png(
Lantern("Green0"): Png(
"element.icons.lantern_green-0",
),
Lantern(Blue0): Png(
Lantern("Blue0"): Png(
"element.icons.lantern_blue-0",
),
Lantern(Red0): Png(
Lantern("Red0"): Png(
"element.icons.lantern_red-0",
),
// Farming Equipment
@ -1047,55 +1047,54 @@
(0.0, 0.0, 0.0), (-90.0, 180.0, 0.0), 1.0,
),
// Consumables
Consumable(Apple):
Png(
Consumable("Apple"): Png(
"element.icons.item_apple",
),
Consumable(Coconut): Png(
Consumable("Coconut"): Png(
"element.icons.item_coconut",
),
Consumable(PotionMed): VoxTrans(
Consumable("PotionMed"): VoxTrans(
"voxel.object.potion_red",
(0.0, 0.0, 0.0), (-50.0, 30.0, 20.0), 0.7,
),
Consumable(PotionMinor): VoxTrans(
Consumable("PotionMinor"): VoxTrans(
"voxel.object.potion_red",
(0.0, 0.0, 0.0), (-50.0, 30.0, 20.0), 0.5,
),
Consumable(PotionLarge): VoxTrans(
Consumable("PotionLarge"): VoxTrans(
"voxel.object.potion_red",
(0.0, 0.0, 0.0), (-50.0, 30.0, 20.0), 0.9,
),
Consumable(PotionExp): VoxTrans(
Consumable("PotionExp"): VoxTrans(
"voxel.object.potion_turq",
(0.0, 0.0, 0.0), (-50.0, 30.0, 20.0), 0.8,
),
Consumable(Cheese): Png(
Consumable("Cheese"): Png(
"element.icons.item_cheese",
),
Consumable(Potion): VoxTrans(
Consumable("Potion"): VoxTrans(
"voxel.object.potion_red",
(0.0, 0.0, 0.0), (-50.0, 30.0, 20.0), 1.0,
),
Consumable(Mushroom): VoxTrans(
Consumable("Mushroom"): VoxTrans(
"voxel.sprite.mushrooms.mushroom-10",
(0.0, 0.0, 0.0), (-50.0, 70.0, 40.0), 1.0,
),
Consumable(Velorite): VoxTrans(
Consumable("Velorite"): VoxTrans(
"voxel.sprite.velorite.velorite_ore",
(0.0, -1.0, 0.0), (-50.0, 40.0, 20.0), 0.8,
),
Consumable(VeloriteFrag): VoxTrans(
Consumable("VeloriteFrag"): VoxTrans(
"voxel.sprite.velorite.velorite_1",
(0.0, 0.0, 0.0), (-50.0, 40.0, 20.0), 0.8,
),
Consumable(AppleShroomCurry): Png(
Consumable("AppleShroomCurry"): Png(
"element.icons.item_apple_curry",
),
Consumable(AppleStick): Png(
Consumable("AppleStick"): Png(
"element.icons.item_apple_stick",
),
Consumable(MushroomStick): Png(
Consumable("MushroomStick"): Png(
"element.icons.item_shroom_stick",
),
@ -1109,36 +1108,36 @@
(0.0, -1.0, 0.0), (-50.0, 40.0, 20.0), 0.8,
),
// Ingredients
Ingredient(CraftsmanHammer): VoxTrans( //TODO This should be a 1h hammer!
Ingredient("CraftsmanHammer"): VoxTrans( //TODO This should be a 1h hammer!
"voxel.weapon.hammer.craftsman",
(1.0, 1.0, 0.0), (-135.0, 90.0, 0.0), 1.0,
),
Ingredient(Flower): VoxTrans(
Ingredient("Flower"): VoxTrans(
"voxel.sprite.flowers.flower_red_2",
(0.0, -1.0, 0.0), (-50.0, 40.0, 20.0), 0.8,
),
Ingredient(Grass): VoxTrans(
Ingredient("Grass"): VoxTrans(
"voxel.sprite.grass.grass_long_5",
(0.0, 0.0, 0.0), (-90.0, 50.0, 0.0), 1.0,
),
Ingredient(Stones): VoxTrans(
Ingredient("Stones"): VoxTrans(
"voxel.sprite.rocks.rock-0",
(0.0, 0.0, 0.0), (-50.0, 40.0, 20.0), 0.8,
),
Ingredient(Twigs): VoxTrans(
Ingredient("Twigs"): VoxTrans(
"voxel.sprite.twigs.twigs-0",
(0.0, 0.0, 0.0), (-20.0, 10.0, 20.0), 0.9,
),
Ingredient(LeatherScraps): Png(
Ingredient("LeatherScraps"): Png(
"element.icons.item_leather0",
),
Ingredient(ShinyGem): Png(
Ingredient("ShinyGem"): Png(
"element.icons.gem",
),
Ingredient(MortarPestle): Png(
Ingredient("MortarPestle"): Png(
"element.icons.item_mortarpestlecoco",
),
Ingredient(EmptyVial): VoxTrans(
Ingredient("EmptyVial"): VoxTrans(
"voxel.object.potion_empty",
(0.0, 0.0, 0.0), (-50.0, 30.0, 20.0), 0.8,
),

View File

@ -4,19 +4,19 @@
color: None
),
map: {
Green0: (
"Green0": (
vox_spec: ("armor.lantern.green-0", (-2.0, -2.0, -7.0)),
color: None
),
Black0: (
"Black0": (
vox_spec: ("armor.lantern.black-0", (-2.0, -2.0, -7.0)),
color: None
),
Red0: (
"Red0": (
vox_spec: ("armor.lantern.red-0", (-2.0, -2.0, -7.0)),
color: None
),
Blue0: (
"Blue0": (
vox_spec: ("armor.lantern.blue-0", (-2.0, -2.0, -7.0)),
color: None
),

View File

@ -16,24 +16,6 @@ use specs_idvs::IdvStorage;
use std::{fs::File, io::BufReader};
use vek::Rgb;
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum Consumable {
Coconut,
Apple,
Cheese,
Potion,
Mushroom,
Velorite,
VeloriteFrag,
PotionMinor,
PotionMed,
PotionLarge,
PotionExp,
AppleShroomCurry,
AppleStick,
MushroomStick,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum Throwable {
Bomb,
@ -45,43 +27,14 @@ pub enum Utility {
Collar,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum Ingredient {
Flower,
Grass,
EmptyVial,
LeatherScraps,
ShinyGem,
Stones,
Twigs,
MortarPestle,
CraftsmanHammer,
}
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[repr(u32)]
pub enum LanternKind {
Black0 = 1,
Green0 = 2,
Red0 = 3,
Blue0 = 4,
}
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct Lantern {
pub kind: LanternKind,
pub kind: String,
color: Rgb<u32>,
strength_thousandths: u32,
flicker_thousandths: u32,
}
pub const ALL_LANTERNS: [LanternKind; 4] = [
LanternKind::Black0,
LanternKind::Green0,
LanternKind::Red0,
LanternKind::Blue0,
];
impl Lantern {
pub fn strength(&self) -> f32 { self.strength_thousandths as f32 / 1000_f32 }
@ -97,7 +50,7 @@ pub enum ItemKind {
Lantern(Lantern),
Armor(armor::Armor),
Consumable {
kind: Consumable,
kind: String,
effect: Effect,
#[serde(default = "default_amount")]
amount: u32,
@ -113,7 +66,7 @@ pub enum ItemKind {
amount: u32,
},
Ingredient {
kind: Ingredient,
kind: String,
#[serde(default = "default_amount")]
amount: u32,
},

View File

@ -2,7 +2,7 @@ pub mod item;
pub mod slot;
use crate::{assets, recipe::Recipe};
use item::{Consumable, Item, ItemKind};
use item::{Item, ItemKind};
use serde::{Deserialize, Serialize};
use specs::{Component, FlaggedStorage, HashMapStorage};
use specs_idvs::IdvStorage;
@ -38,7 +38,7 @@ impl Inventory {
/// Adds a new item to the first fitting group of the inventory or starts a
/// new group. Returns the item again if no space was found.
pub fn push(&mut self, item: Item) -> Option<Item> {
let item = match item.kind {
let item = match &item.kind {
ItemKind::Tool(_) | ItemKind::Armor { .. } | ItemKind::Lantern(_) => {
self.add_to_first_empty(item)
},
@ -61,7 +61,7 @@ impl Inventory {
..
}) = slot
{
if item_kind == *kind {
if *item_kind == *kind {
*amount += new_amount;
self.recount_items();
return None;
@ -92,7 +92,7 @@ impl Inventory {
..
}) = slot
{
if item_kind == *kind {
if *item_kind == *kind {
*amount += new_amount;
self.recount_items();
return None;
@ -123,7 +123,7 @@ impl Inventory {
..
}) = slot
{
if item_kind == *kind {
if *item_kind == *kind {
*amount += new_amount;
self.recount_items();
return None;
@ -153,7 +153,7 @@ impl Inventory {
..
}) = slot
{
if item_kind == *kind {
if *item_kind == *kind {
*amount += new_amount;
self.recount_items();
return None;
@ -424,7 +424,7 @@ impl Inventory {
} else {
*amount -= 1;
return_item.kind = ItemKind::Consumable {
kind: *kind,
kind: kind.clone(),
effect: *effect,
amount: 1,
};
@ -451,7 +451,7 @@ impl Inventory {
} else {
*amount -= 1;
return_item.kind = ItemKind::Ingredient {
kind: *kind,
kind: kind.clone(),
amount: 1,
};
self.recount_items();
@ -531,7 +531,7 @@ impl Component for Inventory {
pub enum InventoryUpdateEvent {
Init,
Used,
Consumed(Consumable),
Consumed(String),
Gave,
Given,
Swapped,

View File

@ -24,12 +24,12 @@ pub fn handle_lantern(server: &mut Server, entity: EcsEntity) {
.write_storage::<comp::LightEmitter>()
.remove(entity);
} else {
let lantern_opt = ecs
.read_storage::<comp::Loadout>()
let loadout_storage = ecs.read_storage::<comp::Loadout>();
let lantern_opt = loadout_storage
.get(entity)
.and_then(|loadout| loadout.lantern.as_ref())
.and_then(|item| {
if let comp::item::ItemKind::Lantern(l) = item.kind {
if let comp::item::ItemKind::Lantern(l) = &item.kind {
Some(l)
} else {
None

View File

@ -157,7 +157,7 @@ pub fn handle_inventory(server: &mut Server, entity: EcsEntity, manip: comp::Inv
match &item.kind {
ItemKind::Consumable { kind, effect, .. } => {
maybe_effect = Some(*effect);
Some(comp::InventoryUpdateEvent::Consumed(*kind))
Some(comp::InventoryUpdateEvent::Consumed(kind.clone()))
},
ItemKind::Throwable { kind, .. } => {
if let Some(pos) =

View File

@ -88,7 +88,7 @@ use crate::audio::AudioFrontend;
use common::{
assets,
comp::{
item::{Consumable, ItemKind, ToolCategory},
item::{ItemKind, ToolCategory},
CharacterAbilityType, InventoryUpdateEvent, Ori, Pos,
},
event::EventBus,
@ -153,7 +153,7 @@ pub enum SfxInventoryEvent {
Collected,
CollectedTool(ToolCategory),
CollectFailed,
Consumed(Consumable),
Consumed(String),
Debug,
Dropped,
Given,
@ -177,7 +177,7 @@ impl From<&InventoryUpdateEvent> for SfxEvent {
SfxEvent::Inventory(SfxInventoryEvent::CollectFailed)
},
InventoryUpdateEvent::Consumed(consumable) => {
SfxEvent::Inventory(SfxInventoryEvent::Consumed(*consumable))
SfxEvent::Inventory(SfxInventoryEvent::Consumed(consumable.clone()))
},
InventoryUpdateEvent::Debug => SfxEvent::Inventory(SfxInventoryEvent::Debug),
InventoryUpdateEvent::Dropped => SfxEvent::Inventory(SfxInventoryEvent::Dropped),

View File

@ -77,8 +77,8 @@ impl State {
.filter(|kind| {
use common::comp::item::{tool::ToolKind, ItemKind};
if let ItemKind::Tool(kind) = kind {
if let ToolKind::Staff(_) = &kind.kind {
true
if let ToolKind::Staff(kind) = &kind.kind {
kind != "Sceptre"
} else if let ToolKind::Debug(kind) = &kind.kind {
kind == "Boost"
} else {

View File

@ -4,7 +4,7 @@ use common::{
comp::item::{
armor::{Armor, ArmorKind},
tool::{Tool, ToolKind},
Consumable, Ingredient, Item, ItemKind, Lantern, LanternKind, Throwable, Utility,
Item, ItemKind, Lantern, Throwable, Utility,
},
figure::Segment,
};
@ -20,24 +20,24 @@ use vek::*;
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum ItemKey {
Tool(ToolKind),
Lantern(LanternKind),
Lantern(String),
Armor(ArmorKind),
Utility(Utility),
Consumable(Consumable),
Consumable(String),
Throwable(Throwable),
Ingredient(Ingredient),
Ingredient(String),
Empty,
}
impl From<&Item> for ItemKey {
fn from(item: &Item) -> Self {
match &item.kind {
ItemKind::Tool(Tool { kind, .. }) => ItemKey::Tool(kind.clone()),
ItemKind::Lantern(Lantern { kind, .. }) => ItemKey::Lantern(*kind),
ItemKind::Lantern(Lantern { kind, .. }) => ItemKey::Lantern(kind.clone()),
ItemKind::Armor(Armor { kind, .. }) => ItemKey::Armor(kind.clone()),
ItemKind::Utility { kind, .. } => ItemKey::Utility(*kind),
ItemKind::Consumable { kind, .. } => ItemKey::Consumable(*kind),
ItemKind::Consumable { kind, .. } => ItemKey::Consumable(kind.clone()),
ItemKind::Throwable { kind, .. } => ItemKey::Throwable(*kind),
ItemKind::Ingredient { kind, .. } => ItemKey::Ingredient(*kind),
ItemKind::Ingredient { kind, .. } => ItemKey::Ingredient(kind.clone()),
}
}
}

View File

@ -8,7 +8,7 @@ use anim::Skeleton;
use common::{
assets::watch::ReloadIndicator,
comp::{
item::{armor::ArmorKind, tool::ToolKind, ItemKind, LanternKind},
item::{armor::ArmorKind, tool::ToolKind, ItemKind},
Body, CharacterState, Loadout,
},
figure::Segment,
@ -37,7 +37,7 @@ struct CharacterCacheKey {
chest: Option<ArmorKind>,
belt: Option<ArmorKind>,
back: Option<ArmorKind>,
lantern: Option<LanternKind>,
lantern: Option<String>,
hand: Option<ArmorKind>,
pants: Option<ArmorKind>,
foot: Option<ArmorKind>,
@ -86,7 +86,7 @@ impl CharacterCacheKey {
lantern: if let Some(ItemKind::Lantern(lantern)) =
loadout.lantern.as_ref().map(|i| &i.kind)
{
Some(lantern.kind)
Some(lantern.kind.clone())
} else {
None
},

View File

@ -13,7 +13,7 @@ use common::{
item::{
armor::{Armor, ArmorKind},
tool::{Tool, ToolKind},
ItemKind, Lantern, LanternKind,
ItemKind, Lantern,
},
object,
quadruped_low::{BodyType as QLBodyType, Species as QLSpecies},
@ -268,7 +268,7 @@ pub struct HumArmorFootSpec(ArmorVoxSpecMap<String, ArmorVoxSpec>);
#[derive(Serialize, Deserialize)]
pub struct HumMainWeaponSpec(HashMap<ToolKind, ArmorVoxSpec>);
#[derive(Serialize, Deserialize)]
pub struct HumArmorLanternSpec(ArmorVoxSpecMap<LanternKind, ArmorVoxSpec>);
pub struct HumArmorLanternSpec(ArmorVoxSpecMap<String, ArmorVoxSpec>);
#[derive(Serialize, Deserialize)]
pub struct HumArmorHeadSpec(ArmorVoxSpecMap<String, ArmorVoxSpec>);
#[derive(Serialize, Deserialize)]
@ -841,7 +841,7 @@ impl HumArmorLanternSpec {
let spec = if let Some(ItemKind::Lantern(Lantern { kind, .. })) =
loadout.lantern.as_ref().map(|i| &i.kind)
{
match self.0.map.get(&kind) {
match self.0.map.get(kind) {
Some(spec) => spec,
None => {
error!(?kind, "No lantern specification exists");