Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed some code repetition, simplified forced pause/slowdown check #362

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

SokyranTheDragon
Copy link
Member

@SokyranTheDragon SokyranTheDragon commented Feb 4, 2023

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 and bool IsForceSlowdown. The checks for force pause/slowdown have been moved from ITickable.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 of ITickable.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 calls ActualRateMultiplier once instead of twice.

@SokyranTheDragon SokyranTheDragon added the 1.4 Fixes or bugs relating to 1.4 (Not Biotech). label Feb 4, 2023
@SokyranTheDragon
Copy link
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.

@SokyranTheDragon SokyranTheDragon added enhancement New feature or request. and removed 1.4 Fixes or bugs relating to 1.4 (Not Biotech). labels Feb 21, 2023
# 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`.
@SokyranTheDragon SokyranTheDragon added the 1.5 Fixes or bugs relating to 1.5 (Not Anomaly). label Aug 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.5 Fixes or bugs relating to 1.5 (Not Anomaly). enhancement New feature or request.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant