Update CloseTo to CloseToPercent (#4708)
This commit is contained in:
@@ -101,7 +101,7 @@ namespace Content.Client.Chat.UI
|
||||
}
|
||||
|
||||
// Lerp to our new vertical offset if it's been modified.
|
||||
if (MathHelper.CloseTo(_verticalOffsetAchieved - VerticalOffset, 0, 0.1))
|
||||
if (MathHelper.CloseToPercent(_verticalOffsetAchieved - VerticalOffset, 0, 0.1))
|
||||
{
|
||||
_verticalOffsetAchieved = VerticalOffset;
|
||||
}
|
||||
|
||||
@@ -140,7 +140,7 @@ namespace Content.Client.EscapeMenu.UI.Tabs
|
||||
var isFullscreenSame = FullscreenCheckBox.Pressed == ConfigIsFullscreen;
|
||||
var isLightingQualitySame = LightingPresetOption.SelectedId == GetConfigLightingQuality();
|
||||
var isHudThemeSame = HudThemeOption.SelectedId == _cfg.GetCVar(CCVars.HudTheme);
|
||||
var isUIScaleSame = MathHelper.CloseTo(UIScaleOptions[UIScaleOption.SelectedId], ConfigUIScale);
|
||||
var isUIScaleSame = MathHelper.CloseToPercent(UIScaleOptions[UIScaleOption.SelectedId], ConfigUIScale);
|
||||
var isVPStretchSame = ViewportStretchCheckBox.Pressed == _cfg.GetCVar(CCVars.ViewportStretch);
|
||||
var isVPScaleSame = (int) ViewportScaleSlider.Value == _cfg.GetCVar(CCVars.ViewportFixedScaleFactor);
|
||||
var isIntegerScalingSame = IntegerScalingCheckBox.Pressed == (_cfg.GetCVar(CCVars.ViewportSnapToleranceMargin) != 0);
|
||||
@@ -215,7 +215,7 @@ namespace Content.Client.EscapeMenu.UI.Tabs
|
||||
{
|
||||
for (var i = 0; i < UIScaleOptions.Length; i++)
|
||||
{
|
||||
if (MathHelper.CloseTo(UIScaleOptions[i], value))
|
||||
if (MathHelper.CloseToPercent(UIScaleOptions[i], value))
|
||||
{
|
||||
return i;
|
||||
}
|
||||
|
||||
@@ -263,7 +263,7 @@ namespace Content.Client.Tabletop
|
||||
var max = (eyePosition + size / 2) / eyeScale;
|
||||
|
||||
// If 90/270 degrees rotated, flip X and Y
|
||||
if (MathHelper.CloseTo(eyeRotation.Degrees % 180d, 90d) || MathHelper.CloseTo(eyeRotation.Degrees % 180d, -90d))
|
||||
if (MathHelper.CloseToPercent(eyeRotation.Degrees % 180d, 90d) || MathHelper.CloseToPercent(eyeRotation.Degrees % 180d, -90d))
|
||||
{
|
||||
(min.Y, min.X) = (min.X, min.Y);
|
||||
(max.Y, max.X) = (max.X, max.Y);
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems
|
||||
|
||||
var outputStartingPressure = outlet.Air.Pressure;
|
||||
|
||||
if (MathHelper.CloseTo(pump.TargetPressure, outputStartingPressure))
|
||||
if (MathHelper.CloseToPercent(pump.TargetPressure, outputStartingPressure))
|
||||
{
|
||||
appearance?.SetData(PressurePumpVisuals.Enabled, false);
|
||||
return; // No need to pump gas if target has been reached.
|
||||
|
||||
@@ -186,7 +186,7 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
|
||||
DirtyUI(uid, canister, nodeContainer, containerManager);
|
||||
|
||||
// If last pressure is very close to the current pressure, do nothing.
|
||||
if (MathHelper.CloseTo(canister.Air.Pressure, canister.LastPressure))
|
||||
if (MathHelper.CloseToPercent(canister.Air.Pressure, canister.LastPressure))
|
||||
return;
|
||||
|
||||
canister.LastPressure = canister.Air.Pressure;
|
||||
|
||||
@@ -85,7 +85,7 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
|
||||
var removed = tile.Remove(transferMoles);
|
||||
|
||||
// Nothing left to remove from the tile.
|
||||
if (MathHelper.CloseTo(removed.TotalMoles, 0f))
|
||||
if (MathHelper.CloseToPercent(removed.TotalMoles, 0f))
|
||||
return;
|
||||
|
||||
atmosphereSystem.ScrubInto(removed, outlet.Air, scrubber.FilterGases);
|
||||
|
||||
@@ -178,7 +178,7 @@ namespace Content.Server.Doors.Components
|
||||
|
||||
var timingStatus =
|
||||
new StatusLightData(Color.Orange, !AutoClose ? StatusLightState.Off :
|
||||
!MathHelper.CloseTo(ev.CloseTimeModifier, 1.0f) ? StatusLightState.BlinkingSlow :
|
||||
!MathHelper.CloseToPercent(ev.CloseTimeModifier, 1.0f) ? StatusLightState.BlinkingSlow :
|
||||
StatusLightState.On,
|
||||
"TIME");
|
||||
|
||||
|
||||
@@ -233,7 +233,7 @@ namespace Content.Server.Light.Components
|
||||
|
||||
var currentCharge = Cell.CurrentCharge;
|
||||
|
||||
if (MathHelper.CloseTo(currentCharge, 0) || Wattage > currentCharge)
|
||||
if (MathHelper.CloseToPercent(currentCharge, 0) || Wattage > currentCharge)
|
||||
return 0;
|
||||
|
||||
return (byte?) ContentHelpers.RoundToNearestLevels(currentCharge / Cell.MaxCharge * 255, 255, StatusLevels);
|
||||
|
||||
@@ -105,6 +105,11 @@ namespace Content.Server.Physics.Controllers
|
||||
// ShuttleSystem has already worked out the ratio so we'll just multiply it back by the mass.
|
||||
var movement = (mover.VelocityDir.walking + mover.VelocityDir.sprinting);
|
||||
|
||||
if (physicsComponent.LinearVelocity.LengthSquared == 0f)
|
||||
{
|
||||
movement *= 5f;
|
||||
}
|
||||
|
||||
switch (shuttleComponent.Mode)
|
||||
{
|
||||
case ShuttleMode.Docking:
|
||||
@@ -137,12 +142,6 @@ namespace Content.Server.Physics.Controllers
|
||||
|
||||
var velocity = physicsComponent.LinearVelocity;
|
||||
|
||||
if (velocity.Length < 0.1f && movement.Length == 0f)
|
||||
{
|
||||
physicsComponent.LinearVelocity = Vector2.Zero;
|
||||
return;
|
||||
}
|
||||
|
||||
if (velocity.Length > speedCap)
|
||||
{
|
||||
physicsComponent.LinearVelocity = velocity.Normalized * speedCap;
|
||||
|
||||
@@ -175,7 +175,7 @@ namespace Content.Server.Power.Components
|
||||
}
|
||||
|
||||
var delta = netBat.CurrentReceiving - netBat.LoadingNetworkDemand;
|
||||
if (!MathHelper.CloseTo(delta, 0, 0.1f) && delta < 0)
|
||||
if (!MathHelper.CloseToPercent(delta, 0, 0.1f) && delta < 0)
|
||||
{
|
||||
return ApcExternalPowerState.Low;
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace Content.Server.Power.Components
|
||||
public override string Name => "ApcPowerReceiver";
|
||||
|
||||
[ViewVariables]
|
||||
public bool Powered => (MathHelper.CloseTo(NetworkLoad.ReceivingPower, Load) || !NeedsPower) && !PowerDisabled;
|
||||
public bool Powered => (MathHelper.CloseToPercent(NetworkLoad.ReceivingPower, Load) || !NeedsPower) && !PowerDisabled;
|
||||
|
||||
/// <summary>
|
||||
/// The max distance from a <see cref="ApcPowerProviderComponent"/> that this can receive power from.
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace Content.Server.Power.Components
|
||||
/// <summary>
|
||||
/// True if the battery is fully charged.
|
||||
/// </summary>
|
||||
[ViewVariables] public bool IsFullyCharged => MathHelper.CloseTo(CurrentCharge, MaxCharge);
|
||||
[ViewVariables] public bool IsFullyCharged => MathHelper.CloseToPercent(CurrentCharge, MaxCharge);
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)] [DataField("autoRecharge")] public bool AutoRecharge { get; set; }
|
||||
|
||||
|
||||
@@ -189,7 +189,7 @@ namespace Content.Server.Power.EntitySystems
|
||||
var recv = apcReceiver.NetworkLoad.ReceivingPower;
|
||||
ref var last = ref apcReceiver.LastPowerReceived;
|
||||
|
||||
if (!MathHelper.CloseTo(recv, last))
|
||||
if (!MathHelper.CloseToPercent(recv, last))
|
||||
{
|
||||
last = recv;
|
||||
apcReceiver.ApcPowerChanged();
|
||||
@@ -200,7 +200,7 @@ namespace Content.Server.Power.EntitySystems
|
||||
{
|
||||
var newRecv = consumer.NetworkLoad.ReceivingPower;
|
||||
ref var lastRecv = ref consumer.LastReceived;
|
||||
if (!MathHelper.CloseTo(lastRecv, newRecv))
|
||||
if (!MathHelper.CloseToPercent(lastRecv, newRecv))
|
||||
{
|
||||
lastRecv = newRecv;
|
||||
var msg = new PowerConsumerReceivedChanged(newRecv, consumer.DrawRate);
|
||||
|
||||
@@ -124,7 +124,8 @@ namespace Content.Server.Shuttles
|
||||
component.BodyStatus = BodyStatus.InAir;
|
||||
//component.FixedRotation = false; TODO WHEN ROTATING SHUTTLES FIXED.
|
||||
component.FixedRotation = true;
|
||||
component.LinearDamping = 0.05f;
|
||||
component.LinearDamping = 0.2f;
|
||||
component.AngularDamping = 0.1f;
|
||||
}
|
||||
|
||||
private void Disable(PhysicsComponent component)
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace Content.Shared.Friction
|
||||
get => _modifier;
|
||||
set
|
||||
{
|
||||
if (MathHelper.CloseTo(_modifier, value)) return;
|
||||
if (MathHelper.CloseToPercent(_modifier, value)) return;
|
||||
|
||||
_modifier = value;
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace Content.Shared.Movement.Components
|
||||
get => _stepSoundDistance;
|
||||
set
|
||||
{
|
||||
if (MathHelper.CloseTo(_stepSoundDistance, value)) return;
|
||||
if (MathHelper.CloseToPercent(_stepSoundDistance, value)) return;
|
||||
_stepSoundDistance = value;
|
||||
}
|
||||
}
|
||||
@@ -52,7 +52,7 @@ namespace Content.Shared.Movement.Components
|
||||
get => _grabRange;
|
||||
set
|
||||
{
|
||||
if (MathHelper.CloseTo(_grabRange, value)) return;
|
||||
if (MathHelper.CloseToPercent(_grabRange, value)) return;
|
||||
_grabRange = value;
|
||||
Dirty();
|
||||
}
|
||||
@@ -64,7 +64,7 @@ namespace Content.Shared.Movement.Components
|
||||
get => _pushStrength;
|
||||
set
|
||||
{
|
||||
if (MathHelper.CloseTo(_pushStrength, value)) return;
|
||||
if (MathHelper.CloseToPercent(_pushStrength, value)) return;
|
||||
_pushStrength = value;
|
||||
Dirty();
|
||||
}
|
||||
@@ -76,7 +76,7 @@ namespace Content.Shared.Movement.Components
|
||||
get => _weightlessStrength;
|
||||
set
|
||||
{
|
||||
if (MathHelper.CloseTo(_weightlessStrength, value)) return;
|
||||
if (MathHelper.CloseToPercent(_weightlessStrength, value)) return;
|
||||
_weightlessStrength = value;
|
||||
Dirty();
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@ namespace Content.Shared.Movement
|
||||
new Angle(transform.Parent!.WorldRotation.Theta).RotateVec(total) :
|
||||
total;
|
||||
|
||||
DebugTools.Assert(MathHelper.CloseTo(total.Length, worldTotal.Length));
|
||||
DebugTools.Assert(MathHelper.CloseToPercent(total.Length, worldTotal.Length));
|
||||
|
||||
if (weightless)
|
||||
{
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace Content.Shared.Slippery
|
||||
get => _paralyzeTime;
|
||||
set
|
||||
{
|
||||
if (MathHelper.CloseTo(_paralyzeTime, value)) return;
|
||||
if (MathHelper.CloseToPercent(_paralyzeTime, value)) return;
|
||||
|
||||
_paralyzeTime = value;
|
||||
Dirty();
|
||||
@@ -80,7 +80,7 @@ namespace Content.Shared.Slippery
|
||||
get => _intersectPercentage;
|
||||
set
|
||||
{
|
||||
if (MathHelper.CloseTo(_intersectPercentage, value)) return;
|
||||
if (MathHelper.CloseToPercent(_intersectPercentage, value)) return;
|
||||
|
||||
_intersectPercentage = value;
|
||||
Dirty();
|
||||
@@ -97,7 +97,7 @@ namespace Content.Shared.Slippery
|
||||
get => _requiredSlipSpeed;
|
||||
set
|
||||
{
|
||||
if (MathHelper.CloseTo(_requiredSlipSpeed, value)) return;
|
||||
if (MathHelper.CloseToPercent(_requiredSlipSpeed, value)) return;
|
||||
|
||||
_requiredSlipSpeed = value;
|
||||
Dirty();
|
||||
@@ -114,7 +114,7 @@ namespace Content.Shared.Slippery
|
||||
get => _launchForwardsMultiplier;
|
||||
set
|
||||
{
|
||||
if (MathHelper.CloseTo(_launchForwardsMultiplier, value)) return;
|
||||
if (MathHelper.CloseToPercent(_launchForwardsMultiplier, value)) return;
|
||||
|
||||
_launchForwardsMultiplier = value;
|
||||
Dirty();
|
||||
|
||||
Reference in New Issue
Block a user