16 if (metatile_attributes_.contains(metatile_id)) {
17 panic(
"id " + std::to_string(metatile_id) +
" already exists in attribute map");
19 metatile_attributes_.insert({metatile_id, std::move(attribute)});
24 if (metatile_attributes_.contains(metatile_id)) {
25 return metatile_attributes_.at(metatile_id);
32 const auto it = prior_pin_column_states_.find(role);
38 prior_pin_column_states_[role] = state;
44 panic(std::format(
"invalid palette index {}: out of range", palette_index));
46 palettes_[palette_index] = std::move(palette);
49const std::optional<Palette<Rgba32, palette::max_size>> &
53 panic(std::format(
"invalid palette index {}: out of range", palette_index));
55 return palettes_[palette_index];
60 return bottom_.size() == 0 && middle_.size() == 0 && top_.size() == 0;
66 if (bottom_.width() != middle_.width() || bottom_.width() != top_.width() || bottom_.height() != middle_.height() ||
67 bottom_.height() != top_.height()) {
70 "layer images have mismatched dimensions: bottom={}x{}, middle={}x{}, top={}x{}",
79 const std::size_t width = bottom_.width();
80 const std::size_t height = bottom_.height();
85 bool bottom_has_opaque =
false;
86 bool middle_has_opaque =
false;
87 bool top_has_opaque =
false;
92 if (!bottom_.at(row, col).is_transparent(extrinsic)) {
93 bottom_has_opaque =
true;
95 if (!middle_.at(row, col).is_transparent(extrinsic)) {
96 middle_has_opaque =
true;
98 if (!top_.at(row, col).is_transparent(extrinsic)) {
99 top_has_opaque =
true;
103 if (bottom_has_opaque && middle_has_opaque && top_has_opaque) {
117 const std::string &
name = anim.
name();
118 if (anims_.contains(
name)) {
119 panic(
"animation '" +
name +
"' already exists in PorytilesTilesetComponent");
121 anims_.insert({
name, std::move(anim)});
A complete tileset animation with name, configuration, and frame data.
const std::string & name() const
A result type that maintains a chainable sequence of errors for debugging and error reporting.
A generic palette container for colors that support transparency checking.
const std::optional< Palette< Rgba32, palette::max_size > > & palette_at(std::size_t palette_index) const
void set_palette(std::size_t palette_index, Palette< Rgba32, palette::max_size > palette)
std::optional< MetatileAttribute > get_attribute(std::size_t metatile_id) const
PriorPinColumnState prior_pin_column_state(FieldRole role) const
Returns the recorded prior pin-column state for a role, or no_csv when none was recorded.
ChainableResult< LayerMode > detect_layer_mode(const Rgba32 &extrinsic) const
void insert_attribute(std::size_t metatile_id, MetatileAttribute attribute)
Insert a MetatileAttribute to the end of the attribute vector.
void add_anim(Animation< Rgba32 > anim)
Represents a 32-bit RGBA color.
constexpr std::size_t num_palettes
constexpr std::size_t side_length_pix
void panic(const StringViewSourceLoc &s)
Unconditionally terminates the program with a panic message.
PriorPinColumnState
What an attributes.csv (if any) said about a role's pin column when this component was loaded.
FieldRole
Semantic roles a schema field can carry beyond holding a plain per-metatile value.