#world #bevy #component #entities #utilities #direct #access

micro_bevy_world_utils

Handy, reusable utilities for working with direct world access in a Bevy exclusive system

5 releases (3 breaking)

0.4.0 Feb 25, 2024
0.3.0 Jul 22, 2023
0.2.1 Apr 21, 2023
0.2.0 Apr 21, 2023
0.1.0 Nov 18, 2022

#665 in Game dev

34 downloads per month

Apache-2.0

13KB
175 lines

Bevy World Utils

https://crates.io/crates/micro_bevy_world_utils https://docs.rs/micro_bevy_world_utils

Handy, reusable utilities for working with direct world access in a Bevy exclusive system

Installation

cargo add micro_bevy_world_utils

Usage

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.

Sending events

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

Sort entities based on components

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

Bevy Compatibility

world_utiles ver bevy ver
0.4 0.13
0.3 0.11
0.2 0.10
0.1 0.9

Dependencies

~10MB
~189K SLoC