com.puzzlescapegames.services 1.2.8 → 1.3.0

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.
@@ -1,6 +1,8 @@
1
1
  using Cysharp.Threading.Tasks;
2
2
  using System;
3
3
  using System.Linq;
4
+ using System.Threading;
5
+ using UnityEngine;
4
6
  using Object = UnityEngine.Object;
5
7
 
6
8
  namespace PuzzlescapeGames.Services.UITransitionService
@@ -16,13 +18,39 @@ namespace PuzzlescapeGames.Services.UITransitionService
16
18
  _settings = settings ?? throw new ArgumentNullException( nameof(settings) );
17
19
  }
18
20
 
19
- public async UniTask LoadThroughBlank( string uid, Action onShowed = null, Action onLoaded = null, Action onHided = null )
21
+ public async UniTask LoadThroughBlank(
22
+ int index = 0,
23
+ Action onShowed = null,
24
+ Action onLoaded = null,
25
+ Action onHided = null,
26
+ CancellationToken cancellationToken = default,
27
+ params UniTask[] tasks
28
+ )
29
+ {
30
+ await LoadThroughBlank( _settings.LoadingSettings[ index ], onShowed, onLoaded, onHided, cancellationToken, tasks );
31
+ }
32
+
33
+ public async UniTask LoadThroughBlank(
34
+ string uid,
35
+ Action onShowed = null,
36
+ Action onLoaded = null,
37
+ Action onHided = null,
38
+ CancellationToken cancellationToken = default,
39
+ params UniTask[] tasks
40
+ )
20
41
  {
21
42
  var loading = _settings.LoadingSettings.FirstOrDefault( ( x ) => string.Equals( x.UID, uid, StringComparison.InvariantCultureIgnoreCase ) );
22
- await LoadThroughBlank( loading, onShowed, onLoaded, onHided );
43
+ await LoadThroughBlank( loading, onShowed, onLoaded, onHided, cancellationToken, tasks );
23
44
  }
24
45
 
25
- public async UniTask LoadThroughBlank( LoadingSettings loading, Action onShowed = null, Action onLoaded = null , Action onHided = null )
46
+ public async UniTask LoadThroughBlank(
47
+ LoadingSettings loading,
48
+ Action onShowed = null,
49
+ Action onLoaded = null,
50
+ Action onHided = null,
51
+ CancellationToken cancellationToken = default,
52
+ params UniTask[] tasks
53
+ )
26
54
  {
27
55
  if ( _blank == null )
28
56
  {
@@ -31,7 +59,20 @@ namespace PuzzlescapeGames.Services.UITransitionService
31
59
  }
32
60
 
33
61
  await _blank.ShowAsync( loading.InDuration, loading.InCurve, onShowed );
34
- await UniTask.WaitForSeconds( loading.LoadingTime );
62
+ if ( tasks.Length > 0 )
63
+ {
64
+ var start = Time.time;
65
+ await UniTask.WhenAll( tasks );
66
+ var diff = loading.LoadingTime - ( Time.time - start );
67
+ if ( diff > 0f )
68
+ {
69
+ await UniTask.WaitForSeconds( diff, cancellationToken: cancellationToken );
70
+ }
71
+ }
72
+ else
73
+ {
74
+ await UniTask.WaitForSeconds( loading.LoadingTime, cancellationToken: cancellationToken );
75
+ }
35
76
  onLoaded?.Invoke();
36
77
  await _blank.HideAsync( loading.OutDuration, loading.OutCurve, onHided );
37
78
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name" : "com.puzzlescapegames.services",
3
3
  "displayName" : "Puzzlescape Games Services",
4
- "version" : "1.2.8",
4
+ "version" : "1.3.0",
5
5
  "author" : "Puzzlescape Games",
6
6
  "description" : "Common services.",
7
7
  "repository": {