move puzzle implementations out of engine

This commit is contained in:
2023-03-22 09:44:17 +01:00
parent e1bfecbd4b
commit 30d8f986df
70 changed files with 82 additions and 46 deletions

View File

@@ -0,0 +1,38 @@
using System.Collections.Generic;
namespace EscapeRoomEngine.Engine.Runtime.Utilities
{
public enum Orientation
{
North = 0, East = 90, South = 180, West = 270
}
public static class OrientationExtensions
{
public static HashSet<Orientation> EveryOrientation() => new(new[]
{
Orientation.North, Orientation.East, Orientation.South, Orientation.West
});
/// <summary>
/// Return the orientation corresponding to an angle, starting at 0 degrees North and going clockwise around the compass.
/// </summary>
public static Orientation FromAngle(int angle) => (Orientation)angle;
/// <summary>
/// Turn an orientation into its corresponding angle.
/// </summary>
public static float Angle(this Orientation orientation) => (float)orientation;
/// <summary>
/// Turn an orientation into its corresponding angle.
/// </summary>
public static int AngleInt(this Orientation orientation) => (int)orientation;
/// <summary>
/// Rotate an orientation by a specific amount of quarter rotations. Rotating <c>East</c> thrice would return <c>North</c>.
/// </summary>
public static Orientation Rotated(this Orientation orientation, int quarterRotations) =>
orientation + quarterRotations * 90;
}
}