diff --git a/BuildChecker/BuildChecker.csproj b/BuildChecker/BuildChecker.csproj index 33d05d070d..7acdbe9935 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 ed18e5b05d..6614968153 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 5752aaa4d2..983c229b3b 100644 --- a/Content.Client/GameObjects/Components/Power/SolarControlConsoleBoundUserInterface.cs +++ b/Content.Client/GameObjects/Components/Power/SolarControlConsoleBoundUserInterface.cs @@ -77,7 +77,7 @@ namespace Content.Client.GameObjects.Components.Power 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 e7eeb0c606..9b8e2ce4bd 100644 --- a/Content.Client/Parallax/ParallaxGenerator.cs +++ b/Content.Client/Parallax/ParallaxGenerator.cs @@ -12,6 +12,9 @@ using SixLabors.ImageSharp; 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 @@ namespace Content.Client.Parallax 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 @@ namespace Content.Client.Parallax 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 @@ namespace Content.Client.Parallax 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 @@ namespace Content.Client.Parallax 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 0a60e3adf1..2fd25666df 100644 --- a/Content.Client/State/LobbyState.cs +++ b/Content.Client/State/LobbyState.cs @@ -18,6 +18,9 @@ using Robust.Shared.Localization; 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 6bd8f3bade..ae09ec8fb8 100644 --- a/Content.Client/UserInterface/CooldownGraphic.cs +++ b/Content.Client/UserInterface/CooldownGraphic.cs @@ -6,6 +6,9 @@ using System; 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 @@ namespace Robust.Client.UserInterface.Controls { 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 @@ namespace Robust.Client.UserInterface.Controls } 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 7e3213e930..8d92cff95d 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 dcc3debeff..2d0cdb163c 100644 --- a/Content.Server/AI/StaticBarkerProcessor.cs +++ b/Content.Server/AI/StaticBarkerProcessor.cs @@ -5,6 +5,9 @@ using Robust.Server.AI; 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 @@ namespace Content.Server.AI { 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 bcd7b3579c..f1430efaf5 100644 --- a/Content.Server/AI/WanderProcessor.cs +++ b/Content.Server/AI/WanderProcessor.cs @@ -214,7 +214,7 @@ namespace Content.Server.AI 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 d220bb1805..bbf83bc5d8 100644 --- a/Content.Server/Chemistry/Metabolism/DefaultFood.cs +++ b/Content.Server/Chemistry/Metabolism/DefaultFood.cs @@ -24,7 +24,7 @@ namespace Content.Server.Chemistry.Metabolism 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 @@ namespace Content.Server.Chemistry.Metabolism 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 2bdff9b1c2..1996e287a6 100644 --- a/Content.Server/Chemistry/ReactionEffects/ExplosionReactionEffect.cs +++ b/Content.Server/Chemistry/ReactionEffects/ExplosionReactionEffect.cs @@ -4,6 +4,9 @@ using Content.Server.GameObjects.Components.Chemistry; 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 @@ namespace Content.Server.Chemistry.ReactionEffects 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 @@ namespace Content.Server.Chemistry.ReactionEffects //Handle scaling if (_scaled) { - floatIntensity = Math.Min(floatIntensity, _maxScale); + floatIntensity = MathF.Min(floatIntensity, _maxScale); } else { @@ -54,10 +57,10 @@ namespace Content.Server.Chemistry.ReactionEffects } //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 f1b977269d..0c9be50c54 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 fdbd9ed5ca..3d14e1c481 100644 --- a/Content.Server/GameObjects/Components/Chemistry/PourableComponent.cs +++ b/Content.Server/GameObjects/Components/Chemistry/PourableComponent.cs @@ -47,7 +47,7 @@ namespace Content.Server.GameObjects.Components.Chemistry 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 1b3f334f12..aa262e1b20 100644 --- a/Content.Server/GameObjects/Components/Chemistry/SolutionComponent.cs +++ b/Content.Server/GameObjects/Components/Chemistry/SolutionComponent.cs @@ -488,7 +488,7 @@ namespace Content.Server.GameObjects.Components.Chemistry //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 8d3283fe25..5e754e5e63 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 e163b56cea..8948752b88 100644 --- a/Content.Server/GameObjects/Components/Mobs/StunnableComponent.cs +++ b/Content.Server/GameObjects/Components/Mobs/StunnableComponent.cs @@ -21,6 +21,9 @@ using Robust.Shared.Maths; 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 6fc9d90f76..5dce4c1738 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.IoC; 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 562b463958..fc01bada12 100644 --- a/Content.Server/GameObjects/EntitySystems/PowerSolarSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/PowerSolarSystem.cs @@ -12,6 +12,9 @@ using Robust.Shared.IoC; 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 @@ namespace Content.Server.GameObjects.EntitySystems { 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 9e5e28071b..4bd2eb30f0 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 42e0da9e1d..36ee26581a 100644 --- a/Content.Server/Throw/ThrowHelper.cs +++ b/Content.Server/Throw/ThrowHelper.cs @@ -13,6 +13,9 @@ using Robust.Shared.Physics; 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 @@ namespace Content.Server.Throw 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 05686ccf07..20de8420c0 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 @@ namespace Content.Shared.Chemistry 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 e74bd41fc8..ae71925bbb 100644 --- a/Content.Shared/Chemistry/ReagentUnit.cs +++ b/Content.Shared/Chemistry/ReagentUnit.cs @@ -30,11 +30,6 @@ namespace Content.Shared.Chemistry 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 @@ namespace Content.Shared.Chemistry 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 @@ namespace Content.Shared.Chemistry 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 @@ namespace Content.Shared.Chemistry 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 5faefd8430..7c452f0ddb 100644 --- a/Content.Shared/Chemistry/Solution.cs +++ b/Content.Shared/Chemistry/Solution.cs @@ -136,7 +136,7 @@ namespace Content.Shared.Chemistry 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 @@ namespace Content.Shared.Chemistry } 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 4afb38c225..3f40e04a9e 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 003ecf4663..ffdb9e79c9 100644 --- a/Content.Tests/Shared/Chemistry/ReagentUnit_Tests.cs +++ b/Content.Tests/Shared/Chemistry/ReagentUnit_Tests.cs @@ -35,16 +35,6 @@ namespace Content.Tests.Shared.Chemistry 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 @@ namespace Content.Tests.Shared.Chemistry [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); }