Skip to main content

AutoConstrain

Trait AutoConstrain 

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

Source

type Position: OffsetPosition

The type of a tile’s position.

Source

type Terrain: TileTerrain

The type of tile terrains. Each terrain represents a set of possible patterns.

Required Methods§

Source

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.

Source

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.

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.

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.

Implementors§

Source§

impl<'b, Pos, Ter, Pat> AutoConstrain for AutoPatternConstraint<'_, 'b, Pos, Ter, Pat>
where Pos: OffsetPosition, Ter: Hash + Eq, Pat: TilePattern<Offset = <Pos as OffsetPosition>::Offset, Diagonal = <Pos as OffsetPosition>::Diagonal> + Clone + Debug, <Pos as OffsetPosition>::Offset: Debug,

Source§

type Position = Pos

Source§

type Terrain = ListTerrain<'b, Pat>