Removed stuff no longer needed after new method of crafting modular weapons.

This commit is contained in:
Sam 2021-11-04 23:01:10 -04:00
parent e9885140c3
commit 33feee787b
63 changed files with 69 additions and 387 deletions

View File

@ -18,9 +18,6 @@ ItemDef(
weapon_name: "Axe", weapon_name: "Axe",
)), )),
quality: Modular, quality: Modular,
tags: [ tags: [],
ModularComponent((toolkind: Axe, modkind: Damage, hands: One)),
ModularComponent((toolkind: Axe, modkind: Damage, hands: Two)),
],
) )

View File

@ -18,8 +18,5 @@ ItemDef(
weapon_name: "Battleaxe", weapon_name: "Battleaxe",
)), )),
quality: Modular, quality: Modular,
tags: [ tags: [],
ModularComponent((toolkind: Axe, modkind: Damage, hands: One)),
ModularComponent((toolkind: Axe, modkind: Damage, hands: Two)),
],
) )

View File

@ -18,7 +18,5 @@ ItemDef(
weapon_name: "Greataxe", weapon_name: "Greataxe",
)), )),
quality: Modular, quality: Modular,
tags: [ tags: [],
ModularComponent((toolkind: Axe, modkind: Damage, hands: Two)),
],
) )

View File

@ -18,9 +18,6 @@ ItemDef(
weapon_name: "Jagged Axe", weapon_name: "Jagged Axe",
)), )),
quality: Modular, quality: Modular,
tags: [ tags: [],
ModularComponent((toolkind: Axe, modkind: Damage, hands: One)),
ModularComponent((toolkind: Axe, modkind: Damage, hands: Two)),
],
) )

View File

@ -18,8 +18,6 @@ ItemDef(
weapon_name: "Great Mace", weapon_name: "Great Mace",
)), )),
quality: Modular, quality: Modular,
tags: [ tags: [],
ModularComponent((toolkind: Hammer, modkind: Damage, hands: Two)),
],
) )

View File

@ -18,8 +18,5 @@ ItemDef(
weapon_name: "Ornate Axe", weapon_name: "Ornate Axe",
)), )),
quality: Modular, quality: Modular,
tags: [ tags: [],
ModularComponent((toolkind: Axe, modkind: Damage, hands: One)),
ModularComponent((toolkind: Axe, modkind: Damage, hands: Two)),
],
) )

View File

@ -18,7 +18,5 @@ ItemDef(
weapon_name: "Poleaxe", weapon_name: "Poleaxe",
)), )),
quality: Modular, quality: Modular,
tags: [ tags: [],
ModularComponent((toolkind: Axe, modkind: Damage, hands: Two)),
],
) )

View File

@ -18,8 +18,6 @@ ItemDef(
weapon_name: "Bow", weapon_name: "Bow",
)), )),
quality: Modular, quality: Modular,
tags: [ tags: [],
ModularComponent((toolkind: Bow, modkind: Damage, hands: Two)),
],
) )

View File

@ -18,8 +18,6 @@ ItemDef(
weapon_name: "Composite Bow", weapon_name: "Composite Bow",
)), )),
quality: Modular, quality: Modular,
tags: [ tags: [],
ModularComponent((toolkind: Bow, modkind: Damage, hands: Two)),
],
) )

View File

@ -18,8 +18,6 @@ ItemDef(
weapon_name: "Greatbow", weapon_name: "Greatbow",
)), )),
quality: Modular, quality: Modular,
tags: [ tags: [],
ModularComponent((toolkind: Bow, modkind: Damage, hands: Two)),
],
) )

View File

@ -18,8 +18,6 @@ ItemDef(
weapon_name: "Longbow", weapon_name: "Longbow",
)), )),
quality: Modular, quality: Modular,
tags: [ tags: [],
ModularComponent((toolkind: Bow, modkind: Damage, hands: Two)),
],
) )

View File

@ -18,8 +18,6 @@ ItemDef(
weapon_name: "Ornate Bow", weapon_name: "Ornate Bow",
)), )),
quality: Modular, quality: Modular,
tags: [ tags: [],
ModularComponent((toolkind: Bow, modkind: Damage, hands: Two)),
],
) )

