pub trait MapData: Hash + Component {
// Required methods
fn into_chunk_pos(&self, cell: Cell) -> ChunkPos;
fn max_chunk_size(&self) -> UVec2;
fn break_data_vecs_down_into_chunk_data<TileData>(
&self,
data: &[Vec<TileData>],
chunk_pos: ChunkPos,
max_chunk_size: UVec2,
) -> Vec<Vec<TileData>>
where TileData: Clone + Copy + Sized + Default + Send + Sync + 'static;
fn break_data_vecs_into_chunks<TileData, MapChunk>(
&self,
data: &[Vec<TileData>],
max_chunk_size: UVec2,
chunk_settings: MapChunk::ChunkSettings,
) -> Vec<Vec<Chunk<MapChunk, TileData>>>
where TileData: Hash + Clone + Copy + Sized + Default + Send + Sync + 'static,
MapChunk: ChunkLayer<TileData> + Send + Sync + 'static + Default;
fn break_hashmap_into_chunks<TileData, MapChunk>(
&self,
map_layer: impl MapLayer,
data: &HashMap<Cell, TileData>,
map_size: UVec2,
max_chunk_size: UVec2,
chunk_settings: MapChunk::ChunkSettings,
) -> Vec<Vec<Chunk<MapChunk, TileData>>>
where TileData: Hash + Clone + Copy + Sized + Default + Send + Sync + 'static,
MapChunk: ChunkLayer<TileData> + Send + Sync + 'static + Default;
// Provided method
fn add_entities_to_layer<TileData, MapChunk>(
&self,
map_layer: u32,
chunks: &mut Vec<Vec<Chunk<MapChunk, TileData>>>,
entities: &HashMap<Cell, Entity>,
)
where TileData: Hash + Clone + Copy + Sized + Default + Send + Sync + 'static,
MapChunk: ChunkLayer<TileData> + Send + Sync + 'static + Default { ... }
}
Expand description
Trait that must be implemented for a map type. It consists of mandatory functions used in building new maps as well as implementing a way to convert a given Cell
into a chunk pos
Required Methods§
Sourcefn into_chunk_pos(&self, cell: Cell) -> ChunkPos
fn into_chunk_pos(&self, cell: Cell) -> ChunkPos
Sourcefn max_chunk_size(&self) -> UVec2
fn max_chunk_size(&self) -> UVec2
The maximum size that a chunk can be
Sourcefn break_data_vecs_down_into_chunk_data<TileData>(
&self,
data: &[Vec<TileData>],
chunk_pos: ChunkPos,
max_chunk_size: UVec2,
) -> Vec<Vec<TileData>>
fn break_data_vecs_down_into_chunk_data<TileData>( &self, data: &[Vec<TileData>], chunk_pos: ChunkPos, max_chunk_size: UVec2, ) -> Vec<Vec<TileData>>
Function that breaks a Vec<Vec<TileData>>
down into a Vec<Vec<TileData>>
of the given ChunkPos
chunks data
Sourcefn break_data_vecs_into_chunks<TileData, MapChunk>(
&self,
data: &[Vec<TileData>],
max_chunk_size: UVec2,
chunk_settings: MapChunk::ChunkSettings,
) -> Vec<Vec<Chunk<MapChunk, TileData>>>
fn break_data_vecs_into_chunks<TileData, MapChunk>( &self, data: &[Vec<TileData>], max_chunk_size: UVec2, chunk_settings: MapChunk::ChunkSettings, ) -> Vec<Vec<Chunk<MapChunk, TileData>>>
Function that breaks a Vec<Vec<TileData>>
into Vec<Vec<Chunk<TileData>>>
This function should:
- Create new chunks
- Insert the correct data for each chunk
- Return a
Vec<Vec<Chunk<TileData>>>
where each chunk is correctly positioned.- Correctly positioned meaning chunk 0:0 contains the tiles for cell positions 0:0 -> 0:max chunk size and max chunk size:0 and so forth for each chunk in order
Sourcefn break_hashmap_into_chunks<TileData, MapChunk>(
&self,
map_layer: impl MapLayer,
data: &HashMap<Cell, TileData>,
map_size: UVec2,
max_chunk_size: UVec2,
chunk_settings: MapChunk::ChunkSettings,
) -> Vec<Vec<Chunk<MapChunk, TileData>>>
fn break_hashmap_into_chunks<TileData, MapChunk>( &self, map_layer: impl MapLayer, data: &HashMap<Cell, TileData>, map_size: UVec2, max_chunk_size: UVec2, chunk_settings: MapChunk::ChunkSettings, ) -> Vec<Vec<Chunk<MapChunk, TileData>>>
Function that breaks a HashMap<TilePos, TileData>
into Vec<Vec<Chunk<TileData>>>
Provided Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.