mirror of
https://github.com/ACEmulator/ACE
synced 2026-08-17 12:26:06 -04:00
* Update Switch to support nested switch * Update changelog.md * Update Switch.cs * Update delete command * Rework Switch to use TryCastSpell * Add support for InflictVitaePenalty in EmoteManager * cleanup * Update changelog.md * misc changes * Update Player_Xp.cs * Fixbusy * Changes for vitae * Fix syntax error * Fix SaveBiota issue with players that have vitae * Fix Remove for Vitae Layer EF issue * Update PositionExtensions.cs Co-Authored-By: gmriggs <gmriggs@gmail.com> * Update WorldObject_Magic.cs Fix issues with delays and Summon portal * Updates to Transition to Portal Space * Add sound to switch and visibility check for rotate
27 lines
773 B
C#
27 lines
773 B
C#
using System;
|
|
|
|
namespace ACE.Common.Extensions
|
|
{
|
|
public static class FloatExtensions
|
|
{
|
|
public static int Round(this float num, int decimalPlaces = 0)
|
|
{
|
|
return (int)Math.Round(num, decimalPlaces, MidpointRounding.AwayFromZero);
|
|
}
|
|
|
|
public static float Truncate(this float num, int decimalPlaces)
|
|
{
|
|
var multiplier = Math.Pow(10, decimalPlaces);
|
|
|
|
return (float)(Math.Truncate(num * multiplier) / multiplier);
|
|
}
|
|
|
|
public static bool EpsilonEquals(this float num, float val/*, int decimalPlaces = 4*/)
|
|
{
|
|
//var epsilon = 1.0f / Math.Pow(10, decimalPlaces);
|
|
var epsilon = 0.0001f;
|
|
|
|
return Math.Abs(num - val) < epsilon;
|
|
}
|
|
}
|
|
}
|