NodeTree
NodeTree is a framework to create large scalable programs and games through a tree of processes. Each process is fully autonomous and is capable of storing its own state or data, and communicating with other processes. These processes are known as Nodes.
β οΈWARNINGβ οΈ This crate is in early development. Beware of possible bugs or safety violations.
Getting Started!
Simply either run cargo add node_tree
at the terminal directed towards the directory of your project, or add node_tree = X.X
to your cargo.toml
file.
To begin creating a program in Rust that utilizes a NodeTree
, we must first create a root Node
. In order to reduce boilerplate, we will use the included NodeSys
derive macro to implement the required Dynamic
and NodeAbstract
traits. We will then implement the Node
trait ourselves.
use *;
// Nodes require `Debug` and `Clone`.
// Example implementation of the Node trait with custom behaviours.
Finally, in order to activate our NodeTree
, we must instance the root Node
and feed it into the NodeTree
constructor.
// ...previous implementations
use TreeSimple;
Node Scenes
You may also input a NodeScene
when initializing a NodeTree
or adding a child via add_child
:
use *;
let scene: NodeScene = scene! ;
// Scenes can also be cloned, stored, and reused.
let _ = scene.clone;
Logging
Logging is also supported. Here is an example setup with an output of a warning and a crash. Note that the crash header/footer are customizable, and that the output is actually colored in a real terminal.
use *;
use TreeSimple;
About Cloning
All nodes are expected to implement the Clone
trait since there are a few implementations that depend on it, such as NodeScene
. However, it is possible to mark a field of a node so that it either has a special clone attribute or is uncloneable via provided types by this crate:
use ; // All of these types implement Deref & DerefMut!
Features
- ποΈ An easy abstraction framework for different processes to communicate and interact with each other in a scalable manner. Inspired by Godot!
- β―οΈ The ability to
pause()
andunpause()
theNodeTree
, and fine tune individualNode
behaviours for when a tree is paused/unpaused. - π‘ Various methods to communicate with other nodes, such as
owner()
,parent()
,get_child()
,children()
, andget_node()
. - π An abstracted smart pointer known as
Tp<T>
andTpDyn
which clones implicitly to reduce syntax noise and allows for low boilerplate. - π A caching system hosted on the
NodeTree
to act as a safe interface to ensureTp<T>
/TpDyn
soundness, and increase performance! - πͺ The ability to manage nodes with
add_child()
andremove_child()
. - π Includes a dynamic logging and error handling system that is deeply integrated with the node framework.
- π² Allows for the direct referencing of the
NodeTree
through a node'sroot()
function. - π Includes a method to save (TODO) and handle individual node scenes, such as the handy visual macro
scene!
.