Struct InfiniteTileLayer

Source
pub struct InfiniteTileLayer<'map> { /* private fields */ }
Expand description

A TileLayer with no bounds, internally stored using Chunks.

Implementations§

Source§

impl<'map> InfiniteTileLayer<'map>

Source

pub fn map(&self) -> &'map Map

Get the map this object is from.

Source§

impl<'map> InfiniteTileLayer<'map>

Source

pub fn get_tile(&self, x: i32, y: i32) -> Option<LayerTile<'map>>

Obtains the tile present at the position given.

If the position is empty, this function will return None.

Source

pub fn chunks( &self, ) -> impl ExactSizeIterator<Item = ((i32, i32), Chunk<'map>)> + 'map

Returns an iterator over different parts of this map called Chunks.

These may not correspond with the chunks in the TMX file, as the chunk size is implementation defined (see ChunkData::WIDTH, ChunkData::HEIGHT).

The iterator item contains the position of the chunk in chunk coordinates along with a reference to the actual chunk at that position.

This iterator doesn’t have any particular order.

§Example
use tiled::ChunkData;

for (chunk_pos, chunk) in infinite_layer.chunks() {
    for x in 0..ChunkData::WIDTH as i32 {
        for y in 0..ChunkData::HEIGHT as i32 {
            if let Some(tile) = chunk.get_tile(x, y) {
                let tile_pos = (
                    chunk_pos.0 * ChunkData::WIDTH as i32 + x,
                    chunk_pos.1 * ChunkData::HEIGHT as i32 + y,
                );
                println!("At ({}, {}): {:?}", tile_pos.0, tile_pos.1, tile);
            }
        }
    }
}
Source

pub fn get_chunk(&self, x: i32, y: i32) -> Option<Chunk<'map>>

Obtains a chunk by its position. To obtain the position of the chunk that contains a tile, use ChunkData::tile_to_chunk_pos().

Methods from Deref<Target = InfiniteTileLayerData>§

Source

pub fn get_tile_data(&self, x: i32, y: i32) -> Option<&LayerTileData>

Obtains the tile data present at the position given.

If the position given is invalid or the position is empty, this function will return None.

If you want to get a Tile instead, use InfiniteTileLayer::get_tile().

Source

pub fn chunk_data( &self, ) -> impl ExactSizeIterator<Item = ((i32, i32), &ChunkData)>

Returns an iterator over only the data part of the chunks of this tile layer.

In 99.99% of cases you’ll want to use InfiniteTileLayer::chunks() instead; Using this method is only needed if you only require the tile data of the chunks (and no other utilities provided by the map-wrapped LayerTile), and you are in dire need for that extra bit of performance.

This iterator doesn’t have any particular order.

Source

pub fn get_chunk_data(&self, x: i32, y: i32) -> Option<&ChunkData>

Obtains a chunk’s data by its position. To obtain the position of the chunk that contains a tile, use ChunkData::tile_to_chunk_pos().

In 99.99% of cases you’ll want to use InfiniteTileLayer::get_chunk() instead; Using this method is only needed if you only require the tile data of the chunk (and no other utilities provided by the map-wrapped LayerTile), and you are in dire need for that extra bit of performance.

Trait Implementations§

Source§

impl<'map> Clone for InfiniteTileLayer<'map>

Source§

fn clone(&self) -> InfiniteTileLayer<'map>

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<'map> Debug for InfiniteTileLayer<'map>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'map> Deref for InfiniteTileLayer<'map>

Source§

type Target = InfiniteTileLayerData

The resulting type after dereferencing.
Source§

fn deref(&self) -> &'map Self::Target

Dereferences the value.
Source§

impl<'map> PartialEq for InfiniteTileLayer<'map>

Source§

fn eq(&self, other: &InfiniteTileLayer<'map>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'map> Copy for InfiniteTileLayer<'map>

Source§

impl<'map> StructuralPartialEq for InfiniteTileLayer<'map>

Auto Trait Implementations§

§

impl<'map> Freeze for InfiniteTileLayer<'map>

§

impl<'map> RefUnwindSafe for InfiniteTileLayer<'map>

§

impl<'map> Send for InfiniteTileLayer<'map>

§

impl<'map> Sync for InfiniteTileLayer<'map>

§

impl<'map> Unpin for InfiniteTileLayer<'map>

§

impl<'map> UnwindSafe for InfiniteTileLayer<'map>

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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.