🛠️ Moonshine Utilities
Collection of utilities for Bevy.
Features
Expect<T>
A decorator for QueryData which panics if it doesn't match.
This helps avoid silent failures in systems due to missing components:
use *;
use *;
;
;
Normally, expected components would just be added as required components. However, in some cases it may not be possible to add the required components, such as when dealing with third party crates or generic code.
Note that Expect<T> may also be used as a required component:
use *;
use *;
;
// Expect `A` to be present
;
In this context, Expect<T> will panic if B is ever inserted into an entity without A.
Get<T> and FromQuery
An ergonomic and generic way to process repetitive query patterns:
use *;
use *;
;
HierarchyQuery
A convenient SystemParam for traversing and querying entity hierarchies:
use *;
use HierarchyQuery;
;
;
Some useful functions include:
fn parent(&self, Entity) -> Option<Entity>fn children(&self, Entity) -> Iterator<Item = Entity>fn ancestors(&self, Entity) -> Iterator<Item = Entity>fn descendants_wide(&self, Entity) -> Iterator<Item = Entity>fn descendants_deep(&self, Entity) -> Iterator<Item = Entity>
See documentation for details.
For even more convenient hierarchy traversal, check out 🌴 Moonshine Object.
RunSystemLoop
A trait similar to RunSystemOnce which allows you to run a system loop for testing purposes:
use *;
use RunSystemLoop;
let mut world = new;
let outputs = world.run_system_loop;
assert_eq!;
assert!;
assert!;
Utility Systems
A growing collection of simple and generic systems useful for constructing larger system pipelines:
has_event<T: Event>has_resource<T: Resource>remove_resource<T: Resource>remove_resource_immediate<T: Resource>remove_all_components<T: Component>
See documentation for details and usage examples.
Installation
Add the following to your Cargo.toml:
[]
= "0.2.7"
This crate is also included as part of 🍸 Moonshine Core.
Support
Please post an issue for any bugs, questions, or suggestions.
You may also contact me on the official Bevy Discord server as @Zeenobit.