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,
|
scale: None,
|
||||||
health_scaling: 80,
|
health_scaling: 80,
|
||||||
loadout_config: Some(Husk),
|
loadout_config: Some(HuskSummon),
|
||||||
skillset_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);
|
pub struct LoadoutBuilder(Loadout);
|
||||||
|
|
||||||
#[derive(Copy, Clone, PartialEq, Deserialize, Serialize, Debug, EnumIter)]
|
#[derive(Copy, Clone, PartialEq, Deserialize, Serialize, Debug, EnumIter)]
|
||||||
pub enum LoadoutPreset {
|
pub enum Preset {
|
||||||
Husk,
|
HuskSummon,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Clone)]
|
#[derive(Debug, Deserialize, Clone)]
|
||||||
@ -426,10 +426,10 @@ impl LoadoutBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[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();
|
let rng = &mut rand::thread_rng();
|
||||||
match preset {
|
match preset {
|
||||||
LoadoutPreset::Husk => {
|
Preset::HuskSummon => {
|
||||||
self = self.with_asset_expect("common.loadout.dungeon.tier-5.husk", rng)
|
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
|
// Things that will be catched - invalid assets paths
|
||||||
#[test]
|
#[test]
|
||||||
fn test_loadout_presets() {
|
fn test_loadout_presets() {
|
||||||
for preset in LoadoutPreset::iter() {
|
for preset in Preset::iter() {
|
||||||
std::mem::drop(LoadoutBuilder::default().with_preset(preset));
|
std::mem::drop(LoadoutBuilder::default().with_preset(preset));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@ use crate::{
|
|||||||
assets::{self, AssetExt},
|
assets::{self, AssetExt},
|
||||||
comp::{
|
comp::{
|
||||||
self, agent, humanoid,
|
self, agent, humanoid,
|
||||||
inventory::loadout_builder::{ItemSpec, LoadoutBuilder, LoadoutPreset},
|
inventory::loadout_builder::{ItemSpec, LoadoutBuilder},
|
||||||
Alignment, Body, Item,
|
Alignment, Body, Item,
|
||||||
},
|
},
|
||||||
npc::{self, NPC_NAMES},
|
npc::{self, NPC_NAMES},
|
||||||
@ -43,10 +43,7 @@ pub struct EntityInfo {
|
|||||||
// TODO: Properly give NPCs skills
|
// TODO: Properly give NPCs skills
|
||||||
pub level: Option<u16>,
|
pub level: Option<u16>,
|
||||||
pub loot_drop: Option<Item>,
|
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_config: Option<String>,
|
||||||
pub loadout_preset: Option<LoadoutPreset>,
|
|
||||||
pub make_loadout: Option<fn(LoadoutBuilder, Option<&trade::SiteInformation>) -> LoadoutBuilder>,
|
pub make_loadout: Option<fn(LoadoutBuilder, Option<&trade::SiteInformation>) -> LoadoutBuilder>,
|
||||||
pub skillset_config: Option<String>,
|
pub skillset_config: Option<String>,
|
||||||
pub skillset_preset: Option<SkillSetConfig>,
|
pub skillset_preset: Option<SkillSetConfig>,
|
||||||
@ -73,7 +70,6 @@ impl EntityInfo {
|
|||||||
level: None,
|
level: None,
|
||||||
loot_drop: None,
|
loot_drop: None,
|
||||||
loadout_config: None,
|
loadout_config: None,
|
||||||
loadout_preset: None,
|
|
||||||
make_loadout: None,
|
make_loadout: None,
|
||||||
skillset_config: None,
|
skillset_config: None,
|
||||||
skillset_preset: None,
|
skillset_preset: None,
|
||||||
@ -114,7 +110,7 @@ impl EntityInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if let Some(loadout_config) = loadout_config {
|
if let Some(loadout_config) = loadout_config {
|
||||||
self = self.with_loadout_config(&loadout_config);
|
self = self.with_loadout_config(loadout_config);
|
||||||
}
|
}
|
||||||
|
|
||||||
self
|
self
|
||||||
@ -187,13 +183,8 @@ impl EntityInfo {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn with_loadout_preset(mut self, preset: LoadoutPreset) -> Self {
|
pub fn with_loadout_config(mut self, config: String) -> Self {
|
||||||
self.loadout_preset = Some(preset);
|
self.loadout_config = Some(config);
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn with_loadout_config(mut self, config: &str) -> Self {
|
|
||||||
self.loadout_config = Some(config.to_owned());
|
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
comp::{
|
comp::{
|
||||||
self,
|
self,
|
||||||
inventory::loadout_builder::{LoadoutBuilder, LoadoutPreset},
|
inventory::loadout_builder::{self, LoadoutBuilder},
|
||||||
Behavior, BehaviorCapability, CharacterState, StateUpdate,
|
Behavior, BehaviorCapability, CharacterState, StateUpdate,
|
||||||
},
|
},
|
||||||
event::{LocalEvent, ServerEvent},
|
event::{LocalEvent, ServerEvent},
|
||||||
@ -79,7 +79,7 @@ impl CharacterBehavior for Data {
|
|||||||
let mut loadout_builder =
|
let mut loadout_builder =
|
||||||
LoadoutBuilder::new().with_default_maintool(&body);
|
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);
|
loadout_builder = loadout_builder.with_preset(preset);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,7 +88,7 @@ impl CharacterBehavior for Data {
|
|||||||
let stats = comp::Stats::new("Summon".to_string());
|
let stats = comp::Stats::new("Summon".to_string());
|
||||||
let skill_set = SkillSetBuilder::build_skillset(
|
let skill_set = SkillSetBuilder::build_skillset(
|
||||||
&None,
|
&None,
|
||||||
self.static_data.summon_info.skillset_preset,
|
self.static_data.summon_info.skillset_config,
|
||||||
)
|
)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
@ -177,7 +177,7 @@ pub struct SummonInfo {
|
|||||||
body: comp::Body,
|
body: comp::Body,
|
||||||
scale: Option<comp::Scale>,
|
scale: Option<comp::Scale>,
|
||||||
health_scaling: u16,
|
health_scaling: u16,
|
||||||
// TODO: use assets for specifying skills and loadouts?
|
// TODO: use assets for specifying skills and loadout?
|
||||||
loadout_preset: Option<LoadoutPreset>,
|
loadout_config: Option<loadout_builder::Preset>,
|
||||||
skillset_preset: Option<SkillSetConfig>,
|
skillset_config: Option<SkillSetConfig>,
|
||||||
}
|
}
|
||||||
|
@ -197,7 +197,6 @@ impl<'a> System<'a> for Sys {
|
|||||||
let EntityInfo {
|
let EntityInfo {
|
||||||
skillset_preset,
|
skillset_preset,
|
||||||
main_tool,
|
main_tool,
|
||||||
loadout_preset,
|
|
||||||
loadout_config,
|
loadout_config,
|
||||||
make_loadout,
|
make_loadout,
|
||||||
trading_information: economy,
|
trading_information: economy,
|
||||||
@ -217,20 +216,13 @@ impl<'a> System<'a> for Sys {
|
|||||||
loadout_builder = loadout_builder.with_default_maintool(&body);
|
loadout_builder = loadout_builder.with_default_maintool(&body);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If there are configs, apply them
|
// If there is config, apply it.
|
||||||
match (loadout_preset, &loadout_config) {
|
// If not, use default equipement for this body.
|
||||||
(Some(preset), Some(config)) => {
|
match loadout_config {
|
||||||
loadout_builder = loadout_builder.with_preset(preset);
|
Some(asset) => {
|
||||||
loadout_builder = loadout_builder.with_asset_expect(&config, rng);
|
loadout_builder = loadout_builder.with_asset_expect(&asset, rng);
|
||||||
},
|
},
|
||||||
(Some(preset), None) => {
|
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) => {
|
|
||||||
loadout_builder = loadout_builder.with_default_equipment(&body);
|
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(
|
entities.push(
|
||||||
EntityInfo::at(tile_wcenter.map(|e| e as f32))
|
EntityInfo::at(tile_wcenter.map(|e| e as f32))
|
||||||
.with_body(comp::Body::Humanoid(comp::humanoid::Body::random()))
|
.with_body(comp::Body::Humanoid(comp::humanoid::Body::random()))
|
||||||
.with_name("Beastmaster".to_string())
|
|
||||||
.with_loot_drop(trainer_loot.read().choose().to_item())
|
.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_skillset_preset(common::skillset_builder::SkillSetConfig::CultistAcolyte)
|
||||||
.with_main_tool(comp::Item::new_from_asset_expect(
|
.with_asset_expect("common.entity.dungeon.tier-5.beastmaster"),
|
||||||
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",
|
|
||||||
},
|
|
||||||
)),
|
|
||||||
);
|
);
|
||||||
entities.resize_with(entities.len() + 2, || {
|
entities.resize_with(entities.len() + 2, || {
|
||||||
EntityInfo::at(tile_wcenter.map(|e| e as f32))
|
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,
|
&comp::biped_small::Species::Husk,
|
||||||
),
|
),
|
||||||
))
|
))
|
||||||
.with_name("Cultist Husk".to_string())
|
|
||||||
.with_loot_drop(chosen.read().choose().to_item())
|
.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