mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Box inlined LoadoutSpec
This commit is contained in:
parent
11bf16e3d7
commit
8a1d665b0d
@ -278,11 +278,10 @@ mod entity_v2 {
|
||||
pub type Config = EntityConfig;
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize, Clone)]
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum LoadoutKindNew {
|
||||
FromBody,
|
||||
Asset(String),
|
||||
Inline(super::loadout_v2::LoadoutSpecNew),
|
||||
Inline(Box<super::loadout_v2::LoadoutSpecNew>),
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize, Clone)]
|
||||
@ -307,7 +306,7 @@ mod entity_v2 {
|
||||
fn from(old: LoadoutAsset) -> Self {
|
||||
match old {
|
||||
LoadoutAsset::Loadout(s) => LoadoutKindNew::Asset(s),
|
||||
LoadoutAsset::Choice(bases) => LoadoutKindNew::Inline(LoadoutSpecNew {
|
||||
LoadoutAsset::Choice(bases) => LoadoutKindNew::Inline(Box::new(LoadoutSpecNew {
|
||||
inherit: Some(Base::Choice(
|
||||
bases
|
||||
.iter()
|
||||
@ -315,7 +314,7 @@ mod entity_v2 {
|
||||
.collect(),
|
||||
)),
|
||||
..Default::default()
|
||||
}),
|
||||
})),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -364,7 +363,7 @@ mod entity_v2 {
|
||||
items: Vec<(u32, String)>,
|
||||
) -> Self {
|
||||
Self {
|
||||
loadout: LoadoutKindNew::Inline(LoadoutSpecNew {
|
||||
loadout: LoadoutKindNew::Inline(Box::new(LoadoutSpecNew {
|
||||
inherit: loadout.map(|asset| match asset {
|
||||
LoadoutAsset::Loadout(s) => Base::Asset(s),
|
||||
LoadoutAsset::Choice(bases) => Base::Choice(
|
||||
@ -376,7 +375,7 @@ mod entity_v2 {
|
||||
}),
|
||||
active_hands: Some(hands.into()),
|
||||
..Default::default()
|
||||
}),
|
||||
})),
|
||||
items,
|
||||
}
|
||||
}
|
||||
|
@ -38,11 +38,10 @@ impl Default for AlignmentMark {
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum LoadoutKind {
|
||||
FromBody,
|
||||
Asset(String),
|
||||
Inline(LoadoutSpec),
|
||||
Inline(Box<LoadoutSpec>),
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
@ -316,7 +315,7 @@ impl EntityInfo {
|
||||
},
|
||||
LoadoutKind::Inline(loadout_spec) => {
|
||||
let loadout =
|
||||
LoadoutBuilder::from_loadout_spec(loadout_spec, rng).unwrap_or_else(|e| {
|
||||
LoadoutBuilder::from_loadout_spec(*loadout_spec, rng).unwrap_or_else(|e| {
|
||||
panic!("failed to load loadout for {config_asset}: {e:?}");
|
||||
});
|
||||
self.loadout = loadout;
|
||||
|
Loading…
Reference in New Issue
Block a user