From fa5ddaa570473ece02e0a3bfb35702211d21ce12 Mon Sep 17 00:00:00 2001 From: troido Date: Sat, 3 Oct 2020 15:20:52 +0200 Subject: added dense grass; home is now part of monsterAI component --- src/components/faction.rs | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) (limited to 'src/components/faction.rs') diff --git a/src/components/faction.rs b/src/components/faction.rs index 5fc02a2..32184d5 100644 --- a/src/components/faction.rs +++ b/src/components/faction.rs @@ -1,4 +1,5 @@ +use strum_macros::{EnumString, Display}; use specs::{ Component, HashMapStorage, @@ -6,7 +7,8 @@ use specs::{ Entity, }; -#[derive(Component, Debug, Clone, Copy, PartialEq, Eq, Hash)] +#[derive(Component, Debug, Clone, Copy, PartialEq, Eq, Hash, EnumString, Display)] +#[strum(serialize_all = "lowercase")] #[storage(HashMapStorage)] pub enum Faction { Neutral, @@ -19,17 +21,6 @@ use Faction::{Neutral, Good, Evil, None}; impl Faction { - pub fn from_str(name: &str) -> Option { - match name.to_lowercase().as_str() { - "neutral" => Some(Neutral), - "good" => Some(Good), - "evil" => Some(Evil), - "none" => Some(None), - "" => Some(None), - _ => Option::None - } - } - pub fn is_enemy(&self, other: Faction) -> bool { match self { Neutral => false, -- cgit