#bevy #world #access #direct #component #utilities #events

micro_bevy_world_utils

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

6 releases (breaking)

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

#412 in Game dev

Download history 4/week @ 2024-07-16 9/week @ 2024-07-23 9/week @ 2024-07-30 11/week @ 2024-09-10 8/week @ 2024-09-17 10/week @ 2024-09-24 5/week @ 2024-10-01

284 downloads per month
Used in micro_games_macros

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.5 0.14
0.4 0.13
0.3 0.11
0.2 0.10
0.1 0.9

Dependencies

~12MB
~212K SLoC