Removed some code repetition, simplified forced pause/slowdown check#362
Open
SokyranTheDragon wants to merge 4 commits intorwmt:masterfrom
Open
Removed some code repetition, simplified forced pause/slowdown check#362SokyranTheDragon wants to merge 4 commits intorwmt:masterfrom
SokyranTheDragon wants to merge 4 commits intorwmt:masterfrom
Conversation
Member
Author
|
As a side note - this should, in theory, have better performance. I say in theory, as the performance gain from those changes is gonna be so small that it won't be noticeable. The changes I've made here were mostly to simplify code (forced pause/slowdown), and reduce repeated calls. |
# Conflicts: # Source/Client/AsyncTime/AsyncTimeComp.cs # Source/Client/AsyncTime/TimeControlUI.cs # Source/Client/Comp/MultiplayerWorldComp.cs
Some changes that originally were made for `MultiplayerWorldComp` were properly moved to `AsyncWorldTimeComp`. Some names were changed to be clearer to what it does or is. `IsPaused` property was renamed to `IsForcePaused`. `TimePauseSlowdownInfo` enum was renamed to `ForcedTickRate`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently, to check if map/world is force paused down, you need to call
ITickable.TickRateMultiplier(TimeSpeed)(with speed other than paused). The situation is similar with force slowed down, but you need to call the method twice with 2 different speeds and compare if they're equal. This is not the most intuitive way to do it, and is a bit wasteful as well.The replacement I've introduced introduced 2 properties to
ITickable-bool IsForcePausedandbool IsForceSlowdown. The checks for force pause/slowdown have been moved fromITickable.TickRateMultiplierto those properties instead, and they can now be accessed from other places.A new method was added to the
TickPatchclass -GetForcedTickRate. The idea was to make a method method that can check if the tick rate is forcibly paused or slowed down. It does so by using the new properties instead ofITickable.TickRateMultiplier.On top of the previously mentioned change to force pause/slowdown checking, this also includes following changes:
ColonistBarTimeControl.DrawButtonsnow uses the new property instead of checking the TickRateMultiplier, which skips force slowdown checks. Additionally, the check is now only done once instead of (potentially) twice.TickPatch.TimePerTicknow only callsActualRateMultiplieronce instead of twice.