split into multiple assemblies
This commit is contained in:
63
Assets/Engine/Runtime/Dimensions.cs
Normal file
63
Assets/Engine/Runtime/Dimensions.cs
Normal file
@@ -0,0 +1,63 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace EscapeRoomEngine.Engine.Runtime
|
||||
{
|
||||
public struct Dimensions
|
||||
{
|
||||
internal Dimensions(int width, int length, int x, int z)
|
||||
{
|
||||
this.width = width;
|
||||
this.length = length;
|
||||
this.x = x;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public int width;
|
||||
public int length;
|
||||
public int x;
|
||||
public int z;
|
||||
|
||||
public Vector2Int Position
|
||||
{
|
||||
get => new(x, z);
|
||||
set
|
||||
{
|
||||
x = value.x;
|
||||
z = value.y;
|
||||
}
|
||||
}
|
||||
|
||||
public Vector2Int Size
|
||||
{
|
||||
get => new(width, length);
|
||||
set
|
||||
{
|
||||
width = value.x;
|
||||
length = value.y;
|
||||
}
|
||||
}
|
||||
|
||||
public int Area => width * length;
|
||||
|
||||
public HashSet<Vector2Int> EveryPosition
|
||||
{
|
||||
get
|
||||
{
|
||||
var positions = new HashSet<Vector2Int>();
|
||||
|
||||
for (var zIter = 0; zIter < length; zIter++)
|
||||
{
|
||||
for (var xIter = 0; xIter < width; xIter++)
|
||||
{
|
||||
positions.Add(new Vector2Int(xIter, zIter));
|
||||
}
|
||||
}
|
||||
|
||||
return positions;
|
||||
}
|
||||
}
|
||||
|
||||
public override string ToString() => $"({width}, {length}) at ({x}, {z})";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user