Expand description
An extendable system made up of autonomous execution services known as nodes organized in a tree of processes. Inspired by Godot!
A simple node implementation will look like the following:
ⓘ
use node_tree::prelude::*;
class! {
/// Documentation and attributes are supported!
pub dec NodeName;
/// A signal can be connected to node functions and emitted.
/// Safety is guaranteed via the scene tree.
pub sig on_event(param_name: Type, ..);
/// Constants are supported.
const SOME_CONST: &str = "Hello";
/// Fields can be defined like so, with default or without default values.
let field_uninit: u8;
let field_initialized: String = "These are not constant expressions!".to_string();
// Fields can have special attributes, like so:
default let field_default: u8; // Will automatically initialize to zero.
unique let field_unique: *mut c_void; // When cloned or serialized, this will safetly be initialized as a `None` value.
// Exportable fields will be saved and loaded from whenever a node scene is serialized.
// Note: All exported types will need to implement the `Exportable` trait.
export let some_parameter: String;
export default let some_parameter_default: bool;
// Hooks are any system functions that can be overridden.
// This include the constructor `_init()`, `loaded()`, `ready()`, `process()`, `terminal()`, and `process_mode()`.
/// The constructor may only need to be implemented if there exists fields that do not have
/// a default value.
/// Note that this macro will automatically create a `new()` invokation, even without a
/// predefined `_init()` hook. All attributes given to this hook will be transferred to the
/// `new()` function.
hk _init(starter_value: u8) {
// Initialize a value by creating a variable with the same field name:
let field_uninit: u8 = starter_value;
}
/// Functions can be declared as per usual.
fn foo(bar: Type) -> Type {
todo!();
}
}
Re-exports§
pub use ctor;
Modules§
- prelude
- Contains everything you’ll need to create and handle Nodes and NodeTrees. You’ll probably want to import all from this module.
- services
- structs
- traits
- trees
- utils
Macros§
- debug
- A simple macro which is compatible with Rust’s format syntax used in macros like
print!
,println!
, andformat!
. Prints debug info to the logger. - error
- A simple macro which is compatible with Rust’s format syntax used in macros like
print!
,println!
, andformat!
. Prints a panic to the logger and causes a crash. - info
- A simple macro which is compatible with Rust’s format syntax used in macros like
print!
,println!
, andformat!
. Prints info to the logger. - nodepath
- A simple macro which is compatible with Rust’s format syntax used in macros like
print!
,println!
, andformat!
. Creates a `NodePath from the passed in syntax. - warn
- A simple macro which is compatible with Rust’s format syntax used in macros like
print!
,println!
, andformat!
. Prints a warning to the logger.