Destringified consumables

This commit is contained in:
Sam 2021-06-23 23:26:09 -05:00
parent aaf5f89076
commit 1978b590aa
42 changed files with 85 additions and 80 deletions

View File

@ -2,7 +2,7 @@ ItemDef(
name: "Potent Potion",
description: "A potent healing potion.",
kind: Consumable(
kind: "Potion",
kind: Potion,
effect: [
Buff((
kind: Potion,

View File

@ -2,7 +2,7 @@ ItemDef(
name: "Large Potion",
description: "",
kind: Consumable(
kind: "PotionLarge",
kind: Potion,
effect: [
Buff((
kind: Potion,

View File

@ -2,7 +2,7 @@ ItemDef(
name: "Medium Potion",
description: "",
kind: Consumable(
kind: "PotionMed",
kind: Potion,
effect: [
Buff((
kind: Potion,

View File

@ -2,7 +2,7 @@ ItemDef(
name: "Minor Potion",
description: "",
kind: Consumable(
kind: "PotionMinor",
kind: Potion,
effect: [
Buff((
kind: Potion,

View File

@ -2,7 +2,7 @@ ItemDef(
name: "Apple",
description: "Red and juicy",
kind: Consumable(
kind: "Apple",
kind: Food,
effect: [
Buff((
kind: Saturation,

View File

@ -2,7 +2,7 @@ ItemDef(
name: "Mushroom Curry",
description: "Who could say no to that?",
kind: Consumable(
kind: "AppleShroomCurry",
kind: Food,
effect: [
Buff((
kind: Saturation,

View File

@ -2,7 +2,7 @@ ItemDef(
name: "Apple Stick",
description: "The stick makes it easier to carry!",
kind: Consumable(
kind: "AppleStick",
kind: Food,
effect: [
Buff((
kind: Saturation,

View File

@ -2,7 +2,7 @@ ItemDef(
name: "Cactus Colada",
description: "Giving you that special prickle.",
kind: Consumable(
kind: "CactusColada",
kind: Food,
effect: [
Buff((
kind: Saturation,

View File

@ -2,7 +2,7 @@ ItemDef(
name: "Carrot",
description: "An orange root vegetable. They say it'll improve your vision!",
kind: Consumable(
kind: "Carrot",
kind: Food,
effect: [
Buff((
kind: Saturation,

View File

@ -2,7 +2,7 @@ ItemDef(
name: "Dwarven Cheese",
description: "Aromatic and nutritious",
kind: Consumable(
kind: "Cheese",
kind: Food,
effect: [
Buff((
kind: Saturation,

View File

@ -2,7 +2,7 @@ ItemDef(
name: "Coconut",
description: "Reliable source of water and fat.\n\nNaturally growing at the top of palm trees.",
kind: Consumable(
kind: "Coconut",
kind: Food,
effect: [
Buff((
kind: Saturation,

View File

@ -2,7 +2,7 @@ ItemDef(
name: "Coltsfoot",
description: "A daisy-like flower often used in herbal teas.",
kind: Consumable(
kind: "Coltsfoot",
kind: Food,
effect: [
Buff((
kind: Saturation,

View File

@ -2,7 +2,7 @@ ItemDef(
name: "Dandelion",
description: "A small, yellow flower. Uses the wind to spread its seeds.",
kind: Consumable(
kind: "Dandelion",
kind: Food,
effect: [
Buff((
kind: Saturation,

View File

@ -2,7 +2,7 @@ ItemDef(
name: "Garlic",
description: "Make sure to brush your teeth after eating.",
kind: Consumable(
kind: "Garlic",
kind: Food,
effect: [
Buff((
kind: Saturation,

View File

@ -2,7 +2,7 @@ ItemDef(
name: "Lettuce",
description: "A vibrant green leafy vegetable. Lettuce make some salads!",
kind: Consumable(
kind: "Lettuce",
kind: Food,
effect: [
Buff((
kind: Saturation,

View File

@ -2,7 +2,7 @@ ItemDef(
name: "Meat",
description: "Meat. The lifeblood of mankind.",
kind: Consumable(
kind: "Meat",
kind: Food,
effect: [
Buff((
kind: Saturation,

View File

@ -2,7 +2,7 @@ ItemDef(
name: "Cooked Meat Slab",
description: "Medium Rare.",
kind: Consumable(
kind: "BeastLargeCooked",
kind: Food,
effect: [
Buff((
kind: Saturation,

View File

@ -2,7 +2,7 @@ ItemDef(
name: "Raw Meat Slab",
description: "Chunk of beastly animal meat, best after cooking.",
kind: Consumable(
kind: "BeastLargeRaw",
kind: Food,
effect: [
Buff((
kind: Saturation,

View File

@ -2,7 +2,7 @@ ItemDef(
name: "Cooked Meat Sliver",
description: "Medium Rare.",
kind: Consumable(
kind: "BeastSmallCooked",
kind: Food,
effect: [
Buff((
kind: Saturation,

View File

@ -2,7 +2,7 @@ ItemDef(
name: "Raw Meat Sliver",
description: "Small hunk of beastly animal meat, best after cooking.",
kind: Consumable(
kind: "BeastSmallRaw",
kind: Food,
effect: [
Buff((
kind: Saturation,

View File

@ -2,7 +2,7 @@ ItemDef(
name: "Cooked Bird Meat",
description: "Best enjoyed with one in each hand.",
kind: Consumable(
kind: "BirdCooked",
kind: Food,
effect: [
Buff((
kind: Saturation,

View File

@ -2,7 +2,7 @@ ItemDef(
name: "Huge Cooked Drumstick",
description: "Makes for a legendary meal.",
kind: Consumable(
kind: "BirdLargeCooked",
kind: Food,
effect: [
Buff((
kind: Saturation,

View File

@ -2,7 +2,7 @@ ItemDef(
name: "Huge Raw Drumstick",
description: "It's magificent.",
kind: Consumable(
kind: "BirdLargeRaw",
kind: Food,
effect: [
Buff((
kind: Saturation,

View File

@ -2,7 +2,7 @@ ItemDef(
name: "Raw Bird Meat",
description: "A hefty drumstick.",
kind: Consumable(
kind: "BirdRaw",
kind: Food,
effect: [
Buff((
kind: Saturation,

View File

@ -2,7 +2,7 @@ ItemDef(
name: "Cooked Fish",
description: "A fresh cooked seafood steak.",
kind: Consumable(
kind: "FishCooked",
kind: Food,
effect: [
Buff((
kind: Saturation,

View File

@ -2,7 +2,7 @@ ItemDef(
name: "Raw Fish",
description: "A steak chopped from a fish, best after cooking.",
kind: Consumable(
kind: "FishRaw",
kind: Food,
effect: [
Buff((
kind: Saturation,

View File

@ -2,7 +2,7 @@ ItemDef(
name: "Cooked Tough Meat",
description: "Tastes exotic.",
kind: Consumable(
kind: "ToughCooked",
kind: Food,
effect: [
Buff((
kind: Saturation,

View File

@ -2,7 +2,7 @@ ItemDef(
name: "Raw Tough Meat",
description: "Peculiar bit of meat, best after cooking.",
kind: Consumable(
kind: "ToughRaw",
kind: Food,
effect: [
Buff((
kind: Saturation,

View File

@ -2,7 +2,7 @@ ItemDef(
name: "Mushroom",
description: "Hopefully this one is not poisonous",
kind: Consumable(
kind: "Mushroom",
kind: Food,
effect: [
Buff((
kind: Saturation,

View File

@ -2,7 +2,7 @@ ItemDef(
name: "Mushroom Stick",
description: "Roasted mushrooms on a stick for easy carrying",
kind: Consumable(
kind: "MushroomStick",
kind: Food,
effect: [
Buff((
kind: Saturation,

View File

@ -2,7 +2,7 @@ ItemDef(
name: "Onion",
description: "A vegetable that's made the toughest men cry.",
kind: Consumable(
kind: "Onion",
kind: Food,
effect: [
Buff((
kind: Saturation,

View File

@ -2,7 +2,7 @@ ItemDef(
name: "Plain Salad",
description: "Literally just chopped lettuce. Does this even count as a salad?",
kind: Consumable(
kind: "PlainSalad",
kind: Food,
effect: [
Buff((
kind: Saturation,

View File

@ -2,7 +2,7 @@ ItemDef(
name: "Sage",
description: "A herb commonly used in tea.",
kind: Consumable(
kind: "Sage",
kind: Food,
effect: [
Buff((
kind: Saturation,

View File

@ -2,7 +2,7 @@ ItemDef(
name: "Sunflower Ice Tea",
description: "Brewed from freshly shelled sunflower seeds",
kind: Consumable(
kind: "SunflowerTea",
kind: Food,
effect: [
Buff((
kind: Saturation,

View File

@ -2,7 +2,7 @@ ItemDef(
name: "Tomato",
description: "A red fruit. Not actually a vegetable.",
kind: Consumable(
kind: "Tomato",
kind: Food,
effect: [
Buff((
kind: Saturation,

View File

@ -2,7 +2,7 @@ ItemDef(
name: "Tomato Salad",
description: "Leafy salad with some chopped, juicy tomatoes mixed in.",
kind: Consumable(
kind: "TomatoSalad",
kind: Food,
effect: [
Buff((
kind: Saturation,

View File

@ -2235,40 +2235,36 @@
"element.items.item_bag_blue",
),
// Consumables
Consumable("Apple"): Png(
Consumable("common.items.food.apple"): Png(
"element.items.item_apple",
),
Consumable("Coconut"): Png(
Consumable("common.items.food.coconut"): Png(
"element.items.item_coconut",
),
Consumable("CactusColada"): VoxTrans(
Consumable("common.items.food.cactus_colada"): VoxTrans(
"voxel.object.cactus_drink",
(-1.0, 1.0, 0.0), (-50.0, 30.0, 20.0), 0.8,
),
Consumable("PotionMed"): VoxTrans(
Consumable("common.items.consumable.potion_med"): VoxTrans(
"voxel.object.potion_red",
(0.0, 0.0, 0.0), (-50.0, 30.0, 20.0), 0.7,
),
Consumable("PotionMinor"): VoxTrans(
Consumable("common.items.consumable.potion_minor"): VoxTrans(
"voxel.object.potion_red",
(0.0, 0.0, 0.0), (-50.0, 30.0, 20.0), 0.5,
),
Consumable("PotionLarge"): VoxTrans(
Consumable("common.items.consumable.potion_big"): VoxTrans(
"voxel.object.potion_red",
(0.0, 0.0, 0.0), (-50.0, 30.0, 20.0), 0.9,
),
Ingredient("PotionExp"): VoxTrans(
"voxel.object.potion_turq",
(0.0, 0.0, 0.0), (-50.0, 30.0, 20.0), 0.8,
Consumable("common.items.boss_drops.potions"): VoxTrans(
"voxel.object.potion_red",
(0.0, 0.0, 0.0), (-50.0, 30.0, 20.0), 0.9,
),
Consumable("Cheese"): Png(
Consumable("common.items.food.cheese"): Png(
"element.items.item_cheese",
),
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("common.items.food.mushroom"): VoxTrans(
"voxel.sprite.mushrooms.mushroom-10",
(0.0, 0.0, 0.0), (-50.0, 70.0, 40.0), 1.0,
),
@ -2280,83 +2276,83 @@
"voxel.sprite.velorite.velorite_1",
(0.0, 0.0, 0.0), (-50.0, 40.0, 20.0), 0.8,
),
Consumable("AppleShroomCurry"): Png(
Consumable("common.items.food.apple_mushroom_curry"): Png(
"element.items.item_apple_curry",
),
Consumable("AppleStick"): Png(
Consumable("common.items.food.apple_stick"): Png(
"element.items.item_apple_stick",
),
Consumable("MushroomStick"): Png(
Consumable("common.items.food.mushroom_stick"): Png(
"element.items.item_shroom_stick",
),
Consumable("SunflowerTea"): Png(
Consumable("common.items.food.sunflower_icetea"): Png(
"element.items.item_sunflower_tea",
),
Consumable("Carrot"): VoxTrans(
Consumable("common.items.food.carrot"): VoxTrans(
"voxel.sprite.carrot.carrot",
(0.0, 0.0, 0.0), (-20.0, 10.0, 20.0), 0.9,
),
Consumable("Tomato"): VoxTrans(
Consumable("common.items.food.tomato"): VoxTrans(
"voxel.sprite.tomato.tomato",
(0.0, 0.0, 0.0), (-50.0, 30.0, 20.0), 0.8,
),
Consumable("Lettuce"): VoxTrans(
Consumable("common.items.food.lettuce"): VoxTrans(
"voxel.sprite.cabbage.cabbage",
(0.0, 0.0, 0.0), (-50.0, 30.0, 20.0), 0.8,
),
Consumable("FishRaw"): VoxTrans(
Consumable("common.items.food.meat.fish_raw"): VoxTrans(
"voxel.sprite.food.meat.fish_raw",
(0.0, 0.0, 0.0), (-20.0, 10.0, 20.0), 0.9,
),
Consumable("FishCooked"): VoxTrans(
Consumable("common.items.food.meat.fish_cooked"): VoxTrans(
"voxel.sprite.food.meat.fish_cooked",
(0.0, 0.0, 0.0), (-20.0, 10.0, 20.0), 0.9,
),
Consumable("BirdRaw"): VoxTrans(
Consumable("common.items.food.meat.bird_raw"): VoxTrans(
"voxel.sprite.food.meat.bird_raw",
(0.0, 0.0, 0.0), (-20.0, 10.0, 20.0), 0.9,
),
Consumable("BirdCooked"): VoxTrans(
Consumable("common.items.food.meat.bird_cooked"): VoxTrans(
"voxel.sprite.food.meat.bird_cooked",
(0.0, 0.0, 0.0), (-20.0, 10.0, 20.0), 0.9,
),
Consumable("BirdLargeRaw"): VoxTrans(
Consumable("common.items.food.meat.bird_large_raw"): VoxTrans(
"voxel.sprite.food.meat.bird_large_raw",
(0.0, 0.0, 0.0), (-20.0, 10.0, 20.0), 0.9,
),
Consumable("BirdLargeCooked"): VoxTrans(
Consumable("common.items.food.meat.bird_large_cooked"): VoxTrans(
"voxel.sprite.food.meat.bird_large_cooked",
(0.0, 0.0, 0.0), (-20.0, 10.0, 20.0), 0.9,
),
Consumable("BeastSmallRaw"): VoxTrans(
Consumable("common.items.food.meat.beast_small_raw"): VoxTrans(
"voxel.sprite.food.meat.beast_small_raw",
(0.0, 0.0, 0.0), (-50.0, 10.0, 0.0), 1.0,
),
Consumable("BeastSmallCooked"): VoxTrans(
Consumable("common.items.food.meat.beast_small_cooked"): VoxTrans(
"voxel.sprite.food.meat.beast_small_cooked",
(0.0, 0.0, 0.0), (-50.0, 20.0, 0.0), 1.0,
),
Consumable("ToughRaw"): VoxTrans(
Consumable("common.items.food.meat.tough_raw"): VoxTrans(
"voxel.sprite.food.meat.tough_raw",
(0.0, 0.0, 0.0), (-50.0, 10.0, 0.0), 1.0,
),
Consumable("ToughCooked"): VoxTrans(
Consumable("common.items.food.meat.tough_cooked"): VoxTrans(
"voxel.sprite.food.meat.tough_cooked",
(0.0, 0.0, 0.0), (-50.0, 20.0, 0.0), 1.0,
),
Consumable("BeastLargeRaw"): VoxTrans(
Consumable("common.items.food.meat.beast_large_raw"): VoxTrans(
"voxel.sprite.food.meat.beast_large_raw",
(-1.0, 0.0, 0.0), (-80.0, 40.0, 0.0), 0.8,
),
Consumable("BeastLargeCooked"): VoxTrans(
Consumable("common.items.food.meat.beast_large_cooked"): VoxTrans(
"voxel.sprite.food.meat.beast_large_cooked",
(-1.0, 0.0, 0.0), (-80.0, 40.0, 0.0), 0.8,
),
Consumable("PlainSalad"): VoxTrans(
Consumable("common.items.food.plainsalad"): VoxTrans(
"voxel.sprite.food.salad_plain",
(0.0, 0.0, 0.0), (-50.0, 30.0, 20.0), 0.8,
),
Consumable("TomatoSalad"): VoxTrans(
Consumable("common.items.food.tomatosalad"): VoxTrans(
"voxel.sprite.food.salad_tomato",
(0.0, 0.0, 0.0), (-50.0, 30.0, 20.0), 0.8,
),

View File

@ -251,7 +251,7 @@ pub enum ItemKind {
Armor(armor::Armor),
Glider(Glider),
Consumable {
kind: String,
kind: ConsumableKind,
effect: Vec<Effect>,
},
Throwable {
@ -270,6 +270,12 @@ pub enum ItemKind {
},
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum ConsumableKind {
Potion,
Food,
}
impl ItemKind {
pub fn is_equippable(&self) -> bool {
matches!(

View File

@ -9,7 +9,10 @@ use vek::Vec3;
use crate::{
comp::{
inventory::{
item::{tool::AbilityMap, ItemDef, ItemKind, MaterialStatManifest, TagExampleInfo},
item::{
tool::AbilityMap, ConsumableKind, ItemDef, ItemKind, MaterialStatManifest,
TagExampleInfo,
},
loadout::Loadout,
slot::{EquipSlot, Slot, SlotError},
},
@ -803,7 +806,7 @@ impl Component for Inventory {
pub enum InventoryUpdateEvent {
Init,
Used,
Consumed(String),
Consumed(ConsumableKind),
Gave,
Given,
Swapped,

View File

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

View File

@ -92,7 +92,7 @@ use common::{
assets::{self, AssetExt, AssetHandle},
comp::{
beam, biped_large, biped_small, humanoid,
item::{ItemKind, ToolKind},
item::{ConsumableKind, ItemKind, ToolKind},
object,
poise::PoiseState,
quadruped_low, quadruped_medium, quadruped_small, Body, CharacterAbilityType,
@ -276,7 +276,7 @@ pub enum SfxInventoryEvent {
CollectedTool(ToolKind),
CollectedItem(String),
CollectFailed,
Consumed(String),
Consumed(ConsumableKind),
Debug,
Dropped,
Given,
@ -308,7 +308,7 @@ impl From<&InventoryUpdateEvent> for SfxEvent {
SfxEvent::Inventory(SfxInventoryEvent::CollectFailed)
},
InventoryUpdateEvent::Consumed(consumable) => {
SfxEvent::Inventory(SfxInventoryEvent::Consumed(consumable.clone()))
SfxEvent::Inventory(SfxInventoryEvent::Consumed(*consumable))
},
InventoryUpdateEvent::Debug => SfxEvent::Inventory(SfxInventoryEvent::Debug),
InventoryUpdateEvent::Dropped => SfxEvent::Inventory(SfxInventoryEvent::Dropped),

View File

@ -49,7 +49,7 @@ impl<T: ItemDesc> From<&T> for ItemKey {
ItemKind::Glider(Glider { kind, .. }) => ItemKey::Glider(kind.clone()),
ItemKind::Armor(Armor { kind, .. }) => ItemKey::Armor(kind.clone()),
ItemKind::Utility { kind, .. } => ItemKey::Utility(*kind),
ItemKind::Consumable { kind, .. } => ItemKey::Consumable(kind.clone()),
ItemKind::Consumable { .. } => ItemKey::Consumable(item_definition_id.to_owned()),
ItemKind::Throwable { kind, .. } => ItemKey::Throwable(*kind),
ItemKind::Ingredient { kind, .. } => ItemKey::Ingredient(kind.clone()),
ItemKind::TagExamples { item_ids } => ItemKey::TagExamples(