|
Porytiles
|
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 |
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.
|
default |
|
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".
Definition at line 79 of file metatile_attribute.hpp.
|
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.
| layer_type | The user-pinned layer type. |
Definition at line 91 of file metatile_attribute.hpp.
|
inline |
Returns the value of a named field, or 0 if the field is absent.
| field_name | The field name to look up |
Definition at line 101 of file metatile_attribute.hpp.
|
inline |
Sets the value of a named field, inserting or overwriting as needed.
| field_name | The field name to set |
| value | The value to store |
Definition at line 111 of file metatile_attribute.hpp.
|
inline |
Definition at line 116 of file metatile_attribute.hpp.
|
inline |
Definition at line 51 of file metatile_attribute.hpp.
|
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.
| layer_type | The inferred layer type. |
Definition at line 64 of file metatile_attribute.hpp.