Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,326 changes: 1,840 additions & 486 deletions Cargo.lock

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "bevy_sparse_tilemap"
description = "A Tilemap crate for the Bevy game engine with a focus on large map sizes and ECS sparse maps"
version = "0.4.0"
version = "0.5.0"
edition = "2021"
license = "MIT OR Apache-2.0"
readme = "README.md"
Expand Down Expand Up @@ -32,7 +32,7 @@ opt-level = 1
opt-level = 3

[dependencies]
bevy = { version = "0.15", default-features = false, features = [] }
bevy = { version = "0.16", default-features = false, features = [] }
bst_map_layer_derive = { version = "0.1.0" }
# thiserror = "2.0.1"
thiserror = "1.0.44"
Expand All @@ -42,7 +42,7 @@ lettuces = { version = "0.0.7" }
serde = { version = "1.0.214", optional = true }

[dev-dependencies]
bevy = { version = "0.15" }
bevy = { version = "0.16" }
rand = { version = "0.8.5" }
serde = "1.0.214"
ron = "0.8.1"
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ You should use `bevy_sparse_tilemap` if:

| BST Version | Bevy Version |
| :---------: | :----------: |
| 0.5 | 0.16 |
| 0.4 | 0.15 |
| 0.3 | 0.14 |
| 0.2 | 0.13 |
Expand Down
5 changes: 4 additions & 1 deletion examples/hexagon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ fn main() {
}),
..default()
}))
.add_plugins((LogDiagnosticsPlugin::default(), FrameTimeDiagnosticsPlugin))
.add_plugins((
LogDiagnosticsPlugin::default(),
FrameTimeDiagnosticsPlugin::default(),
))
.add_systems(Startup, (spawn_map, spawn_tiles).chain())
.add_systems(FixedUpdate, change_random_tile_color)
.insert_resource(Time::<Fixed>::from_seconds(0.1))
Expand Down
5 changes: 4 additions & 1 deletion examples/square.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ fn main() {
}),
..default()
}))
.add_plugins((LogDiagnosticsPlugin::default(), FrameTimeDiagnosticsPlugin))
.add_plugins((
LogDiagnosticsPlugin::default(),
FrameTimeDiagnosticsPlugin::default(),
))
.add_systems(Startup, (spawn_map, spawn_tiles).chain())
.init_resource::<ColorHandles>()
.run();
Expand Down
4 changes: 2 additions & 2 deletions src/hex/map_chunk_layer.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use crate::map::chunk::{ChunkCell, ChunkLayer, ChunkLayerType};
use bevy::ecs::entity::{EntityMapper, MapEntities};
use bevy::math::UVec2;
use bevy::platform::collections::hash_map::HashMap;
use bevy::prelude::{Component, Entity};
use bevy::utils::HashMap;
use lettuces::cell::Cell;
use lettuces::storage::hex::HexRectangleStorage;
use lettuces::HexOrientation;
Expand Down Expand Up @@ -56,7 +56,7 @@ where
{
fn map_entities<M: EntityMapper>(&mut self, entity_mapper: &mut M) {
for tile_entity in self.tile_entities.iter_mut() {
*tile_entity.1 = entity_mapper.map_entity(*tile_entity.1);
*tile_entity.1 = entity_mapper.get_mapped(*tile_entity.1);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/hex/map_data.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use bevy::{
math::{vec2, UVec2},
platform::collections::hash_map::HashMap,
prelude::Component,
utils::hashbrown::HashMap,
};

#[cfg(feature = "reflect")]
Expand Down Expand Up @@ -108,7 +108,7 @@ impl MapData for HexMapData {
fn break_hashmap_into_chunks<TileData, MapChunk>(
&self,
map_layer: impl MapLayer,
data: &bevy::utils::HashMap<lettuces::cell::Cell, TileData>,
data: &HashMap<lettuces::cell::Cell, TileData>,
map_size: UVec2,
max_chunk_size: UVec2,
chunk_settings: MapChunk::ChunkSettings,
Expand Down
5 changes: 4 additions & 1 deletion src/map/chunk/layer_data.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
use std::hash::Hash;

use bevy::{ecs::entity::MapEntities, math::UVec2, prelude::Entity, utils::HashMap};
use bevy::{
ecs::entity::MapEntities, math::UVec2, platform::collections::hash_map::HashMap,
prelude::Entity,
};
use lettuces::cell::Cell;

use super::ChunkCell;
Expand Down
6 changes: 3 additions & 3 deletions src/map/chunk/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ pub use crate::map::chunk::chunk_cell::ChunkCell;
pub use crate::map::chunk::chunk_pos::ChunkPos;
use crate::map::MapLayer;
use bevy::ecs::entity::{EntityMapper, MapEntities};
use bevy::platform::collections::HashMap;
use bevy::prelude::{Component, Entity, UVec2};
use bevy::utils::hashbrown::HashMap;
pub use layer_data::{ChunkLayer, ChunkLayerType};
use lettuces::cell::Cell;
use lettuces::storage::grid::Grid;
Expand Down Expand Up @@ -39,7 +39,7 @@ pub struct Chunks {
impl MapEntities for Chunks {
fn map_entities<M: EntityMapper>(&mut self, entity_mapper: &mut M) {
for tile_entity in self.chunk_entities.iter_mut() {
*tile_entity = entity_mapper.map_entity(*tile_entity);
*tile_entity = entity_mapper.get_mapped(*tile_entity);
}
}
}
Expand Down Expand Up @@ -336,7 +336,7 @@ mod tests {
map::chunk::chunk_cell::ChunkCell, map::chunk::chunk_pos::ChunkPos, map::chunk::Chunk,
};
use bevy::math::UVec2;
use bevy::utils::hashbrown::HashMap;
use bevy::platform::collections::hash_map::HashMap;
use bst_map_layer_derive::MapLayer;

#[derive(Clone, Copy, Default, PartialEq, Eq, Debug, Hash)]
Expand Down
2 changes: 1 addition & 1 deletion src/map/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ mod tilemap;

use bevy::{
math::UVec2,
platform::collections::hash_map::HashMap,
prelude::{Component, Entity},
utils::HashMap,
};
use chunk::{Chunk, ChunkLayer, ChunkPos};
use lettuces::cell::Cell;
Expand Down
4 changes: 2 additions & 2 deletions src/square/map_chunk_layer.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use crate::map::chunk::{ChunkCell, ChunkLayer, ChunkLayerType};
use bevy::ecs::entity::{EntityMapper, MapEntities};
use bevy::math::UVec2;
use bevy::platform::collections::hash_map::HashMap;
use bevy::prelude::{Component, Entity};
use bevy::utils::HashMap;
use lettuces::storage::grid::Grid;
use std::hash::{Hash, Hasher};

Expand Down Expand Up @@ -51,7 +51,7 @@ where
{
fn map_entities<M: EntityMapper>(&mut self, entity_mapper: &mut M) {
for tile_entity in self.tile_entities.iter_mut() {
*tile_entity.1 = entity_mapper.map_entity(*tile_entity.1);
*tile_entity.1 = entity_mapper.get_mapped(*tile_entity.1);
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/square/map_data.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use bevy::{
math::{vec2, UVec2},
platform::collections::hash_map::HashMap,
prelude::Component,
utils::hashbrown::HashMap,
};

#[cfg(feature = "reflect")]
Expand Down Expand Up @@ -108,7 +108,7 @@ impl MapData for SquareMapData {
fn break_hashmap_into_chunks<TileData, MapChunk>(
&self,
map_layer: impl MapLayer,
data: &bevy::utils::HashMap<lettuces::cell::Cell, TileData>,
data: &HashMap<lettuces::cell::Cell, TileData>,
map_size: UVec2,
max_chunk_size: UVec2,
chunk_settings: MapChunk::ChunkSettings,
Expand Down Expand Up @@ -176,7 +176,7 @@ mod tests {

use crate::tilemap_builder::tilemap_layer_builder::TilemapLayer;
use bevy::math::UVec2;
use bevy::utils::HashMap;
use bevy::platform::collections::hash_map::HashMap;
use bst_map_layer_derive::MapLayer;
use lettuces::cell::Cell;

Expand Down
4 changes: 2 additions & 2 deletions src/tilemap_builder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ pub mod tilemap_layer_builder;
use crate::map::chunk::{Chunk, ChunkLayer, ChunkLayerType, Chunks};
use crate::map::{MapData, MapLayer, Tilemap};
use crate::tilemap_builder::tilemap_layer_builder::TilemapLayer;
use bevy::prelude::{BuildChildren, Commands, Entity, UVec2};
use bevy::utils::HashMap;
use bevy::platform::collections::HashMap;
use bevy::prelude::{Commands, Entity, UVec2};
use std::hash::Hash;
use std::marker::PhantomData;

Expand Down
2 changes: 1 addition & 1 deletion src/tilemap_builder/tilemap_layer_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
//! and then convert those into chunks

use bevy::math::UVec2;
use bevy::platform::collections::hash_map::HashMap;
use bevy::prelude::{Bundle, Commands, Entity};
use bevy::utils::hashbrown::HashMap;
use lettuces::cell::Cell;

/// An enum that holds all the data for a tilemap layer. This layer is only used in the [`TilemapBuilder`](crate::tilemap_builder::TilemapBuilder)
Expand Down
4 changes: 2 additions & 2 deletions src/tilemap_manager/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ pub enum TilemapManagerError {
TileDataDoesNotExist,
}

impl<'w> From<QueryEntityError<'w>> for TilemapManagerError {
fn from(_: QueryEntityError<'w>) -> Self {
impl<'w> From<QueryEntityError> for TilemapManagerError {
fn from(_: QueryEntityError) -> Self {
TilemapManagerError::ChunkEntityDoesNotExist
}
}
6 changes: 3 additions & 3 deletions src/tilemap_manager/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::tilemap_manager::TilemapManagerError;
use crate::tilemap_manager::{LayerIndex, MapEntity};
use bevy::ecs::system::SystemParam;
use bevy::math::UVec2;
use bevy::prelude::{Children, Commands, DespawnRecursiveExt, Entity, Local, Query};
use bevy::prelude::{Children, Commands, Entity, Local, Query};
use lettuces::cell::Cell;
use std::hash::Hash;
use std::ops::Deref;
Expand Down Expand Up @@ -267,7 +267,7 @@ where
self.layer_index.0,
MapChunk::into_chunk_cell(cell, &chunk.chunk_settings),
) {
self.commands.entity(entity).despawn_recursive();
self.commands.entity(entity).despawn();
};

Ok(())
Expand Down Expand Up @@ -305,8 +305,8 @@ mod tests {
use crate::tilemap_manager::manager::TilemapManager;
use bevy::ecs::system::{Commands, SystemState};
use bevy::math::UVec2;
use bevy::platform::collections::hash_map::HashMap;
use bevy::prelude::World;
use bevy::utils::hashbrown::HashMap;
use bst_map_layer_derive::MapLayer;
use lettuces::cell::Cell;

Expand Down