pub struct PatternBits(pub [i8; 9]);Expand description
PatternBits represents a tile’s pattern as a 3x3 grid of i8 values
for doing autotiling in 2D with Vector2<i32> positions.
The center of the 3x3 grid is called the pattern’s terrain.
The 8 values around the outside of the grid are called the pattern’s
peering bits.
The peering bits of this pattern determine whether it is permitted to use this pattern adjacent to other patterns. A pattern is only legal if all three peering bits along each edge match the bits on the nearest edge of the adjacent pattern.
In the case of diagonal connections, only only bit must match in each pattern: the corner bit that is nearest to the other pattern.
For the details of how peering bits constrain where this pattern may be used,
see the implementation of TilePattern.
Tuple Fields§
§0: [i8; 9]Implementations§
Source§impl PatternBits
impl PatternBits
Sourcepub fn center(&self) -> i8
pub fn center(&self) -> i8
The pattern’s terrain ID that can be used to categorize this pattern, and to determine which peering bits are the most important for pattern sorting. Patterns that have more peering bits that match its terrain are given higher priority when sorting and appear earlier in the list.
Sourcepub fn center_terrain_count(&self) -> usize
pub fn center_terrain_count(&self) -> usize
The number of bits in the pattern that match the terrain ID. This count is at most 9 and at least 1 because the center bit always matches itself.
Sourcepub fn unique_terrain_count(&self) -> usize
pub fn unique_terrain_count(&self) -> usize
The number of distinct distinct values in this pattern. This count is at most 9 and at least 1, for the case where every bit is the same.
Trait Implementations§
Source§impl Clone for PatternBits
impl Clone for PatternBits
Source§fn clone(&self) -> PatternBits
fn clone(&self) -> PatternBits
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PatternBits
impl Debug for PatternBits
Source§impl Default for PatternBits
impl Default for PatternBits
Source§fn default() -> PatternBits
fn default() -> PatternBits
Source§impl From<NineI8> for PatternBits
impl From<NineI8> for PatternBits
Source§impl Hash for PatternBits
impl Hash for PatternBits
Source§impl Index<Matrix<usize, Const<2>, Const<1>, ArrayStorage<usize, 2, 1>>> for PatternBits
impl Index<Matrix<usize, Const<2>, Const<1>, ArrayStorage<usize, 2, 1>>> for PatternBits
Source§impl IndexMut<Matrix<usize, Const<2>, Const<1>, ArrayStorage<usize, 2, 1>>> for PatternBits
impl IndexMut<Matrix<usize, Const<2>, Const<1>, ArrayStorage<usize, 2, 1>>> for PatternBits
Source§impl Ord for PatternBits
impl Ord for PatternBits
Source§fn cmp(&self, other: &PatternBits) -> Ordering
fn cmp(&self, other: &PatternBits) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for PatternBits
impl PartialEq for PatternBits
Source§impl PartialOrd for PatternBits
impl PartialOrd for PatternBits
Source§impl TilePattern for PatternBits
impl TilePattern for PatternBits
Source§type Offset = Vector2Offset
type Offset = Vector2Offset
Source§type Diagonal = Vector2Diagonal
type Diagonal = Vector2Diagonal
Source§fn is_legal(&self, offset: &Vector2Offset, to: &PatternBits) -> bool
fn is_legal(&self, offset: &Vector2Offset, to: &PatternBits) -> bool
offset relative to this pattern.Source§fn is_legal_diagonal(
&self,
diagonal: &Vector2Diagonal,
to: &PatternBits,
) -> bool
fn is_legal_diagonal( &self, diagonal: &Vector2Diagonal, to: &PatternBits, ) -> bool
offset relative to this pattern.impl Copy for PatternBits
impl Eq for PatternBits
impl StructuralPartialEq for PatternBits
Auto Trait Implementations§
impl Freeze for PatternBits
impl RefUnwindSafe for PatternBits
impl Send for PatternBits
impl Sync for PatternBits
impl Unpin for PatternBits
impl UnwindSafe for PatternBits
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<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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<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<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.