pub struct OptionTileSet<'a>(pub Option<&'a mut TileSet>);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.
Tuple Fields§
§0: Option<&'a mut TileSet>Implementations§
Source§impl<'a> OptionTileSet<'a>
impl<'a> OptionTileSet<'a>
Sourcepub fn as_ref(&'a self) -> Option<&'a TileSet>
pub fn as_ref(&'a self) -> Option<&'a TileSet>
A reference to the underlying TileSet if it was successfully loaded.
Sourcepub fn all_tiles(&self) -> TileSetHandleIterator<'_> ⓘ
pub fn all_tiles(&self) -> TileSetHandleIterator<'_> ⓘ
Iterate all valid tile handles.
Sourcepub fn tile_property_value<T>(
&self,
handle: TileDefinitionHandle,
property_id: Uuid,
) -> Result<T, TilePropertyError>
pub fn tile_property_value<T>( &self, handle: TileDefinitionHandle, property_id: Uuid, ) -> Result<T, TilePropertyError>
The property value for the property of the given name for the tile at the given position in this tile map. If there is no tile data at the given handle or no property at the given UUID, then the default value for the property’s value type is returned.
Sourcepub fn tile_property_value_by_name(
&self,
handle: TileDefinitionHandle,
property_name: &ImmutableString,
) -> Result<TileSetPropertyValue, TilePropertyError>
pub fn tile_property_value_by_name( &self, handle: TileDefinitionHandle, property_name: &ImmutableString, ) -> Result<TileSetPropertyValue, TilePropertyError>
The property value for the property of the given name for the tile at the given position in this tile map. If there is no tile data at the given handle, then the default value for the property’s value type is returned.
Sourcepub fn tile_property_value_by_uuid_untyped(
&self,
handle: TileDefinitionHandle,
property_id: Uuid,
) -> Result<TileSetPropertyValue, TilePropertyError>
pub fn tile_property_value_by_uuid_untyped( &self, handle: TileDefinitionHandle, property_id: Uuid, ) -> Result<TileSetPropertyValue, TilePropertyError>
The property value for the property of the given UUID for the tile at the given position in this tile map. If there is no tile data at the given handle, then the default value for the property’s value type is returned.
Sourcepub fn properties(&self) -> &[TileSetPropertyLayer]
pub fn properties(&self) -> &[TileSetPropertyLayer]
Slice containing the properties of this tile set, or an empty slice if the tile set is not loaded.
Sourcepub fn colliders(&self) -> &[TileSetColliderLayer]
pub fn colliders(&self) -> &[TileSetColliderLayer]
Slice containing the colliders of this tile set, or an empty slice if the tile set is not loaded.
Sourcepub fn collider_color(&self, uuid: Uuid) -> Option<Color>
pub fn collider_color(&self, uuid: Uuid) -> Option<Color>
The color of the collider layer with the given uuid.
Sourcepub fn tile_collider(
&self,
handle: TileDefinitionHandle,
uuid: Uuid,
) -> &TileCollider
pub fn tile_collider( &self, handle: TileDefinitionHandle, uuid: Uuid, ) -> &TileCollider
The collider of the given tile.
Sourcepub fn tile_color(&self, handle: TileDefinitionHandle) -> Option<Color>
pub fn tile_color(&self, handle: TileDefinitionHandle) -> Option<Color>
The color of the given tile.
Sourcepub fn tile_data(&self, handle: TileDefinitionHandle) -> Option<&TileData>
pub fn tile_data(&self, handle: TileDefinitionHandle) -> Option<&TileData>
The data of the given tile.
Sourcepub fn tile_bounds(
&self,
handle: TileDefinitionHandle,
) -> Option<&TileMaterialBounds>
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.
Sourcepub fn tile_redirect(
&self,
handle: TileDefinitionHandle,
) -> Option<TileDefinitionHandle>
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.
Sourcepub fn keys_on_page(&self, page: Vector2<i32>) -> Vec<Vector2<i32>> ⓘ
pub fn keys_on_page(&self, page: Vector2<i32>) -> Vec<Vector2<i32>> ⓘ
Generate a list of all tile positions in the given page.
Sourcepub fn has_tile_at(&self, page: Vector2<i32>, tile: Vector2<i32>) -> bool
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.
Sourcepub fn page_icon(&self, page: Vector2<i32>) -> Option<TileDefinitionHandle>
pub fn page_icon(&self, page: Vector2<i32>) -> Option<TileDefinitionHandle>
The handle of the icon that represents the given page.
Sourcepub fn property_name_to_uuid(&self, name: &ImmutableString) -> Option<Uuid>
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.
Sourcepub fn collider_name_to_uuid(&self, name: &ImmutableString) -> Option<Uuid>
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.
Sourcepub fn find_property(&self, uuid: Uuid) -> Option<&TileSetPropertyLayer>
pub fn find_property(&self, uuid: Uuid) -> Option<&TileSetPropertyLayer>
Find a property layer by its UUID.
Sourcepub fn find_collider(&self, uuid: Uuid) -> Option<&TileSetColliderLayer>
pub fn find_collider(&self, uuid: Uuid) -> Option<&TileSetColliderLayer>
Find a collider layer by its UUID.
Sourcepub fn rebuild_transform_sets(&mut self)
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.
Sourcepub fn rebuild_animations(&mut self)
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.
Sourcepub fn preview_texture(&self) -> Option<TextureResource>
pub fn preview_texture(&self) -> Option<TextureResource>
Find a texture from some material page to serve as a preview for the tile set.
Sourcepub fn get_page(&self, position: Vector2<i32>) -> Option<&TileSetPage>
pub fn get_page(&self, position: Vector2<i32>) -> Option<&TileSetPage>
Get the page at the given position.
Sourcepub fn get_page_mut(
&mut self,
position: Vector2<i32>,
) -> Option<&mut TileSetPage>
pub fn get_page_mut( &mut self, position: Vector2<i32>, ) -> Option<&mut TileSetPage>
Get the page at the given position.
Sourcepub fn is_valid_tile(&self, handle: TileDefinitionHandle) -> bool
pub fn is_valid_tile(&self, handle: TileDefinitionHandle) -> bool
Returns true if the given handle points to a tile definition.
Sourcepub fn get_abstract_tile(
&self,
page: Vector2<i32>,
tile: Vector2<i32>,
) -> Option<AbstractTile>
pub fn get_abstract_tile( &self, page: Vector2<i32>, tile: Vector2<i32>, ) -> Option<AbstractTile>
The tile at the given page and tile coordinates.
Sourcepub fn get_transformed_render_data(
&self,
trans: OrthoTransformation,
handle: TileDefinitionHandle,
) -> Option<TileRenderData>
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.
Sourcepub fn get_tile_render_data(
&self,
position: ResourceTilePosition,
) -> Option<TileRenderData>
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.
Sourcepub fn get_tile_collider(
&self,
handle: TileDefinitionHandle,
uuid: Uuid,
) -> Option<&TileCollider>
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.
Sourcepub fn palette_render_loop<F>(
&self,
stage: TilePaletteStage,
page: Vector2<i32>,
func: F,
)
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.
Sourcepub fn tile_collider_loop<F>(&self, page: Vector2<i32>, func: F)
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.
Sourcepub fn redirect_handle(
&self,
position: ResourceTilePosition,
) -> Option<TileDefinitionHandle>
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.
Sourcepub fn get_transform_tile_source(
&self,
handle: TileDefinitionHandle,
) -> Option<TileDefinitionHandle>
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.
Sourcepub fn get_definition(
&self,
handle: TileDefinitionHandle,
) -> Option<TileDefinition>
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.
Sourcepub fn get_transformed_definition(
&self,
trans: OrthoTransformation,
handle: TileDefinitionHandle,
) -> Option<TileDefinition>
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.
Sourcepub fn get_tile_bounds(
&self,
position: ResourceTilePosition,
) -> Option<TileMaterialBounds>
pub fn get_tile_bounds( &self, position: ResourceTilePosition, ) -> Option<TileMaterialBounds>
Get the tile definition at the given position.
Sourcepub fn property_value(
&self,
handle: TileDefinitionHandle,
property_id: Uuid,
) -> Option<TileSetPropertyValue>
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.
Sourcepub fn get_tile_data(&self, position: ResourceTilePosition) -> Option<&TileData>
pub fn get_tile_data(&self, position: ResourceTilePosition) -> Option<&TileData>
Get the tile data at the given position.
Sourcepub fn get_tile_data_mut(
&mut self,
handle: TileDefinitionHandle,
) -> Option<&mut TileData>
pub fn get_tile_data_mut( &mut self, handle: TileDefinitionHandle, ) -> Option<&mut TileData>
Get the tile data at the given position.
Sourcepub fn get_transformed_version(
&self,
transform: OrthoTransformation,
handle: TileDefinitionHandle,
) -> Option<TileDefinitionHandle>
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.
Sourcepub fn get_animated_version(
&self,
time: f32,
handle: TileDefinitionHandle,
) -> Option<TileDefinitionHandle>
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.
Sourcepub fn get_tiles<I: Iterator<Item = Vector2<i32>>>(
&self,
stage: TilePaletteStage,
page: Vector2<i32>,
iter: I,
tiles: &mut Tiles,
)
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.
Sourcepub fn pages_bounds(&self) -> OptionTileRect
pub fn pages_bounds(&self) -> OptionTileRect
The bounding rect of the pages.
Sourcepub fn tiles_bounds(
&self,
stage: TilePaletteStage,
page: Vector2<i32>,
) -> OptionTileRect
pub fn tiles_bounds( &self, stage: TilePaletteStage, page: Vector2<i32>, ) -> OptionTileRect
The bounding rect of the tiles of the given page.
Sourcepub fn is_free_at(&self, position: ResourceTilePosition) -> bool
pub fn is_free_at(&self, position: ResourceTilePosition) -> bool
Returns true if the tile set is unoccupied at the given position.
Methods from Deref<Target = Option<&'a mut TileSet>>§
1.0.0 · Sourcepub fn as_ref(&self) -> Option<&T>
pub fn as_ref(&self) -> Option<&T>
Converts from &Option<T> to Option<&T>.
§Examples
Calculates the length of an Option<String> as an Option<usize>
without moving the String. The map method takes the self argument by value,
consuming the original, so this technique uses as_ref to first take an Option to a
reference to the value inside the original.
let text: Option<String> = Some("Hello, world!".to_string());
// First, cast `Option<String>` to `Option<&String>` with `as_ref`,
// then consume *that* with `map`, leaving `text` on the stack.
let text_length: Option<usize> = text.as_ref().map(|s| s.len());
println!("still can print text: {text:?}");1.75.0 · Sourcepub fn as_slice(&self) -> &[T]
pub fn as_slice(&self) -> &[T]
Returns a slice of the contained value, if any. If this is None, an
empty slice is returned. This can be useful to have a single type of
iterator over an Option or slice.
Note: Should you have an Option<&T> and wish to get a slice of T,
you can unpack it via opt.map_or(&[], std::slice::from_ref).
§Examples
assert_eq!(
[Some(1234).as_slice(), None.as_slice()],
[&[1234][..], &[][..]],
);The inverse of this function is (discounting
borrowing) [_]::first:
for i in [Some(1234_u16), None] {
assert_eq!(i.as_ref(), i.as_slice().first());
}1.40.0 · Sourcepub fn as_deref(&self) -> Option<&<T as Deref>::Target>where
T: Deref,
pub fn as_deref(&self) -> Option<&<T as Deref>::Target>where
T: Deref,
Converts from Option<T> (or &Option<T>) to Option<&T::Target>.
Leaves the original Option in-place, creating a new one with a reference
to the original one, additionally coercing the contents via Deref.
§Examples
let x: Option<String> = Some("hey".to_owned());
assert_eq!(x.as_deref(), Some("hey"));
let x: Option<String> = None;
assert_eq!(x.as_deref(), None);Trait Implementations§
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> AsyncTaskResult for T
impl<T> AsyncTaskResult for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&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 Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&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> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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 moreSource§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
Source§impl<T, U> ObjectOrVariant<T> for Uwhere
PhantomData<U>: ObjectOrVariantHelper<T, U>,
impl<T, U> ObjectOrVariant<T> for Uwhere
PhantomData<U>: ObjectOrVariantHelper<T, U>,
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.