mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Removed inner toolkind from ModularBase::Tool.
This commit is contained in:
parent
eecc1b42c3
commit
36da0cf981
@ -405,7 +405,7 @@ where
|
||||
{
|
||||
Ok(match serialized_item_base {
|
||||
// TODO: Make this work
|
||||
"modular" => ItemBase::Modular(ModularBase::Tool(ToolKind::Empty)),
|
||||
"modular" => ItemBase::Modular(ModularBase::Tool),
|
||||
item_definition_id => {
|
||||
ItemBase::Raw(Arc::<ItemDef>::load_expect_cloned(item_definition_id))
|
||||
},
|
||||
|
@ -11,13 +11,13 @@ use std::{borrow::Cow, sync::Arc};
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
pub enum ModularBase {
|
||||
Tool(ToolKind),
|
||||
Tool,
|
||||
}
|
||||
|
||||
impl ModularBase {
|
||||
pub(super) fn duplicate(&self) -> Self {
|
||||
match self {
|
||||
ModularBase::Tool(toolkind) => ModularBase::Tool(*toolkind),
|
||||
ModularBase::Tool => ModularBase::Tool,
|
||||
}
|
||||
}
|
||||
|
||||
@ -53,9 +53,20 @@ impl ModularBase {
|
||||
.fold(tool::Stats::one(), |a, b| a * b)
|
||||
}
|
||||
|
||||
let toolkind = components
|
||||
.iter()
|
||||
.find_map(|comp| match &*comp.kind() {
|
||||
ItemKind::ModularComponent(ModularComponent::ToolPrimaryComponent {
|
||||
toolkind,
|
||||
..
|
||||
}) => Some(*toolkind),
|
||||
_ => None,
|
||||
})
|
||||
.unwrap_or(ToolKind::Empty);
|
||||
|
||||
match self {
|
||||
ModularBase::Tool(toolkind) => Cow::Owned(ItemKind::Tool(tool::Tool {
|
||||
kind: *toolkind,
|
||||
ModularBase::Tool => Cow::Owned(ItemKind::Tool(tool::Tool {
|
||||
kind: toolkind,
|
||||
hands: resolve_hands(components),
|
||||
stats: resolve_stats(components, msm),
|
||||
})),
|
||||
@ -67,7 +78,7 @@ impl ModularBase {
|
||||
/// the damage component is created from.
|
||||
pub fn generate_name(&self, components: &[Item]) -> Cow<str> {
|
||||
match self {
|
||||
ModularBase::Tool(_toolkind) => {
|
||||
ModularBase::Tool => {
|
||||
let name = components
|
||||
.iter()
|
||||
.find_map(|comp| match &*comp.kind() {
|
||||
@ -101,9 +112,15 @@ impl ModularBase {
|
||||
.fold(Quality::Low, |a, b| a.max(b.quality()))
|
||||
}
|
||||
|
||||
pub fn ability_spec(&self, _components: &[Item]) -> Option<Cow<AbilitySpec>> {
|
||||
pub fn ability_spec(&self, components: &[Item]) -> Option<Cow<AbilitySpec>> {
|
||||
match self {
|
||||
ModularBase::Tool(toolkind) => Some(Cow::Owned(AbilitySpec::Tool(*toolkind))),
|
||||
ModularBase::Tool => components.iter().find_map(|comp| match &*comp.kind() {
|
||||
ItemKind::ModularComponent(ModularComponent::ToolPrimaryComponent {
|
||||
toolkind,
|
||||
..
|
||||
}) => Some(Cow::Owned(AbilitySpec::Tool(*toolkind))),
|
||||
_ => None,
|
||||
}),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -329,7 +346,7 @@ pub fn random_weapon(
|
||||
// Create modular weapon
|
||||
let components = vec![primary_component, secondary_component];
|
||||
Ok(Item::new_from_item_base(
|
||||
ItemBase::Modular(ModularBase::Tool(tool)),
|
||||
ItemBase::Modular(ModularBase::Tool),
|
||||
&components,
|
||||
&ability_map,
|
||||
&msm,
|
||||
|
@ -288,7 +288,7 @@ pub fn modular_weapon(
|
||||
let hands_check =
|
||||
hands_a.map_or(true, |hands| hands_b.map_or(true, |hands2| hands == hands2));
|
||||
if hands_check {
|
||||
Ok(tool_a)
|
||||
Ok(())
|
||||
} else {
|
||||
Err(ModularWeaponError::DifferentHands)
|
||||
}
|
||||
@ -303,7 +303,7 @@ pub fn modular_weapon(
|
||||
};
|
||||
|
||||
match compatiblity {
|
||||
Ok(tool_kind) => {
|
||||
Ok(()) => {
|
||||
// Remove components from inventory
|
||||
let primary_component = inv
|
||||
.take(primary_component, ability_map, msm)
|
||||
@ -315,7 +315,7 @@ pub fn modular_weapon(
|
||||
// Create modular weapon
|
||||
let components = vec![primary_component, secondary_component];
|
||||
Ok(Item::new_from_item_base(
|
||||
ItemBase::Modular(modular::ModularBase::Tool(tool_kind)),
|
||||
ItemBase::Modular(modular::ModularBase::Tool),
|
||||
&components,
|
||||
ability_map,
|
||||
msm,
|
||||
|
Loading…
Reference in New Issue
Block a user