add int variant to MathHelper.Approach

main
cosmonaut 2022-03-31 14:51:18 -07:00
parent c96c7a0d90
commit ec5160c060
1 changed files with 13 additions and 0 deletions

View File

@ -360,6 +360,19 @@ namespace MoonWorks.Math
System.Math.Max(start - change, end); System.Math.Max(start - change, end);
} }
/// <summary>
/// Step from start towards end by change.
/// </summary>
/// <param name="start">Start value.</param>
/// <param name="end">End value.</param>
/// <param name="change">Change value.</param>
public static int Approach(int start, int end, int change)
{
return start < end ?
System.Math.Min(start + change, end) :
System.Math.Max(start - change, end);
}
#endregion #endregion
#region Internal Static Methods #region Internal Static Methods