com.wallstop-studios.unity-helpers 2.0.0-rc22 → 2.0.0-rc24

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.
Files changed (60) hide show
  1. package/Editor/AnimationCopier.cs +39 -10
  2. package/Editor/AnimationCreator.cs +68 -24
  3. package/Editor/AnimationEventEditor.cs +206 -79
  4. package/Editor/AnimatorControllerCopier.cs +42 -14
  5. package/Editor/CustomEditors/MatchColliderToSpriteEditor.cs +5 -2
  6. package/Editor/PrefabCheckWizard.cs +37 -14
  7. package/Editor/SpriteSettingsApplier.cs +23 -9
  8. package/Editor/TextureResizerWizard.cs +37 -14
  9. package/Editor/TextureSettingsApplier.cs +23 -10
  10. package/Editor/Utils/EditorUtilities.cs +4 -2
  11. package/Editor/Utils/ReadOnlyPropertyDrawer.cs +2 -4
  12. package/README.md +10 -0
  13. package/Runtime/Core/Attributes/AnimationEventAttribute.cs +52 -23
  14. package/Runtime/Core/Attributes/KSerializableAttribute.cs +2 -6
  15. package/Runtime/Core/Attributes/NotNullAttribute.cs +3 -4
  16. package/Runtime/Core/Attributes/ReadOnlyAttribute.cs +1 -3
  17. package/Runtime/Core/Attributes/ValidateAssignmentAttribute.cs +12 -6
  18. package/Runtime/Core/DataStructure/Adapters/FastVector2Int.cs +1 -0
  19. package/Runtime/Core/DataStructure/Adapters/FastVector3Int.cs +13 -8
  20. package/Runtime/Core/DataStructure/Adapters/KGuid.cs +24 -7
  21. package/Runtime/Core/DataStructure/Adapters/KVector2.cs +1 -0
  22. package/Runtime/Core/DataStructure/Circle.cs +1 -1
  23. package/Runtime/Core/DataStructure/CyclicBuffer.cs +45 -49
  24. package/Runtime/Core/DataStructure/ISpatialTree.cs +22 -20
  25. package/Runtime/Core/DataStructure/StringWrapper.cs +1 -0
  26. package/Runtime/Core/Extension/CircleExtensions.cs +2 -2
  27. package/Runtime/Core/Extension/DictionaryExtensions.cs +62 -17
  28. package/Runtime/Core/Extension/StringExtensions.cs +30 -10
  29. package/Runtime/Core/Helper/Enumerables.cs +1 -1
  30. package/Runtime/Core/Helper/LifetimeHelpers.cs +2 -1
  31. package/Runtime/Core/Math/Line.cs +1 -1
  32. package/Runtime/Core/Math/Parabola.cs +4 -2
  33. package/Runtime/Core/Math/PointPolygonCheck.cs +12 -5
  34. package/Runtime/Core/Math/Range.cs +9 -8
  35. package/Runtime/Core/Math/XXHash.cs +22 -20
  36. package/Runtime/Core/Model/Direction.cs +26 -9
  37. package/Runtime/Core/OneOf/FastOneOf.cs +11 -4
  38. package/Runtime/Core/OneOf/None.cs +1 -3
  39. package/Runtime/Core/Serialization/JsonConverters/Vector2Converter.cs +13 -4
  40. package/Runtime/Core/Serialization/JsonConverters/Vector3Converter.cs +15 -5
  41. package/Runtime/Core/Threading/SingleThreadedThreadPool.cs +2 -3
  42. package/Runtime/Utils/AnimationEventEqualityComparer.cs +22 -10
  43. package/Runtime/Utils/AnimatorEnumStateMachine.cs +3 -4
  44. package/Runtime/Utils/Buffers.cs +1 -1
  45. package/Runtime/Utils/CenterPointOffset.cs +1 -2
  46. package/Runtime/Utils/CoroutineHandler.cs +1 -1
  47. package/Runtime/Utils/Oscillator.cs +4 -2
  48. package/Runtime/Utils/SetTextureImportData.cs +1 -1
  49. package/Runtime/Utils/SpriteRendererSyncer.cs +5 -3
  50. package/Runtime/Utils/TextureScale.cs +21 -6
  51. package/Tests/Runtime/DataStructures/BalancedKDTreeTests.cs +1 -1
  52. package/Tests/Runtime/DataStructures/CyclicBufferTests.cs +213 -0
  53. package/Tests/Runtime/DataStructures/CyclicBufferTests.cs.meta +3 -0
  54. package/Tests/Runtime/DataStructures/QuadTreeTests.cs +1 -1
  55. package/Tests/Runtime/DataStructures/UnbalancedKDTreeTests.cs +1 -1
  56. package/Tests/Runtime/Extensions/DictionaryExtensionTests.cs +41 -21
  57. package/Tests/Runtime/Extensions/StringExtensionTests.cs +1 -1
  58. package/Tests/Runtime/Performance/QuadTreePerformanceTests.cs +1 -1
  59. package/Tests/Runtime/Performance/UnbalancedKDTreeTests.cs +1 -1
  60. package/package.json +3 -2
