summaryrefslogtreecommitdiff
path: root/dungeon/src/pos.rs
diff options
context:
space:
mode:
Diffstat (limited to 'dungeon/src/pos.rs')
-rw-r--r--dungeon/src/pos.rs11
1 files changed, 10 insertions, 1 deletions
diff --git a/dungeon/src/pos.rs b/dungeon/src/pos.rs
index dc1bd2d..27d9b8f 100644
--- a/dungeon/src/pos.rs
+++ b/dungeon/src/pos.rs
@@ -2,6 +2,9 @@
//! entity or objects position and facing direction inside the
//! dungeon grid.
+use strum::IntoEnumIterator;
+use strum_macros::EnumIter;
+
use std::ops::{AddAssign, SubAssign};
use crate::{MAP_SIZE_USIZE, map::MAP_SIZE};
@@ -29,13 +32,19 @@ macro_rules! const_pos {
/// or any position object is facing inside the dungeon map.
/// Since the dungeon lives on a grid, there are only four
/// possible directions.
-#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
+#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, EnumIter)]
pub enum Direction {
North,
South,
East,
West,
}
+impl Direction {
+ /// Returns an iterator over all possible directions
+ pub fn values() -> impl Iterator<Item = Self> {
+ Self::iter()
+ }
+}
/// The `Pos` type represents a 2D position inside the dungeon grid.
///