Skip to main content

Transitions

Struct Transitions 

Source
pub struct Transitions { /* private fields */ }
Expand description

A profile’s terrain transitions, as read and checked by the loader.

Every Transitions comes from a load, so its terrains, prototypes, layers and patterns are consistent; its parts are read through accessors.

Implementations§

Source§

impl Transitions

Source

pub fn resolve_chunk<'a, S>( &'a self, source: &'a S, layer: i32, cx: i64, cy: i64, ) -> ResolvedChunk<'a>
where S: TerrainSource + ?Sized,

Resolves the chunk at (layer, cx, cy) of source: its ground tiles, one list per profile ground layer, with the transitions applied as docs/spec/FORMAT.md section 13 defines.

It reads the chunk’s grids and the edge tiles of its eight neighbours’ terrain grids, so tiles along chunk edges agree across them. A chunk the source does not have resolves to empty tiles. The result depends only on the source’s grids and the transitions, so it is the same for every caller. A tile looks up only the transitions of its own terrain and of its neighbours’ terrains, at most MAXIMUM_TILE_TRANSITIONS, each in a table of its neighbourhoods, so the cost is linear in the chunk’s tiles however large the document.

Source§

impl Transitions

Source

pub fn path(&self) -> &str

Source path of the document, relative to the root.

Source

pub const fn terrain_layer(&self) -> usize

The index in the profile’s ground layers of the layer that holds painted terrain.

Source

pub const fn ground_layers(&self) -> usize

How many ground layers the profile has: the grids a resolved chunk holds.

Source

pub fn terrains(&self) -> &[Terrain]

Terrains from lowest to highest precedence.

Source

pub fn transitions(&self) -> &[Transition]

Every transition, in the order they run: terrains in order, each terrain’s transitions in order.

Source

pub fn terrain(&self, id: &str) -> Option<usize>

The index of the terrain id.

Source

pub fn terrain_of(&self, proto: &str) -> Option<usize>

The index of the terrain proto paints, if it paints one.

Source

pub fn protos(&self) -> impl Iterator<Item = &str> + '_

Every prototype the document names, with repeats: the terrains’ prototypes and every variant a transition may draw. Resolved tiles hold only these and the source’s own prototypes.

Source

pub fn paint(&self, terrain: usize) -> Option<&str>

The prototype a brush writes into the terrain layer to paint the terrain at index terrain: its first.

Trait Implementations§

Source§

impl Clone for Transitions

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Transitions

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Transitions

Source§

impl PartialEq for Transitions

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Transitions

Auto Trait Implementations§

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> 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.