@@ -59,14 +59,20 @@
59
59
  return new KGuid(System.Guid.NewGuid());
60
60
  }
61
61
 
62
- public KGuid(Guid guid) : this(guid.ToByteArray()) { }
62
+ public KGuid(Guid guid)
63
+ : this(guid.ToByteArray()) { }
63
64
 
64
65
  [JsonConstructor]
65
- public KGuid(string guid) : this(System.Guid.Parse(guid)) { }
66
+ public KGuid(string guid)
67
+ : this(System.Guid.Parse(guid)) { }
66
68
 
67
69
  public KGuid(byte[] guidBytes)
68
70
  {
69
- _a = (int)guidBytes[3] << 24 | (int)guidBytes[2] << 16 | (int)guidBytes[1] << 8 | (int)guidBytes[0];
71
+ _a =
72
+ (int)guidBytes[3] << 24
73
+ | (int)guidBytes[2] << 16
74
+ | (int)guidBytes[1] << 8
75
+ | (int)guidBytes[0];
70
76
  _b = (short)((int)guidBytes[5] << 8 | (int)guidBytes[4]);
71
77
  _c = (short)((int)guidBytes[7] << 8 | (int)guidBytes[6]);
72
78
  _d = guidBytes[8];
@@ -83,7 +89,18 @@
83
89
  public static implicit operator Guid(KGuid guid)
84
90
  {
85
91
  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);
92
+ guid._a,
93
+ guid._b,
94
+ guid._c,
95
+ guid._d,
96
+ guid._e,
97
+ guid._f,
98
+ guid._g,
99
+ guid._h,
100
+ guid._i,
101
+ guid._j,
102
+ guid._k
103
+ );
87
104
  }
88
105
 
89
106
  public static implicit operator KGuid(Guid guid)
@@ -237,7 +254,7 @@
237
254
  {
238
255
  KGuid otherKGuid => Equals(otherKGuid),
239
256
  Guid otherGuid => Equals(otherGuid),
240
- _ => false
257
+ _ => false,
241
258
  };
242
259
  }
243
260
 
@@ -275,7 +292,7 @@
275
292
  _h,
276
293
  _i,
277
294
  _j,
278
- _k
295
+ _k,
279
296
  };
280
297
  }
281
298
 
@@ -285,4 +302,4 @@
285
302
  _hashCode = 0;
286
303
  }
287
304
  }
288
- }
305
+ }
@@ -14,6 +14,7 @@
14
14
  [DataMember]
15
15
  [ProtoMember(1)]
16
16
  public float x;
17
+
17
18
  [DataMember]
18
19
  [ProtoMember(2)]
19
20
  public float y;
@@ -3,7 +3,7 @@
3
3
  using System;
4
4
  using Extension;
5
5
  using UnityEngine;
6
-
6
+
7
7
  public readonly struct Circle
