File tree Expand file tree Collapse file tree 4 files changed +29
-18
lines changed
Expand file tree Collapse file tree 4 files changed +29
-18
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,12 @@ public interface IClientManager {
1212 /// Class that manages player locations on the in-game map.
1313 /// </summary>
1414 IMapManager MapManager { get ; }
15-
15+
16+ /// <summary>
17+ /// Class that manages pause-related operations.
18+ /// </summary>
19+ IPauseManager PauseManager { get ; }
20+
1621 /// <summary>
1722 /// The current username of the local player.
1823 /// </summary>
@@ -90,9 +95,4 @@ public interface IClientManager {
9095 /// Event that is called when another player leaves the local scene.
9196 /// </summary>
9297 event Action < IClientPlayer > PlayerLeaveSceneEvent ;
93-
94- /// <summary>
95- /// Event that is called when HKMP modifies the game's time scale.
96- /// </summary>
97- event Action < float > SetTimeScaleEvent ;
9898}
Original file line number Diff line number Diff line change 1+ using System ;
2+
3+ namespace Hkmp . Api . Client ;
4+
5+ /// <summary>
6+ /// Client-side class that handles pause-related operations.
7+ /// </summary>
8+ public interface IPauseManager {
9+ /// <summary>
10+ /// Event that is called when HKMP modifies the game's timescale.
11+ /// </summary>
12+ event Action < float > SetTimeScaleEvent ;
13+ }
Original file line number Diff line number Diff line change @@ -101,6 +101,9 @@ internal class ClientManager : IClientManager {
101101 /// <inheritdoc />
102102 public IMapManager MapManager => _mapManager ;
103103
104+ /// <inheritdoc />
105+ public IPauseManager PauseManager => _pauseManager ;
106+
104107 /// <inheritdoc />
105108 public string Username {
106109 get {
@@ -133,9 +136,6 @@ public string Username {
133136 /// <inheritdoc />
134137 public event Action < IClientPlayer > PlayerLeaveSceneEvent ;
135138
136- /// <inheritdoc />
137- public event Action < float > SetTimeScaleEvent ;
138-
139139 /// <inheritdoc />
140140 public Team Team => _playerManager . LocalPlayerTeam ;
141141
@@ -188,7 +188,7 @@ ModSettings modSettings
188188
189189 _entityManager = new EntityManager ( netClient ) ;
190190
191- _pauseManager = new PauseManager ( netClient , timeScale => SetTimeScaleEvent ? . Invoke ( timeScale ) ) ;
191+ _pauseManager = new PauseManager ( netClient ) ;
192192 _pauseManager . RegisterHooks ( ) ;
193193
194194 new FsmPatcher ( ) . RegisterHooks ( ) ;
Original file line number Diff line number Diff line change 22using System . Collections ;
33using System . Reflection ;
44using GlobalEnums ;
5+ using Hkmp . Api . Client ;
56using Hkmp . Networking . Client ;
67using Modding ;
78using UnityEngine ;
@@ -11,20 +12,17 @@ namespace Hkmp.Game.Client;
1112/// <summary>
1213/// Handles pause related things to prevent player being invincible in pause menu while connected to a server.
1314/// </summary>
14- internal class PauseManager {
15+ internal class PauseManager : IPauseManager {
1516 /// <summary>
1617 /// The net client instance.
1718 /// </summary>
1819 private readonly NetClient _netClient ;
1920
20- /// <summary>
21- /// Hook for time scale changes.
22- /// </summary>
23- private readonly Action < float > _onSetTimeScale ;
21+ /// <inheritdoc />
22+ public event Action < float > SetTimeScaleEvent ;
2423
25- public PauseManager ( NetClient netClient , Action < float > onSetTimeScale ) {
24+ public PauseManager ( NetClient netClient ) {
2625 _netClient = netClient ;
27- _onSetTimeScale = onSetTimeScale ;
2826 }
2927
3028 /// <summary>
@@ -204,6 +202,6 @@ private static void ImmediateUnpauseIfPaused() {
204202 public void SetTimeScale ( float timeScale ) {
205203 timeScale = timeScale > 0.00999999977648258 ? timeScale : 0.0f ;
206204 TimeController . GenericTimeScale = timeScale ;
207- _onSetTimeScale ( timeScale ) ;
205+ SetTimeScaleEvent ? . Invoke ( timeScale ) ;
208206 }
209207}
You can’t perform that action at this time.
0 commit comments