From de274de9e37129ce27e153a716ad0a60a7404ecc Mon Sep 17 00:00:00 2001 From: Tyler Young Date: Sat, 13 Jun 2020 01:28:28 -0400 Subject: [PATCH] use CannyFastMath in various places even where it might not be any different also update a bunch of packages clean up redundant YamlDotNet references --- BuildChecker/BuildChecker.csproj | 1 + Content.Client/Content.Client.csproj | 4 ++-- .../SolarControlConsoleBoundUserInterface.cs | 2 +- Content.Client/Parallax/ParallaxGenerator.cs | 19 +++++++++++-------- Content.Client/State/LobbyState.cs | 3 +++ .../UserInterface/CooldownGraphic.cs | 7 +++++-- .../Content.Server.Database.csproj | 2 +- Content.Server/AI/StaticBarkerProcessor.cs | 5 ++++- Content.Server/AI/WanderProcessor.cs | 2 +- .../Chemistry/Metabolism/DefaultFood.cs | 4 ++-- .../ExplosionReactionEffect.cs | 17 ++++++++++------- Content.Server/Content.Server.csproj | 2 +- .../Components/Chemistry/PourableComponent.cs | 2 +- .../Components/Chemistry/SolutionComponent.cs | 2 +- .../Mobs/HeatResistanceComponent.cs | 3 +++ .../Components/Mobs/StunnableComponent.cs | 3 +++ .../Weapon/Melee/MeleeWeaponComponent.cs | 3 +++ .../EntitySystems/PowerSolarSystem.cs | 5 ++++- .../Interfaces/Chemistry/IReactionEffect.cs | 2 +- Content.Server/Throw/ThrowHelper.cs | 5 ++++- .../Chemistry/DefaultMetabolizable.cs | 6 +++--- Content.Shared/Chemistry/ReagentUnit.cs | 18 +----------------- Content.Shared/Chemistry/Solution.cs | 6 +++--- Content.Shared/Content.Shared.csproj | 2 +- .../Shared/Chemistry/ReagentUnit_Tests.cs | 12 +----------- 25 files changed, 71 insertions(+), 66 deletions(-) diff --git a/BuildChecker/BuildChecker.csproj b/BuildChecker/BuildChecker.csproj index 33d05d070d6b..7acdbe9935a2 100644 --- a/BuildChecker/BuildChecker.csproj +++ b/BuildChecker/BuildChecker.csproj @@ -18,6 +18,7 @@ https://docs.microsoft.com/en-us/visualstudio/msbuild/msbuild py -3 {C899FCA4-7037-4E49-ABC2-44DE72487110} .NETFramework, Version=v4.7.2 + false Library diff --git a/Content.Client/Content.Client.csproj b/Content.Client/Content.Client.csproj index ed18e5b05de3..66149681535c 100644 --- a/Content.Client/Content.Client.csproj +++ b/Content.Client/Content.Client.csproj @@ -11,10 +11,10 @@ - + - + diff --git a/Content.Client/GameObjects/Components/Power/SolarControlConsoleBoundUserInterface.cs b/Content.Client/GameObjects/Components/Power/SolarControlConsoleBoundUserInterface.cs index 5752aaa4d2c7..983c229b3b04 100644 --- a/Content.Client/GameObjects/Components/Power/SolarControlConsoleBoundUserInterface.cs +++ b/Content.Client/GameObjects/Components/Power/SolarControlConsoleBoundUserInterface.cs @@ -77,7 +77,7 @@ protected override void UpdateState(BoundUserInterfaceState state) SolarControlConsoleBoundInterfaceState scc = (SolarControlConsoleBoundInterfaceState) state; _lastState = scc; _window.NotARadar.UpdateState(scc); - _window.OutputPower.Text = ((int) Math.Floor(scc.OutputPower)).ToString(); + _window.OutputPower.Text = ((int) MathF.Floor(scc.OutputPower)).ToString(); _window.SunAngle.Text = FormatAngle(scc.TowardsSun); UpdateField(_window.PanelRotation, FormatAngle(scc.Rotation)); UpdateField(_window.PanelVelocity, FormatAngle(scc.AngularVelocity * 60)); diff --git a/Content.Client/Parallax/ParallaxGenerator.cs b/Content.Client/Parallax/ParallaxGenerator.cs index e7eeb0c606ff..9b8e2ce4bd9b 100644 --- a/Content.Client/Parallax/ParallaxGenerator.cs +++ b/Content.Client/Parallax/ParallaxGenerator.cs @@ -12,6 +12,9 @@ using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.PixelFormats; using Color = Robust.Shared.Maths.Color; +using CannyFastMath; +using Math = CannyFastMath.Math; +using MathF = CannyFastMath.MathF; namespace Content.Client.Parallax { @@ -78,7 +81,7 @@ private class LayerNoise : Layer private readonly NoiseGenerator.NoiseType NoiseType = NoiseGenerator.NoiseType.Fbm; private readonly uint Seed = 1234; private readonly float Persistence = 0.5f; - private readonly float Lacunarity = (float) (Math.PI * 2 / 3); + private readonly float Lacunarity = (float) (Math.TAU / 3); private readonly float Frequency = 1; private readonly uint Octaves = 3; private readonly float Threshold; @@ -179,12 +182,12 @@ public override void Apply(Image bitmap) for (var x = 0; x < bitmap.Width; x++) { // Do noise calculations. - var noiseVal = Math.Min(1, Math.Max(0, (noise.GetNoiseTiled(x, y) + 1) / 2)); + var noiseVal = MathF.Min(1, MathF.Max(0, (noise.GetNoiseTiled(x, y) + 1) / 2)); // Threshold - noiseVal = Math.Max(0, noiseVal - Threshold); + noiseVal = MathF.Max(0, noiseVal - Threshold); noiseVal *= threshVal; - noiseVal = (float) Math.Pow(noiseVal, powFactor); + noiseVal = (float) MathF.Pow(noiseVal, powFactor); // Get colors based on noise values. var srcColor = Color.InterpolateBetween(OuterColor, InnerColor, noiseVal) @@ -215,7 +218,7 @@ private class LayerPoints : Layer private readonly NoiseGenerator.NoiseType MaskNoiseType = NoiseGenerator.NoiseType.Fbm; private readonly uint MaskSeed = 1234; private readonly float MaskPersistence = 0.5f; - private readonly float MaskLacunarity = (float) Math.PI * 2 / 3; + private readonly float MaskLacunarity = (float) (Math.PI * 2 / 3); private readonly float MaskFrequency = 1; private readonly uint MaskOctaves = 3; private readonly float MaskThreshold; @@ -406,11 +409,11 @@ private void GenPointsMasked(Image buffer) var y = random.Next(0, buffer.Height); // Grab noise at this point. - var noiseVal = Math.Min(1, Math.Max(0, (noise.GetNoiseTiled(x, y) + 1) / 2)); + var noiseVal = MathF.Min(1, MathF.Max(0, (noise.GetNoiseTiled(x, y) + 1) / 2)); // Threshold - noiseVal = Math.Max(0, noiseVal - MaskThreshold); + noiseVal = MathF.Max(0, noiseVal - MaskThreshold); noiseVal *= threshVal; - noiseVal = (float) Math.Pow(noiseVal, powFactor); + noiseVal = (float) MathF.Pow(noiseVal, powFactor); var randomThresh = random.NextFloat(); if (randomThresh > noiseVal) diff --git a/Content.Client/State/LobbyState.cs b/Content.Client/State/LobbyState.cs index 0a60e3adf107..2fd25666df34 100644 --- a/Content.Client/State/LobbyState.cs +++ b/Content.Client/State/LobbyState.cs @@ -18,6 +18,9 @@ using Robust.Shared.Prototypes; using Robust.Shared.Timing; using Robust.Shared.ViewVariables; +using CannyFastMath; +using Math = CannyFastMath.Math; +using MathF = CannyFastMath.MathF; namespace Content.Client.State { diff --git a/Content.Client/UserInterface/CooldownGraphic.cs b/Content.Client/UserInterface/CooldownGraphic.cs index 6bd8f3badee8..ae09ec8fb83c 100644 --- a/Content.Client/UserInterface/CooldownGraphic.cs +++ b/Content.Client/UserInterface/CooldownGraphic.cs @@ -6,6 +6,9 @@ using Robust.Client.Graphics.Shaders; using Robust.Shared.IoC; using Robust.Shared.Prototypes; +using CannyFastMath; +using Math = CannyFastMath.Math; +using MathF = CannyFastMath.MathF; namespace Robust.Client.UserInterface.Controls { @@ -33,7 +36,7 @@ protected override void Draw(DrawingHandleScreen handle) { Color color; - var lerp = 1f - Math.Abs(Progress); // for future bikeshedding purposes + var lerp = 1f - MathF.Abs(Progress); // for future bikeshedding purposes if (Progress >= 0f) { @@ -42,7 +45,7 @@ protected override void Draw(DrawingHandleScreen handle) } else { - var alpha = Math.Clamp(0.5f * lerp, 0f, 0.5f); + var alpha = MathF.Clamp(0.5f * lerp, 0f, 0.5f); color = new Color(1f, 1f, 1f, alpha); } diff --git a/Content.Server.Database/Content.Server.Database.csproj b/Content.Server.Database/Content.Server.Database.csproj index 7e3213e9304e..8d92cff95dee 100644 --- a/Content.Server.Database/Content.Server.Database.csproj +++ b/Content.Server.Database/Content.Server.Database.csproj @@ -18,7 +18,7 @@ all - + diff --git a/Content.Server/AI/StaticBarkerProcessor.cs b/Content.Server/AI/StaticBarkerProcessor.cs index dcc3debefff4..2d0cdb163ca0 100644 --- a/Content.Server/AI/StaticBarkerProcessor.cs +++ b/Content.Server/AI/StaticBarkerProcessor.cs @@ -5,6 +5,9 @@ using Robust.Shared.Interfaces.Timing; using Robust.Shared.IoC; using Robust.Shared.Utility; +using CannyFastMath; +using Math = CannyFastMath.Math; +using MathF = CannyFastMath.MathF; namespace Content.Server.AI { @@ -35,7 +38,7 @@ public override void Update(float frameTime) { if(_timeMan.CurTime < _nextBark) return; - + var rngState = GenSeed(); _nextBark = _timeMan.CurTime + MinimumDelay + TimeSpan.FromSeconds(Random01(ref rngState) * 10); diff --git a/Content.Server/AI/WanderProcessor.cs b/Content.Server/AI/WanderProcessor.cs index bcd7b3579c47..f1430efaf57c 100644 --- a/Content.Server/AI/WanderProcessor.cs +++ b/Content.Server/AI/WanderProcessor.cs @@ -214,7 +214,7 @@ private void EmitProfanity(ref uint rngState) if(Random01(ref rngState) < 0.5f) return; - var pick = (int) Math.Round(Random01(ref rngState) * (_normalAssistantConversation.Count - 1)); + var pick = (int) MathF.Round(Random01(ref rngState) * (_normalAssistantConversation.Count - 1)); _chatMan.EntitySay(SelfEntity, _normalAssistantConversation[pick]); } diff --git a/Content.Server/Chemistry/Metabolism/DefaultFood.cs b/Content.Server/Chemistry/Metabolism/DefaultFood.cs index d220bb180518..bbf83bc5d8c9 100644 --- a/Content.Server/Chemistry/Metabolism/DefaultFood.cs +++ b/Content.Server/Chemistry/Metabolism/DefaultFood.cs @@ -24,7 +24,7 @@ class DefaultFood : IMetabolizable void IExposeData.ExposeData(ObjectSerializer serializer) { - serializer.DataField(ref _metabolismRate, "rate", ReagentUnit.New(1M)); + serializer.DataField(ref _metabolismRate, "rate", ReagentUnit.New(1.0)); serializer.DataField(ref _nutritionFactor, "nutrimentFactor", 30.0f); } @@ -36,7 +36,7 @@ ReagentUnit IMetabolizable.Metabolize(IEntity solutionEntity, string reagentId, hunger.UpdateFood(metabolismAmount.Float() * NutritionFactor); //Return amount of reagent to be removed, remove reagent regardless of HungerComponent presence - return metabolismAmount; + return metabolismAmount; } } } diff --git a/Content.Server/Chemistry/ReactionEffects/ExplosionReactionEffect.cs b/Content.Server/Chemistry/ReactionEffects/ExplosionReactionEffect.cs index 2bdff9b1c243..1996e287a65f 100644 --- a/Content.Server/Chemistry/ReactionEffects/ExplosionReactionEffect.cs +++ b/Content.Server/Chemistry/ReactionEffects/ExplosionReactionEffect.cs @@ -4,6 +4,9 @@ using Content.Shared.Interfaces; using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Serialization; +using CannyFastMath; +using Math = CannyFastMath.Math; +using MathF = CannyFastMath.MathF; namespace Content.Server.Chemistry.ReactionEffects { @@ -35,9 +38,9 @@ public void ExposeData(ObjectSerializer serializer) serializer.DataField(ref _maxScale, "maxScale", 1); } - public void React(IEntity solutionEntity, decimal intensity) + public void React(IEntity solutionEntity, double intensity) { - float floatIntensity = (float)intensity; + float floatIntensity = (float)intensity; if (solutionEntity == null) return; if(!solutionEntity.TryGetComponent(out SolutionComponent solution)) @@ -46,7 +49,7 @@ public void React(IEntity solutionEntity, decimal intensity) //Handle scaling if (_scaled) { - floatIntensity = Math.Min(floatIntensity, _maxScale); + floatIntensity = MathF.Min(floatIntensity, _maxScale); } else { @@ -54,10 +57,10 @@ public void React(IEntity solutionEntity, decimal intensity) } //Calculate intensities - int finalDevastationRange = (int)Math.Round(_devastationRange * floatIntensity); - int finalHeavyImpactRange = (int)Math.Round(_heavyImpactRange * floatIntensity); - int finalLightImpactRange = (int)Math.Round(_lightImpactRange * floatIntensity); - int finalFlashRange = (int)Math.Round(_flashRange * floatIntensity); + int finalDevastationRange = (int)MathF.Round(_devastationRange * floatIntensity); + int finalHeavyImpactRange = (int)MathF.Round(_heavyImpactRange * floatIntensity); + int finalLightImpactRange = (int)MathF.Round(_lightImpactRange * floatIntensity); + int finalFlashRange = (int)MathF.Round(_flashRange * floatIntensity); ExplosionHelper.SpawnExplosion(solutionEntity.Transform.GridPosition, finalDevastationRange, finalHeavyImpactRange, finalLightImpactRange, finalFlashRange); } diff --git a/Content.Server/Content.Server.csproj b/Content.Server/Content.Server.csproj index f1b977269de3..0c9be50c549e 100644 --- a/Content.Server/Content.Server.csproj +++ b/Content.Server/Content.Server.csproj @@ -13,7 +13,7 @@ - + diff --git a/Content.Server/GameObjects/Components/Chemistry/PourableComponent.cs b/Content.Server/GameObjects/Components/Chemistry/PourableComponent.cs index fdbd9ed5ca72..3d14e1c48152 100644 --- a/Content.Server/GameObjects/Components/Chemistry/PourableComponent.cs +++ b/Content.Server/GameObjects/Components/Chemistry/PourableComponent.cs @@ -47,7 +47,7 @@ public ReagentUnit TransferAmount public override void ExposeData(ObjectSerializer serializer) { base.ExposeData(serializer); - serializer.DataField(ref _transferAmount, "transferAmount", ReagentUnit.New(5.0M)); + serializer.DataField(ref _transferAmount, "transferAmount", ReagentUnit.New(5.0)); } /// diff --git a/Content.Server/GameObjects/Components/Chemistry/SolutionComponent.cs b/Content.Server/GameObjects/Components/Chemistry/SolutionComponent.cs index 1b3f334f125f..aa262e1b20c7 100644 --- a/Content.Server/GameObjects/Components/Chemistry/SolutionComponent.cs +++ b/Content.Server/GameObjects/Components/Chemistry/SolutionComponent.cs @@ -488,7 +488,7 @@ private void PerformReaction(ReactionPrototype reaction, ReagentUnit unitReactio //Trigger reaction effects foreach (var effect in reaction.Effects) { - effect.React(Owner, unitReactions.Decimal()); + effect.React(Owner, unitReactions.Double()); } //Play reaction sound client-side diff --git a/Content.Server/GameObjects/Components/Mobs/HeatResistanceComponent.cs b/Content.Server/GameObjects/Components/Mobs/HeatResistanceComponent.cs index 8d3283fe25e5..5e754e5e638b 100644 --- a/Content.Server/GameObjects/Components/Mobs/HeatResistanceComponent.cs +++ b/Content.Server/GameObjects/Components/Mobs/HeatResistanceComponent.cs @@ -1,6 +1,9 @@ using System; using Content.Shared.GameObjects.Components.Inventory; using Robust.Shared.GameObjects; +using CannyFastMath; +using Math = CannyFastMath.Math; +using MathF = CannyFastMath.MathF; namespace Content.Server.GameObjects { diff --git a/Content.Server/GameObjects/Components/Mobs/StunnableComponent.cs b/Content.Server/GameObjects/Components/Mobs/StunnableComponent.cs index e163b56cea7b..8948752b88c5 100644 --- a/Content.Server/GameObjects/Components/Mobs/StunnableComponent.cs +++ b/Content.Server/GameObjects/Components/Mobs/StunnableComponent.cs @@ -21,6 +21,9 @@ using Robust.Shared.Serialization; using Robust.Shared.ViewVariables; using Timer = Robust.Shared.Timers.Timer; +using CannyFastMath; +using Math = CannyFastMath.Math; +using MathF = CannyFastMath.MathF; namespace Content.Server.GameObjects.Components.Mobs { diff --git a/Content.Server/GameObjects/Components/Weapon/Melee/MeleeWeaponComponent.cs b/Content.Server/GameObjects/Components/Weapon/Melee/MeleeWeaponComponent.cs index 6fc9d90f7693..5dce4c17382f 100644 --- a/Content.Server/GameObjects/Components/Weapon/Melee/MeleeWeaponComponent.cs +++ b/Content.Server/GameObjects/Components/Weapon/Melee/MeleeWeaponComponent.cs @@ -15,6 +15,9 @@ using Robust.Shared.Maths; using Robust.Shared.Serialization; using Robust.Shared.ViewVariables; +using CannyFastMath; +using Math = CannyFastMath.Math; +using MathF = CannyFastMath.MathF; namespace Content.Server.GameObjects.Components.Weapon.Melee { diff --git a/Content.Server/GameObjects/EntitySystems/PowerSolarSystem.cs b/Content.Server/GameObjects/EntitySystems/PowerSolarSystem.cs index 562b46395844..fc01bada126e 100644 --- a/Content.Server/GameObjects/EntitySystems/PowerSolarSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/PowerSolarSystem.cs @@ -12,6 +12,9 @@ using Robust.Shared.Maths; using System; using System.Linq; +using CannyFastMath; +using Math = CannyFastMath.Math; +using MathF = CannyFastMath.MathF; namespace Content.Server.GameObjects.EntitySystems { @@ -77,7 +80,7 @@ public override void Initialize() { EntityQuery = new TypeEntityQuery(typeof(SolarPanelComponent)); // Initialize the sun to something random - TowardsSun = Math.PI * 2 * _robustRandom.NextDouble(); + TowardsSun = Math.TAU * _robustRandom.NextDouble(); SunAngularVelocity = Angle.FromDegrees(0.1 + ((_robustRandom.NextDouble() - 0.5) * 0.05)); } diff --git a/Content.Server/Interfaces/Chemistry/IReactionEffect.cs b/Content.Server/Interfaces/Chemistry/IReactionEffect.cs index 9e5e28071bd3..4bd2eb30f024 100644 --- a/Content.Server/Interfaces/Chemistry/IReactionEffect.cs +++ b/Content.Server/Interfaces/Chemistry/IReactionEffect.cs @@ -8,6 +8,6 @@ namespace Content.Shared.Interfaces /// public interface IReactionEffect : IExposeData { - void React(IEntity solutionEntity, decimal intensity); + void React(IEntity solutionEntity, double intensity); } } diff --git a/Content.Server/Throw/ThrowHelper.cs b/Content.Server/Throw/ThrowHelper.cs index 42e0da9e1d81..36ee26581a95 100644 --- a/Content.Server/Throw/ThrowHelper.cs +++ b/Content.Server/Throw/ThrowHelper.cs @@ -13,6 +13,9 @@ using Robust.Shared.Random; using System; using Robust.Shared.Interfaces.Physics; +using CannyFastMath; +using Math = CannyFastMath.Math; +using MathF = CannyFastMath.MathF; namespace Content.Server.Throw { @@ -146,7 +149,7 @@ public static void ThrowTo(IEntity thrownEnt, float throwForceMax, GridCoordinat var forceNecessary = impulseNecessary * (1f / timing.TickRate); // Then clamp it to the max force allowed and call Throw(). - Throw(thrownEnt, Math.Min(forceNecessary, throwForceMax), targetLoc, sourceLoc, spread, throwSourceEnt); + Throw(thrownEnt, MathF.Min(forceNecessary, throwForceMax), targetLoc, sourceLoc, spread, throwSourceEnt); } } } diff --git a/Content.Shared/Chemistry/DefaultMetabolizable.cs b/Content.Shared/Chemistry/DefaultMetabolizable.cs index 05686ccf07e1..20de8420c085 100644 --- a/Content.Shared/Chemistry/DefaultMetabolizable.cs +++ b/Content.Shared/Chemistry/DefaultMetabolizable.cs @@ -10,8 +10,8 @@ namespace Content.Shared.Chemistry class DefaultMetabolizable : IMetabolizable { //Rate of metabolism in units / second - private decimal _metabolismRate = 1; - public decimal MetabolismRate => _metabolismRate; + private double _metabolismRate = 1; + public double MetabolismRate => _metabolismRate; void IExposeData.ExposeData(ObjectSerializer serializer) { @@ -20,7 +20,7 @@ void IExposeData.ExposeData(ObjectSerializer serializer) ReagentUnit IMetabolizable.Metabolize(IEntity solutionEntity, string reagentId, float tickTime) { - return ReagentUnit.New(MetabolismRate * (decimal)tickTime); + return ReagentUnit.New(MetabolismRate * tickTime); } } } diff --git a/Content.Shared/Chemistry/ReagentUnit.cs b/Content.Shared/Chemistry/ReagentUnit.cs index e74bd41fc850..ae71925bbbdc 100644 --- a/Content.Shared/Chemistry/ReagentUnit.cs +++ b/Content.Shared/Chemistry/ReagentUnit.cs @@ -30,11 +30,6 @@ public static ReagentUnit New(int value) return new ReagentUnit(value * (int) Math.Pow(10, Shift)); } - public static ReagentUnit New(decimal value) - { - return new ReagentUnit((int) Math.Round(value * (decimal) Math.Pow(10, Shift), MidpointRounding.AwayFromZero)); - } - public static ReagentUnit New(float value) { return new ReagentUnit(FromFloat(value)); @@ -42,7 +37,7 @@ public static ReagentUnit New(float value) private static int FromFloat(float value) { - return (int) Math.Round(value * (float) Math.Pow(10, Shift), MidpointRounding.AwayFromZero); + return (int) MathF.Round(value * MathF.Pow(10, Shift), MidpointRounding.AwayFromZero); } public static ReagentUnit New(double value) @@ -83,12 +78,6 @@ private static float FloatFromString(string value) return New(aD * b); } - public static ReagentUnit operator *(ReagentUnit a, decimal b) - { - var aD = (decimal) a.ShiftDown(); - return New(aD * b); - } - public static ReagentUnit operator *(ReagentUnit a, double b) { var aD = a.ShiftDown(); @@ -166,11 +155,6 @@ public float Float() return (float) ShiftDown(); } - public decimal Decimal() - { - return (decimal) ShiftDown(); - } - public double Double() { return ShiftDown(); diff --git a/Content.Shared/Chemistry/Solution.cs b/Content.Shared/Chemistry/Solution.cs index 5faefd8430b1..7c452f0ddb89 100644 --- a/Content.Shared/Chemistry/Solution.cs +++ b/Content.Shared/Chemistry/Solution.cs @@ -136,7 +136,7 @@ public void RemoveSolution(ReagentUnit quantity) if(quantity <= 0) return; - var ratio = (TotalVolume - quantity).Decimal() / TotalVolume.Decimal(); + var ratio = (TotalVolume - quantity).Double() / TotalVolume.Double(); if (ratio <= 0) { @@ -180,13 +180,13 @@ public Solution SplitSolution(ReagentUnit quantity) } newSolution = new Solution(); - var newTotalVolume = ReagentUnit.New(0M); + var newTotalVolume = ReagentUnit.New(0); var remainingVolume = TotalVolume; for (var i = 0; i < _contents.Count; i++) { var reagent = _contents[i]; - var ratio = (remainingVolume - quantity).Decimal() / remainingVolume.Decimal(); + var ratio = (remainingVolume - quantity).Double() / remainingVolume.Double(); remainingVolume -= reagent.Quantity; var newQuantity = reagent.Quantity * ratio; diff --git a/Content.Shared/Content.Shared.csproj b/Content.Shared/Content.Shared.csproj index 4afb38c22515..3f40e04a9ea4 100644 --- a/Content.Shared/Content.Shared.csproj +++ b/Content.Shared/Content.Shared.csproj @@ -12,7 +12,7 @@ - + diff --git a/Content.Tests/Shared/Chemistry/ReagentUnit_Tests.cs b/Content.Tests/Shared/Chemistry/ReagentUnit_Tests.cs index 003ecf46637c..ffdb9e79c918 100644 --- a/Content.Tests/Shared/Chemistry/ReagentUnit_Tests.cs +++ b/Content.Tests/Shared/Chemistry/ReagentUnit_Tests.cs @@ -35,16 +35,6 @@ public void ReagentUnitDoubleTests(double value, string expected) Assert.AreEqual(expected, $"{result}"); } - [Test] - [TestCase("1.001", "1")] - [TestCase("0.999", "1")] - public void ReagentUnitDecimalTests(string valueAsString, string expected) - { - var value = decimal.Parse(valueAsString); - var result = ReagentUnit.New(value); - Assert.AreEqual(expected, $"{result}"); - } - [Test] [TestCase("1.005", "1.01")] [TestCase("0.999", "1")] @@ -116,7 +106,7 @@ public void CalculusMultiplication(float aFloat, float bFloat, string expected) [TestCase(2.005f, 201)] public void FloatRoundingTest(float a, int expected) { - var result = (int) Math.Round(a * (float) Math.Pow(10, 2), MidpointRounding.AwayFromZero); + var result = (int) MathF.Round(a * (float) MathF.Pow(10, 2), MidpointRounding.AwayFromZero); Assert.AreEqual(expected, result); }