From ad783396f897a61692be96983720d4ab3e73c9e9 Mon Sep 17 00:00:00 2001 From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Wed, 29 Sep 2021 20:07:01 +1000 Subject: [PATCH] Update CloseTo to CloseToPercent (#4708) --- Content.Client/Chat/UI/SpeechBubble.cs | 2 +- Content.Client/EscapeMenu/UI/Tabs/GraphicsTab.xaml.cs | 4 ++-- Content.Client/Tabletop/TabletopSystem.cs | 2 +- .../Binary/EntitySystems/GasPressurePumpSystem.cs | 2 +- .../Piping/Unary/EntitySystems/GasCanisterSystem.cs | 2 +- .../Unary/EntitySystems/GasVentScrubberSystem.cs | 2 +- Content.Server/Doors/Components/AirlockComponent.cs | 2 +- .../Light/Components/HandheldLightComponent.cs | 2 +- Content.Server/Physics/Controllers/MoverController.cs | 11 +++++------ Content.Server/Power/Components/ApcComponent.cs | 2 +- .../Power/Components/ApcPowerReceiverComponent.cs | 2 +- Content.Server/Power/Components/BatteryComponent.cs | 2 +- Content.Server/Power/EntitySystems/PowerNetSystem.cs | 4 ++-- Content.Server/Shuttles/ShuttleSystem.cs | 3 ++- Content.Shared/Friction/TileFrictionModifier.cs | 2 +- .../Components/SharedPlayerMobMoverComponent.cs | 8 ++++---- Content.Shared/Movement/SharedMoverController.cs | 2 +- Content.Shared/Slippery/SlipperyComponent.cs | 8 ++++---- 18 files changed, 31 insertions(+), 31 deletions(-) diff --git a/Content.Client/Chat/UI/SpeechBubble.cs b/Content.Client/Chat/UI/SpeechBubble.cs index ef57ad96c3..fb71812eb0 100644 --- a/Content.Client/Chat/UI/SpeechBubble.cs +++ b/Content.Client/Chat/UI/SpeechBubble.cs @@ -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; } diff --git a/Content.Client/EscapeMenu/UI/Tabs/GraphicsTab.xaml.cs b/Content.Client/EscapeMenu/UI/Tabs/GraphicsTab.xaml.cs index 38bca3b7ff..25583b1e39 100644 --- a/Content.Client/EscapeMenu/UI/Tabs/GraphicsTab.xaml.cs +++ b/Content.Client/EscapeMenu/UI/Tabs/GraphicsTab.xaml.cs @@ -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; } diff --git a/Content.Client/Tabletop/TabletopSystem.cs b/Content.Client/Tabletop/TabletopSystem.cs index cd2f9d959e..102d5cf49b 100644 --- a/Content.Client/Tabletop/TabletopSystem.cs +++ b/Content.Client/Tabletop/TabletopSystem.cs @@ -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); diff --git a/Content.Server/Atmos/Piping/Binary/EntitySystems/GasPressurePumpSystem.cs b/Content.Server/Atmos/Piping/Binary/EntitySystems/GasPressurePumpSystem.cs index 04b1da6196..41a0e8e47c 100644 --- a/Content.Server/Atmos/Piping/Binary/EntitySystems/GasPressurePumpSystem.cs +++ b/Content.Server/Atmos/Piping/Binary/EntitySystems/GasPressurePumpSystem.cs @@ -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. diff --git a/Content.Server/Atmos/Piping/Unary/EntitySystems/GasCanisterSystem.cs b/Content.Server/Atmos/Piping/Unary/EntitySystems/GasCanisterSystem.cs index 57dd8fecbe..04bf2a1335 100644 --- a/Content.Server/Atmos/Piping/Unary/EntitySystems/GasCanisterSystem.cs +++ b/Content.Server/Atmos/Piping/Unary/EntitySystems/GasCanisterSystem.cs @@ -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; diff --git a/Content.Server/Atmos/Piping/Unary/EntitySystems/GasVentScrubberSystem.cs b/Content.Server/Atmos/Piping/Unary/EntitySystems/GasVentScrubberSystem.cs index 7584830ecb..c71fc8a152 100644 --- a/Content.Server/Atmos/Piping/Unary/EntitySystems/GasVentScrubberSystem.cs +++ b/Content.Server/Atmos/Piping/Unary/EntitySystems/GasVentScrubberSystem.cs @@ -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); diff --git a/Content.Server/Doors/Components/AirlockComponent.cs b/Content.Server/Doors/Components/AirlockComponent.cs index 14a0cee02b..9730cf9d34 100644 --- a/Content.Server/Doors/Components/AirlockComponent.cs +++ b/Content.Server/Doors/Components/AirlockComponent.cs @@ -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"); diff --git a/Content.Server/Light/Components/HandheldLightComponent.cs b/Content.Server/Light/Components/HandheldLightComponent.cs index 12a5ed590b..0b74f9e056 100644 --- a/Content.Server/Light/Components/HandheldLightComponent.cs +++ b/Content.Server/Light/Components/HandheldLightComponent.cs @@ -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); diff --git a/Content.Server/Physics/Controllers/MoverController.cs b/Content.Server/Physics/Controllers/MoverController.cs index 572d720f10..373dccb288 100644 --- a/Content.Server/Physics/Controllers/MoverController.cs +++ b/Content.Server/Physics/Controllers/MoverController.cs @@ -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; diff --git a/Content.Server/Power/Components/ApcComponent.cs b/Content.Server/Power/Components/ApcComponent.cs index 157859e5b3..ab6b142984 100644 --- a/Content.Server/Power/Components/ApcComponent.cs +++ b/Content.Server/Power/Components/ApcComponent.cs @@ -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; } diff --git a/Content.Server/Power/Components/ApcPowerReceiverComponent.cs b/Content.Server/Power/Components/ApcPowerReceiverComponent.cs index 16fa1791c5..16d30d9674 100644 --- a/Content.Server/Power/Components/ApcPowerReceiverComponent.cs +++ b/Content.Server/Power/Components/ApcPowerReceiverComponent.cs @@ -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; /// /// The max distance from a that this can receive power from. diff --git a/Content.Server/Power/Components/BatteryComponent.cs b/Content.Server/Power/Components/BatteryComponent.cs index 4dd6b805ae..8c4da4d530 100644 --- a/Content.Server/Power/Components/BatteryComponent.cs +++ b/Content.Server/Power/Components/BatteryComponent.cs @@ -32,7 +32,7 @@ namespace Content.Server.Power.Components /// /// True if the battery is fully charged. /// - [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; } diff --git a/Content.Server/Power/EntitySystems/PowerNetSystem.cs b/Content.Server/Power/EntitySystems/PowerNetSystem.cs index 605d1839c7..d88d89bbb6 100644 --- a/Content.Server/Power/EntitySystems/PowerNetSystem.cs +++ b/Content.Server/Power/EntitySystems/PowerNetSystem.cs @@ -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); diff --git a/Content.Server/Shuttles/ShuttleSystem.cs b/Content.Server/Shuttles/ShuttleSystem.cs index 576e272506..50b67996fa 100644 --- a/Content.Server/Shuttles/ShuttleSystem.cs +++ b/Content.Server/Shuttles/ShuttleSystem.cs @@ -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) diff --git a/Content.Shared/Friction/TileFrictionModifier.cs b/Content.Shared/Friction/TileFrictionModifier.cs index 052af70447..575cae37c2 100644 --- a/Content.Shared/Friction/TileFrictionModifier.cs +++ b/Content.Shared/Friction/TileFrictionModifier.cs @@ -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; } diff --git a/Content.Shared/Movement/Components/SharedPlayerMobMoverComponent.cs b/Content.Shared/Movement/Components/SharedPlayerMobMoverComponent.cs index f521ff6e81..8101531d92 100644 --- a/Content.Shared/Movement/Components/SharedPlayerMobMoverComponent.cs +++ b/Content.Shared/Movement/Components/SharedPlayerMobMoverComponent.cs @@ -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(); } diff --git a/Content.Shared/Movement/SharedMoverController.cs b/Content.Shared/Movement/SharedMoverController.cs index 5bd03f9c94..2b595ed223 100644 --- a/Content.Shared/Movement/SharedMoverController.cs +++ b/Content.Shared/Movement/SharedMoverController.cs @@ -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) { diff --git a/Content.Shared/Slippery/SlipperyComponent.cs b/Content.Shared/Slippery/SlipperyComponent.cs index 46f76306e9..1cc3142534 100644 --- a/Content.Shared/Slippery/SlipperyComponent.cs +++ b/Content.Shared/Slippery/SlipperyComponent.cs @@ -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();