Organize custom scripts under Assets/Baba_yaga and merge Opsive folders to Assets root
This commit is contained in:
32
Assets/Baba_yaga/GameSetup/Maze/MapLocation.cs
Normal file
32
Assets/Baba_yaga/GameSetup/Maze/MapLocation.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
namespace Baba_yaga.GameSetup.Maze
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a 2D coordinate on the maze grid.
|
||||
/// Used as a lightweight value type to avoid GC allocations.
|
||||
/// </summary>
|
||||
public readonly struct MapLocation
|
||||
{
|
||||
public readonly int x;
|
||||
public readonly int z;
|
||||
|
||||
public MapLocation(int _x, int _z)
|
||||
{
|
||||
x = _x;
|
||||
z = _z;
|
||||
}
|
||||
|
||||
// Static predefined directions to eliminate magic numbers in algorithms
|
||||
public static MapLocation Right => new MapLocation(1, 0);
|
||||
public static MapLocation Left => new MapLocation(-1, 0);
|
||||
public static MapLocation Up => new MapLocation(0, 1);
|
||||
public static MapLocation Down => new MapLocation(0, -1);
|
||||
|
||||
/// <summary>
|
||||
/// Returns a list of all 4 cardinal directions.
|
||||
/// </summary>
|
||||
public static System.Collections.Generic.List<MapLocation> Directions => new System.Collections.Generic.List<MapLocation>
|
||||
{
|
||||
Right, Up, Left, Down
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user