fix(node): get client returns option

This commit is contained in:
Nova
2022-10-13 00:29:50 -04:00
parent a421b27e0c
commit 1f371fe497
4 changed files with 52 additions and 33 deletions

View File

@@ -62,7 +62,14 @@ impl Model {
let _ = model_arc.pending_model_path.set(
model_arc
.resource_id
.get_file(&node.get_client().base_resource_prefixes.lock().clone())
.get_file(
&node
.get_client()
.ok_or_else(|| anyhow!("Client not found"))?
.base_resource_prefixes
.lock()
.clone(),
)
.ok_or_else(|| anyhow!("Resource not found"))?,
);
let _ = node.model.set(model_arc.clone());

View File

@@ -5,7 +5,7 @@ use crate::{
Node,
},
};
use anyhow::{ensure, Result};
use anyhow::{anyhow, ensure, Result};
use glam::{vec3, Mat4, Vec2};
use mint::Vector2;
use once_cell::sync::OnceCell;
@@ -63,11 +63,13 @@ impl Text {
"Internal: Node already has text attached!"
);
let client = node
.get_client()
.ok_or_else(|| anyhow!("Client not found"))?;
let text = TEXT_REGISTRY.add(Text {
space: node.spatial.get().unwrap().clone(),
font_path: font_resource_id.and_then(|res| {
res.get_file(&node.get_client().base_resource_prefixes.lock().clone())
}),
font_path: font_resource_id
.and_then(|res| res.get_file(&client.base_resource_prefixes.lock().clone())),
style: OnceCell::new(),
data: Mutex::new(TextData {