Skip to content

Commit

Permalink
Merge branch 'main' into move-render-settings
Browse files Browse the repository at this point in the history
  • Loading branch information
StarArawn committed Feb 11, 2024
2 parents 71d2884 + 86549e9 commit 8bbafcd
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 29 deletions.
4 changes: 2 additions & 2 deletions src/helpers/hex_grid/axial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ pub const UNIT_R: AxialPos = AxialPos { q: 0, r: -1 };
pub const UNIT_S: AxialPos = AxialPos { q: 1, r: -1 };

impl AxialPos {
pub fn new(q: i32, r: i32) -> Self {
pub const fn new(q: i32, r: i32) -> Self {
Self { q, r }
}

Expand Down Expand Up @@ -485,7 +485,7 @@ pub struct FractionalAxialPos {
}

impl FractionalAxialPos {
pub fn new(q: f32, r: f32) -> Self {
pub const fn new(q: f32, r: f32) -> Self {
Self { q, r }
}

Expand Down
4 changes: 2 additions & 2 deletions src/helpers/hex_grid/cube.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ impl Mul<CubePos> for u32 {
}

impl CubePos {
pub fn new(q: i32, r: i32, s: i32) -> Self {
pub const fn new(q: i32, r: i32, s: i32) -> Self {
Self { q, r, s }
}

Expand Down Expand Up @@ -139,7 +139,7 @@ impl From<FractionalAxialPos> for FractionalCubePos {
}

impl FractionalCubePos {
pub fn new(q: f32, r: f32, s: f32) -> Self {
pub const fn new(q: f32, r: f32, s: f32) -> Self {
Self { q, r, s }
}

Expand Down
8 changes: 4 additions & 4 deletions src/helpers/hex_grid/offset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub struct RowOddPos {
}

impl RowOddPos {
pub fn new(q: i32, r: i32) -> Self {
pub const fn new(q: i32, r: i32) -> Self {
Self { q, r }
}

Expand Down Expand Up @@ -105,7 +105,7 @@ pub struct RowEvenPos {
}

impl RowEvenPos {
pub fn new(q: i32, r: i32) -> Self {
pub const fn new(q: i32, r: i32) -> Self {
Self { q, r }
}

Expand Down Expand Up @@ -196,7 +196,7 @@ pub struct ColOddPos {
}

impl ColOddPos {
pub fn new(q: i32, r: i32) -> Self {
pub const fn new(q: i32, r: i32) -> Self {
Self { q, r }
}

Expand Down Expand Up @@ -287,7 +287,7 @@ pub struct ColEvenPos {
}

impl ColEvenPos {
pub fn new(q: i32, r: i32) -> Self {
pub const fn new(q: i32, r: i32) -> Self {
Self { q, r }
}

Expand Down
2 changes: 1 addition & 1 deletion src/helpers/square_grid/diamond.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ impl From<&SquarePos> for DiamondPos {
}

impl DiamondPos {
pub fn new(x: i32, y: i32) -> Self {
pub const fn new(x: i32, y: i32) -> Self {
Self { x, y }
}

Expand Down
2 changes: 1 addition & 1 deletion src/helpers/square_grid/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ impl From<StaggeredPos> for SquarePos {
}

impl SquarePos {
pub fn new(x: i32, y: i32) -> Self {
pub const fn new(x: i32, y: i32) -> Self {
Self { x, y }
}

Expand Down
2 changes: 1 addition & 1 deletion src/helpers/square_grid/staggered.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ impl Mul<StaggeredPos> for i32 {
}

impl StaggeredPos {
pub fn new(x: i32, y: i32) -> Self {
pub const fn new(x: i32, y: i32) -> Self {
Self { x, y }
}

Expand Down
14 changes: 7 additions & 7 deletions src/map/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ pub struct TilemapSize {
}

impl TilemapSize {
pub fn new(x: u32, y: u32) -> Self {
pub const fn new(x: u32, y: u32) -> Self {
Self { x, y }
}

pub fn count(&self) -> usize {
pub const fn count(&self) -> usize {
(self.x * self.y) as usize
}
}
Expand Down Expand Up @@ -214,7 +214,7 @@ pub struct TilemapTileSize {
}

impl TilemapTileSize {
pub fn new(x: f32, y: f32) -> Self {
pub const fn new(x: f32, y: f32) -> Self {
Self { x, y }
}
}
Expand Down Expand Up @@ -259,7 +259,7 @@ pub struct TilemapGridSize {
}

impl TilemapGridSize {
pub fn new(x: f32, y: f32) -> Self {
pub const fn new(x: f32, y: f32) -> Self {
Self { x, y }
}
}
Expand Down Expand Up @@ -304,11 +304,11 @@ impl From<TilemapSpacing> for Vec2 {
}

impl TilemapSpacing {
pub fn new(x: f32, y: f32) -> Self {
pub const fn new(x: f32, y: f32) -> Self {
Self { x, y }
}

pub fn zero() -> Self {
pub const fn zero() -> Self {
Self { x: 0.0, y: 0.0 }
}
}
Expand All @@ -322,7 +322,7 @@ pub struct TilemapTextureSize {
}

impl TilemapTextureSize {
pub fn new(x: f32, y: f32) -> Self {
pub const fn new(x: f32, y: f32) -> Self {
Self { x, y }
}
}
Expand Down
16 changes: 8 additions & 8 deletions src/render/extract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -383,27 +383,27 @@ pub fn extract(

pub fn extract_removal(
mut commands: Commands,
removed_tiles_query: Extract<Query<&RemovedTileEntity>>,
removed_maps_query: Extract<Query<&RemovedMapEntity>>,
removed_tiles_query: Extract<Query<(Entity, &RemovedTileEntity)>>,
removed_maps_query: Extract<Query<(Entity, &RemovedMapEntity)>>,
) {
let mut removed_tiles: Vec<(Entity, ExtractedRemovedTileBundle)> = Vec::new();
for entity in removed_tiles_query.iter() {
for (entity, removed) in removed_tiles_query.iter() {
removed_tiles.push((
entity.0,
entity,
ExtractedRemovedTileBundle {
tile: ExtractedRemovedTile { entity: entity.0 },
tile: ExtractedRemovedTile { entity: removed.0 },
},
));
}

commands.insert_or_spawn_batch(removed_tiles);

let mut removed_maps: Vec<(Entity, ExtractedRemovedMapBundle)> = Vec::new();
for entity in removed_maps_query.iter() {
for (entity, removed) in removed_maps_query.iter() {
removed_maps.push((
entity.0,
entity,
ExtractedRemovedMapBundle {
map: ExtractedRemovedMap { entity: entity.0 },
map: ExtractedRemovedMap { entity: removed.0 },
},
));
}
Expand Down
4 changes: 2 additions & 2 deletions src/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ pub struct DefaultSampler(ImageSamplerDescriptor);
pub(crate) struct RenderChunkSize(UVec2);

impl RenderChunkSize {
pub fn new(chunk_size: UVec2) -> RenderChunkSize {
pub const fn new(chunk_size: UVec2) -> RenderChunkSize {
RenderChunkSize(chunk_size)
}

Expand Down Expand Up @@ -106,7 +106,7 @@ impl Plugin for TilemapRenderingPlugin {
app.add_systems(Update, set_texture_to_copy_src);

app.add_systems(First, clear_removed);
app.add_systems(PostUpdate, (removal_helper_tilemap, removal_helper));
app.add_systems(PostUpdate, (removal_helper, removal_helper_tilemap));

app.add_plugins(MaterialTilemapPlugin::<StandardTilemapMaterial>::default());

Expand Down
2 changes: 1 addition & 1 deletion src/tiles/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub struct TilePos {
}

impl TilePos {
pub fn new(x: u32, y: u32) -> Self {
pub const fn new(x: u32, y: u32) -> Self {
Self { x, y }
}

Expand Down

0 comments on commit 8bbafcd

Please sign in to comment.