8
8
  {
9
9
  public readonly Vector2 center;
@@ -1,31 +1,21 @@
1
1
  namespace UnityHelpers.Core.DataStructure
2
2
  {
3
- using Helper;
4
3
  using System;
5
4
  using System.Collections;
6
5
  using System.Collections.Generic;
7
- using System.ComponentModel;
8
-
9
- public enum BufferAddMethod
10
- {
11
- Prepend,
12
- Append
13
- }
6
+ using System.Linq;
7
+ using Helper;
14
8
 
15
9
  [Serializable]
16
- public sealed class CyclicBuffer<T> : IEnumerable<T>
10
+ public sealed class CyclicBuffer<T> : IReadOnlyList<T>
17
11
  {
18
- private readonly T[] _buffer;
19
-
20
- private int _position;
21
-
22
- public readonly BufferAddMethod AddMethod;
23
-
24
- public readonly int Capacity;
25
-
26
12
  public int Count { get; private set; }
13
+ public bool IsReadOnly => false;
27
14
 
28
- public readonly bool IsReadOnly;
15
+ public readonly int capacity;
16
+
17
+ private readonly List<T> _buffer;
18
+ private int _position;
29
19
 
30
20
  public T this[int index]
31
21
  {
@@ -41,24 +31,29 @@
41
31
  }
42
32
  }
43
33
 
44
- public CyclicBuffer(int capacity, BufferAddMethod addMethod = BufferAddMethod.Prepend)
34
+ public CyclicBuffer(int capacity, IEnumerable<T> initialContents = null)
45
35
  {
46
36
  if (capacity < 0)
47
37
  {
48
38
  throw new ArgumentException(nameof(capacity));
49
39
  }
50
- AddMethod = addMethod;
51
- Capacity = capacity;
40
+
41
+ this.capacity = capacity;
52
42
  _position = 0;
53
- _buffer = new T[capacity];
54
- IsReadOnly = false;
43
+ Count = 0;
44
+ _buffer = new List<T>();
45
+ foreach (T item in initialContents ?? Enumerable.Empty<T>())
46
+ {
47
+ Add(item);
48
+ }
55
49
  }
56
50
 
57
51
  public IEnumerator<T> GetEnumerator()
58
52
  {
59
53
  for (int i = 0; i < Count; ++i)
60
54
  {
61
- yield return this[i];
55
+ // No need for bounds check, we're safe
56
+ yield return _buffer[AdjustedIndexFor(i)];
62
57
  }
63
58
  }
64
59
 
@@ -69,9 +64,22 @@
69
64
 
70
65
  public void Add(T item)
71
66
  {
72
- _buffer[_position] = item;
73
- _position = WallMath.WrappedIncrement(_position, Capacity);
74
- if (Count < Capacity)
67
+ if (capacity == 0)
68
+ {
69
+ return;
70
+ }
71
+
72
+ if (_position < _buffer.Count)
73
+ {
74
+ _buffer[_position] = item;
75
+ }
76
+ else
77
+ {
78
+ _buffer.Add(item);
79
+ }
80
+
81
+ _position = _position.WrappedIncrement(capacity);
82
+ if (Count < capacity)
75
83
  {
76
84
  ++Count;
77
85
  }
@@ -82,35 +90,23 @@
82
90
  /* Simply reset state */
83
91
  Count = 0;
84
92
  _position = 0;
93
+ _buffer.Clear();
85
94
  }
86
95
 
87
- public bool Peek(out T value)
96
+ public bool Contains(T item)
88
97
  {
89
- if (InBounds(0))
90
- {
91
- value = this[0];
92
- return true;
93
- }
94
- value = default(T);
95
- return false;
98
+ return _buffer.Contains(item);
96
99
  }
97
100
 
98
101
  private int AdjustedIndexFor(int index)
99
102
  {
100
- switch (AddMethod)
103
+ long longCapacity = capacity;
104
+ unchecked
101
105
  {
102
- case BufferAddMethod.Prepend:
103
- {
104
- return (_position - 1 + Capacity - index) % Capacity;
105
- }
106
- case BufferAddMethod.Append:
107
- {
108
- return index;
109
- }
110
- default:
111
- {
112
- throw new InvalidEnumArgumentException("Unexpected AddMethod: " + AddMethod);
113
- }
106
+ int adjustedIndex = (int)(
107
+ (_position - 1L + longCapacity - (_buffer.Count - 1 - index)) % longCapacity
108
+ );
109
+ return adjustedIndex;
114
110
  }
115
111
  }
116
112
 
@@ -124,7 +120,7 @@
124
120
 
125
121
  private bool InBounds(int index)
126
122
  {
127
- return !(Count <= index || index < 0);
123
+ return 0 <= index && index < Count;
128
124
  }
129
125
  }
130
126
  }