View File

@ -18,8 +18,6 @@ ItemDef(
weapon_name: "Shortbow", weapon_name: "Shortbow",
)), )),
quality: Modular, quality: Modular,
tags: [ tags: [],
ModularComponent((toolkind: Bow, modkind: Damage, hands: Two)),
],
) )

View File

@ -18,8 +18,6 @@ ItemDef(
weapon_name: "Warbow", weapon_name: "Warbow",
)), )),
quality: Modular, quality: Modular,
tags: [ tags: [],
ModularComponent((toolkind: Bow, modkind: Damage, hands: Two)),
],
) )

View File

@ -18,7 +18,5 @@ ItemDef(
weapon_name: "Greathammer", weapon_name: "Greathammer",
)), )),
quality: Modular, quality: Modular,
tags: [ tags: [],
ModularComponent((toolkind: Hammer, modkind: Damage, hands: Two)),
],
) )

View File

@ -18,8 +18,6 @@ ItemDef(
weapon_name: "Great Mace", weapon_name: "Great Mace",
)), )),
quality: Modular, quality: Modular,
tags: [ tags: [],
ModularComponent((toolkind: Hammer, modkind: Damage, hands: Two)),
],
) )

View File

@ -18,9 +18,6 @@ ItemDef(
weapon_name: "Hammer", weapon_name: "Hammer",
)), )),
quality: Modular, quality: Modular,
tags: [ tags: [],
ModularComponent((toolkind: Hammer, modkind: Damage, hands: One)),
ModularComponent((toolkind: Hammer, modkind: Damage, hands: Two)),
],
) )

View File

@ -18,7 +18,5 @@ ItemDef(
weapon_name: "Maul", weapon_name: "Maul",
)), )),
quality: Modular, quality: Modular,
tags: [ tags: [],
ModularComponent((toolkind: Hammer, modkind: Damage, hands: Two)),
],
) )

View File

@ -18,8 +18,5 @@ ItemDef(
weapon_name: "Ornate Hammer", weapon_name: "Ornate Hammer",
)), )),
quality: Modular, quality: Modular,
tags: [ tags: [],
ModularComponent((toolkind: Hammer, modkind: Damage, hands: One)),
ModularComponent((toolkind: Hammer, modkind: Damage, hands: Two)),
],
) )

View File

@ -18,9 +18,6 @@ ItemDef(
weapon_name: "Spiked Mace", weapon_name: "Spiked Mace",
)), )),
quality: Modular, quality: Modular,
tags: [ tags: [],
ModularComponent((toolkind: Hammer, modkind: Damage, hands: One)),
ModularComponent((toolkind: Hammer, modkind: Damage, hands: Two)),
],
) )

View File

@ -18,9 +18,6 @@ ItemDef(
weapon_name: "Warhammer", weapon_name: "Warhammer",
)), )),
quality: Modular, quality: Modular,
tags: [ tags: [],
ModularComponent((toolkind: Hammer, modkind: Damage, hands: One)),
ModularComponent((toolkind: Hammer, modkind: Damage, hands: Two)),
],
) )

View File

@ -18,8 +18,6 @@ ItemDef(
weapon_name: "", weapon_name: "",
)), )),
quality: Direct(Common), quality: Direct(Common),
tags: [ tags: [],
ModularComponent((toolkind: Sceptre, modkind: Damage, hands: Two)),
],
) )

View File

@ -18,8 +18,6 @@ ItemDef(
weapon_name: "", weapon_name: "",
)), )),
quality: Direct(Common), quality: Direct(Common),
tags: [ tags: [],
ModularComponent((toolkind: Sceptre, modkind: Damage, hands: Two)),
],
) )

View File

@ -18,8 +18,6 @@ ItemDef(
weapon_name: "", weapon_name: "",
)), )),
quality: Direct(Common), quality: Direct(Common),
tags: [ tags: [],
ModularComponent((toolkind: Sceptre, modkind: Damage, hands: Two)),
],
) )

