mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
clippy helped to get rid of one level of indirection
This commit is contained in:
parent
d2aa9028ec
commit
eab062450a
@ -364,76 +364,71 @@ impl From<Vec<(f32, LootSpec<String>)>> for ProbabilityFile {
|
|||||||
1.0 / content.iter().map(|e| e.0).sum::<f32>()
|
1.0 / content.iter().map(|e| e.0).sum::<f32>()
|
||||||
};
|
};
|
||||||
Self {
|
Self {
|
||||||
content: content
|
content: content.into_iter().flat_map(|(p0, loot)| match loot {
|
||||||
.into_iter()
|
LootSpec::Item(asset) => {
|
||||||
.flat_map(|(p0, loot)| match loot {
|
vec![(p0 * rescale, ItemDefinitionIdOwned::Simple(asset), 1.0)]
|
||||||
LootSpec::Item(asset) => {
|
},
|
||||||
vec![(p0 * rescale, ItemDefinitionIdOwned::Simple(asset), 1.0)].into_iter()
|
LootSpec::ItemQuantity(asset, a, b) => vec![(
|
||||||
},
|
p0 * rescale,
|
||||||
LootSpec::ItemQuantity(asset, a, b) => vec![(
|
ItemDefinitionIdOwned::Simple(asset),
|
||||||
p0 * rescale,
|
(a + b) as f32 * 0.5,
|
||||||
ItemDefinitionIdOwned::Simple(asset),
|
)],
|
||||||
(a + b) as f32 * 0.5,
|
LootSpec::LootTable(table_asset) => {
|
||||||
)]
|
let unscaled = &Self::load_expect(&table_asset).read().content;
|
||||||
.into_iter(),
|
let scale = p0 * rescale;
|
||||||
LootSpec::LootTable(table_asset) => {
|
unscaled
|
||||||
let unscaled = &Self::load_expect(&table_asset).read().content;
|
.iter()
|
||||||
let scale = p0 * rescale;
|
.map(|(p1, asset, amount)| (*p1 * scale, asset.clone(), *amount))
|
||||||
unscaled
|
.collect::<Vec<_>>()
|
||||||
.iter()
|
},
|
||||||
.map(|(p1, asset, amount)| (*p1 * scale, asset.clone(), *amount))
|
LootSpec::ModularWeapon {
|
||||||
.collect::<Vec<_>>()
|
tool,
|
||||||
.into_iter()
|
material,
|
||||||
},
|
hands,
|
||||||
LootSpec::ModularWeapon {
|
} => {
|
||||||
tool,
|
let mut primary = expand_primary_component(tool, material, hands);
|
||||||
material,
|
let secondary: Vec<ItemDefinitionIdOwned> =
|
||||||
hands,
|
expand_secondary_component(tool, material, hands).collect();
|
||||||
} => {
|
let freq = if primary.is_empty() || secondary.is_empty() {
|
||||||
let mut primary = expand_primary_component(tool, material, hands);
|
0.0
|
||||||
let secondary: Vec<ItemDefinitionIdOwned> =
|
} else {
|
||||||
expand_secondary_component(tool, material, hands).collect();
|
p0 * rescale / ((primary.len() * secondary.len()) as f32)
|
||||||
let freq = if primary.is_empty() || secondary.is_empty() {
|
};
|
||||||
0.0
|
let res: Vec<(f32, ItemDefinitionIdOwned, f32)> = primary
|
||||||
} else {
|
.drain(0..)
|
||||||
p0 * rescale / ((primary.len() * secondary.len()) as f32)
|
.flat_map(|p| {
|
||||||
};
|
secondary.iter().map(move |s| {
|
||||||
let res: Vec<(f32, ItemDefinitionIdOwned, f32)> = primary
|
let components = vec![p.clone(), s.clone()];
|
||||||
.drain(0..)
|
(
|
||||||
.flat_map(|p| {
|
freq,
|
||||||
secondary.iter().map(move |s| {
|
ItemDefinitionIdOwned::Modular {
|
||||||
let components = vec![p.clone(), s.clone()];
|
pseudo_base: ModularBase::Tool.pseudo_item_id().into(),
|
||||||
(
|
components,
|
||||||
freq,
|
},
|
||||||
ItemDefinitionIdOwned::Modular {
|
1.0f32,
|
||||||
pseudo_base: ModularBase::Tool.pseudo_item_id().into(),
|
)
|
||||||
components,
|
|
||||||
},
|
|
||||||
1.0f32,
|
|
||||||
)
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
.collect();
|
})
|
||||||
res.into_iter()
|
.collect();
|
||||||
},
|
res
|
||||||
LootSpec::ModularWeaponPrimaryComponent {
|
},
|
||||||
tool,
|
LootSpec::ModularWeaponPrimaryComponent {
|
||||||
material,
|
tool,
|
||||||
hands,
|
material,
|
||||||
} => {
|
hands,
|
||||||
let mut res = expand_primary_component(tool, material, hands);
|
} => {
|
||||||
let freq = if res.is_empty() {
|
let mut res = expand_primary_component(tool, material, hands);
|
||||||
0.0
|
let freq = if res.is_empty() {
|
||||||
} else {
|
0.0
|
||||||
p0 * rescale / (res.len() as f32)
|
} else {
|
||||||
};
|
p0 * rescale / (res.len() as f32)
|
||||||
let res: Vec<(f32, ItemDefinitionIdOwned, f32)> =
|
};
|
||||||
res.drain(0..).map(|e| (freq, e, 1.0f32)).collect();
|
let res: Vec<(f32, ItemDefinitionIdOwned, f32)> =
|
||||||
res.into_iter()
|
res.drain(0..).map(|e| (freq, e, 1.0f32)).collect();
|
||||||
},
|
res
|
||||||
LootSpec::Nothing => Vec::new().into_iter(),
|
},
|
||||||
})
|
LootSpec::Nothing => Vec::new(),
|
||||||
.collect(),
|
}).collect(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user