aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/engine/graphics/matrix.hpp2
-rw-r--r--src/engine/graphics/matrix_impl.hpp6
-rw-r--r--src/game/cell_helper_impl.hpp3
-rw-r--r--src/interfaces/matrix.hpp9
4 files changed, 14 insertions, 6 deletions
diff --git a/src/engine/graphics/matrix.hpp b/src/engine/graphics/matrix.hpp
index 58905ee..5964f0f 100644
--- a/src/engine/graphics/matrix.hpp
+++ b/src/engine/graphics/matrix.hpp
@@ -32,6 +32,8 @@ public:
[[nodiscard]] auto get_column_cnt() const noexcept -> std::uint32_t override;
+ [[nodiscard]] auto get_size() const noexcept -> Bounds override;
+
[[nodiscard]] auto begin() const noexcept -> MatrixIterator<Element> override;
[[nodiscard]] auto end() const noexcept -> MatrixIterator<Element> override;
diff --git a/src/engine/graphics/matrix_impl.hpp b/src/engine/graphics/matrix_impl.hpp
index 9105149..d2de795 100644
--- a/src/engine/graphics/matrix_impl.hpp
+++ b/src/engine/graphics/matrix_impl.hpp
@@ -82,6 +82,12 @@ auto Matrix<Element>::get_column_cnt() const noexcept -> std::uint32_t
}
template <typename Element>
+auto Matrix<Element>::get_size() const noexcept -> Bounds
+{
+ return Bounds({.width = _column_cnt, .height = _row_cnt});
+}
+
+template <typename Element>
auto Matrix<Element>::begin() const noexcept -> MatrixIterator<Element>
{
return MatrixIterator(_matrix, _column_cnt);
diff --git a/src/game/cell_helper_impl.hpp b/src/game/cell_helper_impl.hpp
index e2010fa..2a42f6c 100644
--- a/src/game/cell_helper_impl.hpp
+++ b/src/game/cell_helper_impl.hpp
@@ -92,8 +92,7 @@ auto CellHelper<MatrixElement>::_get_valid_pos_neighbours(
position + Vector2::down() + Vector2::left(),
position + Vector2::down() + Vector2::right()};
- const auto matrix_size =
- Bounds({.width = _matrix->get_column_cnt(), .height = _matrix->get_row_cnt()});
+ const auto matrix_size = _matrix->get_size();
return neighbours |
ranges::views::filter(
diff --git a/src/interfaces/matrix.hpp b/src/interfaces/matrix.hpp
index 8edad80..6a6966e 100644
--- a/src/interfaces/matrix.hpp
+++ b/src/interfaces/matrix.hpp
@@ -1,13 +1,12 @@
#pragma once
+#include <memory>
+#include <yacppdic/factory.hpp>
+
#include "engine/data/bounds.hpp"
#include "engine/data/vector2.hpp"
#include "engine/graphics/matrix_iterator.hpp"
-#include <yacppdic/factory.hpp>
-
-#include <memory>
-
template <typename ElementType>
// NOLINTNEXTLINE(cppcoreguidelines-special-member-functions)
class IMatrix
@@ -27,6 +26,8 @@ public:
[[nodiscard]] virtual auto get_column_cnt() const noexcept -> std::uint32_t = 0;
+ [[nodiscard]] virtual auto get_size() const noexcept -> Bounds = 0;
+
[[nodiscard]] virtual auto begin() const noexcept -> MatrixIterator<Element> = 0;
[[nodiscard]] virtual auto end() const noexcept -> MatrixIterator<Element> = 0;