OptionTileSet

Struct OptionTileSet 

Source
pub struct OptionTileSet<'a>(/* private fields */);
Expand description

Maybe a TileSet, maybe not, depending on whether the resource was successfully loaded. If it is not a TileSet, its methods pretend it is an empty TileSet.

Implementations§

Source§

impl<'a> OptionTileSet<'a>

Source

pub fn as_ref(&'a self) -> Option<&'a TileSet>

A reference to the underlying TileSet if it was successfully loaded.

Source

pub fn properties(&self) -> &[TileSetPropertyLayer]

Slice containing the properties of this tile set, or an empty slice if the tile set is not loaded.

Source

pub fn colliders(&self) -> &[TileSetColliderLayer]

Slice containing the colliders of this tile set, or an empty slice if the tile set is not loaded.

Source

pub fn collider_color(&self, uuid: Uuid) -> Option<Color>

The color of the collider layer with the given uuid.

Source

pub fn tile_collider( &self, handle: TileDefinitionHandle, uuid: Uuid, ) -> &TileCollider

The collider of the given tile.

Source

pub fn tile_color(&self, handle: TileDefinitionHandle) -> Option<Color>

The color of the given tile.

Source

pub fn tile_data(&self, handle: TileDefinitionHandle) -> Option<&TileData>

The data of the given tile.

Source

pub fn tile_bounds( &self, handle: TileDefinitionHandle, ) -> Option<&TileMaterialBounds>

The material and bounds of the given tile, if it stores its own material and bounds because it is a freeform tile.

Source

pub fn tile_redirect( &self, handle: TileDefinitionHandle, ) -> Option<TileDefinitionHandle>

The redirect target of the given tile. When a tile set tile does not contain its own data, but instead it points toward a tile elsewhere in the set, this method returns the TileDefinitionHandle of that other tile.

Source

pub fn keys_on_page(&self, page: Vector2<i32>) -> Vec<Vector2<i32>>

Generate a list of all tile positions in the given page.

Source

pub fn page_keys(&self) -> Vec<Vector2<i32>>

Generate a list of all page positions.

Source

pub fn has_tile_at(&self, page: Vector2<i32>, tile: Vector2<i32>) -> bool

True if there is a tile at the given position on the given page.

Source

pub fn page_icon(&self, page: Vector2<i32>) -> Option<TileDefinitionHandle>

The handle of the icon that represents the given page.

Source

pub fn property_name_to_uuid(&self, name: &ImmutableString) -> Option<Uuid>

Get the UUID of the property with the given name, if that property exists.

Source

pub fn collider_name_to_uuid(&self, name: &ImmutableString) -> Option<Uuid>

Get the UUID of the collider with the given name, if that collider exists.

Source

pub fn find_property(&self, uuid: Uuid) -> Option<&TileSetPropertyLayer>

Find a property layer by its UUID.

Source

pub fn find_collider(&self, uuid: Uuid) -> Option<&TileSetColliderLayer>

Find a collider layer by its UUID.

Source

pub fn rebuild_transform_sets(&mut self)

Find every transform set tile handle in this set. A transform set tile reference is a tile with data that includes transform_tile with some value. The given function will be called as func(source_tile, transform_tile) where source_tile is the handle of the tile containing the data.

Source

pub fn rebuild_animations(&mut self)

Iterate through the tiles of every animation page and establish the connection between the tiles of other pages and their corresponding position in an animation page. This should happen after any animation page is changed and before it is next used.

Source

pub fn preview_texture(&self) -> Option<TextureResource>

Find a texture from some material page to serve as a preview for the tile set.

Source

pub fn get_page(&self, position: Vector2<i32>) -> Option<&TileSetPage>

Get the page at the given position.

Source

pub fn get_page_mut( &mut self, position: Vector2<i32>, ) -> Option<&mut TileSetPage>

Get the page at the given position.

Source

pub fn is_valid_tile(&self, handle: TileDefinitionHandle) -> bool

Returns true if the given handle points to a tile definition.

Source

pub fn get_abstract_tile( &self, page: Vector2<i32>, tile: Vector2<i32>, ) -> Option<AbstractTile>

The tile at the given page and tile coordinates.

Source

pub fn get_transformed_render_data( &self, trans: OrthoTransformation, handle: TileDefinitionHandle, ) -> Option<TileRenderData>

The render data for the tile at the given handle after applying the transform.

Source

pub fn get_tile_render_data( &self, position: ResourceTilePosition, ) -> Option<TileRenderData>

Return the TileRenderData needed to render the tile at the given handle. The handle is redirected if it refers to a reference to another tile. If a reference is redirected and the resulting handle does not point to a tile definition, then TileRenderData::missing_tile() is returned to that an error tile will be rendered. If the given handle does not point to a reference and it does not point to a tile definition, then None is returned since nothing should be rendered.

Source

pub fn get_tile_collider( &self, handle: TileDefinitionHandle, uuid: Uuid, ) -> Option<&TileCollider>

The tile collider with the given UUID for the tile at the given handle.

Source

pub fn palette_render_loop<F>( &self, stage: TilePaletteStage, page: Vector2<i32>, func: F, )

Loop through the tiles of the given page and find the render data for each tile, then passes it to the given function.

Source

pub fn tile_collider_loop<F>(&self, page: Vector2<i32>, func: F)

Loop through the tiles of the given page and find each of the tile colliders on each tile, then pass the collider to the given function along with the collider’s UUID and color.

Source

pub fn redirect_handle( &self, position: ResourceTilePosition, ) -> Option<TileDefinitionHandle>

Some tiles in a tile set are references to tiles elsewhere in the tile set. In particular, the tiles of a transform set page all contain references to other pages, and the page tiles are also references. If this method is given the position of one of these reference tiles, then it returns the handle of the referenced tile. If the given position points to a tile without a redirect, then the tile’s handle is returned. If the given position points to a non-existent page or a non-existent tile, then None is returned.

Source

pub fn get_transform_tile_source( &self, handle: TileDefinitionHandle, ) -> Option<TileDefinitionHandle>

If the given handle refers to a transform set page, find the tile on that page and return the handle of wherever the tile comes from originally. Return None if the page is not a transform set or there is no tile at that position.

Source

pub fn get_definition( &self, handle: TileDefinitionHandle, ) -> Option<TileDefinition>

Returns a clone of the full definition of the tile at the given handle, if possible. Use TileSet::get_tile_data if a clone is not needed.

Source

pub fn get_transformed_definition( &self, trans: OrthoTransformation, handle: TileDefinitionHandle, ) -> Option<TileDefinition>

Return a copy of the definition of the tile at the given handle with the given transformation applied.

Source

pub fn get_tile_bounds( &self, position: ResourceTilePosition, ) -> Option<TileMaterialBounds>

Get the tile definition at the given position.

Source

pub fn property_value( &self, handle: TileDefinitionHandle, property_id: Uuid, ) -> Option<TileSetPropertyValue>

The value of the property with the given UUID for the given tile.

Source

pub fn get_tile_data(&self, position: ResourceTilePosition) -> Option<&TileData>

Get the tile data at the given position.

Source

pub fn get_tile_data_mut( &mut self, handle: TileDefinitionHandle, ) -> Option<&mut TileData>

Get the tile data at the given position.

Source

pub fn get_transformed_version( &self, transform: OrthoTransformation, handle: TileDefinitionHandle, ) -> Option<TileDefinitionHandle>

Finds the handle of the tile that represents a transformed version of the tile at the given handle, if such a tile exists. The given tile needs to have a transform_tile in its data, that handle needs to point to a transform set page, and that page needs to have a tile in the position corresponding to the desired transform relative to the transform_tile position. All 8 possible transforms are grouped together in 4x2 rectangles within each transform set page, and every transformation is possible so long as all 8 cells are filled with tiles. Otherwise, None is returned.

Source

pub fn get_animated_version( &self, time: f32, handle: TileDefinitionHandle, ) -> Option<TileDefinitionHandle>

The handle of the tile in the animation sequence starting from the given tile handle at the given time, or none if the given handle is not part of any animation sequence.

Source

pub fn get_tiles<I: Iterator<Item = Vector2<i32>>>( &self, stage: TilePaletteStage, page: Vector2<i32>, iter: I, tiles: &mut Tiles, )

Get the tile definition handles for all of the given coordinates on the given page.

Source

pub fn pages_bounds(&self) -> OptionTileRect

The bounding rect of the pages.

Source

pub fn tiles_bounds( &self, stage: TilePaletteStage, page: Vector2<i32>, ) -> OptionTileRect

The bounding rect of the tiles of the given page.

Source

pub fn is_free_at(&self, position: ResourceTilePosition) -> bool

Returns true if the tile set is unoccupied at the given position.

Auto Trait Implementations§

§

impl<'a> Freeze for OptionTileSet<'a>

§

impl<'a> !RefUnwindSafe for OptionTileSet<'a>

§

impl<'a> Send for OptionTileSet<'a>

§

impl<'a> Sync for OptionTileSet<'a>

§

impl<'a> Unpin for OptionTileSet<'a>

§

impl<'a> !UnwindSafe for OptionTileSet<'a>

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> AsyncTaskResult for T
where T: Any + Send + 'static,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

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> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Converts self reference as a reference to Any. Could be used to downcast a trait object to a particular type.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Converts self reference as a reference to Any. Could be used to downcast a trait object to a particular type.
Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> FieldValue for T
where T: 'static,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Casts self to a &dyn Any
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V