Crates.io | micro_bevy_world_utils |
lib.rs | micro_bevy_world_utils |
version | 0.5.0 |
source | src |
created_at | 2022-11-18 11:25:56.026176 |
updated_at | 2024-07-09 12:30:05.219857 |
description | Handy, reusable utilities for working with direct world access in a Bevy exclusive system |
homepage | |
repository | https://lab.lcr.gr/microhacks/micro-bevy-world-utils |
max_upload_size | |
id | 717845 |
size | 23,709 |
Handy, reusable utilities for working with direct world access in a Bevy exclusive system
cargo add micro_bevy_world_utils
Check out the docs to get a full list of functions. Each function will take at least
an &mut World
, as well as whatever parameters it is working on.
If you're working on highly branching code in an exclusive system (e.g. monolith collision handlers), instead of
creating an event writer for every possible event, just call send_event(&mut World, EventType)
; the type of
event writer to use is inferred from the event parameter
If you have two entities, and you want to figure out which one contains a certain component, or to sort based on parent components,
you can call one of the get_[specifier]_[specifier]_entities
. Check the docs for more in depth information on how these work;
at a basic level, you pass in two entities and will receive those entities back in a sorted tuple, where the left and right entities
correspond to the left and right component parameters.
E.g.: get_left_right_entities::<GroundSensor, GroundTag>(world, first_entity, second_entity)
will mean that the first returned tuple
entry has the "GroundSensor" component, and the second will have the "GroundTag" component. If the conditions cannot be fulfilled with
the given entities, the result will be None
world_utiles ver | bevy ver |
---|---|
0.5 | 0.14 |
0.4 | 0.13 |
0.3 | 0.11 |
0.2 | 0.10 |
0.1 | 0.9 |