fix(pulse sender): add aspect to node

This commit is contained in:
Nova
2022-06-11 23:52:13 -04:00
parent 0c1a7af8a5
commit 3ef45a1041
2 changed files with 7 additions and 1 deletions

View File

@@ -1,8 +1,10 @@
use super::data::PulseSender;
use super::field::Field;
use super::spatial::Spatial;
use crate::core::client::Client;
use crate::nodes::spatial::Spatial;
use anyhow::{anyhow, Result};
use std::rc::{Rc, Weak};
use std::sync::Arc;
use std::{collections::HashMap, vec::Vec};
pub type Signal = fn(&Node, Rc<Client>, &[u8]) -> Result<()>;
@@ -18,6 +20,7 @@ pub struct Node<'a> {
pub spatial: Option<Rc<Spatial>>,
pub field: Option<Rc<Field>>,
pub pulse_sender: Option<Arc<PulseSender>>,
}
impl<'a> Node<'a> {
@@ -45,8 +48,10 @@ impl<'a> Node<'a> {
local_signals: HashMap::new(),
local_methods: HashMap::new(),
destroyable,
spatial: None,
field: None,
pulse_sender: None,
};
node.add_local_signal("destroy", Node::destroy_flex);
node

View File

@@ -27,6 +27,7 @@ impl PulseSender {
.upgrade()
.and_then(|event_loop| event_loop.pulse_senders.add(sender.clone()).ok());
*sender.registry_idx.write().unwrap() = idx;
node.borrow_mut().pulse_sender = Some(sender);
Ok(())
}
}