Merge MathHelper and FloatMath

Requires  space-wizards/RobustToolbox#1234
This commit is contained in:
Visne
2020-08-16 14:54:52 +02:00
parent 745f028b89
commit 0b448b500d
18 changed files with 27 additions and 27 deletions

View File

@@ -113,12 +113,12 @@ namespace Content.Client.GameObjects.Components.Disposal
if (normalized <= leftSideSize)
{
normalized /= leftSideSize; // Adjust range to 0.0 to 1.0
finalHue = FloatMath.Lerp(leftHue, middleHue, normalized);
finalHue = MathHelper.Lerp(leftHue, middleHue, normalized);
}
else
{
normalized = (normalized - leftSideSize) / rightSideSize; // Adjust range to 0.0 to 1.0.
finalHue = FloatMath.Lerp(middleHue, rightHue, normalized);
finalHue = MathHelper.Lerp(middleHue, rightHue, normalized);
}
// Check if null first to avoid repeatedly creating this.

View File

@@ -78,7 +78,7 @@ namespace Content.Client.GameObjects.Components
int level;
if (FloatMath.CloseTo(charge, 0))
if (MathHelper.CloseTo(charge, 0))
{
level = 0;
}

View File

@@ -243,7 +243,7 @@ namespace Content.Client.GameObjects.Components
if (int.TryParse(ev.Text, out var result))
{
result = FloatMath.Clamp(result, 0, byte.MaxValue);
result = MathHelper.Clamp(result, 0, byte.MaxValue);
_ignoreEvents = true;
_colorValue = (byte) result;

View File

@@ -87,7 +87,7 @@ namespace Content.Client.GameObjects.Components.Mobs
// Continually restore camera to 0.
var normalized = _currentKick.Normalized;
_lastKickTime += frameTime;
var restoreRate = FloatMath.Lerp(RestoreRateMin, RestoreRateMax, Math.Min(1, _lastKickTime/RestoreRateRamp));
var restoreRate = MathHelper.Lerp(RestoreRateMin, RestoreRateMax, Math.Min(1, _lastKickTime/RestoreRateRamp));
var restore = normalized * restoreRate * frameTime;
var (x, y) = _currentKick - restore;
if (Math.Sign(x) != Math.Sign(_currentKick.X))

View File

@@ -152,7 +152,7 @@ namespace Content.Client.GameObjects.Components.Mobs
var progress = (_gameTiming.CurTime - start).TotalSeconds / length;
var ratio = (progress <= 1 ? (1 - progress) : (_gameTiming.CurTime - end).TotalSeconds * -5);
cooldownGraphic.Progress = FloatMath.Clamp((float)ratio, -1, 1);
cooldownGraphic.Progress = MathHelper.Clamp((float)ratio, -1, 1);
cooldownGraphic.Visible = ratio > -1f;
}
}

View File

@@ -86,12 +86,12 @@ namespace Content.Client.GameObjects.Components.Power
if (normalizedCharge <= leftSideSize)
{
normalizedCharge /= leftSideSize; // Adjust range to 0.0 to 1.0
finalHue = FloatMath.Lerp(leftHue, middleHue, normalizedCharge);
finalHue = MathHelper.Lerp(leftHue, middleHue, normalizedCharge);
}
else
{
normalizedCharge = (normalizedCharge - leftSideSize) / rightSideSize; // Adjust range to 0.0 to 1.0.
finalHue = FloatMath.Lerp(middleHue, rightHue, normalizedCharge);
finalHue = MathHelper.Lerp(middleHue, rightHue, normalizedCharge);
}
// Check if null first to avoid repeatedly creating this.

View File

@@ -141,7 +141,7 @@ namespace Content.Client.GameObjects.Components.Weapons
const float xOffset = 0.0f;
// Overkill but easy to adjust if you want to mess around with the design
var result = (float) FloatMath.Clamp(slope * (float) Math.Pow(ratio - xOffset, exponent) + yOffset, 0.0, 1.0);
var result = (float) MathHelper.Clamp(slope * (float) Math.Pow(ratio - xOffset, exponent) + yOffset, 0.0, 1.0);
DebugTools.Assert(!float.IsNaN(result));
return result;
}