Removed some code repetition, simplified forced pause/slowdown check #362
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 IsForcePaused
andbool IsForceSlowdown
. The checks for force pause/slowdown have been moved fromITickable.TickRateMultiplier
to those properties instead, and they can now be accessed from other places.A new method was added to the
TickPatch
class -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.DrawButtons
now 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.TimePerTick
now only callsActualRateMultiplier
once instead of twice.