got better idea with EntityOwner trait
This commit is contained in:
parent
c4a0c6b0c5
commit
aa4a7da90c
2 changed files with 19 additions and 17 deletions
|
|
@ -51,6 +51,10 @@ next zar = <zar> + 0x1A + unk5
|
||||||
uint16_t type_idx
|
uint16_t type_idx
|
||||||
<esh>
|
<esh>
|
||||||
|
|
||||||
|
<entity>
|
||||||
|
FString entity type
|
||||||
|
<esh>
|
||||||
|
|
||||||
<esh>
|
<esh>
|
||||||
uint32_t N
|
uint32_t N
|
||||||
N times
|
N times
|
||||||
|
|
|
||||||
|
|
@ -7,41 +7,39 @@ use super::stream::{ReadStream, WriteStream};
|
||||||
use anyhow::anyhow;
|
use anyhow::anyhow;
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
|
|
||||||
pub enum EntityOrigin {
|
pub enum EntityEncoding {
|
||||||
File,
|
File,
|
||||||
World
|
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> {
|
pub struct Entity {
|
||||||
origin: EntityOrigin,
|
|
||||||
tag: Option<Tag>,
|
|
||||||
pub id: usize,
|
|
||||||
pub flags: u32,
|
pub flags: u32,
|
||||||
pub type_idx: u16,
|
pub type_idx: usize,
|
||||||
pub type_name: &'a FString,
|
|
||||||
pub esh: ESH,
|
pub esh: ESH,
|
||||||
enc_size: usize
|
enc_size: usize
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct EntityOpt<'b> {
|
pub struct EntityOpt {
|
||||||
pub origin: EntityOrigin,
|
//pub origin: EntityOrigin,
|
||||||
pub flags: u32,
|
pub type_idx: usize
|
||||||
pub type_idx: u16,
|
|
||||||
pub type_name: Option<&'b FString>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Decoder for Entity<'a> {
|
impl Decoder for Entity {
|
||||||
type Opt = EntityOpt<'a>;
|
type Opt = EntityOpt;
|
||||||
fn decode(raw: &Raw, offset: usize, _: usize, opt: Option<Self::Opt>) -> Result<Entity<'a>> {
|
fn decode(raw: &Raw, offset: usize, _: usize, opt: Option<Self::Opt>) -> Result<Self> {
|
||||||
let rd = ReadStream::new(raw, offset);
|
let rd = ReadStream::new(raw, offset);
|
||||||
let opt = match opt {
|
let opt = match opt {
|
||||||
Some(opt) => opt,
|
Some(opt) => opt,
|
||||||
None => return Err(anyhow!("no EntityOpt was provided!"))
|
None => return Err(anyhow!("no EntityOpt was provided!"))
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
todo!();
|
todo!();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue