diff --git a/src/sdk/repr.rs b/src/sdk/repr.rs index 099c320..167717f 100644 --- a/src/sdk/repr.rs +++ b/src/sdk/repr.rs @@ -69,6 +69,26 @@ pub enum UnrealType { Enum(Enum), } +impl UnrealType { + pub fn obj_ref(&self) -> ObjectRef { + match self { + UnrealType::Class(obj) => obj.obj_ref, + UnrealType::Struct(obj) => obj.obj_ref, + UnrealType::Actor(obj) => obj.obj_ref, + UnrealType::Enum(obj) => obj.obj_ref, + } + } + + pub fn get_dependent_types(&self) -> Vec { + match self { + UnrealType::Class(obj) | UnrealType::Struct(obj) | UnrealType::Actor(obj) => { + obj.get_dependent_types() + } + UnrealType::Enum(_) => vec![], + } + } +} + #[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum StructKind { Object, @@ -78,6 +98,7 @@ pub enum StructKind { #[derive(Debug, Serialize, Deserialize)] pub struct Enum { + pub obj_ref: ObjectRef, pub name: String, pub full_name: String, pub values: BTreeMap, @@ -85,6 +106,7 @@ pub struct Enum { #[derive(Debug, Serialize, Deserialize)] pub struct Class { + pub obj_ref: ObjectRef, pub kind: StructKind, pub size: u32, pub name: String, @@ -94,9 +116,6 @@ pub struct Class { pub min_alignment: u32, pub fields: Vec, pub methods: Vec, - /// types this class depends on; includes super types, types of fields and - /// types of function parameters. - pub dependencies: Vec, } #[derive(Debug, Serialize, Deserialize)] @@ -209,3 +228,19 @@ pub enum Type { Class(ObjectRef), Struct(ObjectRef), } + +impl Type { + pub fn dependent_type(&self) -> Option { + match self { + Type::Ptr(ty) | Type::Ref(ty) | Type::Array(ty) | Type::RawArray { ty, .. } => { + ty.dependent_type() + } + Type::WeakPtr(ty) | Type::SoftPtr(ty) | Type::LazyPtr(ty) | Type::AssetPtr(ty) => { + Some(*ty) + } + Type::Enum { underlying, .. } => underlying.dependent_type(), + Type::Class(ty) | Type::Struct(ty) => Some(*ty), + _ => None, + } + } +}