diff --git a/format.txt b/format.txt index 81a37dc..e5e4efc 100644 --- a/format.txt +++ b/format.txt @@ -51,6 +51,10 @@ next zar = + 0x1A + unk5 uint16_t type_idx + + FString entity type + + uint32_t N N times diff --git a/src/fot/entity.rs b/src/fot/entity.rs index 769bf46..63bf7dc 100644 --- a/src/fot/entity.rs +++ b/src/fot/entity.rs @@ -7,40 +7,38 @@ use super::stream::{ReadStream, WriteStream}; use anyhow::anyhow; use anyhow::Result; -pub enum EntityOrigin { +pub enum EntityEncoding { File, World } -// FString type should be reference +pub trait EntityOwner<'a> { + fn get_entity_encoding(&self) -> EntityEncoding; + fn add_new_type(name: FString) -> usize; + fn add_or_get_type(name: FString) -> usize; + fn get_type_name(type_idx: usize) -> &'a FString; +} -pub struct Entity<'a> { - origin: EntityOrigin, - tag: Option, - pub id: usize, +pub struct Entity { pub flags: u32, - pub type_idx: u16, - pub type_name: &'a FString, + pub type_idx: usize, pub esh: ESH, enc_size: usize } -pub struct EntityOpt<'b> { - pub origin: EntityOrigin, - pub flags: u32, - pub type_idx: u16, - pub type_name: Option<&'b FString>, +pub struct EntityOpt { + //pub origin: EntityOrigin, + pub type_idx: usize } -impl<'a> Decoder for Entity<'a> { - type Opt = EntityOpt<'a>; - fn decode(raw: &Raw, offset: usize, _: usize, opt: Option) -> Result> { +impl Decoder for Entity { + type Opt = EntityOpt; + fn decode(raw: &Raw, offset: usize, _: usize, opt: Option) -> Result { let rd = ReadStream::new(raw, offset); let opt = match opt { Some(opt) => opt, None => return Err(anyhow!("no EntityOpt was provided!")) }; - todo!(); }