mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Use item_definition_id for weapon asset mapping
This commit is contained in:
@ -8,7 +8,7 @@
|
|||||||
"voxel.weapon.bow.shortbow_starter",
|
"voxel.weapon.bow.shortbow_starter",
|
||||||
(0.0, 0.0, 0.0), (90.0, 90.0, 0.0), 1.0,
|
(0.0, 0.0, 0.0), (90.0, 90.0, 0.0), 1.0,
|
||||||
),
|
),
|
||||||
Tool(Tool("common.items.weapons.bow.wood_shortbow-0")): VoxTrans(
|
Tool("common.items.weapons.bow.wood_shortbow-0"): VoxTrans(
|
||||||
"voxel.weapon.bow.shortbow_wood-0",
|
"voxel.weapon.bow.shortbow_wood-0",
|
||||||
(0.0, 0.0, 0.0), (90.0, 90.0, 0.0), 1.0,
|
(0.0, 0.0, 0.0), (90.0, 90.0, 0.0), 1.0,
|
||||||
),
|
),
|
||||||
|
@ -461,7 +461,7 @@
|
|||||||
vox_spec: ("weapon.hammer.cult_purp-0", (-3.5, -4.5, -5.0)),
|
vox_spec: ("weapon.hammer.cult_purp-0", (-3.5, -4.5, -5.0)),
|
||||||
color: None
|
color: None
|
||||||
),
|
),
|
||||||
"Craftsman": ( //TODO This should be a 1h hammer!
|
/*"Craftsman": ( //TODO This should be a 1h hammer!
|
||||||
vox_spec: ("weapon.hammer.craftsman", (-2.0, -5.0, -5.5)),
|
vox_spec: ("weapon.hammer.craftsman", (-2.0, -5.0, -5.5)),
|
||||||
color: None
|
color: None
|
||||||
),*/
|
),*/
|
||||||
|
@ -351,6 +351,7 @@ pub trait ItemDesc {
|
|||||||
fn name(&self) -> &str;
|
fn name(&self) -> &str;
|
||||||
fn kind(&self) -> &ItemKind;
|
fn kind(&self) -> &ItemKind;
|
||||||
fn quality(&self) -> &Quality;
|
fn quality(&self) -> &Quality;
|
||||||
|
fn item_definition_id(&self) -> &str;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ItemDesc for Item {
|
impl ItemDesc for Item {
|
||||||
@ -361,6 +362,8 @@ impl ItemDesc for Item {
|
|||||||
fn kind(&self) -> &ItemKind { &self.item_def.kind }
|
fn kind(&self) -> &ItemKind { &self.item_def.kind }
|
||||||
|
|
||||||
fn quality(&self) -> &Quality { &self.item_def.quality }
|
fn quality(&self) -> &Quality { &self.item_def.quality }
|
||||||
|
|
||||||
|
fn item_definition_id(&self) -> &str { &self.item_def.item_definition_id }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ItemDesc for ItemDef {
|
impl ItemDesc for ItemDef {
|
||||||
@ -371,6 +374,8 @@ impl ItemDesc for ItemDef {
|
|||||||
fn kind(&self) -> &ItemKind { &self.kind }
|
fn kind(&self) -> &ItemKind { &self.kind }
|
||||||
|
|
||||||
fn quality(&self) -> &Quality { &self.quality }
|
fn quality(&self) -> &Quality { &self.quality }
|
||||||
|
|
||||||
|
fn item_definition_id(&self) -> &str { &self.item_definition_id }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Component for Item {
|
impl Component for Item {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
-- Changes filepaths of sceptres
|
-- Changes filepaths of npcweapons
|
||||||
|
|
||||||
UPDATE item
|
UPDATE item
|
||||||
SET item_definition_id = 'common.items.npc_weapons.unique.beast_claws' WHERE item_definition_id = 'common.items.npc_weapons.npcweapon.beast_claws';
|
SET item_definition_id = 'common.items.npc_weapons.unique.beast_claws' WHERE item_definition_id = 'common.items.npc_weapons.npcweapon.beast_claws';
|
||||||
|
@ -87,23 +87,6 @@ fn get_tool_kind(kind: &ToolKind) -> String {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*fn get_tool_kind_kind(kind: &ToolKind) -> String {
|
|
||||||
match kind {
|
|
||||||
ToolKind::Sword(x) => x.clone(),
|
|
||||||
ToolKind::Axe(x) => x.clone(),
|
|
||||||
ToolKind::Hammer(x) => x.clone(),
|
|
||||||
ToolKind::Bow(x) => x.clone(),
|
|
||||||
ToolKind::Dagger(x) => x.clone(),
|
|
||||||
ToolKind::Staff(x) => x.clone(),
|
|
||||||
ToolKind::Sceptre(x) => x.clone(),
|
|
||||||
ToolKind::Shield(x) => x.clone(),
|
|
||||||
ToolKind::Debug(x) => x.clone(),
|
|
||||||
ToolKind::Farming(x) => x.clone(),
|
|
||||||
ToolKind::NpcWeapon(x) => x.clone(),
|
|
||||||
ToolKind::Empty => "".to_string(),
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
fn get_armor_kind(kind: &ArmorKind) -> String {
|
fn get_armor_kind(kind: &ArmorKind) -> String {
|
||||||
match kind {
|
match kind {
|
||||||
ArmorKind::Shoulder(_) => "Shoulder".to_string(),
|
ArmorKind::Shoulder(_) => "Shoulder".to_string(),
|
||||||
@ -146,7 +129,6 @@ fn all_items() -> Result<(), Box<dyn Error>> {
|
|||||||
let kind = match item.kind() {
|
let kind = match item.kind() {
|
||||||
ItemKind::Armor(armor) => get_armor_kind_kind(&armor.kind),
|
ItemKind::Armor(armor) => get_armor_kind_kind(&armor.kind),
|
||||||
ItemKind::Lantern(lantern) => lantern.kind.clone(),
|
ItemKind::Lantern(lantern) => lantern.kind.clone(),
|
||||||
//ItemKind::Tool(tool) => get_tool_kind_kind(&tool.kind),
|
|
||||||
_ => "".to_owned(),
|
_ => "".to_owned(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ impl Animation for IdleAnimation {
|
|||||||
next.main.position = Vec3::new(0.0, -5.0, 6.0);
|
next.main.position = Vec3::new(0.0, -5.0, 6.0);
|
||||||
next.main.orientation = Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57);
|
next.main.orientation = Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57);
|
||||||
},
|
},
|
||||||
Some(ToolKind::Staff(_)) | Some(ToolKind::Sceptre(_)) => {
|
Some(ToolKind::Staff) | Some(ToolKind::Sceptre) => {
|
||||||
next.main.position = Vec3::new(2.0, -5.0, -1.0);
|
next.main.position = Vec3::new(2.0, -5.0, -1.0);
|
||||||
next.main.orientation = Quaternion::rotation_y(-0.5) * Quaternion::rotation_z(1.57);
|
next.main.orientation = Quaternion::rotation_y(-0.5) * Quaternion::rotation_z(1.57);
|
||||||
},
|
},
|
||||||
|
@ -272,7 +272,7 @@ impl<'a> Widget for Crafting<'a> {
|
|||||||
let quality_col = get_quality_col(&*recipe.output.0);
|
let quality_col = get_quality_col(&*recipe.output.0);
|
||||||
Button::image(
|
Button::image(
|
||||||
self.item_imgs
|
self.item_imgs
|
||||||
.img_id_or_not_found_img((&*recipe.output.0.kind()).into()),
|
.img_id_or_not_found_img((&*recipe.output.0).into()),
|
||||||
)
|
)
|
||||||
.w_h(55.0, 55.0)
|
.w_h(55.0, 55.0)
|
||||||
.label(&output_text)
|
.label(&output_text)
|
||||||
@ -433,20 +433,17 @@ impl<'a> Widget for Crafting<'a> {
|
|||||||
frame.set(state.ids.ingredient_frame[i], ui);
|
frame.set(state.ids.ingredient_frame[i], ui);
|
||||||
//Item Image
|
//Item Image
|
||||||
let (title, desc) = super::util::item_text(&**item_def);
|
let (title, desc) = super::util::item_text(&**item_def);
|
||||||
Button::image(
|
Button::image(self.item_imgs.img_id_or_not_found_img((&**item_def).into()))
|
||||||
self.item_imgs
|
.w_h(22.0, 22.0)
|
||||||
.img_id_or_not_found_img((&*item_def.kind()).into()),
|
.middle_of(state.ids.ingredient_frame[i])
|
||||||
)
|
.with_tooltip(
|
||||||
.w_h(22.0, 22.0)
|
self.tooltip_manager,
|
||||||
.middle_of(state.ids.ingredient_frame[i])
|
title,
|
||||||
.with_tooltip(
|
&*desc,
|
||||||
self.tooltip_manager,
|
&item_tooltip,
|
||||||
title,
|
quality_col,
|
||||||
&*desc,
|
)
|
||||||
&item_tooltip,
|
.set(state.ids.ingredient_img[i], ui);
|
||||||
quality_col,
|
|
||||||
)
|
|
||||||
.set(state.ids.ingredient_img[i], ui);
|
|
||||||
// Ingredients text and amount
|
// Ingredients text and amount
|
||||||
// Don't show inventory amounts above 999 to avoid the widget clipping
|
// Don't show inventory amounts above 999 to avoid the widget clipping
|
||||||
let over9k = "99+";
|
let over9k = "99+";
|
||||||
|
@ -3,8 +3,7 @@ use common::{
|
|||||||
assets::{self, watch::ReloadIndicator, Asset},
|
assets::{self, watch::ReloadIndicator, Asset},
|
||||||
comp::item::{
|
comp::item::{
|
||||||
armor::{Armor, ArmorKind},
|
armor::{Armor, ArmorKind},
|
||||||
tool::{Tool, ToolKind},
|
Glider, ItemDesc, ItemKind, Lantern, Throwable, Utility,
|
||||||
Glider, ItemKind, Lantern, Throwable, Utility,
|
|
||||||
},
|
},
|
||||||
figure::Segment,
|
figure::Segment,
|
||||||
};
|
};
|
||||||
@ -19,7 +18,7 @@ use vek::*;
|
|||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||||
pub enum ItemKey {
|
pub enum ItemKey {
|
||||||
Tool(ToolKind),
|
Tool(String),
|
||||||
Lantern(String),
|
Lantern(String),
|
||||||
Glider(String),
|
Glider(String),
|
||||||
Armor(ArmorKind),
|
Armor(ArmorKind),
|
||||||
@ -30,10 +29,13 @@ pub enum ItemKey {
|
|||||||
Empty,
|
Empty,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<&ItemKind> for ItemKey {
|
impl<T: ItemDesc> From<&T> for ItemKey {
|
||||||
fn from(item_kind: &ItemKind) -> Self {
|
fn from(item_desc: &T) -> Self {
|
||||||
|
let item_kind = item_desc.kind();
|
||||||
|
let item_definition_id = item_desc.item_definition_id();
|
||||||
|
|
||||||
match item_kind {
|
match item_kind {
|
||||||
ItemKind::Tool(Tool { kind, .. }) => ItemKey::Tool(kind.clone()),
|
ItemKind::Tool(_) => ItemKey::Tool(item_definition_id.to_owned()),
|
||||||
ItemKind::Lantern(Lantern { kind, .. }) => ItemKey::Lantern(kind.clone()),
|
ItemKind::Lantern(Lantern { kind, .. }) => ItemKey::Lantern(kind.clone()),
|
||||||
ItemKind::Glider(Glider { kind, .. }) => ItemKey::Glider(kind.clone()),
|
ItemKind::Glider(Glider { kind, .. }) => ItemKey::Glider(kind.clone()),
|
||||||
ItemKind::Armor(Armor { kind, .. }) => ItemKey::Armor(kind.clone()),
|
ItemKind::Armor(Armor { kind, .. }) => ItemKey::Armor(kind.clone()),
|
||||||
@ -140,13 +142,13 @@ impl ItemImgs {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn img_id(&self, item_kind: ItemKey) -> Option<Id> {
|
pub fn img_id(&self, item_key: ItemKey) -> Option<Id> {
|
||||||
match self.map.get(&item_kind) {
|
match self.map.get(&item_key) {
|
||||||
Some(id) => Some(*id),
|
Some(id) => Some(*id),
|
||||||
// There was no specification in the ron
|
// There was no specification in the ron
|
||||||
None => {
|
None => {
|
||||||
warn!(
|
warn!(
|
||||||
?item_kind,
|
?item_key,
|
||||||
"missing specified image file (note: hot-reloading won't work here)",
|
"missing specified image file (note: hot-reloading won't work here)",
|
||||||
);
|
);
|
||||||
None
|
None
|
||||||
@ -154,8 +156,8 @@ impl ItemImgs {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn img_id_or_not_found_img(&self, item_kind: ItemKey) -> Id {
|
pub fn img_id_or_not_found_img(&self, item_key: ItemKey) -> Id {
|
||||||
self.img_id(item_kind).unwrap_or(self.not_found)
|
self.img_id(item_key).unwrap_or(self.not_found)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ impl SlotKey<Inventory, ItemImgs> for InventorySlot {
|
|||||||
type ImageKey = ItemKey;
|
type ImageKey = ItemKey;
|
||||||
|
|
||||||
fn image_key(&self, source: &Inventory) -> Option<(Self::ImageKey, Option<Color>)> {
|
fn image_key(&self, source: &Inventory) -> Option<(Self::ImageKey, Option<Color>)> {
|
||||||
source.get(self.0).map(|i| (i.kind().into(), None))
|
source.get(self.0).map(|i| (i.into(), None))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn amount(&self, source: &Inventory) -> Option<u32> {
|
fn amount(&self, source: &Inventory) -> Option<u32> {
|
||||||
@ -69,7 +69,7 @@ impl SlotKey<Loadout, ItemImgs> for EquipSlot {
|
|||||||
EquipSlot::Glider => source.glider.as_ref(),
|
EquipSlot::Glider => source.glider.as_ref(),
|
||||||
};
|
};
|
||||||
|
|
||||||
item.map(|i| (i.kind().into(), None))
|
item.map(|i| (i.into(), None))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn amount(&self, _: &Loadout) -> Option<u32> { None }
|
fn amount(&self, _: &Loadout) -> Option<u32> { None }
|
||||||
@ -103,7 +103,7 @@ impl<'a> SlotKey<HotbarSource<'a>, HotbarImageSource<'a>> for HotbarSlot {
|
|||||||
hotbar.get(*self).and_then(|contents| match contents {
|
hotbar.get(*self).and_then(|contents| match contents {
|
||||||
hotbar::SlotContents::Inventory(idx) => inventory
|
hotbar::SlotContents::Inventory(idx) => inventory
|
||||||
.get(idx)
|
.get(idx)
|
||||||
.map(|item| HotbarImage::Item(item.kind().into()))
|
.map(|item| HotbarImage::Item(item.into()))
|
||||||
.map(|i| (i, None)),
|
.map(|i| (i, None)),
|
||||||
hotbar::SlotContents::Ability3 => loadout
|
hotbar::SlotContents::Ability3 => loadout
|
||||||
.active_item
|
.active_item
|
||||||
|
@ -12,7 +12,6 @@ use common::{
|
|||||||
comp::{
|
comp::{
|
||||||
item::{
|
item::{
|
||||||
armor::{Armor, ArmorKind},
|
armor::{Armor, ArmorKind},
|
||||||
tool::ToolKind,
|
|
||||||
ItemKind,
|
ItemKind,
|
||||||
},
|
},
|
||||||
CharacterState, Loadout,
|
CharacterState, Loadout,
|
||||||
@ -69,8 +68,8 @@ pub struct FigureKey<Body> {
|
|||||||
/// person or when the character is in a tool-using state).
|
/// person or when the character is in a tool-using state).
|
||||||
#[derive(Eq, Hash, PartialEq)]
|
#[derive(Eq, Hash, PartialEq)]
|
||||||
pub(super) struct CharacterToolKey {
|
pub(super) struct CharacterToolKey {
|
||||||
pub active: Option<ToolKind>,
|
pub active: Option<String>,
|
||||||
pub second: Option<ToolKind>,
|
pub second: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Character data that exists in third person only.
|
/// Character data that exists in third person only.
|
||||||
@ -180,20 +179,14 @@ impl CharacterCacheKey {
|
|||||||
},
|
},
|
||||||
tool: if are_tools_visible {
|
tool: if are_tools_visible {
|
||||||
Some(CharacterToolKey {
|
Some(CharacterToolKey {
|
||||||
active: if let Some(ItemKind::Tool(tool)) =
|
active: loadout
|
||||||
loadout.active_item.as_ref().map(|i| i.item.kind())
|
.active_item
|
||||||
{
|
.as_ref()
|
||||||
Some(tool.kind.clone())
|
.map(|i| i.item.item_definition_id().to_owned()),
|
||||||
} else {
|
second: loadout
|
||||||
None
|
.second_item
|
||||||
},
|
.as_ref()
|
||||||
second: if let Some(ItemKind::Tool(tool)) =
|
.map(|i| i.item.item_definition_id().to_owned()),
|
||||||
loadout.second_item.as_ref().map(|i| i.item.kind())
|
|
||||||
{
|
|
||||||
Some(tool.kind.clone())
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
@ -9,7 +9,6 @@ use common::{
|
|||||||
fish_medium, fish_small,
|
fish_medium, fish_small,
|
||||||
golem::{self, BodyType as GBodyType, Species as GSpecies},
|
golem::{self, BodyType as GBodyType, Species as GSpecies},
|
||||||
humanoid::{self, Body, BodyType, EyeColor, Skin, Species},
|
humanoid::{self, Body, BodyType, EyeColor, Skin, Species},
|
||||||
item::tool::ToolKind,
|
|
||||||
object,
|
object,
|
||||||
quadruped_low::{self, BodyType as QLBodyType, Species as QLSpecies},
|
quadruped_low::{self, BodyType as QLBodyType, Species as QLSpecies},
|
||||||
quadruped_medium::{self, BodyType as QMBodyType, Species as QMSpecies},
|
quadruped_medium::{self, BodyType as QMBodyType, Species as QMSpecies},
|
||||||
@ -327,7 +326,7 @@ struct HumArmorPantsSpec(ArmorVoxSpecMap<String, ArmorVoxSpec>);
|
|||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
struct HumArmorFootSpec(ArmorVoxSpecMap<String, ArmorVoxSpec>);
|
struct HumArmorFootSpec(ArmorVoxSpecMap<String, ArmorVoxSpec>);
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
struct HumMainWeaponSpec(HashMap<ToolKind, ArmorVoxSpec>);
|
struct HumMainWeaponSpec(HashMap<String, ArmorVoxSpec>);
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
struct HumArmorLanternSpec(ArmorVoxSpecMap<String, ArmorVoxSpec>);
|
struct HumArmorLanternSpec(ArmorVoxSpecMap<String, ArmorVoxSpec>);
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
@ -826,11 +825,11 @@ impl HumArmorFootSpec {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl HumMainWeaponSpec {
|
impl HumMainWeaponSpec {
|
||||||
fn mesh_main_weapon(&self, tool_kind: &ToolKind, flipped: bool) -> BoneMeshes {
|
fn mesh_main_weapon(&self, item_definition_id: &str, flipped: bool) -> BoneMeshes {
|
||||||
let spec = match self.0.get(tool_kind) {
|
let spec = match self.0.get(item_definition_id) {
|
||||||
Some(spec) => spec,
|
Some(spec) => spec,
|
||||||
None => {
|
None => {
|
||||||
error!(?tool_kind, "No tool/weapon specification exists");
|
error!(?item_definition_id, "No tool/weapon specification exists");
|
||||||
return load_mesh("not_found", Vec3::new(-1.5, -1.5, -7.0));
|
return load_mesh("not_found", Vec3::new(-1.5, -1.5, -7.0));
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user