mirror of
https://github.com/ACEmulator/ACE
synced 2026-08-17 12:26:06 -04:00
* update recipes to use mutation scripts * additional refactoring * . * update proficiency code * foolproof salvage code is still needed until recipes are added * add comment * add rare foolproof * update sandstone * adding sandstone mutation * update RecipeManager_New recipes for foolproof salvage * add RecipeManager_New caching * finish removing ClearRecipe() * update comments * update defense imbues to include shields, as per base recipe * improved UpdateObject server sync
32 lines
953 B
C#
32 lines
953 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 int Round(this double 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;
|
|
}
|
|
}
|
|
}
|