app.hypergames.hypersdk 1.11.0-beta.17 → 1.11.0-beta.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ # [1.11.0-beta.18](https://github.com/mvmhyper/hyper-sdk/compare/v1.11.0-beta.17...v1.11.0-beta.18) (2026-09-01)
2
+
3
+
4
+ ### Features
5
+
6
+ * **replay:** support custom replay restarts ([bf722ab](https://github.com/mvmhyper/hyper-sdk/commit/bf722abe48add18c356922c60231cb2017e28443))
7
+
1
8
  # [1.11.0-beta.17](https://github.com/mvmhyper/hyper-sdk/compare/v1.11.0-beta.16...v1.11.0-beta.17) (2026-09-01)
2
9
 
3
10
 
@@ -15,6 +15,8 @@ namespace Hyper.Internal
15
15
  /// </summary>
16
16
  internal static class HyperRuntime
17
17
  {
18
+ private const float ReplayCustomRestartTimeoutSeconds = 10f;
19
+
18
20
  private static HyperRuntimeHost _host;
19
21
  private static GameObject _singletonObject;
20
22
 
@@ -22,6 +24,7 @@ namespace Hyper.Internal
22
24
  private static bool _isSoftRestarting;
23
25
  private static bool _replayRandomResetPending;
24
26
  private static bool _replayCustomRestartPending;
27
+ private static int _replayCustomRestartVersion;
25
28
  private static bool _customLoadingComplete;
26
29
  private static bool _customLoadingActive;
27
30
  private static float _customLoadingProgress;
@@ -123,7 +126,8 @@ namespace Hyper.Internal
123
126
  }
124
127
 
125
128
  /// <summary>
126
- /// Restarts replay playback through HyperLoader while preserving replay session data.
129
+ /// Restarts replay playback while preserving replay session data. Uses the configured
130
+ /// game-owned custom restart flow when available and falls back to HyperLoader.
127
131
  /// </summary>
128
132
  internal static void RestartReplaySession()
129
133
  {
@@ -147,8 +151,64 @@ namespace Hyper.Internal
147
151
 
148
152
  _replayCustomRestartPending = false;
149
153
  _replayRandomResetPending = false;
154
+ int restartVersion = ++_replayCustomRestartVersion;
150
155
  _replayManager?.PrepareForRestart();
151
156
 
157
+ if (_settings != null && _settings.useCustomRestartFlow &&
158
+ _host != null && _gameManager != null && _eventManager != null)
159
+ {
160
+ _replayCustomRestartPending = true;
161
+ _replayRandomResetPending = true;
162
+ _gameManager.ResetUIStateForCustomRestart();
163
+
164
+ try
165
+ {
166
+ if (!_eventManager.InvokeCustomRestartEvent())
167
+ {
168
+ HyperDebug.LogWarning(
169
+ "[Replay] Custom restart has no handler; falling back to HyperLoader.");
170
+ BeginReplaySceneRestart(restartVersion);
171
+ return;
172
+ }
173
+
174
+ _host.StartCoroutine(WaitForReplayCustomRestart(restartVersion));
175
+ return;
176
+ }
177
+ catch (Exception exception)
178
+ {
179
+ HyperDebug.LogWarning(
180
+ $"[Replay] Custom restart failed; falling back to HyperLoader: {exception.Message}");
181
+ BeginReplaySceneRestart(restartVersion);
182
+ return;
183
+ }
184
+ }
185
+
186
+ BeginReplaySceneRestart(restartVersion);
187
+ }
188
+
189
+ private static IEnumerator WaitForReplayCustomRestart(int restartVersion)
190
+ {
191
+ float timeoutAt = Time.realtimeSinceStartup + ReplayCustomRestartTimeoutSeconds;
192
+ while (_replayCustomRestartPending && restartVersion == _replayCustomRestartVersion &&
193
+ Time.realtimeSinceStartup < timeoutAt)
194
+ {
195
+ yield return null;
196
+ }
197
+
198
+ if (!_replayCustomRestartPending || restartVersion != _replayCustomRestartVersion) yield break;
199
+
200
+ HyperDebug.LogWarning(
201
+ $"[Replay] Custom restart did not complete within {ReplayCustomRestartTimeoutSeconds:0} seconds; " +
202
+ "falling back to HyperLoader.");
203
+ BeginReplaySceneRestart(restartVersion);
204
+ }
205
+
206
+ private static void BeginReplaySceneRestart(int restartVersion)
207
+ {
208
+ if (restartVersion != _replayCustomRestartVersion) return;
209
+
210
+ _replayCustomRestartPending = false;
211
+ _replayRandomResetPending = false;
152
212
  if (_host != null)
153
213
  {
154
214
  _host.StartCoroutine(RestartSessionCoroutine());
@@ -443,6 +503,7 @@ namespace Hyper.Internal
443
503
  _customLoadingProgress = 0f;
444
504
  _replayRandomResetPending = false;
445
505
  _replayCustomRestartPending = false;
506
+ _replayCustomRestartVersion++;
446
507
  _fixedSimulationTimeSeconds = 0d;
447
508
 
448
509
  if (_singletonObject != null)
@@ -504,6 +565,7 @@ namespace Hyper.Internal
504
565
  _customLoadingProgress = 0f;
505
566
  _replayRandomResetPending = false;
506
567
  _replayCustomRestartPending = false;
568
+ _replayCustomRestartVersion++;
507
569
  _fixedSimulationTimeSeconds = 0d;
508
570
  }
509
571
  }
@@ -79,7 +79,13 @@ namespace Hyper.Internal.Managers
79
79
  internal void InvokeGameEndedEvent() => OnGameEnded?.Invoke();
80
80
  internal void InvokeLivesExhaustedEvent() => OnLivesExhausted?.Invoke();
81
81
  internal void InvokeHealthExhaustedEvent() => OnHealthExhausted?.Invoke();
82
- internal void InvokeCustomRestartEvent() => OnCustomRestart?.Invoke();
82
+ internal bool InvokeCustomRestartEvent()
83
+ {
84
+ Action handler = OnCustomRestart;
85
+ if (handler == null) return false;
86
+ handler.Invoke();
87
+ return true;
88
+ }
83
89
  internal void InvokeConnectionLostEvent() => OnInternetConnectionLost?.Invoke();
84
90
  internal void InvokeConnectionFoundEvent() => OnInternetConnectionFound?.Invoke();
85
91
  internal void InvokeBackendSocketManuallyClosedEvent() => OnBackendSocketManuallyClosed?.Invoke();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "app.hypergames.hypersdk",
3
- "version": "1.11.0-beta.17",
3
+ "version": "1.11.0-beta.18",
4
4
  "displayName": "HyperSDK",
5
5
  "description": "Official Unity SDK for Hyper: multiplayer battles, leaderboards, deterministic RNG, session management, tutorials, and WebGL optimizations for production-ready games.",
6
6
  "unity": "6000.0",