[][src]Trait amethyst_tiles::Map

pub trait Map {
    fn tile_dimensions(&self) -> &Vector3<u32>;
fn dimensions(&self) -> &Vector3<u32>;
fn origin(&self) -> &Point3<f32>;
fn set_sprite_sheet(&mut self, sprite_sheet: Option<Handle<SpriteSheet>>);
fn to_world(
        &self,
        coord: &Point3<u32>,
        map_transform: Option<&Transform>
    ) -> Vector3<f32>;
fn to_tile(
        &self,
        coord: &Vector3<f32>,
        map_transform: Option<&Transform>
    ) -> Result<Point3<u32>, TileOutOfBoundsError>;
fn transform(&self) -> &Matrix4<f32>;
fn encode(&self, coord: &Point3<u32>) -> Option<u32>;
fn encode_raw(&self, coord: &(u32, u32, u32)) -> Option<u32>;
fn decode(&self, morton: u32) -> Option<Point3<u32>>;
fn decode_raw(&self, morton: u32) -> Option<(u32, u32, u32)>; }

Trait for providing access to an underlying storage type of a 3-dimensional Tile data. This is abstracted to provide for allowing more underlying storage types in the future beyond a flat array, such as networking, chunking, etc.

Required methods

fn tile_dimensions(&self) -> &Vector3<u32>

The world-space (Amethyst) dimensions of a single tile in this map space (1x1x1). This is used to scale our sprites to the world coordinate space. This should usually be the tile sprite dimensions. Beware, Z-size is taken into consideration as well so you will usually want to se Z-size to 1.

fn dimensions(&self) -> &Vector3<u32>

The dimensions of this map instance.

fn origin(&self) -> &Point3<f32>

The origin coordinate of this map instance. Usually 0,0,0. This is allowed for offseting the map off an origin.

fn set_sprite_sheet(&mut self, sprite_sheet: Option<Handle<SpriteSheet>>)

Set the sprite sheet handle which the tile render pass should use for rendering this map.

fn to_world(
    &self,
    coord: &Point3<u32>,
    map_transform: Option<&Transform>
) -> Vector3<f32>

Convert a tile coordinate Point3<u32> to an amethyst world-coordinate space coordinate Vector3<f32> This performs an inverse matrix transformation of the world coordinate, scaling and translating using this maps origin and tile_dimensions respectively. If the tile map entity has a transform component, then it also translates the point using the it's transform.

fn to_tile(
    &self,
    coord: &Vector3<f32>,
    map_transform: Option<&Transform>
) -> Result<Point3<u32>, TileOutOfBoundsError>

Convert an amethyst world-coordinate space coordinate Vector3<f32> to a tile coordinate Point3<u32> This performs an inverse matrix transformation of the world coordinate, scaling and translating using this maps origin and tile_dimensions respectively. If the tile map entity has a transform component, then it also translates the point using the it's transform.

Errors

Returns a TileOutOfBoundsError if the coordinate is not within the bounds of the tiles

fn transform(&self) -> &Matrix4<f32>

Returns the Matrix4 transform which was created for transforming between world and tile coordinate spaces.

fn encode(&self, coord: &Point3<u32>) -> Option<u32>

Call the underlying coordinate encoder for this map instance, which should always reduce to a u32 integer.

fn encode_raw(&self, coord: &(u32, u32, u32)) -> Option<u32>

Call the underlying coordinate encoder for this map instance, which should always reduce to a u32 integer.

fn decode(&self, morton: u32) -> Option<Point3<u32>>

Call the underlying coordinate decoder for this map instance, which should always convert a u32 to a tile-space coordinate.

fn decode_raw(&self, morton: u32) -> Option<(u32, u32, u32)>

Call the underlying coordinate decoder for this map instance, which should always convert a u32 to a tile-space coordinate.

Loading content...

Implementors

impl<T: Tile, E: CoordinateEncoder> Map for TileMap<T, E>[src]

Loading content...