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},
str::FromStr,
};
use strum::IntoEnumIterator;
use strum::{AsRefStr, EnumIter, EnumString, IntoEnumIterator};
use tracing::warn;
/// 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 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! {
static ref ALIGNMENTS: Vec<String> = vec!["wild", "enemy", "npc", "pet"]
.iter()
@ -114,7 +123,7 @@ lazy_static! {
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
.iter()
.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::{
marker::PhantomData,
ops::{Deref, DerefMut},
};
use common::depot::{Depot, Id};
use hashbrown::{hash_map, HashMap};
use vek::*;
#[derive(Default)]

View File

@ -21,8 +21,8 @@ use common::{
assets,
calendar::Calendar,
cmd::{
KitSpec, ServerChatCommand, BUFF_PACK, BUFF_PARSER, ITEM_SPECS, KIT_MANIFEST_PATH,
PRESET_MANIFEST_PATH,
AreaKind, KitSpec, ServerChatCommand, BUFF_PACK, BUFF_PARSER, ITEM_SPECS,
KIT_MANIFEST_PATH, PRESET_MANIFEST_PATH,
},
comp::{
self,
@ -2005,14 +2005,14 @@ fn handle_build(
}
fn get_areas_mut<'l>(kind: &str, state: &'l mut State) -> CmdResult<&'l mut Areas> {
Ok(match kind {
"build" => state
Ok(match AreaKind::from_str(kind).ok() {
Some(AreaKind::Build) => state
.mut_resource::<AreasContainer<BuildArea>>()
.deref_mut(),
"no_durability" => state
Some(AreaKind::NoDurability) => state
.mut_resource::<AreasContainer<NoDurabilityArea>>()
.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},
};
let time = self.get_time();
// TODO: Consider using the area system for this
self.ecs_mut()
.create_entity_synced()
.with(pos)