47 lines
1.4 KiB
C#
47 lines
1.4 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using UnityEngine;
|
|
|
|
namespace EscapeRoomEngine.Engine.Runtime
|
|
{
|
|
public struct Placement
|
|
{
|
|
public Vector3Int position;
|
|
public Vector2Int size;
|
|
public Orientation orientation;
|
|
|
|
/// <summary>
|
|
/// Create a set with every possible combination of position and orientation given the dimensions.
|
|
///
|
|
/// <remarks>
|
|
/// The size of all placements will be (1, 1).
|
|
/// </remarks>
|
|
/// </summary>
|
|
public List<Placement> EveryPlacement
|
|
{
|
|
get
|
|
{
|
|
var placements = new List<Placement>();
|
|
|
|
for (var zIter = 0; zIter < size.y; zIter++)
|
|
{
|
|
for (var xIter = 0; xIter < size.x; xIter++)
|
|
{
|
|
placements.AddRange(OrientationExtensions.EveryOrientation().Select(o => new Placement
|
|
{
|
|
position = new Vector3Int(xIter, 0, zIter),
|
|
size = Vector2Int.one,
|
|
orientation = o
|
|
}));
|
|
}
|
|
}
|
|
|
|
return placements;
|
|
}
|
|
}
|
|
|
|
public string PositionAndOrientation() => $"{{({position.x}, {position.z}), {orientation}}}";
|
|
|
|
public override string ToString() => $"{{{position}, {size}, {orientation}}}";
|
|
}
|
|
} |