rework dimensions and orientation into Placement, optimise requirements to work on previous candidates, use vec3 for positions
This commit is contained in:
@@ -9,13 +9,13 @@ namespace EscapeRoomEngine.Engine.Runtime.Utilities
|
||||
#region Math
|
||||
|
||||
/// <summary>
|
||||
/// Returns whether a position relative to some dimensions is inside those dimensions.
|
||||
/// Returns whether a position relative to some placement is inside its dimensions.
|
||||
/// </summary>
|
||||
/// <param name="position">The position to check, relative to the dimensions.</param>
|
||||
/// <param name="dimensions">The dimensions to check the position against.</param>
|
||||
public static bool IsInsideRelative(this Vector2Int position, Dimensions dimensions)
|
||||
/// <param name="position">The position to check, relative to the placement.</param>
|
||||
/// <param name="placement">The placement to check the position against.</param>
|
||||
public static bool IsInsideRelative(this Vector3Int position, Placement placement)
|
||||
{
|
||||
return position.x >= 0 && position.y >= 0 && position.x < dimensions.width && position.y < dimensions.length;
|
||||
return position.x >= 0 && position.z >= 0 && position.x < placement.size.x && position.z < placement.size.y;
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -29,4 +29,12 @@ namespace EscapeRoomEngine.Engine.Runtime.Utilities
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
public static class Vector2IntExtensions
|
||||
{
|
||||
public static Vector3Int ProjectAtFloor(this Vector2Int vector) => vector.ProjectAtHeight(0);
|
||||
|
||||
public static Vector3Int ProjectAtHeight(this Vector2Int vector, int height) =>
|
||||
new Vector3Int(vector.x, height, vector.y);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user