View File

@ -18,8 +18,6 @@ ItemDef(
weapon_name: "", weapon_name: "",
)), )),
quality: Direct(Common), quality: Direct(Common),
tags: [ tags: [],
ModularComponent((toolkind: Staff, modkind: Damage, hands: Two)),
],
) )

View File

@ -18,7 +18,5 @@ ItemDef(
weapon_name: "", weapon_name: "",
)), )),
quality: Direct(Common), quality: Direct(Common),
tags: [ tags: [],
ModularComponent((toolkind: Staff, modkind: Damage, hands: Two)),
],
) )

View File

@ -18,8 +18,6 @@ ItemDef(
weapon_name: "", weapon_name: "",
)), )),
quality: Direct(Common), quality: Direct(Common),
tags: [ tags: [],
ModularComponent((toolkind: Staff, modkind: Damage, hands: Two)),
],
) )

View File

@ -18,8 +18,6 @@ ItemDef(
weapon_name: "Greatsword", weapon_name: "Greatsword",
)), )),
quality: Modular, quality: Modular,
tags: [ tags: [],
ModularComponent((toolkind: Sword, modkind: Damage, hands: Two)),
],
) )

View File

@ -18,9 +18,6 @@ ItemDef(
weapon_name: "Katana", weapon_name: "Katana",
)), )),
quality: Modular, quality: Modular,
tags: [ tags: [],
ModularComponent((toolkind: Sword, modkind: Damage, hands: One)),
ModularComponent((toolkind: Sword, modkind: Damage, hands: Two)),
],
) )

View File

@ -18,9 +18,6 @@ ItemDef(
weapon_name: "Longsword", weapon_name: "Longsword",
)), )),
quality: Modular, quality: Modular,
tags: [ tags: [],
ModularComponent((toolkind: Sword, modkind: Damage, hands: One)),
ModularComponent((toolkind: Sword, modkind: Damage, hands: Two)),
],
) )

View File

@ -18,9 +18,6 @@ ItemDef(
weapon_name: "Ornate Sword", weapon_name: "Ornate Sword",
)), )),
quality: Modular, quality: Modular,
tags: [ tags: [],
ModularComponent((toolkind: Sword, modkind: Damage, hands: One)),
ModularComponent((toolkind: Sword, modkind: Damage, hands: Two)),
],
) )

View File

@ -18,9 +18,6 @@ ItemDef(
weapon_name: "Sabre", weapon_name: "Sabre",
)), )),
quality: Modular, quality: Modular,
tags: [ tags: [],
ModularComponent((toolkind: Sword, modkind: Damage, hands: One)),
ModularComponent((toolkind: Sword, modkind: Damage, hands: Two)),
],
) )

View File

@ -18,9 +18,6 @@ ItemDef(
weapon_name: "Sawblade", weapon_name: "Sawblade",
)), )),
quality: Modular, quality: Modular,
tags: [ tags: [],
ModularComponent((toolkind: Sword, modkind: Damage, hands: One)),
ModularComponent((toolkind: Sword, modkind: Damage, hands: Two)),
],
) )

View File

@ -18,8 +18,6 @@ ItemDef(
weapon_name: "Zweihander", weapon_name: "Zweihander",
)), )),
quality: Modular, quality: Modular,
tags: [ tags: [],
ModularComponent((toolkind: Sword, modkind: Damage, hands: Two)),
],
) )

View File

@ -18,8 +18,6 @@ ItemDef(
weapon_name: "", weapon_name: "",
)), )),
quality: Direct(Common), quality: Direct(Common),
tags: [ tags: [],
ModularComponent((toolkind: Axe, modkind: Held, hands: Two)),
],
) )

View File

@ -18,9 +18,6 @@ ItemDef(
weapon_name: "", weapon_name: "",
)), )),
quality: Direct(Common), quality: Direct(Common),
tags: [ tags: [],
ModularComponent((toolkind: Axe, modkind: Held, hands: One)),
ModularComponent((toolkind: Axe, modkind: Held, hands: Two)),
],
) )

View File

@ -18,8 +18,6 @@ ItemDef(
weapon_name: "", weapon_name: "",
)), )),
quality: Direct(Common), quality: Direct(Common),
tags: [ tags: [],
ModularComponent((toolkind: Axe, modkind: Held, hands: One)),
],
) )

View File

@ -18,8 +18,6 @@ ItemDef(
weapon_name: "", weapon_name: "",
)), )),
quality: Direct(Common), quality: Direct(Common),
tags: [ tags: [],
ModularComponent((toolkind: Bow, modkind: Held, hands: Two)),
],
) )

View File

@ -18,7 +18,5 @@ ItemDef(
weapon_name: "", weapon_name: "",
)), )),
quality: Direct(Common), quality: Direct(Common),
tags: [ tags: [],
ModularComponent((toolkind: Bow, modkind: Held, hands: Two)),
],
) )

View File

@ -18,8 +18,6 @@ ItemDef(
weapon_name: "", weapon_name: "",
)), )),
quality: Direct(Common), quality: Direct(Common),
tags: [ tags: [],
ModularComponent((toolkind: Bow, modkind: Held, hands: Two)),
],
) )

View File

@ -18,8 +18,6 @@ ItemDef(
weapon_name: "", weapon_name: "",
)), )),
quality: Direct(Common), quality: Direct(Common),
tags: [ tags: [],
ModularComponent((toolkind: Hammer, modkind: Held, hands: Two)),
],
) )

View File

@ -18,9 +18,6 @@ ItemDef(
weapon_name: "", weapon_name: "",
)), )),
quality: Direct(Common), quality: Direct(Common),
tags: [ tags: [],
ModularComponent((toolkind: Hammer, modkind: Held, hands: One)),
ModularComponent((toolkind: Hammer, modkind: Held, hands: Two)),
],
) )

View File

@ -18,8 +18,6 @@ ItemDef(
weapon_name: "", weapon_name: "",
)), )),
quality: Direct(Common), quality: Direct(Common),
tags: [ tags: [],
ModularComponent((toolkind: Hammer, modkind: Held, hands: One)),
],
) )

View File

@ -18,8 +18,6 @@ ItemDef(
weapon_name: "Arbor", weapon_name: "Arbor",
)), )),
quality: Modular, quality: Modular,
tags: [ tags: [],
ModularComponent((toolkind: Sceptre, modkind: Held, hands: Two)),
],
) )

View File

@ -18,8 +18,6 @@ ItemDef(
weapon_name: "Cane", weapon_name: "Cane",
)), )),
quality: Modular, quality: Modular,
tags: [ tags: [],
ModularComponent((toolkind: Sceptre, modkind: Held, hands: Two)),
],
) )

View File

@ -18,8 +18,6 @@ ItemDef(
weapon_name: "Crook", weapon_name: "Crook",
)), )),
quality: Modular, quality: Modular,
tags: [ tags: [],
ModularComponent((toolkind: Sceptre, modkind: Held, hands: Two)),
],
) )

View File

@ -18,8 +18,6 @@ ItemDef(
weapon_name: "Crozier", weapon_name: "Crozier",
)), )),
quality: Modular, quality: Modular,
tags: [ tags: [],
ModularComponent((toolkind: Sceptre, modkind: Held, hands: Two)),
],
) )

View File

@ -18,8 +18,6 @@ ItemDef(
weapon_name: "Grandsceptre", weapon_name: "Grandsceptre",
)), )),
quality: Modular, quality: Modular,
tags: [ tags: [],
ModularComponent((toolkind: Sceptre, modkind: Held, hands: Two)),
],
) )

View File

@ -18,8 +18,6 @@ ItemDef(
weapon_name: "Ornate Sceptre", weapon_name: "Ornate Sceptre",
)), )),
quality: Modular, quality: Modular,
tags: [ tags: [],
ModularComponent((toolkind: Sceptre, modkind: Held, hands: Two)),
],
) )

View File

@ -18,8 +18,6 @@ ItemDef(
weapon_name: "Sceptre", weapon_name: "Sceptre",
)), )),
quality: Modular, quality: Modular,
tags: [ tags: [],
ModularComponent((toolkind: Sceptre, modkind: Held, hands: Two)),
],
) )

