Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rparrett/bevy_two_entities
A tiny crate offering a few convenience traits for working with Bevy queries and exactly two Entities.
https://github.com/rparrett/bevy_two_entities
bevy game-development rust
Last synced: about 1 month ago
JSON representation
A tiny crate offering a few convenience traits for working with Bevy queries and exactly two Entities.
- Host: GitHub
- URL: https://github.com/rparrett/bevy_two_entities
- Owner: rparrett
- License: other
- Created: 2024-02-19T15:31:54.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2024-07-16T18:00:17.000Z (4 months ago)
- Last Synced: 2024-09-27T07:04:27.953Z (about 2 months ago)
- Topics: bevy, game-development, rust
- Language: Rust
- Homepage:
- Size: 52.7 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# bevy_two_entities
[![crates.io](https://img.shields.io/crates/v/bevy_two_entities.svg)](https://crates.io/crates/bevy_two_entities)
[![docs](https://docs.rs/bevy_two_entities/badge.svg)](https://docs.rs/bevy_two_entities)
[![Following released Bevy versions](https://img.shields.io/badge/Bevy%20tracking-released%20version-lightblue)](https://bevyengine.org/learn/book/plugin-development/#main-branch-tracking)A tiny crate offering a few convenience traits on Bevy's `Query` and `(&Query, &Query)` for scenarios involving exactly two entities.
## Examples
```rust
fn game_over(
collisions: Query<&Collision>,
players: Query<(), With>,
enemies: Query<(), With>,
mut next_state: ResMut>,
) {
for collision in &collisions {
if (&players, &enemies).both(collision.0, collision.1) {
next_state.set(GameState::GameOver);
}
}
}
``````rust
fn damage_enemy(
collisions: Query<&Collision>,
players: Query<(), With>,
mut enemies: Query<&mut HitPoints, With>,
) {
for collision in &collisions {
let mut queries = (&players, &mut enemies);
let Some((_, mut enemy_hp)) = queries.get_both_mut(collision.0, collision.1) else {
continue;
};enemy_hp.0 -= 1;
}
}
```## Compatibility
| `bevy_two_entities` | `bevy` |
| :-- | :-- |
| `0.2` | `0.14` |
| `0.1` | `0.13` |