adressed review comments

This commit is contained in:
Maxicarlos08 2023-05-22 22:38:37 +02:00
parent fbe32a9047
commit 777a69e576
No known key found for this signature in database
4 changed files with 20 additions and 11 deletions

View File

@ -12,7 +12,7 @@ use std::{
fmt::{self, Display}, fmt::{self, Display},
str::FromStr, str::FromStr,
}; };
use strum::IntoEnumIterator; use strum::{AsRefStr, EnumIter, EnumString, IntoEnumIterator};
use tracing::warn; use tracing::warn;
/// Struct representing a command that a user can run from server chat. /// Struct representing a command that a user can run from server chat.
@ -66,6 +66,15 @@ impl assets::Asset for SkillPresetManifest {
pub const KIT_MANIFEST_PATH: &str = "server.manifests.kits"; pub const KIT_MANIFEST_PATH: &str = "server.manifests.kits";
pub const PRESET_MANIFEST_PATH: &str = "server.manifests.presets"; pub const PRESET_MANIFEST_PATH: &str = "server.manifests.presets";
/// Enum for all possible area types
#[derive(Debug, Clone, EnumIter, EnumString, AsRefStr)]
pub enum AreaKind {
#[strum(serialize = "build")]
Build,
#[strum(serialize = "no_durability")]
NoDurability,
}
lazy_static! { lazy_static! {
static ref ALIGNMENTS: Vec<String> = vec!["wild", "enemy", "npc", "pet"] static ref ALIGNMENTS: Vec<String> = vec!["wild", "enemy", "npc", "pet"]
.iter() .iter()
@ -114,7 +123,7 @@ lazy_static! {
souls souls
}; };
static ref AREA_KINDS: Vec<String> = vec!["build".to_string(), "no_durability".to_string()]; static ref AREA_KINDS: Vec<String> = AreaKind::iter().map(|kind| kind.as_ref().to_string()).collect();
static ref OBJECTS: Vec<String> = comp::object::ALL_OBJECTS static ref OBJECTS: Vec<String> = comp::object::ALL_OBJECTS
.iter() .iter()
.map(|o| o.to_string().to_string()) .map(|o| o.to_string().to_string())

View File

@ -1,10 +1,9 @@
use common::depot::{Depot, Id};
use hashbrown::{hash_map, HashMap};
use std::{ use std::{
marker::PhantomData, marker::PhantomData,
ops::{Deref, DerefMut}, ops::{Deref, DerefMut},
}; };
use common::depot::{Depot, Id};
use hashbrown::{hash_map, HashMap};
use vek::*; use vek::*;
#[derive(Default)] #[derive(Default)]

View File

@ -21,8 +21,8 @@ use common::{
assets, assets,
calendar::Calendar, calendar::Calendar,
cmd::{ cmd::{
KitSpec, ServerChatCommand, BUFF_PACK, BUFF_PARSER, ITEM_SPECS, KIT_MANIFEST_PATH, AreaKind, KitSpec, ServerChatCommand, BUFF_PACK, BUFF_PARSER, ITEM_SPECS,
PRESET_MANIFEST_PATH, KIT_MANIFEST_PATH, PRESET_MANIFEST_PATH,
}, },
comp::{ comp::{
self, self,
@ -2005,14 +2005,14 @@ fn handle_build(
} }
fn get_areas_mut<'l>(kind: &str, state: &'l mut State) -> CmdResult<&'l mut Areas> { fn get_areas_mut<'l>(kind: &str, state: &'l mut State) -> CmdResult<&'l mut Areas> {
Ok(match kind { Ok(match AreaKind::from_str(kind).ok() {
"build" => state Some(AreaKind::Build) => state
.mut_resource::<AreasContainer<BuildArea>>() .mut_resource::<AreasContainer<BuildArea>>()
.deref_mut(), .deref_mut(),
"no_durability" => state Some(AreaKind::NoDurability) => state
.mut_resource::<AreasContainer<NoDurabilityArea>>() .mut_resource::<AreasContainer<NoDurabilityArea>>()
.deref_mut(), .deref_mut(),
_ => Err(format!("Invalid area type '{kind}'"))?, None => Err(format!("Invalid area type '{kind}'"))?,
}) })
} }

View File

@ -496,6 +496,7 @@ impl StateExt for State {
buff::{BuffCategory, BuffData, BuffKind, BuffSource}, buff::{BuffCategory, BuffData, BuffKind, BuffSource},
}; };
let time = self.get_time(); let time = self.get_time();
// TODO: Consider using the area system for this
self.ecs_mut() self.ecs_mut()
.create_entity_synced() .create_entity_synced()
.with(pos) .with(pos)