From 7dbc5dd608d10d5febc1e635d0f9c0ee0863816c Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Sun, 29 Dec 2019 11:41:11 +0100 Subject: [PATCH] added angle method to direction --- MLEM/Misc/Direction2.cs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/MLEM/Misc/Direction2.cs b/MLEM/Misc/Direction2.cs index a4e076e..10ad758 100644 --- a/MLEM/Misc/Direction2.cs +++ b/MLEM/Misc/Direction2.cs @@ -87,5 +87,28 @@ namespace MLEM.Misc { } } + public static float Angle(this Direction2 dir) { + switch (dir) { + case Direction2.Up: + return MathHelper.PiOver2; + case Direction2.Right: + return MathHelper.TwoPi; + case Direction2.Down: + return 3 * MathHelper.PiOver2; + case Direction2.Left: + return MathHelper.Pi; + case Direction2.UpRight: + return MathHelper.PiOver4; + case Direction2.DownRight: + return 7 * MathHelper.PiOver4; + case Direction2.DownLeft: + return 5 * MathHelper.PiOver4; + case Direction2.UpLeft: + return 3 * MathHelper.PiOver4; + default: + return -1; + } + } + } } \ No newline at end of file