1 unstable release
| 0.1.0 | Feb 1, 2026 |
|---|
#623 in Game dev
18KB
142 lines
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.
Dependencies
~20–34MB
~551K SLoC