0.20.0 - Ergonomics, Observer overhaul
Observer overhaul
The script loading pipeline became more idiomatic with the use of observers.
What you would do previously with TransitionListener implementations you can now do with observers registered against each machine state, for example, to react to fresh scripts being loaded you can do the following:
#![allow(unused)]
fn main() {
app.add_observer(
|trigger: On<LoadingCompleted>| println!("do stuff"),
);
}
Callback command changes
Callback commands now accept a post_callback function pointer which can be set to execute some logic right after the callback runs, to make working with observers and callbacks easier in general.
Ironing out edge cases in the script lifecycle
Contexts are now stored in a Context enum which also contains the “state” of the context. Contexts which are being processed by the pipeline will be marked as loading/reloading or unloading, allowing us to have more information when trying to run callbakcs against these.
Callbacks which are loading or unloading for example, will not have callbacks issued to them generally.
Renaming Reflection Rroxies
Val<T>, Ref<T> and Mut<T> have been renamed to prevent clashes with native bevy types, as well as save a few keystrokes.
You should use: V<T>, R<T> and M<T> instead
Addition of logging bindings
Standard log_info, log_debug, log_trace, log_warn and log_error functions are now available in scripts by default
Variadic bindings & Support for multiple return values
The ArgMeta trait now includes: variadic() -> bool which if true, allows an argument in a binding to capture all remaining arguments from the call (effectively only usable as the last argument).
This is implemented by the brand new VariadicTuple type, which is an untyped wrapper for a variable amount of non-homogenous values.
New variants in the TypedThrough and LAD file format have ben added to represent variadics, and lua definition files generated from these will support them.
Two bindings have been added: pack_args and unpack_args to allow script code to directly create/unpack tuple variants if necessary. However for languages like Lua, supporting multiple return values, ScriptValue::Tuple variants (which is what we produce to represent variadic returns), are converted to many return values naturally.
New VecDeque impls
VecDeque now implements various BMS traits and can be used in bindings as a normal argument.