mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Post refactoring
This commit is contained in:
parent
45e5554ff5
commit
c3a120c551
@ -10,7 +10,7 @@ BasicSummon(
|
||||
)),
|
||||
scale: None,
|
||||
health_scaling: 80,
|
||||
loadout_config: Some(Husk),
|
||||
loadout_config: Some(HuskSummon),
|
||||
skillset_config: None,
|
||||
),
|
||||
)
|
||||
)
|
||||
|
@ -10,4 +10,4 @@ BasicSummon(
|
||||
loadout_config: None,
|
||||
skillset_config: None,
|
||||
),
|
||||
)
|
||||
)
|
||||
|
12
assets/common/entity/dungeon/tier-5/beastmaster.ron
Normal file
12
assets/common/entity/dungeon/tier-5/beastmaster.ron
Normal file
@ -0,0 +1,12 @@
|
||||
EntityConfig (
|
||||
name: Some("Beastmaster"),
|
||||
|
||||
main_tool: Some(Choice([
|
||||
(1.0, Some(Item("common.items.weapons.axe.malachite_axe-0"))),
|
||||
(1.0, Some(Item("common.items.weapons.sword.bloodsteel-1"))),
|
||||
(1.0, Some(Item("common.items.weapons.bow.velorite"))),
|
||||
])),
|
||||
second_tool: None,
|
||||
|
||||
loadout_config: Some("common.loadout.dungeon.tier-5.beastmaster"),
|
||||
)
|
8
assets/common/entity/dungeon/tier-5/husk.ron
Normal file
8
assets/common/entity/dungeon/tier-5/husk.ron
Normal file
@ -0,0 +1,8 @@
|
||||
EntityConfig (
|
||||
name: Some("Cultist Husk"),
|
||||
|
||||
main_tool: None,
|
||||
second_tool: None,
|
||||
|
||||
loadout_config: Some("common.loadout.dungeon.tier-5.husk"),
|
||||
)
|
@ -41,8 +41,8 @@ use tracing::warn;
|
||||
pub struct LoadoutBuilder(Loadout);
|
||||
|
||||
#[derive(Copy, Clone, PartialEq, Deserialize, Serialize, Debug, EnumIter)]
|
||||
pub enum LoadoutPreset {
|
||||
Husk,
|
||||
pub enum Preset {
|
||||
HuskSummon,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
@ -426,10 +426,10 @@ impl LoadoutBuilder {
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn with_preset(mut self, preset: LoadoutPreset) -> Self {
|
||||
pub fn with_preset(mut self, preset: Preset) -> Self {
|
||||
let rng = &mut rand::thread_rng();
|
||||
match preset {
|
||||
LoadoutPreset::Husk => {
|
||||
Preset::HuskSummon => {
|
||||
self = self.with_asset_expect("common.loadout.dungeon.tier-5.husk", rng)
|
||||
},
|
||||
}
|
||||
@ -671,7 +671,7 @@ mod tests {
|
||||
// Things that will be catched - invalid assets paths
|
||||
#[test]
|
||||
fn test_loadout_presets() {
|
||||
for preset in LoadoutPreset::iter() {
|
||||
for preset in Preset::iter() {
|
||||
std::mem::drop(LoadoutBuilder::default().with_preset(preset));
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ use crate::{
|
||||
assets::{self, AssetExt},
|
||||
comp::{
|
||||
self, agent, humanoid,
|
||||
inventory::loadout_builder::{ItemSpec, LoadoutBuilder, LoadoutPreset},
|
||||
inventory::loadout_builder::{ItemSpec, LoadoutBuilder},
|
||||
Alignment, Body, Item,
|
||||
},
|
||||
npc::{self, NPC_NAMES},
|
||||
@ -43,10 +43,7 @@ pub struct EntityInfo {
|
||||
// TODO: Properly give NPCs skills
|
||||
pub level: Option<u16>,
|
||||
pub loot_drop: Option<Item>,
|
||||
// FIXME: using both preset and asset is silly, make it enum
|
||||
// so it will be correct by construction
|
||||
pub loadout_config: Option<String>,
|
||||
pub loadout_preset: Option<LoadoutPreset>,
|
||||
pub make_loadout: Option<fn(LoadoutBuilder, Option<&trade::SiteInformation>) -> LoadoutBuilder>,
|
||||
pub skillset_config: Option<String>,
|
||||
pub skillset_preset: Option<SkillSetConfig>,
|
||||
@ -73,7 +70,6 @@ impl EntityInfo {
|
||||
level: None,
|
||||
loot_drop: None,
|
||||
loadout_config: None,
|
||||
loadout_preset: None,
|
||||
make_loadout: None,
|
||||
skillset_config: None,
|
||||
skillset_preset: None,
|
||||
@ -114,7 +110,7 @@ impl EntityInfo {
|
||||
}
|
||||
|
||||
if let Some(loadout_config) = loadout_config {
|
||||
self = self.with_loadout_config(&loadout_config);
|
||||
self = self.with_loadout_config(loadout_config);
|
||||
}
|
||||
|
||||
self
|
||||
@ -187,13 +183,8 @@ impl EntityInfo {
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_loadout_preset(mut self, preset: LoadoutPreset) -> Self {
|
||||
self.loadout_preset = Some(preset);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_loadout_config(mut self, config: &str) -> Self {
|
||||
self.loadout_config = Some(config.to_owned());
|
||||
pub fn with_loadout_config(mut self, config: String) -> Self {
|
||||
self.loadout_config = Some(config);
|
||||
self
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
use crate::{
|
||||
comp::{
|
||||
self,
|
||||
inventory::loadout_builder::{LoadoutBuilder, LoadoutPreset},
|
||||
inventory::loadout_builder::{self, LoadoutBuilder},
|
||||
Behavior, BehaviorCapability, CharacterState, StateUpdate,
|
||||
},
|
||||
event::{LocalEvent, ServerEvent},
|
||||
@ -79,7 +79,7 @@ impl CharacterBehavior for Data {
|
||||
let mut loadout_builder =
|
||||
LoadoutBuilder::new().with_default_maintool(&body);
|
||||
|
||||
if let Some(preset) = self.static_data.summon_info.loadout_preset {
|
||||
if let Some(preset) = self.static_data.summon_info.loadout_config {
|
||||
loadout_builder = loadout_builder.with_preset(preset);
|
||||
}
|
||||
|
||||
@ -88,7 +88,7 @@ impl CharacterBehavior for Data {
|
||||
let stats = comp::Stats::new("Summon".to_string());
|
||||
let skill_set = SkillSetBuilder::build_skillset(
|
||||
&None,
|
||||
self.static_data.summon_info.skillset_preset,
|
||||
self.static_data.summon_info.skillset_config,
|
||||
)
|
||||
.build();
|
||||
|
||||
@ -177,7 +177,7 @@ pub struct SummonInfo {
|
||||
body: comp::Body,
|
||||
scale: Option<comp::Scale>,
|
||||
health_scaling: u16,
|
||||
// TODO: use assets for specifying skills and loadouts?
|
||||
loadout_preset: Option<LoadoutPreset>,
|
||||
skillset_preset: Option<SkillSetConfig>,
|
||||
// TODO: use assets for specifying skills and loadout?
|
||||
loadout_config: Option<loadout_builder::Preset>,
|
||||
skillset_config: Option<SkillSetConfig>,
|
||||
}
|
||||
|
@ -197,7 +197,6 @@ impl<'a> System<'a> for Sys {
|
||||
let EntityInfo {
|
||||
skillset_preset,
|
||||
main_tool,
|
||||
loadout_preset,
|
||||
loadout_config,
|
||||
make_loadout,
|
||||
trading_information: economy,
|
||||
@ -217,20 +216,13 @@ impl<'a> System<'a> for Sys {
|
||||
loadout_builder = loadout_builder.with_default_maintool(&body);
|
||||
}
|
||||
|
||||
// If there are configs, apply them
|
||||
match (loadout_preset, &loadout_config) {
|
||||
(Some(preset), Some(config)) => {
|
||||
loadout_builder = loadout_builder.with_preset(preset);
|
||||
loadout_builder = loadout_builder.with_asset_expect(&config, rng);
|
||||
// If there is config, apply it.
|
||||
// If not, use default equipement for this body.
|
||||
match loadout_config {
|
||||
Some(asset) => {
|
||||
loadout_builder = loadout_builder.with_asset_expect(&asset, rng);
|
||||
},
|
||||
(Some(preset), None) => {
|
||||
loadout_builder = loadout_builder.with_preset(preset);
|
||||
},
|
||||
(None, Some(config)) => {
|
||||
loadout_builder = loadout_builder.with_asset_expect(&config, rng);
|
||||
},
|
||||
// If not, use default equipement for this body
|
||||
(None, None) => {
|
||||
None => {
|
||||
loadout_builder = loadout_builder.with_default_equipment(&body);
|
||||
},
|
||||
}
|
||||
|
@ -1257,17 +1257,9 @@ fn mini_boss_5(dynamic_rng: &mut impl Rng, tile_wcenter: Vec3<i32>) -> Vec<Entit
|
||||
entities.push(
|
||||
EntityInfo::at(tile_wcenter.map(|e| e as f32))
|
||||
.with_body(comp::Body::Humanoid(comp::humanoid::Body::random()))
|
||||
.with_name("Beastmaster".to_string())
|
||||
.with_loot_drop(trainer_loot.read().choose().to_item())
|
||||
.with_loadout_config("common.loadout.dungeon.tier-5.beastmaster")
|
||||
.with_skillset_preset(common::skillset_builder::SkillSetConfig::CultistAcolyte)
|
||||
.with_main_tool(comp::Item::new_from_asset_expect(
|
||||
match dynamic_rng.gen_range(0..3) {
|
||||
0 => "common.items.weapons.axe.malachite_axe-0",
|
||||
1 => "common.items.weapons.sword.bloodsteel-1",
|
||||
_ => "common.items.weapons.bow.velorite",
|
||||
},
|
||||
)),
|
||||
.with_asset_expect("common.entity.dungeon.tier-5.beastmaster"),
|
||||
);
|
||||
entities.resize_with(entities.len() + 2, || {
|
||||
EntityInfo::at(tile_wcenter.map(|e| e as f32))
|
||||
@ -1292,9 +1284,8 @@ fn mini_boss_5(dynamic_rng: &mut impl Rng, tile_wcenter: Vec3<i32>) -> Vec<Entit
|
||||
&comp::biped_small::Species::Husk,
|
||||
),
|
||||
))
|
||||
.with_name("Cultist Husk".to_string())
|
||||
.with_loot_drop(chosen.read().choose().to_item())
|
||||
.with_loadout_config("common.loadout.dungeon.tier-5.husk")
|
||||
.with_asset_expect("common.entity.dungeon.tier-5.husk")
|
||||
});
|
||||
},
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user