summaryrefslogtreecommitdiff
path: root/dir.go
diff options
context:
space:
mode:
authoranon5 <anon5clam@protonmail.com>2021-06-21 18:47:26 +0000
committeranon5 <anon5clam@protonmail.com>2021-06-21 18:47:26 +0000
commit425da65ed46061303604610bb539d6495b2b1f3f (patch)
tree10ae3e665132c369ce0207676321cef870679923 /dir.go
parent9f239d341ef46b656dda759020da87bdd0606344 (diff)
Add high-level protocol (de)serialization
Diffstat (limited to 'dir.go')
-rw-r--r--dir.go23
1 files changed, 23 insertions, 0 deletions
diff --git a/dir.go b/dir.go
new file mode 100644
index 0000000..693db98
--- /dev/null
+++ b/dir.go
@@ -0,0 +1,23 @@
+package mt
+
+// A Dir represents a direction parallel to an axis.
+type Dir uint8
+
+const (
+ East Dir = iota // +X
+ Above // +Y
+ North // +Z
+ South // -Z
+ Below // -Y
+ West // -X
+ NoDir
+)
+
+// Opposite returns the Dir's opposite.
+// NoDir is its own opposite.
+func (d Dir) Opposite() Dir {
+ if d >= NoDir {
+ return NoDir
+ }
+ return 5 - d
+}