View File

@ -18,8 +18,6 @@ ItemDef(
weapon_name: "Brand", weapon_name: "Brand",
)), )),
quality: Modular, quality: Modular,
tags: [ tags: [],
ModularComponent((toolkind: Staff, modkind: Held, hands: Two)),
],
) )

View File

@ -18,8 +18,6 @@ ItemDef(
weapon_name: "Grandstaff", weapon_name: "Grandstaff",
)), )),
quality: Modular, quality: Modular,
tags: [ tags: [],
ModularComponent((toolkind: Staff, modkind: Held, hands: Two)),
],
) )

View File

@ -18,7 +18,5 @@ ItemDef(
weapon_name: "Long Pole", weapon_name: "Long Pole",
)), )),
quality: Modular, quality: Modular,
tags: [ tags: [],
ModularComponent((toolkind: Staff, modkind: Held, hands: Two)),
],
) )

View File

@ -18,8 +18,6 @@ ItemDef(
weapon_name: "Ornate Staff", weapon_name: "Ornate Staff",
)), )),
quality: Modular, quality: Modular,
tags: [ tags: [],
ModularComponent((toolkind: Staff, modkind: Held, hands: Two)),
],
) )

View File

@ -18,8 +18,6 @@ ItemDef(
weapon_name: "Pole", weapon_name: "Pole",
)), )),
quality: Modular, quality: Modular,
tags: [ tags: [],
ModularComponent((toolkind: Staff, modkind: Held, hands: Two)),
],
) )

View File

@ -18,8 +18,6 @@ ItemDef(
weapon_name: "Rod", weapon_name: "Rod",
)), )),
quality: Modular, quality: Modular,
tags: [ tags: [],
ModularComponent((toolkind: Staff, modkind: Held, hands: Two)),
],
) )

View File

@ -18,8 +18,6 @@ ItemDef(
weapon_name: "Staff", weapon_name: "Staff",
)), )),
quality: Modular, quality: Modular,
tags: [ tags: [],
ModularComponent((toolkind: Staff, modkind: Held, hands: Two)),
],
) )

View File

@ -18,9 +18,6 @@ ItemDef(
weapon_name: "", weapon_name: "",
)), )),
quality: Direct(Common), quality: Direct(Common),
tags: [ tags: [],
ModularComponent((toolkind: Sword, modkind: Held, hands: One)),
ModularComponent((toolkind: Sword, modkind: Held, hands: Two)),
],
) )

View File

@ -18,8 +18,6 @@ ItemDef(
weapon_name: "", weapon_name: "",
)), )),
quality: Direct(Common), quality: Direct(Common),
tags: [ tags: [],
ModularComponent((toolkind: Sword, modkind: Held, hands: One)),
],
) )

View File

@ -18,8 +18,6 @@ ItemDef(
weapon_name: "", weapon_name: "",
)), )),
quality: Direct(Common), quality: Direct(Common),
tags: [ tags: [],
ModularComponent((toolkind: Sword, modkind: Held, hands: Two)),
],
) )

View File

