super-class and name accessor thru unrealtype wrapper
This commit is contained in:
parent
9ebaf8cd5d
commit
ab003e4cdc
|
@ -65,6 +65,12 @@ impl Sdk {
|
|||
.and_then(|text| std::fs::write(path, text).context("failed to write to file."))
|
||||
}
|
||||
|
||||
pub fn get_object(&self, key: &ObjectRef) -> Option<&UnrealType> {
|
||||
self.packages
|
||||
.get(&key.package)
|
||||
.and_then(|pkg| pkg.types.get(key))
|
||||
}
|
||||
|
||||
fn get_packages() -> anyhow::Result<Vec<Package>> {
|
||||
let objects = GOBJECTS
|
||||
.read()
|
||||
|
|
|
@ -70,6 +70,25 @@ pub enum UnrealType {
|
|||
}
|
||||
|
||||
impl UnrealType {
|
||||
pub fn super_class(&self) -> Option<ObjectRef> {
|
||||
match self {
|
||||
UnrealType::Class(class) | UnrealType::Struct(class) | UnrealType::Actor(class) => {
|
||||
class.super_class
|
||||
}
|
||||
UnrealType::Enum(_) => None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn unique_name(&self) -> &str {
|
||||
// FIXME: change this to the unique name field in the future
|
||||
match self {
|
||||
UnrealType::Class(class) | UnrealType::Struct(class) | UnrealType::Actor(class) => {
|
||||
&class.name
|
||||
}
|
||||
UnrealType::Enum(enm) => &enm.name,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn obj_ref(&self) -> ObjectRef {
|
||||
match self {
|
||||
UnrealType::Class(obj) => obj.obj_ref,
|
||||
|
|
Loading…
Reference in a new issue