pub enum TileBook {
Empty,
TileSet(TileSetResource),
Brush(TileMapBrushResource),
}
Expand description
Abstract source of tiles, which can either be a tile set or a brush. It is called a “book” because each of these tile resources contains pages of tiles.
Variants§
Empty
A tile resource containing no tiles.
TileSet(TileSetResource)
Getting tiles from a tile set
Brush(TileMapBrushResource)
Getting tiles from a brush
Implementations§
Source§impl TileBook
impl TileBook
Sourcepub fn page_icon(&self, position: Vector2<i32>) -> Option<TileDefinitionHandle>
pub fn page_icon(&self, position: Vector2<i32>) -> Option<TileDefinitionHandle>
The TileDefinitionHandle of the icon that represents the page at the given position.
Sourcepub fn is_tile_set(&self) -> bool
pub fn is_tile_set(&self) -> bool
Returns true if this resource is a tile set.
Sourcepub fn needs_save(&self) -> bool
pub fn needs_save(&self) -> bool
True if the resource is external and its change_count
is not zero.
Sourcepub fn save(&self) -> Result<(), Box<dyn Error>>
pub fn save(&self) -> Result<(), Box<dyn Error>>
Attempt to save the resource to its file, if it has one and if change_count
not zero.
Otherwise do nothing and return Ok to indicate success.
Sourcepub fn tile_set_ref(&self) -> Option<&TileSetResource>
pub fn tile_set_ref(&self) -> Option<&TileSetResource>
A reference to the TileSetResource, if this is a TileSetResource.
Sourcepub fn get_tile_set(&self) -> Option<TileSetResource>
pub fn get_tile_set(&self) -> Option<TileSetResource>
Returns the tile set associated with this resource. If the resource is a tile set, the return that tile set. If the resource is a brush, then return the tile set used by that brush.
Sourcepub fn get_all_tile_positions(&self, page: Vector2<i32>) -> Vec<Vector2<i32>> ⓘ
pub fn get_all_tile_positions(&self, page: Vector2<i32>) -> Vec<Vector2<i32>> ⓘ
Build a list of the positions of all tiles on the given page.
Sourcepub fn get_all_page_positions(&self) -> Vec<Vector2<i32>> ⓘ
pub fn get_all_page_positions(&self) -> Vec<Vector2<i32>> ⓘ
Build a list of the posiitons of all pages.
Sourcepub fn has_page_at(&self, position: Vector2<i32>) -> bool
pub fn has_page_at(&self, position: Vector2<i32>) -> bool
True if there is a page at the given position.
Sourcepub fn page_type(&self, position: Vector2<i32>) -> Option<PageType>
pub fn page_type(&self, position: Vector2<i32>) -> Option<PageType>
The type of the page at the given position, if there is one.
Sourcepub fn is_atlas_page(&self, position: Vector2<i32>) -> bool
pub fn is_atlas_page(&self, position: Vector2<i32>) -> bool
True if there is a atlas page at the given coordinates.
Sourcepub fn is_free_page(&self, position: Vector2<i32>) -> bool
pub fn is_free_page(&self, position: Vector2<i32>) -> bool
True if there is a free tile page at the given coordinates.
Sourcepub fn is_transform_page(&self, position: Vector2<i32>) -> bool
pub fn is_transform_page(&self, position: Vector2<i32>) -> bool
True if there is a transform page at the given coordinates.
Sourcepub fn is_animation_page(&self, position: Vector2<i32>) -> bool
pub fn is_animation_page(&self, position: Vector2<i32>) -> bool
True if there is a transform page at the given coordinates.
Sourcepub fn is_brush_page(&self, position: Vector2<i32>) -> bool
pub fn is_brush_page(&self, position: Vector2<i32>) -> bool
True if there is a brush page at the given coordinates.
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
Return true if there is a tile at the given position on the page at the given position.
Sourcepub fn get_tile_handle(
&self,
position: ResourceTilePosition,
) -> Option<TileDefinitionHandle>
pub fn get_tile_handle( &self, position: ResourceTilePosition, ) -> Option<TileDefinitionHandle>
Returns the TileDefinitionHandle that points to the data in the tile set that represents this tile. Even if this resource is actually a brush, the handle returned still refers to some page and position in the brush’s tile set.
Sourcepub fn get_tile_iter<I: Iterator<Item = Vector2<i32>>>(
&self,
stage: TilePaletteStage,
page: Vector2<i32>,
positions: I,
) -> TileIter<I> ⓘ
pub fn get_tile_iter<I: Iterator<Item = Vector2<i32>>>( &self, stage: TilePaletteStage, page: Vector2<i32>, positions: I, ) -> TileIter<I> ⓘ
Returns an iterator over (Vector2<i32>, TileDefinitionHandle)
where the first
member of the pair is the position of the tile on the page as provided by positions
and the second member is the handle that would be returned from get_tile_handle
.
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, )
Construct a Tiles object holding the tile definition handles for the tiles at the given positions on the given page.
Sourcepub fn is_missing_tile_set(&self) -> bool
pub fn is_missing_tile_set(&self) -> bool
Returns true if the resource is a brush that has no tile set.
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 position on the given page.
If there is no tile at that position or the tile set is missing or not loaded, then None is returned.
If there is a tile and a tile set, but the handle of the tile does not exist in the tile set,
then the rendering data for an error tile is returned using TileRenderData::missing_tile()
.
Beware that this method is slow. Like most methods in TileBook
, this method involves
locking a resource, so none of them should be called many times per frame, as one might be
tempted to do with this method. Do not render a TileBook
by repeatedly calling this
method. Use tile_render_loop
instead.
Sourcepub fn tile_render_loop<F>(
&self,
stage: TilePaletteStage,
page: Vector2<i32>,
func: F,
)
pub fn tile_render_loop<F>( &self, stage: TilePaletteStage, page: Vector2<i32>, func: F, )
Repeatedly call the given function with each tile for the given stage and page. The function is given the position of the tile within the palette and the data for rendering the tile.
Sourcepub fn tile_collider_loop<F>(&self, page: Vector2<i32>, func: F)
pub fn tile_collider_loop<F>(&self, page: Vector2<i32>, func: F)
Repeatedly call the given function with each collider for each tile on the given page. The function is given the position of the tile
Sourcepub fn get_tile_bounds(
&self,
position: ResourceTilePosition,
) -> Option<TileMaterialBounds>
pub fn get_tile_bounds( &self, position: ResourceTilePosition, ) -> Option<TileMaterialBounds>
Returns the rectangle within a material that a tile should show at the given stage and handle.
Sourcepub fn tiles_bounds(
&self,
stage: TilePaletteStage,
page: Vector2<i32>,
) -> OptionTileRect
pub fn tiles_bounds( &self, stage: TilePaletteStage, page: Vector2<i32>, ) -> OptionTileRect
The bounds of the tiles on the given page.
Trait Implementations§
Source§impl Reflect for TileBook
impl Reflect for TileBook
fn source_path() -> &'static str
fn type_name(&self) -> &'static str
fn doc(&self) -> &'static str
Source§fn assembly_name(&self) -> &'static str
fn assembly_name(&self) -> &'static str
#[derive(Reflect)]
) to ensure that this method will return correct assembly
name. In other words - there’s no guarantee, that any implementation other than proc-macro
will return a correct name of the assembly. Alternatively, you can use env!("CARGO_PKG_NAME")
as an implementation.Source§fn type_assembly_name() -> &'static str
fn type_assembly_name() -> &'static str
#[derive(Reflect)]
) to ensure that this method will return correct assembly
name. In other words - there’s no guarantee, that any implementation other than proc-macro
will return a correct name of the assembly. Alternatively, you can use env!("CARGO_PKG_NAME")
as an implementation.fn fields_info(&self, func: &mut dyn FnMut(&[FieldInfo<'_, '_>]))
fn into_any(self: Box<Self>) -> Box<dyn Any>
fn set( &mut self, value: Box<dyn Reflect>, ) -> Result<Box<dyn Reflect>, Box<dyn Reflect>>
fn as_any(&self, func: &mut dyn FnMut(&dyn Any))
fn as_any_mut(&mut self, func: &mut dyn FnMut(&mut dyn Any))
fn as_reflect(&self, func: &mut dyn FnMut(&dyn Reflect))
fn as_reflect_mut(&mut self, func: &mut dyn FnMut(&mut dyn Reflect))
fn fields(&self, func: &mut dyn FnMut(&[&dyn Reflect]))
fn fields_mut(&mut self, func: &mut dyn FnMut(&mut [&mut dyn Reflect]))
fn field(&self, name: &str, func: &mut dyn FnMut(Option<&dyn Reflect>))
fn field_mut( &mut self, name: &str, func: &mut dyn FnMut(Option<&mut dyn Reflect>), )
Source§fn set_field(
&mut self,
field: &str,
value: Box<dyn Reflect>,
func: &mut dyn FnMut(Result<Box<dyn Reflect>, Box<dyn Reflect>>),
)
fn set_field( &mut self, field: &str, value: Box<dyn Reflect>, func: &mut dyn FnMut(Result<Box<dyn Reflect>, Box<dyn Reflect>>), )
#[reflect(setter = ..)]
or falls back to
Reflect::field_mut
fn as_array(&self, func: &mut dyn FnMut(Option<&(dyn ReflectArray + 'static)>))
fn as_array_mut( &mut self, func: &mut dyn FnMut(Option<&mut (dyn ReflectArray + 'static)>), )
fn as_list(&self, func: &mut dyn FnMut(Option<&(dyn ReflectList + 'static)>))
fn as_list_mut( &mut self, func: &mut dyn FnMut(Option<&mut (dyn ReflectList + 'static)>), )
fn as_inheritable_variable( &self, func: &mut dyn FnMut(Option<&(dyn ReflectInheritableVariable + 'static)>), )
fn as_inheritable_variable_mut( &mut self, func: &mut dyn FnMut(Option<&mut (dyn ReflectInheritableVariable + 'static)>), )
fn as_hash_map( &self, func: &mut dyn FnMut(Option<&(dyn ReflectHashMap + 'static)>), )
fn as_hash_map_mut( &mut self, func: &mut dyn FnMut(Option<&mut (dyn ReflectHashMap + 'static)>), )
Source§impl Visit for TileBook
impl Visit for TileBook
Source§fn visit(&mut self, name: &str, visitor: &mut Visitor) -> VisitResult
fn visit(&mut self, name: &str, visitor: &mut Visitor) -> VisitResult
impl StructuralPartialEq for TileBook
Auto Trait Implementations§
impl Freeze for TileBook
impl !RefUnwindSafe for TileBook
impl Send for TileBook
impl Sync for TileBook
impl Unpin for TileBook
impl !UnwindSafe for TileBook
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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 as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Any
. Could be used to downcast a trait object
to a particular type.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Any
. Could be used to downcast a trait object
to a particular type.fn into_any(self: Box<T>) -> Box<dyn Any>
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> FieldValue for Twhere
T: 'static,
impl<T> FieldValue for Twhere
T: 'static,
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<T> MessageData for T
impl<T> MessageData for T
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian()
.Source§impl<T> ReflectBase for Twhere
T: Reflect,
impl<T> ReflectBase for Twhere
T: Reflect,
fn as_any_raw(&self) -> &(dyn Any + 'static)
fn as_any_raw_mut(&mut self) -> &mut (dyn Any + 'static)
Source§impl<T> ResolvePath for Twhere
T: Reflect,
impl<T> ResolvePath for Twhere
T: Reflect,
fn resolve_path<'p>( &self, path: &'p str, func: &mut dyn FnMut(Result<&(dyn Reflect + 'static), ReflectPathError<'p>>), )
fn resolve_path_mut<'p>( &mut self, path: &'p str, func: &mut dyn FnMut(Result<&mut (dyn Reflect + 'static), ReflectPathError<'p>>), )
fn get_resolve_path<'p, T>(
&self,
path: &'p str,
func: &mut dyn FnMut(Result<&T, ReflectPathError<'p>>),
)where
T: Reflect,
fn get_resolve_path_mut<'p, T>(
&mut self,
path: &'p str,
func: &mut dyn FnMut(Result<&mut T, ReflectPathError<'p>>),
)where
T: Reflect,
Source§impl<T> ScriptMessagePayload for T
impl<T> ScriptMessagePayload for T
Source§fn as_any_ref(&self) -> &(dyn Any + 'static)
fn as_any_ref(&self) -> &(dyn Any + 'static)
self
as &dyn Any
Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
self
as &dyn Any
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.