@ -4,7 +4,7 @@ pub mod modular;
pub mod tool; pub mod tool;
// Reexports // Reexports
pub use modular::{ModularComponent, ModularComponentKind, ModularComponentTag}; pub use modular::{ModularComponent, ModularComponentKind};
pub use tool::{AbilitySet, AbilitySpec, Hands, MaterialStatManifest, Tool, ToolKind}; pub use tool::{AbilitySet, AbilitySpec, Hands, MaterialStatManifest, Tool, ToolKind};
use crate::{ use crate::{
@ -227,7 +227,6 @@ pub enum ItemTag {
Leather, Leather,
Material(Material), Material(Material),
MaterialKind(MaterialKind), MaterialKind(MaterialKind),
ModularComponent(ModularComponentTag),
Cultist, Cultist,
Potion, Potion,
Food, Food,
@ -242,7 +241,6 @@ impl TagExampleInfo for ItemTag {
fn name(&self) -> Cow<'static, str> { fn name(&self) -> Cow<'static, str> {
match self { match self {
ItemTag::Material(material) => material.name(), ItemTag::Material(material) => material.name(),
ItemTag::ModularComponent(kind) => kind.name(),
ItemTag::MaterialKind(material_kind) => Cow::Borrowed(material_kind.into()), ItemTag::MaterialKind(material_kind) => Cow::Borrowed(material_kind.into()),
ItemTag::Leather => Cow::Borrowed("leather"), ItemTag::Leather => Cow::Borrowed("leather"),
ItemTag::Cultist => Cow::Borrowed("cultist"), ItemTag::Cultist => Cow::Borrowed("cultist"),
@ -260,7 +258,6 @@ impl TagExampleInfo for ItemTag {
fn exemplar_identifier(&self) -> Cow<'static, str> { fn exemplar_identifier(&self) -> Cow<'static, str> {
match self { match self {
ItemTag::Material(_) => Cow::Borrowed("common.items.tag_examples.placeholder"), ItemTag::Material(_) => Cow::Borrowed("common.items.tag_examples.placeholder"),
ItemTag::ModularComponent(tag) => tag.exemplar_identifier(),
ItemTag::MaterialKind(_) => Cow::Borrowed("common.items.tag_examples.placeholder"), ItemTag::MaterialKind(_) => Cow::Borrowed("common.items.tag_examples.placeholder"),
ItemTag::Leather => Cow::Borrowed("common.items.tag_examples.leather"), ItemTag::Leather => Cow::Borrowed("common.items.tag_examples.leather"),
ItemTag::Cultist => Cow::Borrowed("common.items.tag_examples.cultist"), ItemTag::Cultist => Cow::Borrowed("common.items.tag_examples.cultist"),

View File

@ -1,12 +1,8 @@
use super::{ use super::{
tool::{self, Hands}, tool::{self, Hands},
Item, ItemDesc, ItemKind, ItemName, ItemTag, RawItemDef, TagExampleInfo, ToolKind, Item, ItemDesc, ItemKind, ItemName, RawItemDef, ToolKind,
};
use crate::{
assets::AssetExt,
lottery::Lottery,
recipe::{self, RawRecipe, RawRecipeBook, RawRecipeInput},
}; };
use crate::{assets::AssetExt, lottery::Lottery, recipe};
use hashbrown::HashMap; use hashbrown::HashMap;
use lazy_static::lazy_static; use lazy_static::lazy_static;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
@ -32,7 +28,7 @@ impl ModularComponentKind {
match tool { match tool {
ToolKind::Sword | ToolKind::Axe | ToolKind::Hammer | ToolKind::Bow => Self::Damage, ToolKind::Sword | ToolKind::Axe | ToolKind::Hammer | ToolKind::Bow => Self::Damage,
ToolKind::Staff | ToolKind::Sceptre => Self::Held, ToolKind::Staff | ToolKind::Sceptre => Self::Held,
_ => unreachable!(), _ => unimplemented!(),
} }
} }
} }
@ -46,70 +42,6 @@ pub struct ModularComponent {
pub weapon_name: String, pub weapon_name: String,
} }
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct ModularComponentTag {
toolkind: ToolKind,
modkind: ModularComponentKind,
hands: Hands,
}
impl TagExampleInfo for ModularComponentTag {
fn name(&self) -> Cow<'static, str> {
Cow::Owned(format!(
"{} {}",
self.hands.identifier_name().to_owned(),
match self.modkind {
ModularComponentKind::Damage => match self.toolkind {
ToolKind::Sword => "sword blade",
ToolKind::Axe => "axe head",
ToolKind::Hammer => "hammer head",
ToolKind::Bow => "bow limbs",
ToolKind::Dagger => "dagger blade",
ToolKind::Staff => "fire staff core",
ToolKind::Sceptre => "nature sceptre core",
// TODO: naming
ToolKind::Spear => "spear damage component",
ToolKind::Blowgun => "blowgun damage component",
ToolKind::Shield => "shield damage component",
ToolKind::Debug => "debug damage component",
ToolKind::Farming => "farming damage component",
ToolKind::Pick => "pickaxe head",
ToolKind::Natural => "natural damage component",
ToolKind::Empty => "empty damage component",
},
ModularComponentKind::Held => match self.toolkind {
ToolKind::Sword => "sword hilt",
ToolKind::Axe => "axe shaft",
ToolKind::Hammer => "hammer shaft",
ToolKind::Bow => "bow grip",
ToolKind::Dagger => "dagger hilt",
ToolKind::Staff => "fire staff grip",
ToolKind::Sceptre => "nature sceptre grip",
// TODO: naming
ToolKind::Spear => "spear held component",
ToolKind::Blowgun => "blowgun held component",
ToolKind::Shield => "shield held component",
ToolKind::Natural => "natural held component",
ToolKind::Debug => "debug held component",
ToolKind::Farming => "farming held component",
ToolKind::Pick => "pickaxe handle",
ToolKind::Empty => "empty held component",
},
}
))
}
fn exemplar_identifier(&self) -> Cow<'static, str> {
Cow::Owned(format!(
"{}.{}.{}.{}",
TAG_EXAMPLES_PREFIX,
self.modkind.identifier_name(),
self.toolkind.identifier_name(),
self.hands.identifier_name()
))
}
}
const SUPPORTED_TOOLKINDS: [ToolKind; 6] = [ const SUPPORTED_TOOLKINDS: [ToolKind; 6] = [
ToolKind::Sword, ToolKind::Sword,
ToolKind::Axe, ToolKind::Axe,
@ -118,13 +50,8 @@ const SUPPORTED_TOOLKINDS: [ToolKind; 6] = [
ToolKind::Staff, ToolKind::Staff,
ToolKind::Sceptre, ToolKind::Sceptre,
]; ];
const MODKINDS: [ModularComponentKind; 2] =
[ModularComponentKind::Damage, ModularComponentKind::Held];
const WEAPON_PREFIX: &str = "common.items.weapons.modular"; const WEAPON_PREFIX: &str = "common.items.weapons.modular";
const TAG_EXAMPLES_PREFIX: &str = "common.items.tag_examples.modular";
const HANDS: [Hands; 2] = [Hands::One, Hands::Two];
fn make_weapon_def(toolkind: ToolKind) -> (String, RawItemDef) { fn make_weapon_def(toolkind: ToolKind) -> (String, RawItemDef) {
let identifier = format!("{}.{}", WEAPON_PREFIX, toolkind.identifier_name()); let identifier = format!("{}.{}", WEAPON_PREFIX, toolkind.identifier_name());
@ -147,123 +74,24 @@ fn make_weapon_def(toolkind: ToolKind) -> (String, RawItemDef) {
(identifier, item) (identifier, item)
} }
fn make_recipe_def(identifier: String, toolkind: ToolKind, hands: Hands) -> RawRecipe { fn initialize_modular_assets() -> HashMap<String, RawItemDef> {
let output = (identifier, 1);
let mut inputs = Vec::new();
for &modkind in &MODKINDS {
let input = RawRecipeInput::Tag(ItemTag::ModularComponent(ModularComponentTag {
toolkind,
modkind,
hands,
}));
inputs.push((input, 1, true));
}
RawRecipe {
output,
inputs,
craft_sprite: None,
}
}
fn make_tagexample_def(
toolkind: ToolKind,
modkind: ModularComponentKind,
hands: Hands,
) -> (String, RawItemDef) {
let identifier = format!(
"{}.{}.{}.{}",
TAG_EXAMPLES_PREFIX,
modkind.identifier_name(),
toolkind.identifier_name(),
hands.identifier_name(),
);
let tag = ModularComponentTag {
toolkind,
modkind,
hands,
};
// TODO: i18n
let name = ItemName::Direct(format!("Any {}", tag.name()));
let kind = ItemKind::TagExamples {
// TODO: Iterate over components
item_ids: Vec::new(),
};
let item = RawItemDef {
name,
description: "".to_string(),
kind,
quality: super::QualityKind::Modular,
tags: vec![ItemTag::ModularComponent(tag)],
slots: 0,
ability_spec: None,
};
(identifier, item)
}
// Checks that modular weapons should exist for a given toolkind and hands
// combination
fn exists(tool: ToolKind, hands: Hands) -> bool {
match tool {
// Has both 1 handed and 2 handed variants
ToolKind::Sword | ToolKind::Axe | ToolKind::Hammer => true,
// Has only 2 handed variants
ToolKind::Bow | ToolKind::Staff | ToolKind::Sceptre => matches!(hands, Hands::Two),
// Modular weapons do not yet exist
ToolKind::Dagger
| ToolKind::Spear
| ToolKind::Blowgun
| ToolKind::Shield
| ToolKind::Natural
| ToolKind::Debug
| ToolKind::Farming
| ToolKind::Pick
| ToolKind::Empty => false,
}
}
fn initialize_modular_assets() -> (HashMap<String, RawItemDef>, RawRecipeBook) {
let mut itemdefs = HashMap::new(); let mut itemdefs = HashMap::new();
let mut recipes = HashMap::new();
for &toolkind in &SUPPORTED_TOOLKINDS { for &toolkind in &SUPPORTED_TOOLKINDS {
let (identifier, item) = make_weapon_def(toolkind); let (identifier, item) = make_weapon_def(toolkind);
itemdefs.insert(identifier.clone(), item); itemdefs.insert(identifier.clone(), item);
for &hands in &HANDS {
if exists(toolkind, hands) {
let recipe = make_recipe_def(identifier.clone(), toolkind, hands);
recipes.insert(
format!("{}.{}", identifier.clone(), hands.identifier_name()),
recipe,
);
for &modkind in &MODKINDS {
let (identifier, item) = make_tagexample_def(toolkind, modkind, hands);
itemdefs.insert(identifier, item);
} }
} itemdefs
}
}
(itemdefs, RawRecipeBook(recipes))
} }
lazy_static! { lazy_static! {
static ref ITEM_DEFS_AND_RECIPES: (HashMap<String, RawItemDef>, RawRecipeBook) = static ref ITEM_DEFS: HashMap<String, RawItemDef> = initialize_modular_assets();
initialize_modular_assets();
}
pub(crate) fn append_modular_recipes(recipes: &mut RawRecipeBook) {
for (name, recipe) in ITEM_DEFS_AND_RECIPES.1.0.iter() {
// avoid clobbering recipes from the filesystem, to allow overrides
if !recipes.0.contains_key(name) {
recipes.0.insert(name.clone(), recipe.clone());
}
}
} }
/// Synthesize modular assets programmatically, to allow for the following: /// Synthesize modular assets programmatically, to allow for the following:
/// - Allow the modular tag_examples to auto-update with the list of applicable /// - Allow the modular tag_examples to auto-update with the list of applicable
/// components /// components
pub(super) fn synthesize_modular_asset(specifier: &str) -> Option<RawItemDef> { pub(super) fn synthesize_modular_asset(specifier: &str) -> Option<RawItemDef> {
let ret = ITEM_DEFS_AND_RECIPES.0.get(specifier).cloned(); let ret = ITEM_DEFS.get(specifier).cloned();
tracing::trace!("synthesize_modular_asset({:?}) -> {:?}", specifier, ret); tracing::trace!("synthesize_modular_asset({:?}) -> {:?}", specifier, ret);
ret ret
} }

View File

@ -342,14 +342,7 @@ impl assets::Compound for RecipeBook {
Ok((def, *amount, *is_mod_comp)) Ok((def, *amount, *is_mod_comp))
} }
let mut raw = cache.load::<RawRecipeBook>(specifier)?.cloned(); let raw = cache.load::<RawRecipeBook>(specifier)?.cloned();
// Avoid showing purple-question-box recipes until the assets are added
// (the `if false` is needed because commenting out the call will add a warning
// that there are no other uses of append_modular_recipes)
// if false {
modular::append_modular_recipes(&mut raw);
// }
let recipes = raw let recipes = raw
.0 .0