diff --git a/Source/Client/AsyncTime/AsyncWorldTimeComp.cs b/Source/Client/AsyncTime/AsyncWorldTimeComp.cs index 6859309e..b86de425 100644 --- a/Source/Client/AsyncTime/AsyncWorldTimeComp.cs +++ b/Source/Client/AsyncTime/AsyncWorldTimeComp.cs @@ -25,13 +25,12 @@ public class AsyncWorldTimeComp : IExposable, ITickable public float TickRateMultiplier(TimeSpeed speed) { - if (Multiplayer.GameComp.asyncTime) - { - var enforcePause = Multiplayer.WorldComp.sessionManager.IsAnySessionCurrentlyPausing(null); + if (IsForcePaused) + return 0f; - if (enforcePause) - return 0f; - } + // Could just skip, as it currently can not be true unless a mod makes a Harmony patch. + if (IsForceSlowdown) + return speed == TimeSpeed.Paused ? 0 : 1; return speed switch { @@ -44,6 +43,11 @@ public float TickRateMultiplier(TimeSpeed speed) }; } + public bool IsForcePaused => Multiplayer.GameComp.asyncTime && + Multiplayer.WorldComp.sessionManager.IsAnySessionCurrentlyPausing(null); + + public bool IsForceSlowdown => false; + // Run at the speed of the fastest map or at chosen speed if there are no maps public TimeSpeed DesiredTimeSpeed => !Find.Maps.Any() ? timeSpeedInt : diff --git a/Source/Client/AsyncTime/ITickable.cs b/Source/Client/AsyncTime/ITickable.cs index b2b5adbc..b83a2338 100644 --- a/Source/Client/AsyncTime/ITickable.cs +++ b/Source/Client/AsyncTime/ITickable.cs @@ -22,7 +22,7 @@ public interface ITickable void ExecuteCmd(ScheduledCommand cmd); - bool IsPaused { get; } + bool IsForcePaused { get; } bool IsForceSlowdown { get; } } diff --git a/Source/Client/AsyncTime/TimeControlUI.cs b/Source/Client/AsyncTime/TimeControlUI.cs index a1549a98..1ef8de3e 100644 --- a/Source/Client/AsyncTime/TimeControlUI.cs +++ b/Source/Client/AsyncTime/TimeControlUI.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using System.Reflection.Emit; using HarmonyLib; @@ -106,11 +106,11 @@ private static void DoTimeControlsGUI(Rect timerRect) rect.x += rect.width; } - ForcedTickRateInfo info = Tickable.GetForcedSpeedInfo(); + ForcedTickRate info = Tickable.GetForcedSpeedInfo(); - if (info == ForcedTickRateInfo.Paused) // Completely paused + if (info == ForcedTickRate.Paused) // Completely paused Widgets.DrawLineHorizontal(rect.width, rect.height / 2f, rect.width * 3f); - else if (info == ForcedTickRateInfo.Slowdown) // Slowed down + else if (info == ForcedTickRate.Slowdown) // Slowed down Widgets.DrawLineHorizontal(rect.width * 2f, rect.height / 2f, rect.width * 2f); Widgets.EndGroup(); diff --git a/Source/Client/Patches/TickPatch.cs b/Source/Client/Patches/TickPatch.cs index c134849f..f05811b1 100644 --- a/Source/Client/Patches/TickPatch.cs +++ b/Source/Client/Patches/TickPatch.cs @@ -288,37 +288,37 @@ public static float ActualRateMultiplier(this ITickable tickable, TimeSpeed spee return rate; } - public static TimePauseSlowdownInfo IsPausedOrSlowedDown(this ITickable tickable) + public static ForcedTickRate GetForcedSpeedInfo(this ITickable tickable) { if (Multiplayer.GameComp.asyncTime) { - if (tickable.IsPaused) - return TimePauseSlowdownInfo.Paused; + if (tickable.IsForcePaused) + return ForcedTickRate.Paused; if (tickable.IsForceSlowdown) - return TimePauseSlowdownInfo.Slowdown; - return TimePauseSlowdownInfo.Normal; + return ForcedTickRate.Slowdown; + return ForcedTickRate.Normal; } - if (Multiplayer.WorldComp.IsPaused) - return TimePauseSlowdownInfo.Paused; + if (Multiplayer.AsyncWorldTime.IsForcePaused) + return ForcedTickRate.Paused; - // Could just use false, as it currently can not be force slowed down. - // If we keep this, some mods may potentially use force slowdown on world. - var isForceSlowdown = Multiplayer.WorldComp.IsForceSlowdown; + // Could just use false as default, as it currently can + // not be true unless a mod makes a Harmony patch. + var isForceSlowdown = Multiplayer.AsyncWorldTime.IsForceSlowdown; foreach (var map in Find.Maps) { var comp = map.AsyncTime(); - if (comp.IsPaused) - return TimePauseSlowdownInfo.Paused; + if (comp.IsForcePaused) + return ForcedTickRate.Paused; if (!isForceSlowdown) isForceSlowdown = comp.IsForceSlowdown; } if (isForceSlowdown) - return TimePauseSlowdownInfo.Slowdown; - return TimePauseSlowdownInfo.Normal; + return ForcedTickRate.Slowdown; + return ForcedTickRate.Normal; } public static void ClearSimulating() @@ -362,5 +362,5 @@ public class SimulatingData public string simTextKey; } - public enum TimePauseSlowdownInfo { Normal, Paused, Slowdown, } + public enum ForcedTickRate { Normal, Paused, Slowdown, } }