Skip to main content

TileMap

Struct TileMap 

Source
pub struct TileMap { /* private fields */ }
Expand description

Grid-based 2D tilemap supporting O(visible) frustum-culled rendering, cached static chunk batching, and tile solidity queries.

Implementations§

Source§

impl TileMap

Tile lookup, mutation, static chunk-cache batching, and world-space queries for TileMap.

Source

pub fn empty(columns: usize, rows: usize, tile_size: f32) -> Self

Creates an empty columns x rows tilemap with cell size tile_size.

§Arguments
  • usize - Number of columns.
  • usize - Number of rows.
  • f32 - Tile width/height in world units.
§Returns
  • Self - Initialized tilemap with default air entry at index 0.
Source

pub fn add_palette_entry(&mut self, entry: TilePaletteEntry) -> u16

Registers a new palette entry and returns its assigned tile ID.

§Arguments
  • &Self - Mutable tilemap.
  • TilePaletteEntry - Visual and solidity properties.
§Returns
  • u16 - Assigned tile identifier.
Source

pub fn set_tile(&mut self, col: usize, row: usize, tile_id: u16)

Sets the tile identifier at grid coordinate (col, row).

§Arguments
  • &Self - Mutable tilemap.
  • usize - Column index.
  • usize - Row index.
  • u16 - Tile identifier.
Source

pub fn has_fresh_chunk_cache(&self) -> bool

Returns true when the retained 16x16 static chunk cache matches the current tilemap revision.

§Arguments
  • &Self - Tilemap reference.
§Returns
  • bool - Whether cached chunk batches are up to date.
Source

pub fn cached_chunks(&self) -> &[TileMapChunkBatch]

Returns the retained cached static chunk batches slice if built.

§Arguments
  • &Self - Tilemap reference.
§Returns
  • &[TileMapChunkBatch] - Cached chunk run batches.
Source

pub fn rebuild_chunk_cache(&mut self)

Rebuilds the retained 16x16 static chunk run cache merging contiguous same-color horizontal tiles to reduce draw command counts.

§Arguments
  • &Self - Mutable tilemap.
Source

pub fn tile_at(&self, col: usize, row: usize) -> u16

Reads the tile identifier at (col, row), returning 0 when out of bounds.

§Arguments
  • &Self - Tilemap reference.
  • usize - Column index.
  • usize - Row index.
§Returns
  • u16 - Tile ID at (col, row).
Source

pub fn is_solid_at_world(&self, world_pt: Point) -> bool

Returns true if the world-space point world_pt falls inside a solid tile.

§Arguments
  • &Self - Tilemap reference.
  • Point - World-space query coordinate.
§Returns
  • bool - Whether the tile at world_pt is solid.
Source

pub fn world_bounds(&self) -> Rect

Returns total world-space dimensions (width, height) of the tilemap.

§Arguments
  • &Self - Tilemap reference.
§Returns
  • Rect - World bounds rectangle starting at (0, 0).
Source§

impl TileMap

Source

pub fn get_columns(&self) -> usize

Source

pub fn get_mut_columns(&mut self) -> &mut usize

Source

pub fn set_columns(&mut self, val: usize) -> &mut Self

Source

pub fn get_rows(&self) -> usize

Source

pub fn get_mut_rows(&mut self) -> &mut usize

Source

pub fn set_rows(&mut self, val: usize) -> &mut Self

Source

pub fn get_tile_size(&self) -> f32

Source

pub fn get_mut_tile_size(&mut self) -> &mut f32

Source

pub fn set_tile_size(&mut self, val: f32) -> &mut Self

Source

pub fn get_cells(&self) -> &Vec<u16>

Source

pub fn get_mut_cells(&mut self) -> &mut Vec<u16>

Source

pub fn set_cells(&mut self, val: Vec<u16>) -> &mut Self

Source

pub fn get_palette(&self) -> &Vec<TilePaletteEntry>

Source

pub fn get_mut_palette(&mut self) -> &mut Vec<TilePaletteEntry>

Source

pub fn set_palette(&mut self, val: Vec<TilePaletteEntry>) -> &mut Self

Source

pub fn get_cache_revision(&self) -> u64

Source

pub fn get_mut_cache_revision(&mut self) -> &mut u64

Source

pub fn set_cache_revision(&mut self, val: u64) -> &mut Self

Source

pub fn get_built_revision(&self) -> u64

Source

pub fn get_mut_built_revision(&mut self) -> &mut u64

Source

pub fn set_built_revision(&mut self, val: u64) -> &mut Self

Trait Implementations§

Source§

impl Clone for TileMap

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TileMap

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.