Porytiles
Loading...
Searching...
No Matches
porytiles::MetatileAttribute Class Reference

The attributes of a single metatile, modeled as a map of named field values. More...

#include <metatile_attribute.hpp>

Public Member Functions

 MetatileAttribute ()=default
 
LayerType layer_type () const
 
void layer_type (LayerType layer_type)
 Sets the plain (inferred) layer type, clearing any explicit pin.
 
const std::optional< LayerType > & explicit_layer_type () const
 Returns the explicit (user-pinned) layer type, if one was set.
 
void explicit_layer_type (LayerType layer_type)
 Pins the layer type to an explicit value.
 
std::uint32_t field (std::string_view field_name) const
 Returns the value of a named field, or 0 if the field is absent.
 
void field (std::string_view field_name, std::uint32_t value)
 Sets the value of a named field, inserting or overwriting as needed.
 
const std::map< std::string, std::uint32_t, std::less<> > & fields () const
 

Detailed Description

The attributes of a single metatile, modeled as a map of named field values.

An attribute is a set of named field values plus the layer type. The bit layout of those fields (their masks, defaults, and how their values are named in a decomp/provider header) is not the attribute's concern; that lives in the Schema. A field absent from the map reads as 0, so an attribute carrying a single field and one carrying seven are the same type, differing only in which keys are populated.

The layer type's value lives outside the fields map because Porytiles manages it: it is inferred at compile time from the metatile's layers (or pinned by the user), never entered as a plain value. The Schema controls where that value fits into a packed attribute: the field carrying FieldRole::layer_type supplies the mask, and a schema without one packs no layer bits at all.

Definition at line 47 of file metatile_attribute.hpp.

Constructor & Destructor Documentation

◆ MetatileAttribute()

porytiles::MetatileAttribute::MetatileAttribute ( )
default

Member Function Documentation

◆ explicit_layer_type() [1/2]

const std::optional< LayerType > & porytiles::MetatileAttribute::explicit_layer_type ( ) const
inline

Returns the explicit (user-pinned) layer type, if one was set.

When set, this value pins the layer type against inference: the compile path uses it verbatim instead of the type it would otherwise infer from the metatile's tiles. It is populated from an explicit layer_type cell in the attributes CSV. Producers of inferred layer types (bin parsers, decompiler, metatileizer) must leave it unset so downstream code can tell "the user explicitly pinned" apart from "inferred value".

Returns
The pinned layer type, or nullopt when the layer type is inferred.

Definition at line 79 of file metatile_attribute.hpp.

◆ explicit_layer_type() [2/2]

void porytiles::MetatileAttribute::explicit_layer_type ( LayerType  layer_type)
inline

Pins the layer type to an explicit value.

Records the pinned value and also updates the plain layer_type so reads through layer_type() stay coherent for code that does not consult the explicit flag.

Parameters
layer_typeThe user-pinned layer type.

Definition at line 91 of file metatile_attribute.hpp.

◆ field() [1/2]

std::uint32_t porytiles::MetatileAttribute::field ( std::string_view  field_name) const
inline

Returns the value of a named field, or 0 if the field is absent.

Parameters
field_nameThe field name to look up
Returns
The stored value, or 0 when no value has been set for the field

Definition at line 101 of file metatile_attribute.hpp.

◆ field() [2/2]

void porytiles::MetatileAttribute::field ( std::string_view  field_name,
std::uint32_t  value 
)
inline

Sets the value of a named field, inserting or overwriting as needed.

Parameters
field_nameThe field name to set
valueThe value to store

Definition at line 111 of file metatile_attribute.hpp.

◆ fields()

const std::map< std::string, std::uint32_t, std::less<> > & porytiles::MetatileAttribute::fields ( ) const
inline

Definition at line 116 of file metatile_attribute.hpp.

◆ layer_type() [1/2]

LayerType porytiles::MetatileAttribute::layer_type ( ) const
inline

Definition at line 51 of file metatile_attribute.hpp.

◆ layer_type() [2/2]

void porytiles::MetatileAttribute::layer_type ( LayerType  layer_type)
inline

Sets the plain (inferred) layer type, clearing any explicit pin.

This is the inferred-value setter: it records the layer type and drops any prior explicit pin, so a later read through explicit_layer_type() cannot report a stale user pin that layer_type() has since overwritten. A caller that means "the user pinned this" must use explicit_layer_type() instead.

Parameters
layer_typeThe inferred layer type.

Definition at line 64 of file metatile_attribute.hpp.


The documentation for this class was generated from the following file: