Skip to main content

OptionTileSet

Struct OptionTileSet 

Source
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>

Source

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

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

Source

pub fn all_tiles(&self) -> TileSetHandleIterator<'_>

Iterate all valid tile handles.

Source

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.

Source

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.

Source

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.

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.

Methods from Deref<Target = Option<&'a mut TileSet>>§

1.0.0 · Source

pub fn is_some(&self) -> bool

Returns true if the option is a Some value.

§Examples
let x: Option<u32> = Some(2);
assert_eq!(x.is_some(), true);

let x: Option<u32> = None;
assert_eq!(x.is_some(), false);
1.0.0 · Source

pub fn is_none(&self) -> bool

Returns true if the option is a None value.

§Examples
let x: Option<u32> = Some(2);
assert_eq!(x.is_none(), false);

let x: Option<u32> = None;
assert_eq!(x.is_none(), true);
1.0.0 · Source

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.33.0 · Source

pub fn as_pin_ref(self: Pin<&Option<T>>) -> Option<Pin<&T>>

Converts from Pin<&Option<T>> to Option<Pin<&T>>.

1.33.0 · Source

pub fn as_pin_mut(self: Pin<&mut Option<T>>) -> Option<Pin<&mut T>>

Converts from Pin<&mut Option<T>> to Option<Pin<&mut T>>.

1.75.0 · Source

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 · Source

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);
1.0.0 · Source

pub fn iter(&self) -> Iter<'_, T>

Returns an iterator over the possibly contained value.

§Examples
let x = Some(4);
assert_eq!(x.iter().next(), Some(&4));

let x: Option<u32> = None;
assert_eq!(x.iter().next(), None);

Trait Implementations§

Source§

impl<'a> Deref for OptionTileSet<'a>

Source§

type Target = Option<&'a mut TileSet>

The resulting type after dereferencing.
Source§

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

Dereferences the value.

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 into_any(self: Box<T>) -> Box<dyn Any>

Converts 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>

Converts 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)

Converts &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)

Converts &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
where T: Any + Send,

Source§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

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

Source§

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

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> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_sync(self: Box<T>) -> Box<dyn Any + Send + Sync>

Converts Box<Trait> (where Trait: DowncastSync) to Box<dyn Any + Send + Sync>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

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

Converts Arc<Trait> (where Trait: DowncastSync) to Arc<Any>, which can then be downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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<F, T> IntoSample<T> for F
where T: FromSample<F>,

Source§

fn into_sample(self) -> T

Source§

impl<T, U> ObjectOrVariant<T> for U

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<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> 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

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more