@@ -20,35 +20,37 @@
20
20
  return GetElementsInBounds(
21
21
  new Bounds(
22
22
  new Vector3(position.x, position.y, 0f),
23
- new Vector3(range * 2f, range * 2f, 1f)))
24
- .Where(
25
- element =>
23
+ new Vector3(range * 2f, range * 2f, 1f)
24
+ )
25
+ )
26
+ .Where(element =>
27
+ {
28
+ Vector2 elementPosition = elementTransformer(element);
29
+ if (!area.Contains(elementPosition))
26
30
  {
27
- Vector2 elementPosition = elementTransformer(element);
28
- if (!area.Contains(elementPosition))
29
- {
30
- return false;
31
- }
31
+ return false;
32
+ }
32
33
 
33
- return !minimumArea.Contains(elementPosition);
34
- });
34
+ return !minimumArea.Contains(elementPosition);
35
+ });
35
36
  }
36
37
 
37
38
  return GetElementsInBounds(
38
39
  new Bounds(
39
40
  new Vector3(position.x, position.y, 0f),
40
- new Vector3(range * 2f, range * 2f, 1f)))
41
- .Where(
42
- element =>
41
+ new Vector3(range * 2f, range * 2f, 1f)
42
+ )
43
+ )
44
+ .Where(element =>
45
+ {
46
+ Vector2 elementPosition = elementTransformer(element);
47
+ if (!area.Contains(elementPosition))
43
48
  {
44
- Vector2 elementPosition = elementTransformer(element);
45
- if (!area.Contains(elementPosition))
46
- {
47
- return false;
48
- }
49
+ return false;
50
+ }
49
51
 
50
- return true;
51
- });
52
+ return true;
53
+ });
52
54
  }
53
55
 
54
56
  IEnumerable<T> GetElementsInBounds(Bounds bounds);
@@ -7,6 +7,7 @@
7
7
  Used to cache strings, meant to be used in place of strings as keys for when a Dictionary
8
8
  has a known set of values
9
9
  */
10
+ [Serializable]
10
11
  public sealed class StringWrapper : IEquatable<StringWrapper>, IComparable<StringWrapper>
