-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(InteractiveProcess): update to use new Pty node
- Loading branch information
1 parent
5a96942
commit 864954a
Showing
3 changed files
with
90 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,41 @@ | ||
use godot::prelude::*; | ||
use godot::{obj::WithBaseField, prelude::*}; | ||
|
||
use super::resource_registry::ResourceRegistry; | ||
|
||
/// The [ResourceProcessor] allows Godot [Resource] objects to run a process | ||
/// function every frame. Resources must register with the [ResourceRegistry] | ||
/// associated with this [ResourceProcessor] in order to be processed from | ||
/// the scene tree. | ||
#[derive(GodotClass)] | ||
#[class(init, base=Node)] | ||
pub struct ResourceProcessor { | ||
base: Base<Node>, | ||
#[export] | ||
registry: Gd<ResourceRegistry>, | ||
initialized: bool, | ||
} | ||
|
||
#[godot_api] | ||
impl INode for ResourceProcessor { | ||
//fn init(base: Base<Self::Base>) -> Self { | ||
// // Load the registry resource | ||
// let mut resource_loader = ResourceLoader::singleton(); | ||
// if let Some(res) = resource_loader.load(res_path.clone().into()) {} | ||
fn process(&mut self, delta: f64) { | ||
if !self.initialized { | ||
// Add any child nodes from the registry | ||
let children = self.registry.bind().get_children(); | ||
for child in children.iter_shared() { | ||
self.base_mut().add_child(child); | ||
} | ||
|
||
// Self { base, registry: () } | ||
//} | ||
// Add any future children that get added to the registry | ||
let ptr = self.to_gd(); | ||
let method = Callable::from_object_method(&ptr, "add_child"); | ||
self.registry.connect("child_added".into(), method); | ||
|
||
fn process(&mut self, delta: f64) { | ||
// Remove any children that get removed from the registry | ||
let method = Callable::from_object_method(&ptr, "remove_child"); | ||
self.registry.connect("child_removed".into(), method); | ||
|
||
self.initialized = true; | ||
} | ||
self.registry.bind_mut().process(delta); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters