Stardew_Valley_Mods/GeneralMods/Revitalize/Framework/Utilities/IntRange.cs

90 lines
2.6 KiB
C#
Raw Normal View History

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Revitalize.Framework.Utilities
{
/// <summary>
/// A class for dealing with integer value ranges.
/// </summary>
public class IntRange
{
/// <summary>
/// The min value for the range.
/// </summary>
public int min;
/// <summary>
/// The max value for the range.
/// </summary>
public int max;
public IntRange()
{
}
/// <summary>
/// Constructor.
/// </summary>
/// <param name="SingleValue">The single value to be tested on for min and max. Note that this will fail every test except for ContainsInclusive.</param>
public IntRange(int SingleValue)
{
this.min = this.max = SingleValue;
}
/// <summary>
/// Constructor.
/// </summary>
/// <param name="Min">The min value.</param>
/// <param name="Max">The max value.</param>
public IntRange(int Min, int Max)
{
this.min = Min;
this.max = Max;
}
/// <summary>
/// Checks to see if the value is inside the range.
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public bool ContainsInclusive(int value)
{
if (value >= this.min && value <= this.max) return true;
else return false;
}
/// <summary>
/// Checks to see if the value is greater/equal than the min but less than the max.
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public bool ContainsExclusiveCeil(int value)
{
if (value >= this.min && value < this.max) return true;
else return false;
}
/// <summary>
/// Checks to see if the value is greater than the min and less/equal to the max.
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public bool ContainsExclusiveFloor(int value)
{
if (value >= this.min && value < this.max) return true;
else return false;
}
/// <summary>
/// Checks to see if the value is inside of the range but not equal to min or max.
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public bool ContainsExclusive(int value)
{
if (value > this.min && value < this.max) return true;
else return false;
}
}
}