-
-
Notifications
You must be signed in to change notification settings - Fork 87
Add hooks for HKMP TimeScale changes #112
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| using System.Collections; | ||
| using System.Reflection; | ||
| using GlobalEnums; | ||
| using Hkmp.Api.Client; | ||
| using Hkmp.Networking.Client; | ||
| using Modding; | ||
| using UnityEngine; | ||
|
|
@@ -15,9 +16,15 @@ internal class PauseManager { | |
| /// The net client instance. | ||
| /// </summary> | ||
| private readonly NetClient _netClient; | ||
|
|
||
| /// <summary> | ||
| /// Hook for time scale changes. | ||
| /// </summary> | ||
| private readonly IClientManager.SetTimeScale _onSetTimeScale; | ||
|
|
||
| public PauseManager(NetClient netClient) { | ||
| public PauseManager(NetClient netClient, IClientManager.SetTimeScale onSetTimeScale) { | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it makes more sense to expose the event for the time scale changing in this class instead. Now we are just juggling a delegate around just to be able to call the event in the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This would be a more invasive change, since PauseManager is an internal class and is not currently exposed at all through the public API. I can make this change if you prefer but I thought it was cleaner this way to stick to the existing API surface. |
||
| _netClient = netClient; | ||
| _onSetTimeScale = onSetTimeScale; | ||
| } | ||
|
|
||
| /// <summary> | ||
|
|
@@ -194,7 +201,9 @@ private static void ImmediateUnpauseIfPaused() { | |
| /// Sets the time scale similarly to the method GameManager#SetTimeScale. | ||
| /// </summary> | ||
| /// <param name="timeScale">The new time scale.</param> | ||
| public static void SetTimeScale(float timeScale) { | ||
| TimeController.GenericTimeScale = timeScale > 0.00999999977648258 ? timeScale : 0.0f; | ||
| public void SetTimeScale(float timeScale) { | ||
| timeScale = timeScale > 0.00999999977648258 ? timeScale : 0.0f; | ||
| TimeController.GenericTimeScale = timeScale; | ||
| _onSetTimeScale(timeScale); | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.