Merge MathHelper and FloatMath
Requires space-wizards/RobustToolbox#1234
This commit is contained in:
@@ -106,13 +106,13 @@ namespace Content.Client.Chat
|
||||
}
|
||||
|
||||
// Lerp to our new vertical offset if it's been modified.
|
||||
if (FloatMath.CloseTo(_verticalOffsetAchieved - VerticalOffset, 0, 0.1))
|
||||
if (MathHelper.CloseTo(_verticalOffsetAchieved - VerticalOffset, 0, 0.1))
|
||||
{
|
||||
_verticalOffsetAchieved = VerticalOffset;
|
||||
}
|
||||
else
|
||||
{
|
||||
_verticalOffsetAchieved = FloatMath.Lerp(_verticalOffsetAchieved, VerticalOffset, 10 * args.DeltaSeconds);
|
||||
_verticalOffsetAchieved = MathHelper.Lerp(_verticalOffsetAchieved, VerticalOffset, 10 * args.DeltaSeconds);
|
||||
}
|
||||
|
||||
var worldPos = _senderEntity.Transform.WorldPosition;
|
||||
@@ -122,7 +122,7 @@ namespace Content.Client.Chat
|
||||
var screenPos = lowerCenter - (Width / 2, ContentHeight + _verticalOffsetAchieved);
|
||||
LayoutContainer.SetPosition(this, screenPos);
|
||||
|
||||
var height = FloatMath.Clamp(lowerCenter.Y - screenPos.Y, 0, ContentHeight);
|
||||
var height = MathHelper.Clamp(lowerCenter.Y - screenPos.Y, 0, ContentHeight);
|
||||
LayoutContainer.SetSize(this, (Size.X, height));
|
||||
}
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -78,7 +78,7 @@ namespace Content.Client.GameObjects.Components
|
||||
|
||||
int level;
|
||||
|
||||
if (FloatMath.CloseTo(charge, 0))
|
||||
if (MathHelper.CloseTo(charge, 0))
|
||||
{
|
||||
level = 0;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace Content.Client.UserInterface
|
||||
}
|
||||
else
|
||||
{
|
||||
var alpha = FloatMath.Clamp(0.5f * lerp, 0f, 0.5f);
|
||||
var alpha = MathHelper.Clamp(0.5f * lerp, 0f, 0.5f);
|
||||
color = new Color(1f, 1f, 1f, alpha);
|
||||
}
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@ namespace Content.Client.UserInterface
|
||||
var progress = (_gameTiming.CurTime - start).TotalSeconds / length;
|
||||
var ratio = (progress <= 1 ? (1 - progress) : (_gameTiming.CurTime - end).TotalSeconds * -5);
|
||||
|
||||
cooldownDisplay.Progress = FloatMath.Clamp((float)ratio, -1, 1);
|
||||
cooldownDisplay.Progress = MathHelper.Clamp((float)ratio, -1, 1);
|
||||
|
||||
if (ratio > -1f)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user