pub trait AutoConstrain {
type Position: OffsetPosition;
type Terrain: TileTerrain;
// Required methods
fn all_positions(&self) -> impl Iterator<Item = &Self::Position>;
fn constraint_at(
&self,
position: &Self::Position,
) -> TileConstraint<Self::Terrain, <Self::Terrain as TileTerrain>::Pattern> ⓘ;
fn is_legal(
&self,
from: &<Self::Terrain as TileTerrain>::Pattern,
offset: &<Self::Position as OffsetPosition>::Offset,
to: &<Self::Terrain as TileTerrain>::Pattern,
) -> bool;
fn is_legal_diagonal(
&self,
from: &<Self::Terrain as TileTerrain>::Pattern,
diagonal: &<Self::Position as OffsetPosition>::Diagonal,
to: &<Self::Terrain as TileTerrain>::Pattern,
) -> bool;
}Expand description
The contraints that control how the autotiler searches for tiles at each position.
Required Associated Types§
Sourcetype Position: OffsetPosition
type Position: OffsetPosition
The type of a tile’s position.
Sourcetype Terrain: TileTerrain
type Terrain: TileTerrain
The type of tile terrains. Each terrain represents a set of possible patterns.
Required Methods§
Sourcefn all_positions(&self) -> impl Iterator<Item = &Self::Position>
fn all_positions(&self) -> impl Iterator<Item = &Self::Position>
An iterator for all the positions that the autotiler should consider when choosing tiles. The autotiler will select tiles for position in the order they are delivered by this iterator.
Sourcefn constraint_at(
&self,
position: &Self::Position,
) -> TileConstraint<Self::Terrain, <Self::Terrain as TileTerrain>::Pattern> ⓘ
fn constraint_at( &self, position: &Self::Position, ) -> TileConstraint<Self::Terrain, <Self::Terrain as TileTerrain>::Pattern> ⓘ
The contraint for the given position. This allows the autotiler to examine adjacent cells when deciding if a particular pattern is a valid choice for the cell under consideration.
Sourcefn is_legal(
&self,
from: &<Self::Terrain as TileTerrain>::Pattern,
offset: &<Self::Position as OffsetPosition>::Offset,
to: &<Self::Terrain as TileTerrain>::Pattern,
) -> bool
fn is_legal( &self, from: &<Self::Terrain as TileTerrain>::Pattern, offset: &<Self::Position as OffsetPosition>::Offset, to: &<Self::Terrain as TileTerrain>::Pattern, ) -> bool
True if the given patterns may be placed adjacent to each other with the
given offset. For example, if offset is up, then return true if
to may be legally placed above from.
Sourcefn is_legal_diagonal(
&self,
from: &<Self::Terrain as TileTerrain>::Pattern,
diagonal: &<Self::Position as OffsetPosition>::Diagonal,
to: &<Self::Terrain as TileTerrain>::Pattern,
) -> bool
fn is_legal_diagonal( &self, from: &<Self::Terrain as TileTerrain>::Pattern, diagonal: &<Self::Position as OffsetPosition>::Diagonal, to: &<Self::Terrain as TileTerrain>::Pattern, ) -> bool
True if the given patterns may be placed adjacent to each other with the
given offset. For example, if offset is up, then return true if
to may be legally placed above from.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.