11
12
  {
12
13
  private static readonly ConcurrentDictionary<string, StringWrapper> Cache = new();
@@ -9,9 +9,9 @@
9
9
  {
10
10
  public static IEnumerable<FastVector3Int> EnumerateArea(this Circle circle, int z = 0)
11
11
  {
12
- for (int x = (int) -circle.radius; x < circle.radius; ++x)
12
+ for (int x = (int)-circle.radius; x < circle.radius; ++x)
13
13
  {
14
- for (int y = (int) -circle.radius; y < circle.radius; ++y)
14
+ for (int y = (int)-circle.radius; y < circle.radius; ++y)
15
15
  {
16
16
  Vector2 point = new(x, y);
17
17
  if (circle.Contains(point))
@@ -7,11 +7,19 @@
7
7
 
8
8
  public static class DictionaryExtensions
9
9
  {
10
- public static V GetOrAdd<K, V>(this IDictionary<K, V> dictionary, K key, Func<V> valueProducer)
10
+ public static V GetOrAdd<K, V>(
11
+ this IDictionary<K, V> dictionary,
12
+ K key,
13
+ Func<V> valueProducer
14
+ )
11
15
  {
12
16
  if (dictionary is ConcurrentDictionary<K, V> concurrentDictionary)
13
17
  {
14
- return concurrentDictionary.GetOrAdd(key, static (_, existing) => existing(), valueProducer);
18
+ return concurrentDictionary.GetOrAdd(
19
+ key,
20
+ static (_, existing) => existing(),
21
+ valueProducer
22
+ );
15
23
  }
16
24
 
17
25
  if (dictionary.TryGetValue(key, out V result))
@@ -22,7 +30,11 @@
22
30
  return dictionary[key] = valueProducer();
23
31
  }
24
32
 
25
- public static V GetOrAdd<K, V>(this IDictionary<K, V> dictionary, K key, Func<K, V> valueProducer)
33
+ public static V GetOrAdd<K, V>(
34
+ this IDictionary<K, V> dictionary,
35
+ K key,
36
+ Func<K, V> valueProducer
37
+ )
26
38
  {
27
39
  if (dictionary is ConcurrentDictionary<K, V> concurrentDictionary)
28
40
  {
@@ -37,7 +49,11 @@
37
49
  return dictionary[key] = valueProducer(key);
38
50
  }
39
51
 
40
- public static V GetOrElse<K, V>(this IReadOnlyDictionary<K, V> dictionary, K key, Func<V> valueProducer)
52
+ public static V GetOrElse<K, V>(
53
+ this IReadOnlyDictionary<K, V> dictionary,
54
+ K key,
55
+ Func<V> valueProducer
56
+ )
41
57
  {
42
58
  if (dictionary.TryGetValue(key, out V value))
43
59
  {
@@ -47,7 +63,11 @@
47
63
  return valueProducer.Invoke();
48
64
  }
49
65
 
50
- public static V GetOrElse<K, V>(this IReadOnlyDictionary<K, V> dictionary, K key, Func<K, V> valueProducer)
66
+ public static V GetOrElse<K, V>(
67
+ this IReadOnlyDictionary<K, V> dictionary,
68
+ K key,
69
+ Func<K, V> valueProducer
70
+ )
51
71
  {
52
72
  if (dictionary.TryGetValue(key, out V value))
53
73
  {
@@ -57,11 +77,16 @@
57
77
  return valueProducer.Invoke(key);
58
78
  }
59
79
 
60
- public static V GetOrAdd<K, V>(this IDictionary<K, V> dictionary, K key) where V : new()
80
+ public static V GetOrAdd<K, V>(this IDictionary<K, V> dictionary, K key)
81
+ where V : new()
61
82
  {
62
83
  if (dictionary is ConcurrentDictionary<K, V> concurrentDictionary)
63
84
  {
64
- return concurrentDictionary.AddOrUpdate(key, _ => new V(), (_, existing) => existing);
85
+ return concurrentDictionary.AddOrUpdate(
86
+ key,
87
+ _ => new V(),
88
+ (_, existing) => existing
89
+ );
65
90
  }
66
91
 
67
92
  if (dictionary.TryGetValue(key, out V result))
@@ -78,14 +103,20 @@
78
103
  }
79
104
 
80
105
  public static V AddOrUpdate<K, V>(
81
- this IDictionary<K, V> dictionary, K key, Func<K, V> creator, Func<K, V, V> updater)
106
+ this IDictionary<K, V> dictionary,
107
+ K key,
108
+ Func<K, V> creator,
109
+ Func<K, V, V> updater
110
+ )
82
111
  {
83
112
  if (dictionary is ConcurrentDictionary<K, V> concurrentDictionary)
84
113
  {
85
114
  return concurrentDictionary.AddOrUpdate(key, creator, updater);
86
115
  }
87
116
 
88
- V latest = dictionary.TryGetValue(key, out V value) ? updater(key, value) : creator(key);
117
+ V latest = dictionary.TryGetValue(key, out V value)
118
+ ? updater(key, value)
119
+ : creator(key);
89
120
  dictionary[key] = latest;
90
121
  return latest;
91
122
  }
@@ -107,7 +138,10 @@
107
138
  return value;
108
139
  }
109
140
 
110
- public static Dictionary<K, V> Merge<K, V>(this IReadOnlyDictionary<K, V> lhs, IReadOnlyDictionary<K, V> rhs)
141
+ public static Dictionary<K, V> Merge<K, V>(
142
+ this IReadOnlyDictionary<K, V> lhs,
143
+ IReadOnlyDictionary<K, V> rhs
144
+ )
111
145
  {
112
146
  Dictionary<K, V> result = new();
113
147
  if (0 < lhs.Count)
@@ -137,7 +171,9 @@
137
171
  /// <param name="rhs">Changed dictionary.</param>
138
172
  /// <returns>All elements of rhs that either don't exist in or are different from lhs</returns>
139
173
  public static Dictionary<K, V> Difference<K, V>(
140
- this IReadOnlyDictionary<K, V> lhs, IReadOnlyDictionary<K, V> rhs)
174
+ this IReadOnlyDictionary<K, V> lhs,
175
+ IReadOnlyDictionary<K, V> rhs
176
+ )
141
177
  {
142
178
  Dictionary<K, V> result = new(rhs.Count);
143
179
  foreach (KeyValuePair<K, V> kvp in rhs)
@@ -170,18 +206,25 @@
170
206
  return new Dictionary<K, V>(dictionary);
171
207
  }
172
208
 
173
- public static Dictionary<K, V> ToDictionary<K, V>(this IEnumerable<KeyValuePair<K, V>> prettyMuchADictionary)
209
+ public static Dictionary<K, V> ToDictionary<K, V>(
210
+ this IEnumerable<KeyValuePair<K, V>> prettyMuchADictionary
211
+ )
174
212
  {
175
213
  return prettyMuchADictionary.ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
176
214
  }
177
215
 
178
- public static Dictionary<K, V> ToDictionary<K, V>(this IEnumerable<(K, V)> prettyMuchADictionary)
216
+ public static Dictionary<K, V> ToDictionary<K, V>(
217
+ this IEnumerable<(K, V)> prettyMuchADictionary
218
+ )
179
219
  {
180
220
  return prettyMuchADictionary.ToDictionary(kvp => kvp.Item1, kvp => kvp.Item2);
181
221
  }
182
222
 
183
223
  public static bool ContentEquals<K, V>(
184
- this IReadOnlyDictionary<K, V> dictionary, IReadOnlyDictionary<K, V> other) where V : IEquatable<V>
224
+ this IReadOnlyDictionary<K, V> dictionary,
225
+ IReadOnlyDictionary<K, V> other
226
+ )
227
+ where V : IEquatable<V>
185
228
  {
186
229
  if (ReferenceEquals(dictionary, other))
187
230
  {
@@ -193,8 +236,10 @@
193
236
  return false;
194
237
  }
195
238
 
196
- return dictionary.Count == other.Count && dictionary.All(
197
- kvp => other.TryGetValue(kvp.Key, out V value) && kvp.Value.Equals(value));
239
+ return dictionary.Count == other.Count
240
+ && dictionary.All(kvp =>
241
+ other.TryGetValue(kvp.Key, out V value) && kvp.Value.Equals(value)
242
+ );
198
243
  }
199
244
 
200
245
  public static void Deconstruct<K, V>(this KeyValuePair<K, V> kvp, out K key, out V value)
@@ -203,4 +248,4 @@
203
248
  value = kvp.Value;
204
249
  }
205
250
  }
206
- }
251
+ }
@@ -6,8 +6,17 @@
6
6
 
7
7
  public static class StringExtensions
8
8
  {
9
- private static readonly HashSet<char> PascalCaseSeparators =
10
- new() { '_', ' ', '\r', '\n', '\t', '.', '\'', '"' };
9
+ private static readonly HashSet<char> PascalCaseSeparators = new()
10
+ {
11
+ '_',
12
+ ' ',
13
+ '\r',
14
+ '\n',
15
+ '\t',
16
+ '.',
17
+ '\'',
18
+ '"',
19
+ };
11
20
 
12
21
  public static string Center(this string input, int length)
13
22
  {
@@ -41,13 +50,18 @@
41
50
  bool appendedAnySeparator = false;
42
51
  for (int i = 0; i < value.Length; ++i)
43
52
  {
44
- while (startIndex < value.Length && PascalCaseSeparators.Contains(value[startIndex]))
53
+ while (
54
+ startIndex < value.Length && PascalCaseSeparators.Contains(value[startIndex])
55
+ )
45
56
  {
46
57
  ++startIndex;
47
58
  }
48
59
 
49
- if (startIndex < i && char.IsLower(value[i - 1]) &&
50
- (char.IsUpper(value[i]) || PascalCaseSeparators.Contains(value[i])))
60
+ if (
61
+ startIndex < i
62
+ && char.IsLower(value[i - 1])
63
+ && (char.IsUpper(value[i]) || PascalCaseSeparators.Contains(value[i]))
64
+ )
51
65
  {
52
66
  _ = stringBuilder.Append(char.ToUpper(value[startIndex]));
53
67
  if (1 < i - startIndex)
@@ -74,8 +88,11 @@
74
88
  continue;
75
89
  }
76
90
 
77
- if (startIndex + 1 < i && char.IsLower(value[i]) &&
78
- (char.IsUpper(value[i - 1]) || PascalCaseSeparators.Contains(value[i - 1])))
91
+ if (
92
+ startIndex + 1 < i
93
+ && char.IsLower(value[i])
94
+ && (char.IsUpper(value[i - 1]) || PascalCaseSeparators.Contains(value[i - 1]))
95
+ )
79
96
  {
80
97
  _ = stringBuilder.Append(char.ToUpper(value[startIndex]));
81
98
  if (1 < i - 1 - startIndex)
@@ -119,8 +136,11 @@
119
136
  }
120
137
  }
121
138
  }
122
- else if (appendedAnySeparator && !string.IsNullOrEmpty(separator) &&
123
- separator.Length <= stringBuilder.Length)
139
+ else if (
140
+ appendedAnySeparator
141
+ && !string.IsNullOrEmpty(separator)
142
+ && separator.Length <= stringBuilder.Length
143
+ )
124
144
  {
125
145
  stringBuilder.Remove(stringBuilder.Length - separator.Length, separator.Length);
126
146
  }
@@ -128,4 +148,4 @@
128
148
  return stringBuilder.ToString();
129
149
  }
130
150
  }
131
- }
151
+ }
@@ -6,7 +6,7 @@
6
6
  {
7
7
  public static IEnumerable<T> Of<T>(T element)
8
8
  {
9
- return new[] {element};
9
+ return new[] { element };
10
10
  }
11
11
 
12
12
  public static IEnumerable<T> Of<T>(params T[] elements)
@@ -4,7 +4,8 @@
4
4
 
5
5
  public static class LifetimeHelpers
6
6
  {
7
- public static void Destroy<T>(this T source, float? afterTime = null) where T : Object
7
+ public static void Destroy<T>(this T source, float? afterTime = null)
8
+ where T : Object
8
9
  {
9
10
  source.SmartDestroy(afterTime);
10
11
  }
@@ -52,4 +52,4 @@
52
52
  return true;
53
53
  }
54
54
  }
