bevy_tiles/lib.rs
1//! A general purpose grided entity library meant to support tilemap libraries,
2//! or other libraries that require accessing entities in a grid based manner.
3//!
4//! The goal is to keep the API surface as simple and intuitive as possible,
5//! and to avoid deferred operations/states where possible to make the structures more intuitive work with.
6//! (ex: an update in one system should be seen by the following system, not the following frame.)
7
8#![deny(missing_docs)]
9
10use bevy::app::Plugin;
11
12/// Provides chunk level utilities.
13pub mod chunks;
14/// Provides commands for interacting with tilemaps.
15pub mod commands;
16/// Provides helper functions for interacting with coordiantes.
17pub mod coords;
18/// Provides map level utilities.
19pub mod maps;
20/// Provides tile level utilities.
21pub mod tiles;
22
23/// Helper aliases for working with 2d grids
24pub mod tiles_2d {
25 use bevy::ecs::system::Commands;
26
27 /// 2d [crate::tiles::TileCoord] alias.
28 pub type TileCoord = crate::tiles::TileCoord<2>;
29
30 /// 2d [crate::tiles::TileMapQuery] alias.
31 pub type TileMapQuery<'w, 's, Q, F = ()> = crate::tiles::TileMapQuery<'w, 's, Q, F, 2>;
32
33 /// 2d [crate::chunks::ChunkCoord] alias.
34 pub type ChunkCoord = crate::chunks::ChunkCoord<2>;
35
36 /// 2d [crate::chunks::ChunkMapQuery] alias.
37 pub type ChunkMapQuery<'w, 's, Q, F = ()> = crate::chunks::ChunkMapQuery<'w, 's, Q, F, 2>;
38
39 /// 2d [crate::commands::TileMapCommands] alias.
40 pub type TileMapCommands<'a, 'w, 's, const N: usize> =
41 crate::commands::TileMapCommands<'a, 'w, 's, 2>;
42
43 /// 2d [crate::commands::TileCommandExt] alias.
44 pub trait TileCommandExt<'w, 's>: crate::commands::TileCommandExt<'w, 's, 2> {}
45
46 impl<'w, 's> TileCommandExt<'w, 's> for Commands<'w, 's> {}
47}
48
49/// Helper aliases for working with 2d grids
50pub mod tiles_3d {
51 use bevy::ecs::system::Commands;
52
53 /// 3d [crate::tiles::TileCoord] alias.
54 pub type TileCoord = crate::tiles::TileCoord<3>;
55
56 /// 3d [crate::tiles::TileMapQuery] alias.
57 pub type TileMapQuery<'w, 's, Q, F = ()> = crate::tiles::TileMapQuery<'w, 's, Q, F, 3>;
58
59 /// 3d [crate::chunks::ChunkCoord] alias.
60 pub type ChunkCoord = crate::chunks::ChunkCoord<3>;
61
62 /// 3d [crate::chunks::ChunkMapQuery] alias.
63 pub type ChunkMapQuery<'w, 's, Q, F = ()> = crate::chunks::ChunkMapQuery<'w, 's, Q, F, 3>;
64
65 /// 3d [crate::commands::TileMapCommands] alias.
66 pub type TileMapCommands<'a, 'w, 's, const N: usize> =
67 crate::commands::TileMapCommands<'a, 'w, 's, 3>;
68
69 /// 3d [crate::commands::TileCommandExt] alias.
70 pub trait TileCommandExt<'w, 's>: crate::commands::TileCommandExt<'w, 's, 3> {}
71
72 impl<'w, 's> TileCommandExt<'w, 's> for Commands<'w, 's> {}
73}
74
75/// Adds Tiles dependencies to the App.
76pub struct TilesPlugin;
77
78impl Plugin for TilesPlugin {
79 fn build(&self, _app: &mut bevy::prelude::App) {}
80}