Porytiles
Loading...
Searching...
No Matches
metatile_attribute.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <cstddef>
4#include <string>
5
7
8namespace porytiles2 {
9
10namespace attr {
11
12/*
13 * TODO: remove these hardcoded constants. fieldmap.c and global.fieldmap.h contain definitions for attribute shifts and
14 * masks that could be used to infer these values
15 */
16constexpr std::size_t bytes_per_attr_emerald = 2;
17constexpr std::size_t bytes_per_attr_firered = 4;
18
19enum class LayerType : std::uint8_t { normal = 0, covered = 1, split = 2 };
20
21[[nodiscard]] std::string to_string(LayerType layerType);
22
23[[nodiscard]] ChainableResult<LayerType> layer_type_from_int(std::uint8_t i);
24
25} // namespace attr
26
28 public:
29 MetatileAttribute() = default;
30
31 MetatileAttribute(attr::LayerType layerType, std::uint16_t behavior) : layer_type_{layerType}, behavior_{behavior}
32 {
33 }
34
35 [[nodiscard]] attr::LayerType layer_type() const
36 {
37 return layer_type_;
38 }
39
40 [[nodiscard]] std::uint16_t behavior() const
41 {
42 return behavior_;
43 }
44
45 private:
46 attr::LayerType layer_type_;
47 std::uint16_t behavior_;
48};
49
50} // namespace porytiles2
A result type that maintains a chainable sequence of errors for debugging and error reporting.
attr::LayerType layer_type() const
MetatileAttribute(attr::LayerType layerType, std::uint16_t behavior)
constexpr std::size_t bytes_per_attr_emerald
ChainableResult< LayerType > layer_type_from_int(std::uint8_t i)
constexpr std::size_t bytes_per_attr_firered
std::string to_string(LayerType layerType)