forked from StrafesNET/strafe-client
load_roblox module
This commit is contained in:
parent
6fe26b8724
commit
dbaa93790b
@ -2,3 +2,4 @@ pub mod framework;
|
|||||||
pub mod body;
|
pub mod body;
|
||||||
pub mod zeroes;
|
pub mod zeroes;
|
||||||
pub mod instruction;
|
pub mod instruction;
|
||||||
|
pub mod load_roblox;
|
||||||
|
28
src/load_roblox.rs
Normal file
28
src/load_roblox.rs
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
fn class_is_a(class: &str, superclass: &str) -> bool {
|
||||||
|
if class==superclass {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
let class_descriptor=rbx_reflection_database::get().classes.get(class);
|
||||||
|
if let Some(descriptor) = &class_descriptor {
|
||||||
|
if let Some(class_super) = &descriptor.superclass {
|
||||||
|
return class_is_a(&class_super, superclass)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get_objects(buf_thing: std::io::BufReader<&[u8]>, superclass: &str) -> Result<std::vec::Vec<rbx_dom_weak::Instance>, Box<dyn std::error::Error>> {
|
||||||
|
// Using buffered I/O is recommended with rbx_binary
|
||||||
|
let dom = rbx_binary::from_reader(buf_thing)?;
|
||||||
|
|
||||||
|
let mut objects = std::vec::Vec::<rbx_dom_weak::Instance>::new();
|
||||||
|
//move matching instances into objects
|
||||||
|
let (_,mut instances) = dom.into_raw();
|
||||||
|
for (_,instance) in instances.drain() {
|
||||||
|
if class_is_a(instance.class.as_str(), superclass) {
|
||||||
|
objects.push(instance);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Ok(objects)
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user