16 if (metatile_attributes_.contains(metatile_id)) {
17 panic(
"id " + std::to_string(metatile_id) +
" already exists in attr map");
19 metatile_attributes_.insert({metatile_id, std::move(attribute)});
24 if (metatile_attributes_.contains(metatile_id)) {
25 return metatile_attributes_.at(metatile_id);
33 panic(std::format(
"invalid pal index {}: out of range", pal_index));
35 pals_[pal_index] = std::move(pal);
41 panic(std::format(
"invalid pal index {}: out of range", pal_index));
43 return pals_[pal_index];
48 return bottom_.size() == 0 && middle_.size() == 0 && top_.size() == 0;
54 if (bottom_.width() != middle_.width() || bottom_.width() != top_.width() || bottom_.height() != middle_.height() ||
55 bottom_.height() != top_.height()) {
58 "layer images have mismatched dimensions: bottom={}x{}, middle={}x{}, top={}x{}",
67 const std::size_t width = bottom_.width();
68 const std::size_t height = bottom_.height();
73 bool bottom_has_opaque =
false;
74 bool middle_has_opaque =
false;
75 bool top_has_opaque =
false;
80 if (!bottom_.at(row, col).is_transparent(extrinsic)) {
81 bottom_has_opaque =
true;
83 if (!middle_.at(row, col).is_transparent(extrinsic)) {
84 middle_has_opaque =
true;
86 if (!top_.at(row, col).is_transparent(extrinsic)) {
87 top_has_opaque =
true;
91 if (bottom_has_opaque && middle_has_opaque && top_has_opaque) {
105 const std::string &name = anim.
name();
106 if (anims_.contains(name)) {
107 panic(
"animation '" + name +
"' already exists in PorytilesTilesetComponent");
109 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.
void set_pal(std::size_t pal_index, Palette< Rgba32, pal::max_size > pal)
std::optional< MetatileAttribute > get_attribute(std::size_t metatile_id) const
const std::optional< Palette< Rgba32, pal::max_size > > & pal_at(std::size_t pal_index) const
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_pals
constexpr std::size_t side_length_pix
void panic(const StringViewSourceLoc &s)
Unconditionally terminates the program with a panic message.