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 *;
// 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
Logging is also supported. Here is an example setup with an output of a few warnings and a crash. Note that the crash header/footer are customizable, and that the output is actually colored in a real terminal.
/// Root Node
<22/04/2024 17:25:46 UTC> | [Root/1_Node/2_Node/3_Node2] | WARN | Simulating warning!
<22/04/2024 17:25:46 UTC> | [Root/1_Node/2_Node1/3_Node2] | WARN | Simulating warning!
<22/04/2024 17:25:46 UTC> | [Root/1_Node/2_Node2/3_Node2] | WARN | Simulating warning!
<22/04/2024 17:25:46 UTC> | [Root/1_Node2/2_Node/3_Node2] | PANIC! | Simulating panic!
Unfortunately the program has crashed. Please contact the development team with the following crash report as well as the attachment of the log posted during the time of the crash.
[REPORT START]
Root
├── 1_Node
│ ├── 2_Node
│ │ ├── 3_Node
│ │ ├── 3_Node1
│ │ └── 3_Node2
│ ├── 2_Node1
│ │ ├── 3_Node
│ │ ├── 3_Node1
│ │ └── 3_Node2
│ └── 2_Node2
│ ├── 3_Node
│ ├── 3_Node1
│ └── 3_Node2
├── 1_Node1
│ ├── 2_Node
│ │ ├── 3_Node
│ │ ├── 3_Node1
│ │ └── 3_Node2
│ ├── 2_Node1
│ │ ├── 3_Node
│ │ ├── 3_Node1
│ │ └── 3_Node2
│ └── 2_Node2
│ ├── 3_Node
│ ├── 3_Node1
│ └── 3_Node2
└── 1_Node2
├── 2_Node
│ ├── 3_Node
│ ├── 3_Node1
│ └── 3_Node2
├── 2_Node1
│ ├── 3_Node
│ ├── 3_Node1
│ └── 3_Node2
└── 2_Node2
├── 3_Node
├── 3_Node1
└── 3_Node2
[Same-Frame Warnings]
3_Node2 - Simulating warning!
3_Node2 - Simulating warning!
3_Node2 - Simulating warning!
[Same-Frame Panics]
3_Node2 - Simulating panic!
[REPORT END]
Time of Crash: 22/04/2024 17:25:46
Exit Code: 1
Goodbye World! (Program Exited)
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 system that is deeply integrated with the node framework.
- 🌲 Allows for the direct referencing of the
NodeTree
through a node'sroot()
function. - 📜 TODO: Includes a method to save and handle individual node scenes, such as the handy visual macro
Scene!
.