diff --git a/src/fot/entitylist.rs b/src/fot/entitylist.rs index 7e86058..8643e64 100644 --- a/src/fot/entitylist.rs +++ b/src/fot/entitylist.rs @@ -44,6 +44,10 @@ impl EntityList { self.types.len() - 1 } + pub fn get_type_idx(&self, type_name: &str) -> Option { + self.types.iter().position(|f| f.eq(type_name)) + } + pub fn add_or_get_type(&mut self, type_name: FString) -> usize { match self.types.iter().position(|f| f.eq(&type_name)) { Some(idx) => idx, diff --git a/src/fot/fstring.rs b/src/fot/fstring.rs index 439ba15..84f0539 100644 --- a/src/fot/fstring.rs +++ b/src/fot/fstring.rs @@ -89,6 +89,12 @@ impl PartialEq for FString { } } +impl std::cmp::PartialEq for FString { + fn eq(&self, other: &str) -> bool { + self.str == other + } +} + impl Hash for FString { fn hash(&self, state: &mut H) { self.str.hash(state); diff --git a/src/fot/world.rs b/src/fot/world.rs index 1f56e4f..1569717 100644 --- a/src/fot/world.rs +++ b/src/fot/world.rs @@ -33,13 +33,11 @@ impl World { const WORLD_HDR_LEN: usize = 0x13; pub fn test(&mut self) -> Result<()> { - /*self.entlist.convert(EntityEncoding::File); - self.entlist - .encode(EntityEncoding::File)? - .dump(Path::new("D:\\entlist.ent"))?;*/ - for (id, ent) in &self.entlist { - println!("{} {}", id, ent.type_idx); - } + let actor_type = self.entlist.get_type_idx("Actor").unwrap(); + println!("Actor type {}", actor_type); + //for (id, ent) in &self.entlist { + // println!("{} {}", id, ent.type_idx); + //} Ok(()) }