| Crates.io | bevy_cells |
| lib.rs | bevy_cells |
| version | 0.1.1 |
| created_at | 2023-11-03 22:55:55.17925+00 |
| updated_at | 2023-11-23 00:29:12.6722+00 |
| description | Bevy library for working with entities in grids. |
| homepage | https://github.com/OxidizedGames/bevy_cells |
| repository | https://github.com/OxidizedGames/bevy_cells |
| max_upload_size | |
| id | 1024733 |
| size | 184,720 |

A general purpose grided entity library meant to support tilemap libraries, or other libraries that require accessing entities in a grid based manner built on top of the aery relations crate. The goal is to keep the API surface as simple and intuitive as possible, and to avoid deferred operations/states where possible to make the structures more intuitive work with (ex: an update in one system should be seen by the following system, not the following frame.).
Currently, bevy_cells supports the following:
Upcoming features:
The basic API revolves around CellQuery's, CellCommands, and CellMapLabel's as seen below.
struct GameLayer;
impl CellMapLabel for GameLayer {
const CHUNK_SIZE: usize = 16;
}
fn move_character(
keyboard_input: Res<Input<KeyCode>>,
mut commands: Commands,
character: CellQuery<GameLayer, CellCoord, With<Character>>,
walls: CellQuery<GameLayer, (), With<Block>>,
) {
let mut cell_commands = commands.cells::<GameLayer, 2>();
let mut x = if keyboard_input.just_pressed(KeyCode::A) {
-1
} else {
0
};
x += if keyboard_input.just_pressed(KeyCode::D) {
1
} else {
0
};
let char_c = character.single();
let new_coord = [char_c[0] + x, char_c[1] + y];
if walls.get_at(new_coord).is_none() {
cell_commands.move_cell(*char_c, new_coord);
}
}
More examples can be found in the examples folder!
| Bevy version | bevy_cells verison |
|---|---|
| 0.12 | 0.1 |
| 0.11 | 0.1-dev |