refactor: modularize getting nodes and aspects

This commit is contained in:
Nova
2022-10-18 10:58:39 -04:00
parent a399db006e
commit 88555ee047
14 changed files with 91 additions and 126 deletions

View File

@@ -1,9 +1,9 @@
use super::{eventloop::EventLoop, scenegraph::Scenegraph};
use crate::{
core::registry::Registry,
nodes::{data, drawable, fields, hmd, input, items, root::Root, spatial, startup},
nodes::{data, drawable, fields, hmd, input, items, root::Root, spatial, startup, Node},
};
use anyhow::Result;
use anyhow::{anyhow, Result};
use lazy_static::lazy_static;
use once_cell::sync::OnceCell;
use parking_lot::Mutex;
@@ -99,6 +99,13 @@ impl Client {
client
}
#[inline]
pub fn get_node(&self, name: &'static str, path: &str) -> Result<Arc<Node>> {
self.scenegraph
.get_node(path)
.ok_or_else(|| anyhow!("{} not found", name))
}
pub async fn dispatch(&self) -> Result<(), std::io::Error> {
match &self.messenger {
Some(messenger) => messenger.dispatch(&self.scenegraph).await,