using System.Collections.Generic; using System.Linq; using UnityEngine; namespace EscapeRoomEngine.Engine.Runtime.Utilities { public static class Utilities { #region Math /// /// Returns whether a position relative to some dimensions is inside those dimensions. /// /// The position to check, relative to the dimensions. /// The dimensions to check the position against. public static bool IsInsideRelative(this Vector2Int position, Dimensions dimensions) { return position.x >= 0 && position.y >= 0 && position.x < dimensions.width && position.y < dimensions.length; } #endregion #region Randomness public static int RandomInclusive(int from, int to) => Random.Range(from, to + 1); public static T RandomElement(this List list) => list[Random.Range(0, list.Count)]; public static T RandomElement(this HashSet set) => set.ElementAt(Random.Range(0, set.Count)); #endregion } }