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."))
|
.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>> {
|
fn get_packages() -> anyhow::Result<Vec<Package>> {
|
||||||
let objects = GOBJECTS
|
let objects = GOBJECTS
|
||||||
.read()
|
.read()
|
||||||
|
|
|
@ -70,6 +70,25 @@ pub enum UnrealType {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl 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 {
|
pub fn obj_ref(&self) -> ObjectRef {
|
||||||
match self {
|
match self {
|
||||||
UnrealType::Class(obj) => obj.obj_ref,
|
UnrealType::Class(obj) => obj.obj_ref,
|
||||||
|
|
Loading…
Reference in a new issue