Expand description
§bevy_exclusive_with
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
- Apache License, Version 2.0 (LICENSE-APACHE-2.0 or http://www.apache.org/licenses/LICENSE-2.0)
- MIT License (LICENSE-MIT or http://opensource.org/licenses/MIT)
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§
- Exclusive
With - A
QueryFilterthat ensures that the queried entity has exactly the componentCfrom the exclusive setS.