55
- }
55
+ }
@@ -21,7 +21,9 @@
21
21
  {
22
22
  if (length <= 0)
23
23
  {
24
- throw new ArgumentException($"Expected a length greater than 0, but found: {length:0.00}.");
24
+ throw new ArgumentException(
25
+ $"Expected a length greater than 0, but found: {length:0.00}."
26
+ );
25
27
  }
26
28
 
27
29
  Length = length;
@@ -42,4 +44,4 @@
42
44
  return true;
43
45
  }
44
46
  }
45
- }
47
+ }
@@ -10,11 +10,18 @@
10
10
  int j = polygon.Length - 1;
11
11
  for (int i = 0; i < polygon.Length; i++)
12
12
  {
13
- if (polygon[i].y < point.y && polygon[j].y >= point.y ||
14
- polygon[j].y < point.y && polygon[i].y >= point.y)
13
+ if (
14
+ polygon[i].y < point.y && polygon[j].y >= point.y
15
+ || polygon[j].y < point.y && polygon[i].y >= point.y
16
+ )
15
17
  {
16
- if (polygon[i].x + (point.y - polygon[i].y) / (polygon[j].y - polygon[i].y) *
17
- (polygon[j].x - polygon[i].x) < point.x)
18
+ if (
19
+ polygon[i].x
20
+ + (point.y - polygon[i].y)
21
+ / (polygon[j].y - polygon[i].y)
22
+ * (polygon[j].x - polygon[i].x)
23
+ < point.x
24
+ )
18
25
  {
19
26
  result = !result;
20
27
  }
@@ -26,4 +33,4 @@
26
33
  return result;
27
34
  }
28
35
  }
29
- }
36
+ }