ace/Source/ACE.Common/Extensions/FloatExtensions.cs
Ty Conner 4ea4dd635e
Fix Trap Door Switch (#1213)
* 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
2019-01-04 03:27:15 -06:00

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;
}
}
}