diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2022-11-01 14:41:50 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2022-11-01 14:41:50 +0100 |
commit | 60eea789335743855f380249b8bbaf544fea3887 (patch) | |
tree | c7ca89db9b7abc21b41c9c4177828a5f2b0568a6 /src/tile.hpp | |
parent | e38dfcc15401b48b5424834ba730d1d229ed9c6a (diff) |
WIP
Diffstat (limited to 'src/tile.hpp')
-rw-r--r-- | src/tile.hpp | 54 |
1 files changed, 46 insertions, 8 deletions
diff --git a/src/tile.hpp b/src/tile.hpp index 52d06b9d..4bfeb84a 100644 --- a/src/tile.hpp +++ b/src/tile.hpp @@ -4,19 +4,57 @@ namespace floormat { -struct tile final +struct chunk; + +enum pass_mode : std::uint8_t { pass_ok, pass_blocked, pass_shoot_through, }; + +struct pass_mode_ref final { - enum pass_mode : std::uint8_t { pass_ok, pass_blocked, pass_shoot_through, }; + pass_mode_ref(chunk& c, std::uint8_t i) noexcept; + pass_mode_ref& operator=(pass_mode x) noexcept; + pass_mode_ref& operator=(const pass_mode_ref& x) noexcept; + operator pass_mode() const noexcept; - tile_image ground, wall_north, wall_west; - pass_mode passability = pass_ok; +private: + chunk* _chunk; + std::uint8_t i; +}; - constexpr tile() = default; +struct tile_proto final +{ + std::shared_ptr<tile_atlas> ground_atlas, wall_north_atlas, wall_west_atlas; + std::uint16_t ground_variant = 0xffff, wall_north_variant = 0xffff, wall_west_variant = 0xffff; + pass_mode pass_mode = pass_mode::pass_shoot_through; - fm_DECLARE_DEPRECATED_COPY_ASSIGNMENT(tile); - fm_DECLARE_DEFAULT_MOVE_ASSIGNMENT_(tile); + friend bool operator==(const tile_proto& a, const tile_proto& b) noexcept; }; -bool operator==(const tile& a, const tile& b) noexcept; +struct tile_ref final +{ + tile_ref(struct chunk& c, std::uint8_t i) noexcept; + + tile_image_ref ground() noexcept; + tile_image_ref wall_north() noexcept; + tile_image_ref wall_west() noexcept; + + tile_image_proto ground() const noexcept; + tile_image_proto wall_north() const noexcept; + tile_image_proto wall_west() const noexcept; + + pass_mode_ref pass_mode() noexcept; + enum pass_mode pass_mode() const noexcept; + + explicit operator tile_proto() const noexcept; + + struct chunk& chunk() noexcept { return *_chunk; } + const struct chunk& chunk() const noexcept { return *_chunk; } + std::size_t index() const noexcept { return i; } + + friend bool operator==(const tile_ref& a, const tile_ref& b) noexcept; + +private: + struct chunk* _chunk; + std::uint8_t i; +}; } //namespace floormat |