Skip to main content

Crate bevy_exclusive_with

Crate bevy_exclusive_with 

Source
Expand description

§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.

Macros§

exclusive_set
Macro to define an exclusive set of components. Requires at least two components. Components are not required to be defined locally and may originate from external crates.

Structs§

ExclusiveWith
A QueryFilter that ensures that the queried entity has exactly the component C from the exclusive set S.