com.wallstop-studios.unity-helpers 2.0.0-rc02 → 2.0.0-rc04
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.
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
{
|
|
3
3
|
using System;
|
|
4
4
|
using System.Runtime.Serialization;
|
|
5
|
+
using System.Text.Json.Serialization;
|
|
5
6
|
using Helper;
|
|
6
7
|
using ProtoBuf;
|
|
7
8
|
|
|
@@ -16,40 +17,52 @@
|
|
|
16
17
|
*/
|
|
17
18
|
[ProtoMember(1)]
|
|
18
19
|
private int _a;
|
|
20
|
+
|
|
19
21
|
[ProtoMember(2)]
|
|
20
22
|
private short _b;
|
|
23
|
+
|
|
21
24
|
[ProtoMember(3)]
|
|
22
25
|
private short _c;
|
|
26
|
+
|
|
23
27
|
[ProtoMember(4)]
|
|
24
28
|
private byte _d;
|
|
29
|
+
|
|
25
30
|
[ProtoMember(5)]
|
|
26
31
|
private byte _e;
|
|
32
|
+
|
|
27
33
|
[ProtoMember(6)]
|
|
28
34
|
private byte _f;
|
|
35
|
+
|
|
29
36
|
[ProtoMember(7)]
|
|
30
37
|
private byte _g;
|
|
38
|
+
|
|
31
39
|
[ProtoMember(8)]
|
|
32
40
|
private byte _h;
|
|
41
|
+
|
|
33
42
|
[ProtoMember(9)]
|
|
34
43
|
private byte _i;
|
|
44
|
+
|
|
35
45
|
[ProtoMember(10)]
|
|
36
46
|
private byte _j;
|
|
47
|
+
|
|
37
48
|
[ProtoMember(11)]
|
|
38
49
|
private byte _k;
|
|
39
50
|
|
|
40
51
|
private int _hashCode;
|
|
41
52
|
|
|
42
|
-
[
|
|
43
|
-
|
|
53
|
+
[JsonInclude]
|
|
54
|
+
[DataMember]
|
|
55
|
+
private string Guid => ((Guid)this).ToString();
|
|
44
56
|
|
|
45
57
|
public static KGuid NewGuid()
|
|
46
58
|
{
|
|
47
59
|
return new KGuid(System.Guid.NewGuid());
|
|
48
60
|
}
|
|
49
|
-
|
|
50
|
-
public KGuid(Guid guid) : this(guid.ToByteArray())
|
|
51
|
-
|
|
52
|
-
|
|
61
|
+
|
|
62
|
+
public KGuid(Guid guid) : this(guid.ToByteArray()) { }
|
|
63
|
+
|
|
64
|
+
[JsonConstructor]
|
|
65
|
+
public KGuid(string guid) : this(System.Guid.Parse(guid)) { }
|
|
53
66
|
|
|
54
67
|
public KGuid(byte[] guidBytes)
|
|
55
68
|
{
|
|
@@ -69,7 +82,8 @@
|
|
|
69
82
|
|
|
70
83
|
public static implicit operator Guid(KGuid guid)
|
|
71
84
|
{
|
|
72
|
-
return new Guid(
|
|
85
|
+
return new Guid(
|
|
86
|
+
guid._a, guid._b, guid._c, guid._d, guid._e, guid._f, guid._g, guid._h, guid._i, guid._j, guid._k);
|
|
73
87
|
}
|
|
74
88
|
|
|
75
89
|
public static implicit operator KGuid(Guid guid)
|
|
@@ -244,16 +258,16 @@
|
|
|
244
258
|
|
|
245
259
|
public byte[] ToByteArray()
|
|
246
260
|
{
|
|
247
|
-
return new
|
|
261
|
+
return new[]
|
|
248
262
|
{
|
|
249
|
-
(byte)
|
|
250
|
-
(byte)
|
|
251
|
-
(byte)
|
|
252
|
-
(byte)
|
|
253
|
-
(byte)
|
|
254
|
-
(byte)
|
|
255
|
-
(byte)
|
|
256
|
-
(byte)
|
|
263
|
+
(byte)_a,
|
|
264
|
+
(byte)(_a >> 8),
|
|
265
|
+
(byte)(_a >> 16),
|
|
266
|
+
(byte)(_a >> 24),
|
|
267
|
+
(byte)_b,
|
|
268
|
+
(byte)((uint)_b >> 8),
|
|
269
|
+
(byte)_c,
|
|
270
|
+
(byte)((uint)_c >> 8),
|
|
257
271
|
_d,
|
|
258
272
|
_e,
|
|
259
273
|
_f,
|
|
@@ -271,4 +285,4 @@
|
|
|
271
285
|
_hashCode = 0;
|
|
272
286
|
}
|
|
273
287
|
}
|
|
274
|
-
}
|
|
288
|
+
}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
using Helper;
|
|
5
5
|
using System;
|
|
6
6
|
using System.Runtime.Serialization;
|
|
7
|
+
using System.Text.Json.Serialization;
|
|
7
8
|
|
|
8
9
|
/// <summary>
|
|
9
10
|
/// Inclusive Range [min,max]
|
|
@@ -13,17 +14,22 @@
|
|
|
13
14
|
public struct Range<T> : IEquatable<Range<T>> where T : IEquatable<T>, IComparable<T>
|
|
14
15
|
{
|
|
15
16
|
[DataMember]
|
|
17
|
+
[JsonInclude]
|
|
16
18
|
public T min;
|
|
17
19
|
|
|
18
20
|
[DataMember]
|
|
21
|
+
[JsonInclude]
|
|
19
22
|
public T max;
|
|
20
23
|
|
|
21
24
|
[DataMember]
|
|
25
|
+
[JsonInclude]
|
|
22
26
|
public bool startInclusive;
|
|
23
27
|
|
|
24
28
|
[DataMember]
|
|
29
|
+
[JsonInclude]
|
|
25
30
|
public bool endInclusive;
|
|
26
31
|
|
|
32
|
+
[JsonConstructor]
|
|
27
33
|
public Range(T min, T max, bool startInclusive = true, bool endInclusive = true)
|
|
28
34
|
{
|
|
29
35
|
this.min = min;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
{
|
|
3
3
|
using System;
|
|
4
4
|
using System.Runtime.Serialization;
|
|
5
|
+
using System.Text.Json.Serialization;
|
|
5
6
|
|
|
6
7
|
/// <summary>
|
|
7
8
|
/// Implementation based off of the reference PCG Random, found here: https://www.pcg-random.org/index.html
|
|
@@ -12,14 +13,17 @@
|
|
|
12
13
|
{
|
|
13
14
|
public static IRandom Instance => ThreadLocalRandom<PcgRandom>.Instance;
|
|
14
15
|
|
|
16
|
+
[JsonInclude]
|
|
17
|
+
[JsonPropertyName("Increment")]
|
|
15
18
|
[DataMember(Name = "Increment")]
|
|
16
19
|
internal readonly ulong _increment;
|
|
20
|
+
|
|
21
|
+
[JsonInclude]
|
|
22
|
+
[JsonPropertyName("State")]
|
|
17
23
|
[DataMember(Name = "State")]
|
|
18
24
|
internal ulong _state;
|
|
19
25
|
|
|
20
|
-
public PcgRandom() : this(Guid.NewGuid())
|
|
21
|
-
{
|
|
22
|
-
}
|
|
26
|
+
public PcgRandom() : this(Guid.NewGuid()) { }
|
|
23
27
|
|
|
24
28
|
public PcgRandom(Guid guid)
|
|
25
29
|
{
|
|
@@ -35,6 +39,7 @@
|
|
|
35
39
|
_cachedGaussian = randomState.Gaussian;
|
|
36
40
|
}
|
|
37
41
|
|
|
42
|
+
[JsonConstructor]
|
|
38
43
|
public PcgRandom(ulong increment, ulong state)
|
|
39
44
|
{
|
|
40
45
|
_increment = increment;
|
|
@@ -45,11 +50,11 @@
|
|
|
45
50
|
{
|
|
46
51
|
// Start with a nice prime
|
|
47
52
|
_increment = 6554638469UL;
|
|
48
|
-
_state = unchecked((ulong)
|
|
53
|
+
_state = unchecked((ulong)seed);
|
|
49
54
|
_increment = NextUlong();
|
|
50
55
|
}
|
|
51
56
|
|
|
52
|
-
public override RandomState InternalState => new
|
|
57
|
+
public override RandomState InternalState => new(_state, _increment, _cachedGaussian);
|
|
53
58
|
|
|
54
59
|
public override uint NextUint()
|
|
55
60
|
{
|
|
@@ -87,6 +92,7 @@
|
|
|
87
92
|
{
|
|
88
93
|
return 0;
|
|
89
94
|
}
|
|
95
|
+
|
|
90
96
|
if (_state < other._state)
|
|
91
97
|
{
|
|
92
98
|
return -1;
|
|
@@ -139,4 +145,4 @@
|
|
|
139
145
|
return new PcgRandom(InternalState);
|
|
140
146
|
}
|
|
141
147
|
}
|
|
142
|
-
}
|
|
148
|
+
}
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
IgnoreReadOnlyProperties = false,
|
|
26
26
|
ReferenceHandler = ReferenceHandler.IgnoreCycles,
|
|
27
27
|
IncludeFields = true,
|
|
28
|
+
PropertyNameCaseInsensitive = true,
|
|
28
29
|
Converters =
|
|
29
30
|
{
|
|
30
31
|
new JsonStringEnumConverter(),
|
|
@@ -38,6 +39,7 @@
|
|
|
38
39
|
IgnoreReadOnlyFields = false,
|
|
39
40
|
IgnoreReadOnlyProperties = false,
|
|
40
41
|
ReferenceHandler = ReferenceHandler.IgnoreCycles,
|
|
42
|
+
PropertyNameCaseInsensitive = true,
|
|
41
43
|
IncludeFields = true,
|
|
42
44
|
Converters =
|
|
43
45
|
{
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
using System.Globalization;
|
|
7
7
|
using System.Linq;
|
|
8
8
|
using System.Runtime.Serialization;
|
|
9
|
+
using System.Text.Json.Serialization;
|
|
9
10
|
using UnityEngine;
|
|
10
11
|
|
|
11
12
|
/// <summary>
|
|
@@ -19,13 +20,20 @@
|
|
|
19
20
|
{
|
|
20
21
|
private static readonly T[] Values = Enum.GetValues(typeof(T)).OfType<T>().ToArray();
|
|
21
22
|
|
|
22
|
-
[
|
|
23
|
+
[JsonIgnore]
|
|
24
|
+
[IgnoreDataMember]
|
|
25
|
+
private readonly HashSet<string> _availableBools = new HashSet<string>();
|
|
23
26
|
|
|
24
|
-
[
|
|
27
|
+
[JsonIgnore]
|
|
28
|
+
[IgnoreDataMember]
|
|
29
|
+
public readonly Animator Animator;
|
|
25
30
|
|
|
26
|
-
[
|
|
31
|
+
[JsonIgnore]
|
|
32
|
+
[IgnoreDataMember]
|
|
33
|
+
private T _value;
|
|
27
34
|
|
|
28
35
|
[DataMember]
|
|
36
|
+
[JsonInclude]
|
|
29
37
|
public T Value
|
|
30
38
|
{
|
|
31
39
|
get { return _value; }
|
|
@@ -45,6 +53,7 @@
|
|
|
45
53
|
}
|
|
46
54
|
|
|
47
55
|
[DataMember]
|
|
56
|
+
[JsonInclude]
|
|
48
57
|
private string Type => typeof(T).Name;
|
|
49
58
|
|
|
50
59
|
public AnimatorEnumStateMachine(Animator animator, T defaultValue = default(T))
|
|
@@ -77,4 +86,4 @@
|
|
|
77
86
|
return this.ToJson();
|
|
78
87
|
}
|
|
79
88
|
}
|
|
80
|
-
}
|
|
89
|
+
}
|