com.amanotes.gdk 0.2.65-4 → 0.2.65-5
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 +11 -2
- package/Editor/Extra/SDKVersionTracking.AirTable.cs +1 -1
- package/Editor/MatchSDKVersion.cs +8 -8
- package/Editor/Utils/AmaGDKEditor.ExtractVersion.cs +8 -8
- package/Extra/AmaGDKInstaller.unitypackage +0 -0
- package/Extra/CheckDiskSpace.unitypackage +0 -0
- package/Extra/ForceUpdate.unitypackage +0 -0
- package/Extra/GoogleCMP.unitypackage +0 -0
- package/Extra/PostProcessor.unitypackage +0 -0
- package/Extra/SDKVersionTracking.unitypackage +0 -0
- package/Packages/AmaGDKConfig.unitypackage +0 -0
- package/Packages/AmaGDKExample.unitypackage +0 -0
- package/Packages/AmaGDKTest.unitypackage +0 -0
- package/Packages/AppsFlyerAdapter.PurchaseConnector.unitypackage +0 -0
- package/Packages/AppsFlyerAdapter.unitypackage +0 -0
- package/Packages/FirebaseAnalyticsAdapter.unitypackage +0 -0
- package/Packages/FirebaseRemoteConfigAdapter.unitypackage +0 -0
- package/Packages/IronSourceAdapter.unitypackage +0 -0
- package/Packages/RevenueCatAdapter.unitypackage +0 -0
- package/Packages/SqliteAnalyticsAdapter.unitypackage +0 -0
- package/Runtime/AmaGDK.Ads.cs +7 -7
- package/Runtime/AmaGDK.IAP.cs +17 -6
- package/Runtime/AmaGDK.UserProfile.cs +1 -1
- package/Runtime/AmaGDK.cs +4 -2
- package/Runtime/AudioToolkit/AmaGDK.Audio.cs +3 -3
- package/Runtime/Core/GDKDispatcher.cs +145 -0
- package/Runtime/Core/GDKDispatcher.cs.meta +11 -0
- package/Runtime/Core/GDKRoutine.cs +10 -9
- package/Runtime/Core/GDKSemVer.cs +154 -0
- package/Runtime/Internal/AmaGDK.Internal.AmaGUI.cs +3 -3
- package/Runtime/Utils/GDKUtils.cs +10 -2
- package/package.json +1 -1
- package/Runtime/Internal/AmaGDK.Event.cs +0 -185
- package/Runtime/Internal/AmaGDK.Event.cs.meta +0 -3
- package/Runtime/Internal/AmaGDK.Internal.SemVer.cs +0 -147
- /package/Runtime/{Internal/AmaGDK.Internal.SemVer.cs.meta → Core/GDKSemVer.cs.meta} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
## [0.2.
|
|
4
|
-
- [
|
|
3
|
+
## [0.2.65-5 - 2024-06-17]
|
|
4
|
+
- [Dev] Update for GDKTest Unity 2022.3 project
|
|
5
|
+
- [Dev] Update for GDKTest Unity 2021.3 project
|
|
6
|
+
- [Dev] Enable pipeline for unity 2020
|
|
7
|
+
- [Dev] Refactor GDKSemVer
|
|
8
|
+
- [Dev] Various minor fixes for class scope & syntax
|
|
9
|
+
- [Dev] Clean up GDKDispatcher
|
|
10
|
+
- [Fix] Temp patch to fix RevenueCat crash
|
|
11
|
+
- [Fix] RevenueCat adapter ready early
|
|
12
|
+
- [Dev] Degrade GDKDev project to Unity 2020
|
|
13
|
+
- [Dev] Audio module supports Unity 2020
|
|
5
14
|
|
|
6
15
|
## [0.2.65 - 2024-06-13]
|
|
7
16
|
- [Dev] Add GDKRoutine
|
|
@@ -38,7 +38,7 @@ namespace Amanotes.Editor
|
|
|
38
38
|
{"RawData", rawData }
|
|
39
39
|
};
|
|
40
40
|
string json = JsonUtils.DictionaryToJson(buildInfo, false, false);
|
|
41
|
-
SendDataToAirTable(json);
|
|
41
|
+
Task.Run(()=>SendDataToAirTable(json));
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
private static async Task SendDataToAirTable(string payload)
|
|
@@ -48,10 +48,10 @@ namespace Amanotes.Core
|
|
|
48
48
|
File.WriteAllLines(filePath, lines);
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
private static KeyValuePair<int,
|
|
51
|
+
private static KeyValuePair<int, GDKSemVer> FindNearestLowerVersion(GDKSemVer inputVersion, Dictionary<int, GDKSemVer> defineLines)
|
|
52
52
|
{
|
|
53
|
-
KeyValuePair<int,
|
|
54
|
-
|
|
53
|
+
KeyValuePair<int, GDKSemVer> versionLessAndNearest = default;
|
|
54
|
+
GDKSemVer bestMatch = GDKSemVer.ZERO;
|
|
55
55
|
|
|
56
56
|
foreach (var kvp in defineLines)
|
|
57
57
|
{
|
|
@@ -67,9 +67,9 @@ namespace Amanotes.Core
|
|
|
67
67
|
return versionLessAndNearest;
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
private static Dictionary<int,
|
|
70
|
+
private static Dictionary<int, GDKSemVer> GetSemVersDefine(string code)
|
|
71
71
|
{
|
|
72
|
-
Dictionary<int,
|
|
72
|
+
Dictionary<int, GDKSemVer> defineLines = new Dictionary<int, GDKSemVer>();
|
|
73
73
|
|
|
74
74
|
string[] lines = code.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None);
|
|
75
75
|
for (int i = 0; i < lines.Length; i++)
|
|
@@ -78,7 +78,7 @@ namespace Amanotes.Core
|
|
|
78
78
|
|
|
79
79
|
if (Regex.IsMatch(line, @"^(\/\/\s*)?#define\s+"))
|
|
80
80
|
{
|
|
81
|
-
defineLines.Add(i, new
|
|
81
|
+
defineLines.Add(i, new GDKSemVer(GetVersionNumber(line)));
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
|
|
@@ -122,9 +122,9 @@ namespace Amanotes.Core
|
|
|
122
122
|
|
|
123
123
|
if (file != null)
|
|
124
124
|
{
|
|
125
|
-
Dictionary<int,
|
|
125
|
+
Dictionary<int, GDKSemVer> defineLines = GetSemVersDefine(File.ReadAllText(file.FullName));
|
|
126
126
|
|
|
127
|
-
KeyValuePair<int,
|
|
127
|
+
KeyValuePair<int, GDKSemVer> r = FindNearestLowerVersion(version, defineLines);
|
|
128
128
|
|
|
129
129
|
if (r.Value.isValid)
|
|
130
130
|
{
|
|
@@ -18,14 +18,14 @@ namespace Amanotes.Editor
|
|
|
18
18
|
internal class IronSourceSDKAdapter
|
|
19
19
|
{
|
|
20
20
|
public string name;
|
|
21
|
-
public
|
|
21
|
+
public GDKSemVer semVer;
|
|
22
22
|
public string version;
|
|
23
23
|
|
|
24
24
|
public IronSourceSDKAdapter(string name, string version)
|
|
25
25
|
{
|
|
26
26
|
this.name = name;
|
|
27
27
|
this.version = version;
|
|
28
|
-
semVer = new
|
|
28
|
+
semVer = new GDKSemVer(version);
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
|
|
@@ -36,11 +36,11 @@ namespace Amanotes.Editor
|
|
|
36
36
|
internal static void ClearCache(){ _cache.Clear(); }
|
|
37
37
|
|
|
38
38
|
public string sdkId;
|
|
39
|
-
public
|
|
40
|
-
public
|
|
39
|
+
public GDKSemVer adapterVersion;
|
|
40
|
+
public GDKSemVer sdkVersion;
|
|
41
41
|
|
|
42
|
-
public bool sdkInstalled => sdkVersion >
|
|
43
|
-
public bool adapterInstalled => adapterVersion >
|
|
42
|
+
public bool sdkInstalled => sdkVersion > GDKSemVer.ZERO;
|
|
43
|
+
public bool adapterInstalled => adapterVersion > GDKSemVer.ZERO;
|
|
44
44
|
|
|
45
45
|
public string ToTSVString()
|
|
46
46
|
{
|
|
@@ -53,8 +53,8 @@ namespace Amanotes.Editor
|
|
|
53
53
|
result = new SDKStatus
|
|
54
54
|
{
|
|
55
55
|
sdkId = sdkId,
|
|
56
|
-
adapterVersion = new
|
|
57
|
-
sdkVersion = new
|
|
56
|
+
adapterVersion = new GDKSemVer(ExtractVersion.GDKAdapter(sdkId)),
|
|
57
|
+
sdkVersion = new GDKSemVer(ExtractVersion.ThirdParty(sdkId))
|
|
58
58
|
};
|
|
59
59
|
|
|
60
60
|
// Debug.LogWarning($"Get <{sdkId} --> " + result.adapterVersion + " | " + result.sdkVersion);
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/Runtime/AmaGDK.Ads.cs
CHANGED
|
@@ -227,37 +227,37 @@ namespace Amanotes.Core
|
|
|
227
227
|
|
|
228
228
|
public static void OnInter_Request(Action callback)
|
|
229
229
|
{
|
|
230
|
-
dispatcher.AddListener(Event.INTER_REQUEST, callback
|
|
230
|
+
dispatcher.AddListener(Event.INTER_REQUEST, callback);
|
|
231
231
|
}
|
|
232
232
|
|
|
233
233
|
public static void OnInter_ShowCalled(Action callback)
|
|
234
234
|
{
|
|
235
|
-
dispatcher.AddListener(Event.INTER_SHOW_CALLED, callback
|
|
235
|
+
dispatcher.AddListener(Event.INTER_SHOW_CALLED, callback);
|
|
236
236
|
}
|
|
237
237
|
|
|
238
238
|
public static void OnReward_ShowCalled(Action callback)
|
|
239
239
|
{
|
|
240
|
-
dispatcher.AddListener(Event.REWARD_VIDEO_SHOW_CALLED, callback
|
|
240
|
+
dispatcher.AddListener(Event.REWARD_VIDEO_SHOW_CALLED, callback);
|
|
241
241
|
}
|
|
242
242
|
|
|
243
243
|
public static void OnInter_ShowReady(Action callback)
|
|
244
244
|
{
|
|
245
|
-
dispatcher.AddListener(Event.INTER_SHOW_READY, callback
|
|
245
|
+
dispatcher.AddListener(Event.INTER_SHOW_READY, callback);
|
|
246
246
|
}
|
|
247
247
|
|
|
248
248
|
public static void OnReward_ShowReady(Action callback)
|
|
249
249
|
{
|
|
250
|
-
dispatcher.AddListener(Event.REWARD_VIDEO_SHOW_READY, callback
|
|
250
|
+
dispatcher.AddListener(Event.REWARD_VIDEO_SHOW_READY, callback);
|
|
251
251
|
}
|
|
252
252
|
|
|
253
253
|
public static void OnInter_ShowNotReady(Action<AdShowReadyStatus> callback)
|
|
254
254
|
{
|
|
255
|
-
dispatcher.AddListener(Event.INTER_SHOW_NOT_READY, callback
|
|
255
|
+
dispatcher.AddListener(Event.INTER_SHOW_NOT_READY, callback);
|
|
256
256
|
}
|
|
257
257
|
|
|
258
258
|
public static void OnReward_ShowNotReady(Action<AdShowReadyStatus> callback)
|
|
259
259
|
{
|
|
260
|
-
dispatcher.AddListener(Event.REWARD_VIDEO_SHOW_NOT_READY, callback
|
|
260
|
+
dispatcher.AddListener(Event.REWARD_VIDEO_SHOW_NOT_READY, callback);
|
|
261
261
|
}
|
|
262
262
|
}
|
|
263
263
|
|
package/Runtime/AmaGDK.IAP.cs
CHANGED
|
@@ -204,14 +204,25 @@ namespace Amanotes.Core
|
|
|
204
204
|
|
|
205
205
|
public void Sync()
|
|
206
206
|
{
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
207
|
+
GDKUtils.StartCoroutine(SyncRoutine());
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
IEnumerator SyncRoutine()
|
|
211
|
+
{
|
|
212
|
+
if (Adapter == null)
|
|
213
|
+
{
|
|
214
|
+
LogWarning("[IAP] Adapter is not available");
|
|
215
|
+
yield break;
|
|
216
|
+
}
|
|
217
|
+
yield return new WaitUntil(() => Adapter.IsReady);
|
|
218
|
+
activeSubscriptionId = Adapter.GetActiveSubscriptionId();
|
|
219
|
+
subscriptionPeriodType = Adapter.GetSubscriptionPeriodType();
|
|
220
|
+
purchasedProducts = Adapter.GetPurchasedProducts();
|
|
221
|
+
_subscriptionLastPurchaseDate = Adapter.GetSubscriptionLastPurchaseDate();
|
|
211
222
|
subscriptionLastPurchaseDate = _subscriptionLastPurchaseDate?.ToString(DATE_FORMAT);
|
|
212
|
-
_subscriptionExpiredDate = Adapter
|
|
223
|
+
_subscriptionExpiredDate = Adapter.GetSubscriptionExpiredDate();
|
|
213
224
|
subscriptionExpiredDate = _subscriptionExpiredDate?.ToString(DATE_FORMAT);
|
|
214
|
-
_unsubscribedDate = Adapter
|
|
225
|
+
_unsubscribedDate = Adapter.GetUnsubscribedDate();
|
|
215
226
|
unsubscribedDate = _unsubscribedDate?.ToString(DATE_FORMAT);
|
|
216
227
|
this.SaveJsonToFile();
|
|
217
228
|
}
|
|
@@ -22,7 +22,7 @@ namespace Amanotes.Core
|
|
|
22
22
|
/// <param name="onUserIdChange"></param>
|
|
23
23
|
public static void SetCallback_OnUserIdUpdated(Action<string> onUserIdChange)
|
|
24
24
|
{
|
|
25
|
-
dispatcher.AddListener(Event.GDK_USER_ID_UPDATED, onUserIdChange
|
|
25
|
+
dispatcher.AddListener(Event.GDK_USER_ID_UPDATED, onUserIdChange);
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
[Serializable]
|
package/Runtime/AmaGDK.cs
CHANGED
|
@@ -17,10 +17,12 @@ namespace Amanotes.Core
|
|
|
17
17
|
{
|
|
18
18
|
public partial class AmaGDK : MonoBehaviour
|
|
19
19
|
{
|
|
20
|
-
public const string VERSION = "0.2.65-
|
|
20
|
+
public const string VERSION = "0.2.65-5";
|
|
21
21
|
|
|
22
22
|
internal static Status _status = Status.None;
|
|
23
23
|
private static ConfigAsset _config = null;
|
|
24
|
+
|
|
25
|
+
internal static readonly GDKDispatcher dispatcher = new GDKDispatcher();
|
|
24
26
|
internal static readonly GDKGeoLocation GeoLocation = new GDKGeoLocation();
|
|
25
27
|
internal static readonly GDKServerTime ServerTime = new GDKServerTime();
|
|
26
28
|
private static readonly ForceQuitMonitor ForceQuit = new ForceQuitMonitor();
|
|
@@ -328,7 +330,7 @@ namespace Amanotes.Core
|
|
|
328
330
|
return;
|
|
329
331
|
}
|
|
330
332
|
|
|
331
|
-
dispatcher.AddListener(Event.ADAPTER_READY, onAdapterReady
|
|
333
|
+
dispatcher.AddListener(Event.ADAPTER_READY, onAdapterReady);
|
|
332
334
|
}
|
|
333
335
|
}
|
|
334
336
|
|
|
@@ -46,19 +46,19 @@ namespace Amanotes.Core
|
|
|
46
46
|
return;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
dispatcher.AddListener(Event.GDK_AUDIO_INFO_CHANGE, onAudioDeviceChange
|
|
49
|
+
dispatcher.AddListener(Event.GDK_AUDIO_INFO_CHANGE, onAudioDeviceChange);
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
public static void SetOnAudioInterruptedCallback(Action beginCallback, Action endCallback)
|
|
53
53
|
{
|
|
54
54
|
if (beginCallback != null)
|
|
55
55
|
{
|
|
56
|
-
dispatcher.AddListener(Event.GDK_AUDIO_INTERRUPT_BEGIN, beginCallback
|
|
56
|
+
dispatcher.AddListener(Event.GDK_AUDIO_INTERRUPT_BEGIN, beginCallback);
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
if (endCallback != null)
|
|
60
60
|
{
|
|
61
|
-
dispatcher.AddListener(Event.GDK_AUDIO_INTERRUPT_END, endCallback
|
|
61
|
+
dispatcher.AddListener(Event.GDK_AUDIO_INTERRUPT_END, endCallback);
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Collections.Generic;
|
|
3
|
+
using System.Reflection;
|
|
4
|
+
using UnityEngine;
|
|
5
|
+
|
|
6
|
+
namespace Amanotes.Core.Internal
|
|
7
|
+
{
|
|
8
|
+
public class GDKDispatcher
|
|
9
|
+
{
|
|
10
|
+
private class EventEntry
|
|
11
|
+
{
|
|
12
|
+
public int nParams;
|
|
13
|
+
private bool _dispatching;
|
|
14
|
+
private Delegate callbacks;
|
|
15
|
+
private Delegate callbackOnce;
|
|
16
|
+
|
|
17
|
+
public bool hasCallback => callbacks != null || callbackOnce != null;
|
|
18
|
+
|
|
19
|
+
internal void Add(Delegate d, bool once)
|
|
20
|
+
{
|
|
21
|
+
callbackOnce = Delegate.Remove(callbackOnce, d);
|
|
22
|
+
callbacks = Delegate.Remove(callbacks, d);
|
|
23
|
+
if (once)
|
|
24
|
+
{
|
|
25
|
+
callbackOnce = Delegate.Combine(callbackOnce, d);
|
|
26
|
+
} else
|
|
27
|
+
{
|
|
28
|
+
callbacks = Delegate.Combine(callbacks, d);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
internal void Remove(Delegate d)
|
|
33
|
+
{
|
|
34
|
+
callbackOnce = Delegate.Remove(callbackOnce, d);
|
|
35
|
+
callbacks = Delegate.Remove(callbacks, d);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
internal bool Dispatch(string eventName, object[] args)
|
|
39
|
+
{
|
|
40
|
+
if (_dispatching)
|
|
41
|
+
{
|
|
42
|
+
GDKUtils.ThrowExceptionInEditor($"Nested dispatching is not supported, eventName: <{eventName}>",
|
|
43
|
+
(m) => new InvalidOperationException(m));
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (args.Length != nParams)
|
|
48
|
+
{
|
|
49
|
+
GDKUtils.ThrowExceptionInEditor($"Dispatch <{eventName}> with incorrect number of params, expecting {nParams}, got {args.Length}!",
|
|
50
|
+
(m) => new TargetParameterCountException(m));
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
_dispatching = true;
|
|
55
|
+
callbacks?.DynamicInvoke(args);
|
|
56
|
+
callbackOnce?.DynamicInvoke(args);
|
|
57
|
+
callbackOnce = null;
|
|
58
|
+
_dispatching = false;
|
|
59
|
+
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
private readonly Dictionary<string, EventEntry> _eventMap = new Dictionary<string, EventEntry>();
|
|
65
|
+
public void ClearAndReset()
|
|
66
|
+
{
|
|
67
|
+
_eventMap.Clear();
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
private EventEntry Get(string eventName)
|
|
71
|
+
{
|
|
72
|
+
if (string.IsNullOrEmpty(eventName)) return null;
|
|
73
|
+
_eventMap.TryGetValue(eventName, out EventEntry entry);
|
|
74
|
+
return entry;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
public void AddListener(string eventName, Delegate d, bool once = false)
|
|
78
|
+
{
|
|
79
|
+
if (d == null)
|
|
80
|
+
{
|
|
81
|
+
Debug.LogWarning("Dispatcher.Add() error: d == null");
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
int nParams = d.Method.GetParameters().Length;
|
|
86
|
+
EventEntry entry = Get(eventName);
|
|
87
|
+
|
|
88
|
+
if (entry == null)
|
|
89
|
+
{
|
|
90
|
+
entry = new EventEntry { nParams = nParams };
|
|
91
|
+
_eventMap.Add(eventName, entry);
|
|
92
|
+
} else if (nParams != entry.nParams)
|
|
93
|
+
{
|
|
94
|
+
GDKUtils.ThrowExceptionInEditor(string.Format(Internal.Messsage.DISPATCHER_WRONG_NUMBER_OF_PARAMS, eventName, entry.nParams, nParams),
|
|
95
|
+
(m) => new TargetParameterCountException(m));
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// Debug.Log("Add: " + eventName + " --> " + d + " | " + once);
|
|
100
|
+
entry.Add(d, once);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
public void RemoveListener(string eventName, Delegate d)
|
|
104
|
+
{
|
|
105
|
+
if (d == null)
|
|
106
|
+
{
|
|
107
|
+
Debug.LogWarning("Dispatcher.Remove() error: d == null");
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
EventEntry entry = Get(eventName);
|
|
112
|
+
entry?.Remove(d);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
public void ClearListeners(string eventName)
|
|
116
|
+
{
|
|
117
|
+
if (_eventMap.ContainsKey(eventName)) _eventMap.Remove(eventName);
|
|
118
|
+
}
|
|
119
|
+
public void Dispatch(string eventName, params object[] data)
|
|
120
|
+
{
|
|
121
|
+
if (string.IsNullOrEmpty(eventName))
|
|
122
|
+
{
|
|
123
|
+
GDKUtils.ThrowExceptionInEditor(
|
|
124
|
+
$"Invalid eventName: <{eventName}> (should not be null or empty)",
|
|
125
|
+
(m) => new ArgumentException(m));
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
EventEntry entry = Get(eventName);
|
|
130
|
+
if (entry == null) return;
|
|
131
|
+
|
|
132
|
+
if (!entry.hasCallback)
|
|
133
|
+
{
|
|
134
|
+
// string[] result = _eventMap
|
|
135
|
+
// .Select(kvp => kvp.Key + ":" + kvp.Value + "\n")
|
|
136
|
+
// .ToArray();
|
|
137
|
+
//
|
|
138
|
+
// Debug.LogWarning("AmaGDK [Event] No listener of type <" + eventName + ">\n\nRegistered events:\n\n" + string.Join("", result));
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
GDKUtils.SafeInvoke(() => entry.Dispatch(eventName, data));
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
using System;
|
|
2
2
|
using System.Collections;
|
|
3
3
|
using UnityEngine;
|
|
4
|
+
|
|
4
5
|
namespace Amanotes.Core.Internal
|
|
5
6
|
{
|
|
6
|
-
[Flags]
|
|
7
|
-
internal enum RoutineStatus
|
|
8
|
-
{
|
|
9
|
-
None,
|
|
10
|
-
Started = 1,
|
|
11
|
-
Stopped = 2
|
|
12
|
-
}
|
|
13
|
-
|
|
14
7
|
public class GDKRoutine
|
|
15
8
|
{
|
|
9
|
+
[Flags]
|
|
10
|
+
internal enum RoutineStatus
|
|
11
|
+
{
|
|
12
|
+
None,
|
|
13
|
+
Started = 1,
|
|
14
|
+
Stopped = 2
|
|
15
|
+
}
|
|
16
|
+
|
|
16
17
|
private RoutineStatus status;
|
|
17
18
|
private readonly IEnumerator action;
|
|
18
19
|
private Coroutine routine;
|
|
@@ -55,7 +56,7 @@ namespace Amanotes.Core.Internal
|
|
|
55
56
|
|
|
56
57
|
public static void StopCoroutine(GDKRoutine gdkRoutine)
|
|
57
58
|
{
|
|
58
|
-
gdkRoutine.StopRoutine();
|
|
59
|
+
if (gdkRoutine != null) gdkRoutine.StopRoutine();
|
|
59
60
|
}
|
|
60
61
|
}
|
|
61
62
|
}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Collections.Generic;
|
|
3
|
+
using System.Text.RegularExpressions;
|
|
4
|
+
using UnityEngine.Profiling;
|
|
5
|
+
using static Amanotes.Core.Internal.Logging;
|
|
6
|
+
|
|
7
|
+
namespace Amanotes.Core.Internal
|
|
8
|
+
{
|
|
9
|
+
public readonly struct GDKSemVer : IComparable<GDKSemVer>, IComparer<GDKSemVer>
|
|
10
|
+
{
|
|
11
|
+
// Zero version constant
|
|
12
|
+
public static readonly GDKSemVer ZERO = new GDKSemVer(0, 0, 0);
|
|
13
|
+
|
|
14
|
+
// Regex for parsing semantic versioning patterns, compiled for performance
|
|
15
|
+
private static readonly Regex VERSION_PATTERN = new Regex(@"^(\d+)\.(\d+)(?:\.(\d+))?(?:\.(\d+))?$", RegexOptions.Compiled);
|
|
16
|
+
|
|
17
|
+
// Version components
|
|
18
|
+
public readonly int major;
|
|
19
|
+
public readonly int minor;
|
|
20
|
+
public readonly int patch;
|
|
21
|
+
public readonly int extra;
|
|
22
|
+
|
|
23
|
+
// Constructor for direct value initialization
|
|
24
|
+
public GDKSemVer(int major, int minor, int patch, int extra = -1)
|
|
25
|
+
{
|
|
26
|
+
this.major = major;
|
|
27
|
+
this.minor = minor;
|
|
28
|
+
this.patch = patch;
|
|
29
|
+
this.extra = extra;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Constructor for string-based version initialization
|
|
33
|
+
public GDKSemVer(string version)
|
|
34
|
+
{
|
|
35
|
+
// Default values
|
|
36
|
+
major = 0;
|
|
37
|
+
minor = 0;
|
|
38
|
+
patch = 0;
|
|
39
|
+
extra = -1;
|
|
40
|
+
|
|
41
|
+
if (string.IsNullOrEmpty(version)) return;
|
|
42
|
+
|
|
43
|
+
Profiler.BeginSample("GDKSemVer()");
|
|
44
|
+
{
|
|
45
|
+
version = version.Trim();
|
|
46
|
+
Match match = VERSION_PATTERN.Match(version);
|
|
47
|
+
if (!match.Success)
|
|
48
|
+
{
|
|
49
|
+
LogWarning($"[GDKSemVer] Invalid version string: [{version}]");
|
|
50
|
+
Profiler.EndSample();
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Parse the version components using TryParse for safety
|
|
55
|
+
major = int.TryParse(match.Groups[1].Value, out int parsedMajor) ? parsedMajor : 0;
|
|
56
|
+
minor = int.TryParse(match.Groups[2].Value, out int parsedMinor) ? parsedMinor : 0;
|
|
57
|
+
if (match.Groups.Count > 3 && !int.TryParse(match.Groups[3].Value, out patch))
|
|
58
|
+
{
|
|
59
|
+
patch = 0;
|
|
60
|
+
}
|
|
61
|
+
if (match.Groups.Count > 4 && !int.TryParse(match.Groups[4].Value, out extra))
|
|
62
|
+
{
|
|
63
|
+
extra = -1;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
Profiler.EndSample();
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Property to check if the version is valid
|
|
70
|
+
public bool isValid => this != ZERO;
|
|
71
|
+
|
|
72
|
+
// Convert the version to a string representation
|
|
73
|
+
public override string ToString()
|
|
74
|
+
{
|
|
75
|
+
if (this == ZERO) return "-";
|
|
76
|
+
return extra != -1 ? $"{major}.{minor}.{patch}.{extra}" : $"{major}.{minor}.{patch}";
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Compare this version to another version
|
|
80
|
+
public int CompareTo(GDKSemVer other)
|
|
81
|
+
{
|
|
82
|
+
if (!isValid && !other.isValid) return 0;
|
|
83
|
+
if (!isValid) return -1;
|
|
84
|
+
if (!other.isValid) return 1;
|
|
85
|
+
|
|
86
|
+
if (major != other.major) return major.CompareTo(other.major);
|
|
87
|
+
if (minor != other.minor) return minor.CompareTo(other.minor);
|
|
88
|
+
if (patch != other.patch) return patch.CompareTo(other.patch);
|
|
89
|
+
if (extra != other.extra) return extra.CompareTo(other.extra);
|
|
90
|
+
return 0;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
public int Compare(GDKSemVer x, GDKSemVer y)
|
|
94
|
+
{
|
|
95
|
+
return x.CompareTo(y);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Check if this version is equal to another version
|
|
99
|
+
public override bool Equals(object obj)
|
|
100
|
+
{
|
|
101
|
+
return obj is GDKSemVer other &&
|
|
102
|
+
major == other.major &&
|
|
103
|
+
minor == other.minor &&
|
|
104
|
+
patch == other.patch &&
|
|
105
|
+
extra == other.extra;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// Equality operators
|
|
109
|
+
public static bool operator ==(GDKSemVer x, GDKSemVer y)
|
|
110
|
+
{
|
|
111
|
+
return x.Equals(y);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
public static bool operator !=(GDKSemVer x, GDKSemVer y)
|
|
115
|
+
{
|
|
116
|
+
return !x.Equals(y);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// Comparison operators
|
|
120
|
+
public static bool operator >(GDKSemVer x, GDKSemVer y)
|
|
121
|
+
{
|
|
122
|
+
return x.CompareTo(y) > 0;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
public static bool operator <(GDKSemVer x, GDKSemVer y)
|
|
126
|
+
{
|
|
127
|
+
return x.CompareTo(y) < 0;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
public static bool operator >=(GDKSemVer x, GDKSemVer y)
|
|
131
|
+
{
|
|
132
|
+
return x.CompareTo(y) >= 0;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
public static bool operator <=(GDKSemVer x, GDKSemVer y)
|
|
136
|
+
{
|
|
137
|
+
return x.CompareTo(y) <= 0;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// Generate a hash code for the version
|
|
141
|
+
public override int GetHashCode()
|
|
142
|
+
{
|
|
143
|
+
unchecked // Allow overflow
|
|
144
|
+
{
|
|
145
|
+
var hash = 17;
|
|
146
|
+
hash = hash * 23 + major.GetHashCode();
|
|
147
|
+
hash = hash * 23 + minor.GetHashCode();
|
|
148
|
+
hash = hash * 23 + patch.GetHashCode();
|
|
149
|
+
hash = hash * 23 + extra.GetHashCode();
|
|
150
|
+
return hash;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
@@ -187,7 +187,7 @@ namespace Amanotes.Core.Internal
|
|
|
187
187
|
return true;
|
|
188
188
|
}
|
|
189
189
|
|
|
190
|
-
public static void SemVerGUI(string title,
|
|
190
|
+
public static void SemVerGUI(string title, GDKSemVer version, Color? color1 = null, Color? color2 = null)
|
|
191
191
|
{
|
|
192
192
|
const int TAG_SIZE = 60;
|
|
193
193
|
Rect rect = GUILayoutUtility.GetRect(120, 16f);
|
|
@@ -210,13 +210,13 @@ namespace Amanotes.Core.Internal
|
|
|
210
210
|
GUI.Label(rect1, title, versionStyle);
|
|
211
211
|
}
|
|
212
212
|
|
|
213
|
-
public static void DrawVersionTag(
|
|
213
|
+
public static void DrawVersionTag(GDKSemVer version, bool? isValid = null)
|
|
214
214
|
{
|
|
215
215
|
Rect rect = GUILayoutUtility.GetRect(60f, 60f, 18f, 18f);
|
|
216
216
|
DrawVersionTag(rect, version, isValid);
|
|
217
217
|
}
|
|
218
218
|
|
|
219
|
-
public static void DrawVersionTag(Rect rect,
|
|
219
|
+
public static void DrawVersionTag(Rect rect, GDKSemVer version, bool? isValid = null)
|
|
220
220
|
{
|
|
221
221
|
isValid ??= version.isValid;
|
|
222
222
|
DrawTag(rect, version.ToString(), isValid.Value ? LIGHT_BLUE : LIGHT_GRAY, 0.5f);
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
using System;
|
|
2
|
-
using System.Collections;
|
|
3
|
-
using System.Threading;
|
|
4
2
|
using UnityEngine;
|
|
5
3
|
using static Amanotes.Core.Internal.Logging;
|
|
6
4
|
|
|
@@ -31,5 +29,15 @@ namespace Amanotes.Core.Internal
|
|
|
31
29
|
{
|
|
32
30
|
SafeInvoke(() => action?.Invoke(eventObject));
|
|
33
31
|
}
|
|
32
|
+
|
|
33
|
+
public static void ThrowExceptionInEditor<T>(string message, Func<string, T> exceptionCreator) where T: Exception
|
|
34
|
+
{
|
|
35
|
+
if (Application.isEditor)
|
|
36
|
+
{
|
|
37
|
+
throw exceptionCreator(message);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
LogWarning(message);
|
|
41
|
+
}
|
|
34
42
|
}
|
|
35
43
|
}
|
package/package.json
CHANGED
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
using System;
|
|
2
|
-
using System.Collections.Generic;
|
|
3
|
-
using System.Linq;
|
|
4
|
-
using System.Reflection;
|
|
5
|
-
using UnityEngine;
|
|
6
|
-
|
|
7
|
-
namespace Amanotes.Core
|
|
8
|
-
{
|
|
9
|
-
public partial class AmaGDK
|
|
10
|
-
{
|
|
11
|
-
internal static readonly Dispatcher dispatcher = new Dispatcher();
|
|
12
|
-
|
|
13
|
-
internal static void ThrowExceptionInEditor<T>(string message, Func<string, T> exceptionCreator) where T: Exception
|
|
14
|
-
{
|
|
15
|
-
#if UNITY_EDITOR
|
|
16
|
-
throw exceptionCreator(message);
|
|
17
|
-
#else
|
|
18
|
-
Debug.LogWarning(message);
|
|
19
|
-
#endif
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
[Serializable] internal class EventEntry
|
|
23
|
-
{
|
|
24
|
-
public int nParams;
|
|
25
|
-
internal bool _dispatching;
|
|
26
|
-
public Delegate callbacks;
|
|
27
|
-
public Delegate callbackOnce;
|
|
28
|
-
|
|
29
|
-
public bool hasCallback => callbacks != null || callbackOnce != null;
|
|
30
|
-
|
|
31
|
-
internal void Add(Delegate d, bool once)
|
|
32
|
-
{
|
|
33
|
-
callbackOnce = Delegate.Remove(callbackOnce, d);
|
|
34
|
-
callbacks = Delegate.Remove(callbacks, d);
|
|
35
|
-
if (once)
|
|
36
|
-
{
|
|
37
|
-
callbackOnce = Delegate.Combine(callbackOnce, d);
|
|
38
|
-
}
|
|
39
|
-
else
|
|
40
|
-
{
|
|
41
|
-
callbacks = Delegate.Combine(callbacks, d);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
internal void Remove(Delegate d)
|
|
46
|
-
{
|
|
47
|
-
callbackOnce = Delegate.Remove(callbackOnce, d);
|
|
48
|
-
callbacks = Delegate.Remove(callbacks, d);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
internal bool Dispatch(string eventName, object[] args)
|
|
54
|
-
{
|
|
55
|
-
if (_dispatching)
|
|
56
|
-
{
|
|
57
|
-
ThrowExceptionInEditor($"Nested dispatching is not supported, eventName: <{eventName}>",
|
|
58
|
-
(m) => new InvalidOperationException(m));
|
|
59
|
-
return false;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
if (args.Length != nParams)
|
|
63
|
-
{
|
|
64
|
-
ThrowExceptionInEditor($"Dispatch <{eventName}> with incorrect number of params, expecting {nParams}, got {args.Length}!",
|
|
65
|
-
(m) => new TargetParameterCountException(m));
|
|
66
|
-
return false;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
_dispatching = true;
|
|
70
|
-
callbacks?.DynamicInvoke(args);
|
|
71
|
-
callbackOnce?.DynamicInvoke(args);
|
|
72
|
-
callbackOnce = null;
|
|
73
|
-
_dispatching = false;
|
|
74
|
-
|
|
75
|
-
return true;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
internal class Dispatcher
|
|
80
|
-
{
|
|
81
|
-
internal readonly Dictionary<string, EventEntry> _eventMap = new Dictionary<string, EventEntry>();
|
|
82
|
-
internal void ClearAndReset()
|
|
83
|
-
{
|
|
84
|
-
_eventMap.Clear();
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
internal EventEntry Get(string eventName)
|
|
88
|
-
{
|
|
89
|
-
if (string.IsNullOrEmpty(eventName)) return null;
|
|
90
|
-
_eventMap.TryGetValue(eventName, out EventEntry entry);
|
|
91
|
-
return entry;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
internal void AddListener(string eventName, Delegate d, bool once)
|
|
95
|
-
{
|
|
96
|
-
if (d == null)
|
|
97
|
-
{
|
|
98
|
-
Debug.LogWarning("Dispatcher.Add() error: d == null");
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
int nParams = d.Method.GetParameters().Length;
|
|
103
|
-
EventEntry entry = Get(eventName);
|
|
104
|
-
|
|
105
|
-
if (entry == null)
|
|
106
|
-
{
|
|
107
|
-
entry = new EventEntry { nParams = nParams };
|
|
108
|
-
_eventMap.Add(eventName, entry);
|
|
109
|
-
}
|
|
110
|
-
else if (nParams != entry.nParams)
|
|
111
|
-
{
|
|
112
|
-
ThrowExceptionInEditor(string.Format(Internal.Messsage.DISPATCHER_WRONG_NUMBER_OF_PARAMS, eventName, entry.nParams, nParams),
|
|
113
|
-
(m) => new TargetParameterCountException(m));
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
// Debug.Log("Add: " + eventName + " --> " + d + " | " + once);
|
|
118
|
-
entry.Add(d, once);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
internal void RemoveListener(string eventName, Delegate d)
|
|
122
|
-
{
|
|
123
|
-
if (d == null)
|
|
124
|
-
{
|
|
125
|
-
Debug.LogWarning("Dispatcher.Remove() error: d == null");
|
|
126
|
-
return;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
EventEntry entry = Get(eventName);
|
|
130
|
-
entry?.Remove(d);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
internal void ClearListeners(string eventName)
|
|
134
|
-
{
|
|
135
|
-
if (_eventMap.ContainsKey(eventName)) _eventMap.Remove(eventName);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
internal void Dispatch(string eventName, params object[] data)
|
|
139
|
-
{
|
|
140
|
-
if (string.IsNullOrEmpty(eventName))
|
|
141
|
-
{
|
|
142
|
-
ThrowExceptionInEditor(
|
|
143
|
-
$"Invalid eventName: <{eventName}> (should not be null or empty)",
|
|
144
|
-
(m)=> new ArgumentException(m));
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
EventEntry entry = Get(eventName);
|
|
149
|
-
if (entry == null) return;
|
|
150
|
-
|
|
151
|
-
if (!entry.hasCallback)
|
|
152
|
-
{
|
|
153
|
-
// string[] result = _eventMap
|
|
154
|
-
// .Select(kvp => kvp.Key + ":" + kvp.Value + "\n")
|
|
155
|
-
// .ToArray();
|
|
156
|
-
//
|
|
157
|
-
// Debug.LogWarning("AmaGDK [Event] No listener of type <" + eventName + ">\n\nRegistered events:\n\n" + string.Join("", result));
|
|
158
|
-
return;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
TryCatchWrapper(() =>
|
|
162
|
-
{
|
|
163
|
-
entry.Dispatch(eventName, data);
|
|
164
|
-
}, !Application.isEditor);
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
internal static void TryCatchWrapper(Action action, bool useTryCatch)
|
|
168
|
-
{
|
|
169
|
-
if (!useTryCatch)
|
|
170
|
-
{
|
|
171
|
-
action();
|
|
172
|
-
return;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
try
|
|
176
|
-
{
|
|
177
|
-
action();
|
|
178
|
-
} catch (Exception e)
|
|
179
|
-
{
|
|
180
|
-
Debug.LogWarning(e);
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
}
|
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
using System;
|
|
2
|
-
using System.Collections.Generic;
|
|
3
|
-
using System.Text.RegularExpressions;
|
|
4
|
-
using UnityEngine;
|
|
5
|
-
using UnityEngine.Profiling;
|
|
6
|
-
using static Amanotes.Core.Internal.Logging;
|
|
7
|
-
|
|
8
|
-
namespace Amanotes.Core.Internal
|
|
9
|
-
{
|
|
10
|
-
public struct SemVer : IComparable<SemVer>, IComparer<SemVer>
|
|
11
|
-
{
|
|
12
|
-
public static readonly SemVer ZERO = new SemVer(0, 0, 0);
|
|
13
|
-
private static readonly Regex VERSION_PATTERN = new Regex(@"^(\d+)\.(\d+)(?:\.(\d+))?(?:\.(\d+))?$");
|
|
14
|
-
|
|
15
|
-
public int major;
|
|
16
|
-
public int minor;
|
|
17
|
-
public int patch;
|
|
18
|
-
public int extra;
|
|
19
|
-
|
|
20
|
-
public SemVer(int major, int minor, int patch, int extra = -1)
|
|
21
|
-
{
|
|
22
|
-
this.major = major;
|
|
23
|
-
this.minor = minor;
|
|
24
|
-
this.patch = patch;
|
|
25
|
-
this.extra = extra;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
public SemVer(string version)
|
|
29
|
-
{
|
|
30
|
-
major = 0;
|
|
31
|
-
minor = 0;
|
|
32
|
-
patch = 0;
|
|
33
|
-
extra = -1;
|
|
34
|
-
|
|
35
|
-
if (string.IsNullOrEmpty(version)) return;
|
|
36
|
-
|
|
37
|
-
Profiler.BeginSample("AmaGDK.SemVer()");
|
|
38
|
-
{
|
|
39
|
-
version = version.Trim();
|
|
40
|
-
Match match = VERSION_PATTERN.Match(version);
|
|
41
|
-
if (!match.Success)
|
|
42
|
-
{
|
|
43
|
-
LogWarning($"Invalid SemVer string: [{version}]");
|
|
44
|
-
Profiler.EndSample();
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
major = int.Parse(match.Groups[1].Value);
|
|
48
|
-
minor = int.Parse(match.Groups[2].Value);
|
|
49
|
-
if (match.Groups.Count > 2)
|
|
50
|
-
{
|
|
51
|
-
if (!int.TryParse(match.Groups[3].Value, out patch))
|
|
52
|
-
{
|
|
53
|
-
patch = 0;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
if (match.Groups.Count > 3)
|
|
57
|
-
{
|
|
58
|
-
if (!int.TryParse(match.Groups[4].Value, out extra))
|
|
59
|
-
{
|
|
60
|
-
extra = -1;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
Profiler.EndSample();
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
public bool isValid => this != ZERO;
|
|
68
|
-
|
|
69
|
-
public override string ToString()
|
|
70
|
-
{
|
|
71
|
-
if (this == ZERO) return "-";
|
|
72
|
-
if (extra != -1) return $"{major}.{minor}.{patch}.{extra}";
|
|
73
|
-
return $"{major}.{minor}.{patch}";
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
public int CompareTo(SemVer other)
|
|
77
|
-
{
|
|
78
|
-
if (!isValid)
|
|
79
|
-
{
|
|
80
|
-
if (!other.isValid)
|
|
81
|
-
{
|
|
82
|
-
return 0;
|
|
83
|
-
}
|
|
84
|
-
return -1;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
if (!other.isValid)
|
|
88
|
-
{
|
|
89
|
-
return 1;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
if (major != other.major) return major.CompareTo(other.major);
|
|
94
|
-
if (minor != other.minor) return minor.CompareTo(other.minor);
|
|
95
|
-
if (patch != other.patch) return patch.CompareTo(other.patch);
|
|
96
|
-
if (extra != other.extra) return extra.CompareTo(other.extra);
|
|
97
|
-
return 0;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
public int Compare(SemVer x, SemVer y)
|
|
101
|
-
{
|
|
102
|
-
return x.CompareTo(y);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
public override bool Equals(object obj)
|
|
106
|
-
{
|
|
107
|
-
if (!(obj is SemVer)) return false;
|
|
108
|
-
var other = (SemVer)obj;
|
|
109
|
-
return major == other.major && minor == other.minor && patch == other.patch && extra == other.extra;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
public static bool operator >(SemVer x, SemVer y)
|
|
113
|
-
{
|
|
114
|
-
return x.CompareTo(y) > 0;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
public static bool operator <(SemVer x, SemVer y)
|
|
118
|
-
{
|
|
119
|
-
return x.CompareTo(y) < 0;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
public static bool operator >=(SemVer x, SemVer y)
|
|
123
|
-
{
|
|
124
|
-
return x.CompareTo(y) >= 0;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
public static bool operator <=(SemVer x, SemVer y)
|
|
128
|
-
{
|
|
129
|
-
return x.CompareTo(y) <= 0;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
public static bool operator ==(SemVer x, SemVer y)
|
|
133
|
-
{
|
|
134
|
-
return x.Equals(y);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
public static bool operator !=(SemVer x, SemVer y)
|
|
138
|
-
{
|
|
139
|
-
return !x.Equals(y);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
public override int GetHashCode()
|
|
143
|
-
{
|
|
144
|
-
return (major << 24) | (minor << 16) | (patch << 8) | extra;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
}
|
|
File without changes
|