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
impl Transitions
Sourcepub fn resolve_chunk<'a, S>(
&'a self,
source: &'a S,
layer: i32,
cx: i64,
cy: i64,
) -> ResolvedChunk<'a>where
S: TerrainSource + ?Sized,
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
impl Transitions
Sourcepub const fn terrain_layer(&self) -> usize
pub const fn terrain_layer(&self) -> usize
The index in the profile’s ground layers of the layer that holds painted terrain.
Sourcepub const fn ground_layers(&self) -> usize
pub const fn ground_layers(&self) -> usize
How many ground layers the profile has: the grids a resolved chunk holds.
Sourcepub fn transitions(&self) -> &[Transition]
pub fn transitions(&self) -> &[Transition]
Every transition, in the order they run: terrains in order, each terrain’s transitions in order.
Sourcepub fn terrain_of(&self, proto: &str) -> Option<usize>
pub fn terrain_of(&self, proto: &str) -> Option<usize>
The index of the terrain proto paints, if it paints one.