use CannyFastMath in various places even where it might not be any different
also update a bunch of packages clean up redundant YamlDotNet references
This commit is contained in:
@@ -18,6 +18,7 @@ https://docs.microsoft.com/en-us/visualstudio/msbuild/msbuild
|
|||||||
<Python Condition="'$(OS)'=='Windows_NT' Or '$(OS)'=='Windows'">py -3</Python>
|
<Python Condition="'$(OS)'=='Windows_NT' Or '$(OS)'=='Windows'">py -3</Python>
|
||||||
<ProjectGuid>{C899FCA4-7037-4E49-ABC2-44DE72487110}</ProjectGuid>
|
<ProjectGuid>{C899FCA4-7037-4E49-ABC2-44DE72487110}</ProjectGuid>
|
||||||
<TargetFrameworkMoniker>.NETFramework, Version=v4.7.2</TargetFrameworkMoniker>
|
<TargetFrameworkMoniker>.NETFramework, Version=v4.7.2</TargetFrameworkMoniker>
|
||||||
|
<RestorePackages>false</RestorePackages>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Library</OutputType>
|
<OutputType>Library</OutputType>
|
||||||
|
|||||||
@@ -11,10 +11,10 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Import Project="..\RobustToolbox\MSBuild\Robust.DefineConstants.targets" />
|
<Import Project="..\RobustToolbox\MSBuild\Robust.DefineConstants.targets" />
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Nett" Version="0.13.0" />
|
<PackageReference Include="Nett" Version="0.15.0" />
|
||||||
<PackageReference Include="SixLabors.ImageSharp" Version="1.0.0-rc0002" />
|
<PackageReference Include="SixLabors.ImageSharp" Version="1.0.0-rc0002" />
|
||||||
<PackageReference Include="SixLabors.ImageSharp.Drawing" Version="1.0.0-beta0009" />
|
<PackageReference Include="SixLabors.ImageSharp.Drawing" Version="1.0.0-beta0009" />
|
||||||
<PackageReference Include="YamlDotNet" Version="8.1.0" />
|
<PackageReference Include="JetBrains.Annotations" Version="2020.1.0" PrivateAssets="All" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\RobustToolbox\Lidgren.Network\Lidgren.Network.csproj" />
|
<ProjectReference Include="..\RobustToolbox\Lidgren.Network\Lidgren.Network.csproj" />
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ namespace Content.Client.GameObjects.Components.Power
|
|||||||
SolarControlConsoleBoundInterfaceState scc = (SolarControlConsoleBoundInterfaceState) state;
|
SolarControlConsoleBoundInterfaceState scc = (SolarControlConsoleBoundInterfaceState) state;
|
||||||
_lastState = scc;
|
_lastState = scc;
|
||||||
_window.NotARadar.UpdateState(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);
|
_window.SunAngle.Text = FormatAngle(scc.TowardsSun);
|
||||||
UpdateField(_window.PanelRotation, FormatAngle(scc.Rotation));
|
UpdateField(_window.PanelRotation, FormatAngle(scc.Rotation));
|
||||||
UpdateField(_window.PanelVelocity, FormatAngle(scc.AngularVelocity * 60));
|
UpdateField(_window.PanelVelocity, FormatAngle(scc.AngularVelocity * 60));
|
||||||
|
|||||||
@@ -12,6 +12,9 @@ using SixLabors.ImageSharp;
|
|||||||
using SixLabors.ImageSharp.Advanced;
|
using SixLabors.ImageSharp.Advanced;
|
||||||
using SixLabors.ImageSharp.PixelFormats;
|
using SixLabors.ImageSharp.PixelFormats;
|
||||||
using Color = Robust.Shared.Maths.Color;
|
using Color = Robust.Shared.Maths.Color;
|
||||||
|
using CannyFastMath;
|
||||||
|
using Math = CannyFastMath.Math;
|
||||||
|
using MathF = CannyFastMath.MathF;
|
||||||
|
|
||||||
namespace Content.Client.Parallax
|
namespace Content.Client.Parallax
|
||||||
{
|
{
|
||||||
@@ -78,7 +81,7 @@ namespace Content.Client.Parallax
|
|||||||
private readonly NoiseGenerator.NoiseType NoiseType = NoiseGenerator.NoiseType.Fbm;
|
private readonly NoiseGenerator.NoiseType NoiseType = NoiseGenerator.NoiseType.Fbm;
|
||||||
private readonly uint Seed = 1234;
|
private readonly uint Seed = 1234;
|
||||||
private readonly float Persistence = 0.5f;
|
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 float Frequency = 1;
|
||||||
private readonly uint Octaves = 3;
|
private readonly uint Octaves = 3;
|
||||||
private readonly float Threshold;
|
private readonly float Threshold;
|
||||||
@@ -179,12 +182,12 @@ namespace Content.Client.Parallax
|
|||||||
for (var x = 0; x < bitmap.Width; x++)
|
for (var x = 0; x < bitmap.Width; x++)
|
||||||
{
|
{
|
||||||
// Do noise calculations.
|
// 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
|
// Threshold
|
||||||
noiseVal = Math.Max(0, noiseVal - Threshold);
|
noiseVal = MathF.Max(0, noiseVal - Threshold);
|
||||||
noiseVal *= threshVal;
|
noiseVal *= threshVal;
|
||||||
noiseVal = (float) Math.Pow(noiseVal, powFactor);
|
noiseVal = (float) MathF.Pow(noiseVal, powFactor);
|
||||||
|
|
||||||
// Get colors based on noise values.
|
// Get colors based on noise values.
|
||||||
var srcColor = Color.InterpolateBetween(OuterColor, InnerColor, noiseVal)
|
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 NoiseGenerator.NoiseType MaskNoiseType = NoiseGenerator.NoiseType.Fbm;
|
||||||
private readonly uint MaskSeed = 1234;
|
private readonly uint MaskSeed = 1234;
|
||||||
private readonly float MaskPersistence = 0.5f;
|
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 float MaskFrequency = 1;
|
||||||
private readonly uint MaskOctaves = 3;
|
private readonly uint MaskOctaves = 3;
|
||||||
private readonly float MaskThreshold;
|
private readonly float MaskThreshold;
|
||||||
@@ -406,11 +409,11 @@ namespace Content.Client.Parallax
|
|||||||
var y = random.Next(0, buffer.Height);
|
var y = random.Next(0, buffer.Height);
|
||||||
|
|
||||||
// Grab noise at this point.
|
// 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
|
// Threshold
|
||||||
noiseVal = Math.Max(0, noiseVal - MaskThreshold);
|
noiseVal = MathF.Max(0, noiseVal - MaskThreshold);
|
||||||
noiseVal *= threshVal;
|
noiseVal *= threshVal;
|
||||||
noiseVal = (float) Math.Pow(noiseVal, powFactor);
|
noiseVal = (float) MathF.Pow(noiseVal, powFactor);
|
||||||
|
|
||||||
var randomThresh = random.NextFloat();
|
var randomThresh = random.NextFloat();
|
||||||
if (randomThresh > noiseVal)
|
if (randomThresh > noiseVal)
|
||||||
|
|||||||
@@ -18,6 +18,9 @@ using Robust.Shared.Localization;
|
|||||||
using Robust.Shared.Prototypes;
|
using Robust.Shared.Prototypes;
|
||||||
using Robust.Shared.Timing;
|
using Robust.Shared.Timing;
|
||||||
using Robust.Shared.ViewVariables;
|
using Robust.Shared.ViewVariables;
|
||||||
|
using CannyFastMath;
|
||||||
|
using Math = CannyFastMath.Math;
|
||||||
|
using MathF = CannyFastMath.MathF;
|
||||||
|
|
||||||
namespace Content.Client.State
|
namespace Content.Client.State
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -6,6 +6,9 @@ using System;
|
|||||||
using Robust.Client.Graphics.Shaders;
|
using Robust.Client.Graphics.Shaders;
|
||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
using Robust.Shared.Prototypes;
|
using Robust.Shared.Prototypes;
|
||||||
|
using CannyFastMath;
|
||||||
|
using Math = CannyFastMath.Math;
|
||||||
|
using MathF = CannyFastMath.MathF;
|
||||||
|
|
||||||
namespace Robust.Client.UserInterface.Controls
|
namespace Robust.Client.UserInterface.Controls
|
||||||
{
|
{
|
||||||
@@ -33,7 +36,7 @@ namespace Robust.Client.UserInterface.Controls
|
|||||||
{
|
{
|
||||||
Color color;
|
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)
|
if (Progress >= 0f)
|
||||||
{
|
{
|
||||||
@@ -42,7 +45,7 @@ namespace Robust.Client.UserInterface.Controls
|
|||||||
}
|
}
|
||||||
else
|
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);
|
color = new Color(1f, 1f, 1f, alpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="3.1.0" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="3.1.0" />
|
||||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="3.1.0" />
|
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="3.1.4" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -5,6 +5,9 @@ using Robust.Server.AI;
|
|||||||
using Robust.Shared.Interfaces.Timing;
|
using Robust.Shared.Interfaces.Timing;
|
||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
using Robust.Shared.Utility;
|
using Robust.Shared.Utility;
|
||||||
|
using CannyFastMath;
|
||||||
|
using Math = CannyFastMath.Math;
|
||||||
|
using MathF = CannyFastMath.MathF;
|
||||||
|
|
||||||
namespace Content.Server.AI
|
namespace Content.Server.AI
|
||||||
{
|
{
|
||||||
@@ -35,7 +38,7 @@ namespace Content.Server.AI
|
|||||||
{
|
{
|
||||||
if(_timeMan.CurTime < _nextBark)
|
if(_timeMan.CurTime < _nextBark)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var rngState = GenSeed();
|
var rngState = GenSeed();
|
||||||
_nextBark = _timeMan.CurTime + MinimumDelay + TimeSpan.FromSeconds(Random01(ref rngState) * 10);
|
_nextBark = _timeMan.CurTime + MinimumDelay + TimeSpan.FromSeconds(Random01(ref rngState) * 10);
|
||||||
|
|
||||||
|
|||||||
@@ -214,7 +214,7 @@ namespace Content.Server.AI
|
|||||||
if(Random01(ref rngState) < 0.5f)
|
if(Random01(ref rngState) < 0.5f)
|
||||||
return;
|
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]);
|
_chatMan.EntitySay(SelfEntity, _normalAssistantConversation[pick]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ namespace Content.Server.Chemistry.Metabolism
|
|||||||
|
|
||||||
void IExposeData.ExposeData(ObjectSerializer serializer)
|
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);
|
serializer.DataField(ref _nutritionFactor, "nutrimentFactor", 30.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -36,7 +36,7 @@ namespace Content.Server.Chemistry.Metabolism
|
|||||||
hunger.UpdateFood(metabolismAmount.Float() * NutritionFactor);
|
hunger.UpdateFood(metabolismAmount.Float() * NutritionFactor);
|
||||||
|
|
||||||
//Return amount of reagent to be removed, remove reagent regardless of HungerComponent presence
|
//Return amount of reagent to be removed, remove reagent regardless of HungerComponent presence
|
||||||
return metabolismAmount;
|
return metabolismAmount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,9 @@ using Content.Server.GameObjects.Components.Chemistry;
|
|||||||
using Content.Shared.Interfaces;
|
using Content.Shared.Interfaces;
|
||||||
using Robust.Shared.Interfaces.GameObjects;
|
using Robust.Shared.Interfaces.GameObjects;
|
||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
|
using CannyFastMath;
|
||||||
|
using Math = CannyFastMath.Math;
|
||||||
|
using MathF = CannyFastMath.MathF;
|
||||||
|
|
||||||
namespace Content.Server.Chemistry.ReactionEffects
|
namespace Content.Server.Chemistry.ReactionEffects
|
||||||
{
|
{
|
||||||
@@ -35,9 +38,9 @@ namespace Content.Server.Chemistry.ReactionEffects
|
|||||||
serializer.DataField(ref _maxScale, "maxScale", 1);
|
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)
|
if (solutionEntity == null)
|
||||||
return;
|
return;
|
||||||
if(!solutionEntity.TryGetComponent(out SolutionComponent solution))
|
if(!solutionEntity.TryGetComponent(out SolutionComponent solution))
|
||||||
@@ -46,7 +49,7 @@ namespace Content.Server.Chemistry.ReactionEffects
|
|||||||
//Handle scaling
|
//Handle scaling
|
||||||
if (_scaled)
|
if (_scaled)
|
||||||
{
|
{
|
||||||
floatIntensity = Math.Min(floatIntensity, _maxScale);
|
floatIntensity = MathF.Min(floatIntensity, _maxScale);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -54,10 +57,10 @@ namespace Content.Server.Chemistry.ReactionEffects
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Calculate intensities
|
//Calculate intensities
|
||||||
int finalDevastationRange = (int)Math.Round(_devastationRange * floatIntensity);
|
int finalDevastationRange = (int)MathF.Round(_devastationRange * floatIntensity);
|
||||||
int finalHeavyImpactRange = (int)Math.Round(_heavyImpactRange * floatIntensity);
|
int finalHeavyImpactRange = (int)MathF.Round(_heavyImpactRange * floatIntensity);
|
||||||
int finalLightImpactRange = (int)Math.Round(_lightImpactRange * floatIntensity);
|
int finalLightImpactRange = (int)MathF.Round(_lightImpactRange * floatIntensity);
|
||||||
int finalFlashRange = (int)Math.Round(_flashRange * floatIntensity);
|
int finalFlashRange = (int)MathF.Round(_flashRange * floatIntensity);
|
||||||
ExplosionHelper.SpawnExplosion(solutionEntity.Transform.GridPosition, finalDevastationRange,
|
ExplosionHelper.SpawnExplosion(solutionEntity.Transform.GridPosition, finalDevastationRange,
|
||||||
finalHeavyImpactRange, finalLightImpactRange, finalFlashRange);
|
finalHeavyImpactRange, finalLightImpactRange, finalFlashRange);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
<Import Project="..\RobustToolbox\MSBuild\Robust.DefineConstants.targets" />
|
<Import Project="..\RobustToolbox\MSBuild\Robust.DefineConstants.targets" />
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" />
|
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" />
|
||||||
<PackageReference Include="YamlDotNet" Version="8.1.0" />
|
<PackageReference Include="JetBrains.Annotations" Version="2020.1.0" PrivateAssets="All" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Content.Server.Database\Content.Server.Database.csproj" />
|
<ProjectReference Include="..\Content.Server.Database\Content.Server.Database.csproj" />
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ namespace Content.Server.GameObjects.Components.Chemistry
|
|||||||
public override void ExposeData(ObjectSerializer serializer)
|
public override void ExposeData(ObjectSerializer serializer)
|
||||||
{
|
{
|
||||||
base.ExposeData(serializer);
|
base.ExposeData(serializer);
|
||||||
serializer.DataField(ref _transferAmount, "transferAmount", ReagentUnit.New(5.0M));
|
serializer.DataField(ref _transferAmount, "transferAmount", ReagentUnit.New(5.0));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -488,7 +488,7 @@ namespace Content.Server.GameObjects.Components.Chemistry
|
|||||||
//Trigger reaction effects
|
//Trigger reaction effects
|
||||||
foreach (var effect in reaction.Effects)
|
foreach (var effect in reaction.Effects)
|
||||||
{
|
{
|
||||||
effect.React(Owner, unitReactions.Decimal());
|
effect.React(Owner, unitReactions.Double());
|
||||||
}
|
}
|
||||||
|
|
||||||
//Play reaction sound client-side
|
//Play reaction sound client-side
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
using System;
|
using System;
|
||||||
using Content.Shared.GameObjects.Components.Inventory;
|
using Content.Shared.GameObjects.Components.Inventory;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
|
using CannyFastMath;
|
||||||
|
using Math = CannyFastMath.Math;
|
||||||
|
using MathF = CannyFastMath.MathF;
|
||||||
|
|
||||||
namespace Content.Server.GameObjects
|
namespace Content.Server.GameObjects
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -21,6 +21,9 @@ using Robust.Shared.Maths;
|
|||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
using Robust.Shared.ViewVariables;
|
using Robust.Shared.ViewVariables;
|
||||||
using Timer = Robust.Shared.Timers.Timer;
|
using Timer = Robust.Shared.Timers.Timer;
|
||||||
|
using CannyFastMath;
|
||||||
|
using Math = CannyFastMath.Math;
|
||||||
|
using MathF = CannyFastMath.MathF;
|
||||||
|
|
||||||
namespace Content.Server.GameObjects.Components.Mobs
|
namespace Content.Server.GameObjects.Components.Mobs
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -15,6 +15,9 @@ using Robust.Shared.IoC;
|
|||||||
using Robust.Shared.Maths;
|
using Robust.Shared.Maths;
|
||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
using Robust.Shared.ViewVariables;
|
using Robust.Shared.ViewVariables;
|
||||||
|
using CannyFastMath;
|
||||||
|
using Math = CannyFastMath.Math;
|
||||||
|
using MathF = CannyFastMath.MathF;
|
||||||
|
|
||||||
namespace Content.Server.GameObjects.Components.Weapon.Melee
|
namespace Content.Server.GameObjects.Components.Weapon.Melee
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -12,6 +12,9 @@ using Robust.Shared.IoC;
|
|||||||
using Robust.Shared.Maths;
|
using Robust.Shared.Maths;
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using CannyFastMath;
|
||||||
|
using Math = CannyFastMath.Math;
|
||||||
|
using MathF = CannyFastMath.MathF;
|
||||||
|
|
||||||
namespace Content.Server.GameObjects.EntitySystems
|
namespace Content.Server.GameObjects.EntitySystems
|
||||||
{
|
{
|
||||||
@@ -77,7 +80,7 @@ namespace Content.Server.GameObjects.EntitySystems
|
|||||||
{
|
{
|
||||||
EntityQuery = new TypeEntityQuery(typeof(SolarPanelComponent));
|
EntityQuery = new TypeEntityQuery(typeof(SolarPanelComponent));
|
||||||
// Initialize the sun to something random
|
// 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));
|
SunAngularVelocity = Angle.FromDegrees(0.1 + ((_robustRandom.NextDouble() - 0.5) * 0.05));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,6 @@ namespace Content.Shared.Interfaces
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IReactionEffect : IExposeData
|
public interface IReactionEffect : IExposeData
|
||||||
{
|
{
|
||||||
void React(IEntity solutionEntity, decimal intensity);
|
void React(IEntity solutionEntity, double intensity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,9 @@ using Robust.Shared.Physics;
|
|||||||
using Robust.Shared.Random;
|
using Robust.Shared.Random;
|
||||||
using System;
|
using System;
|
||||||
using Robust.Shared.Interfaces.Physics;
|
using Robust.Shared.Interfaces.Physics;
|
||||||
|
using CannyFastMath;
|
||||||
|
using Math = CannyFastMath.Math;
|
||||||
|
using MathF = CannyFastMath.MathF;
|
||||||
|
|
||||||
namespace Content.Server.Throw
|
namespace Content.Server.Throw
|
||||||
{
|
{
|
||||||
@@ -146,7 +149,7 @@ namespace Content.Server.Throw
|
|||||||
var forceNecessary = impulseNecessary * (1f / timing.TickRate);
|
var forceNecessary = impulseNecessary * (1f / timing.TickRate);
|
||||||
|
|
||||||
// Then clamp it to the max force allowed and call Throw().
|
// 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ namespace Content.Shared.Chemistry
|
|||||||
class DefaultMetabolizable : IMetabolizable
|
class DefaultMetabolizable : IMetabolizable
|
||||||
{
|
{
|
||||||
//Rate of metabolism in units / second
|
//Rate of metabolism in units / second
|
||||||
private decimal _metabolismRate = 1;
|
private double _metabolismRate = 1;
|
||||||
public decimal MetabolismRate => _metabolismRate;
|
public double MetabolismRate => _metabolismRate;
|
||||||
|
|
||||||
void IExposeData.ExposeData(ObjectSerializer serializer)
|
void IExposeData.ExposeData(ObjectSerializer serializer)
|
||||||
{
|
{
|
||||||
@@ -20,7 +20,7 @@ namespace Content.Shared.Chemistry
|
|||||||
|
|
||||||
ReagentUnit IMetabolizable.Metabolize(IEntity solutionEntity, string reagentId, float tickTime)
|
ReagentUnit IMetabolizable.Metabolize(IEntity solutionEntity, string reagentId, float tickTime)
|
||||||
{
|
{
|
||||||
return ReagentUnit.New(MetabolismRate * (decimal)tickTime);
|
return ReagentUnit.New(MetabolismRate * tickTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,11 +30,6 @@ namespace Content.Shared.Chemistry
|
|||||||
return new ReagentUnit(value * (int) Math.Pow(10, Shift));
|
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)
|
public static ReagentUnit New(float value)
|
||||||
{
|
{
|
||||||
return new ReagentUnit(FromFloat(value));
|
return new ReagentUnit(FromFloat(value));
|
||||||
@@ -42,7 +37,7 @@ namespace Content.Shared.Chemistry
|
|||||||
|
|
||||||
private static int FromFloat(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)
|
public static ReagentUnit New(double value)
|
||||||
@@ -83,12 +78,6 @@ namespace Content.Shared.Chemistry
|
|||||||
return New(aD * b);
|
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)
|
public static ReagentUnit operator *(ReagentUnit a, double b)
|
||||||
{
|
{
|
||||||
var aD = a.ShiftDown();
|
var aD = a.ShiftDown();
|
||||||
@@ -166,11 +155,6 @@ namespace Content.Shared.Chemistry
|
|||||||
return (float) ShiftDown();
|
return (float) ShiftDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
public decimal Decimal()
|
|
||||||
{
|
|
||||||
return (decimal) ShiftDown();
|
|
||||||
}
|
|
||||||
|
|
||||||
public double Double()
|
public double Double()
|
||||||
{
|
{
|
||||||
return ShiftDown();
|
return ShiftDown();
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ namespace Content.Shared.Chemistry
|
|||||||
if(quantity <= 0)
|
if(quantity <= 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var ratio = (TotalVolume - quantity).Decimal() / TotalVolume.Decimal();
|
var ratio = (TotalVolume - quantity).Double() / TotalVolume.Double();
|
||||||
|
|
||||||
if (ratio <= 0)
|
if (ratio <= 0)
|
||||||
{
|
{
|
||||||
@@ -180,13 +180,13 @@ namespace Content.Shared.Chemistry
|
|||||||
}
|
}
|
||||||
|
|
||||||
newSolution = new Solution();
|
newSolution = new Solution();
|
||||||
var newTotalVolume = ReagentUnit.New(0M);
|
var newTotalVolume = ReagentUnit.New(0);
|
||||||
var remainingVolume = TotalVolume;
|
var remainingVolume = TotalVolume;
|
||||||
|
|
||||||
for (var i = 0; i < _contents.Count; i++)
|
for (var i = 0; i < _contents.Count; i++)
|
||||||
{
|
{
|
||||||
var reagent = _contents[i];
|
var reagent = _contents[i];
|
||||||
var ratio = (remainingVolume - quantity).Decimal() / remainingVolume.Decimal();
|
var ratio = (remainingVolume - quantity).Double() / remainingVolume.Double();
|
||||||
remainingVolume -= reagent.Quantity;
|
remainingVolume -= reagent.Quantity;
|
||||||
|
|
||||||
var newQuantity = reagent.Quantity * ratio;
|
var newQuantity = reagent.Quantity * ratio;
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Import Project="..\RobustToolbox\MSBuild\Robust.DefineConstants.targets" />
|
<Import Project="..\RobustToolbox\MSBuild\Robust.DefineConstants.targets" />
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="YamlDotNet" Version="8.1.0" />
|
<PackageReference Include="JetBrains.Annotations" Version="2020.1.0" PrivateAssets="All" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\RobustToolbox\Lidgren.Network\Lidgren.Network.csproj">
|
<ProjectReference Include="..\RobustToolbox\Lidgren.Network\Lidgren.Network.csproj">
|
||||||
|
|||||||
@@ -35,16 +35,6 @@ namespace Content.Tests.Shared.Chemistry
|
|||||||
Assert.AreEqual(expected, $"{result}");
|
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]
|
[Test]
|
||||||
[TestCase("1.005", "1.01")]
|
[TestCase("1.005", "1.01")]
|
||||||
[TestCase("0.999", "1")]
|
[TestCase("0.999", "1")]
|
||||||
@@ -116,7 +106,7 @@ namespace Content.Tests.Shared.Chemistry
|
|||||||
[TestCase(2.005f, 201)]
|
[TestCase(2.005f, 201)]
|
||||||
public void FloatRoundingTest(float a, int expected)
|
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);
|
Assert.AreEqual(expected, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user