add constructors for VmcExtRootPos

This commit is contained in:
Cassandra de la Cruz-Munoz 2024-01-01 12:00:13 -05:00
parent e385ffe5e9
commit d6d74353bd
Signed by: cassdlcm
GPG Key ID: BFEBACEA812DDA70

View File

@ -419,6 +419,26 @@ impl VmcMessage for VmcExtRootPos {
} }
} }
impl VmcExtRootPos {
fn new(name: String, transform: Transform3D, mr_scale: Option<Vector3>, mr_offset: Option<Vector3>) -> Result<Self, MessageCreationErr> {
if mr_scale.is_some() && mr_offset.is_none() {
return Err(MessageCreationErr::OptionalArgs(CreateOptionalArgsErr { expected_sets: vec![String::from("None"), String::from("mr_scale, mr_offset")], actual: String::from("mr_scale"), calling_func: String::from("VmcExtRootPos::new")}));
}
if mr_scale.is_none() && mr_offset.is_some() {
return Err(MessageCreationErr::OptionalArgs(CreateOptionalArgsErr { expected_sets: vec![String::from("None"), String::from("mr_scale, mr_offset")], actual: String::from("mr_offset"), calling_func: String::from("VmcExtRootPos::new")}))
}
return Ok(VmcExtRootPos { name, transform, mr_scale, mr_offset});
}
fn new_vmc_message(name: String, transform: Transform3D, mr_scale: Option<Vector3>, mr_offset: Option<Vector3>) -> Result<Box<dyn VmcMessage>, MessageCreationErr> {
let message = Self::new(name, transform, mr_scale, mr_offset);
if message.is_ok() {
let boxed_result: Box<dyn VmcMessage> = Box::new(message.ok().unwrap());
return Ok(boxed_result);
}
return Err(message.err().unwrap());
}
}
#[derive(Debug)] #[derive(Debug)]
struct VmcExtBonePos { struct VmcExtBonePos {
name: String, name: String,