bevy_exclusive_with 0.1.0

A Bevy plugin to define exclusive sets of components for ergonomic querying.
Documentation
  • Coverage
  • 100%
    3 out of 3 items documented2 out of 3 items with examples
  • Size
  • Source code size: 57.11 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 2.69 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 2m 18s Average build duration of successful builds.
  • all releases: 2m 18s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • jannik4/bevy_exclusive_with
    2 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • jannik4

bevy_exclusive_with

License Build Status crates.io docs.rs

A Bevy plugin to define exclusive sets of components for ergonomic querying.

This can help you to define a set of components that should be mutually exclusive on entities, and then query for them in the same system without getting conflicts.
Caveat: This does not actually enforce the exclusivity when inserting/mutating components, but just helps you to query them without conflicts. A complete solution would require Archetype Invariants.

Usage

use bevy::prelude::*;
use bevy_exclusive_with::*;

// Some components you want to query exclusively
#[derive(Component)]
struct ArcherTower;

#[derive(Component)]
struct CannonTower;

#[derive(Component)]
struct MagicTower;

// Define the set of exclusive components
struct Towers;

exclusive_set!(Towers: ArcherTower, CannonTower, MagicTower);

// Query for them in the same system
fn system(
    _archer_towers: Query<&mut Transform, ExclusiveWith<Towers, ArcherTower>>,
    _cannon_towers: Query<&mut Transform, ExclusiveWith<Towers, CannonTower>>,
    _magic_towers: Query<&mut Transform, ExclusiveWith<Towers, MagicTower>>,
) {}

License

Licensed under either of

at your option.