com.wallstop-studios.unity-helpers 2.1.0 → 2.1.2

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 (106) hide show
  1. package/AGENTS.md +1 -0
  2. package/Docs/ILIST_SORTING_PERFORMANCE.md +92 -0
  3. package/{package-lock.json.meta → Docs/ILIST_SORTING_PERFORMANCE.md.meta} +1 -1
  4. package/Docs/INDEX.md +11 -1
  5. package/Docs/Images/random_generators.svg +7 -7
  6. package/Docs/RANDOM_PERFORMANCE.md +17 -14
  7. package/Docs/REFLECTION_HELPERS.md +84 -1
  8. package/Docs/REFLECTION_PERFORMANCE.md +169 -0
  9. package/Docs/REFLECTION_PERFORMANCE.md.meta +7 -0
  10. package/Docs/RELATIONAL_COMPONENTS.md +6 -0
  11. package/Docs/RELATIONAL_COMPONENT_PERFORMANCE.md +63 -0
  12. package/Docs/RELATIONAL_COMPONENT_PERFORMANCE.md.meta +7 -0
  13. package/Docs/SPATIAL_TREE_2D_PERFORMANCE.md +64 -64
  14. package/Docs/SPATIAL_TREE_3D_PERFORMANCE.md +64 -64
  15. package/Editor/Core/Helper/AnimationEventHelpers.cs +1 -1
  16. package/Editor/Sprites/AnimationCopier.cs +1 -1
  17. package/Editor/Sprites/AnimationViewerWindow.cs +4 -4
  18. package/Editor/Sprites/SpriteSettingsApplierAPI.cs +2 -1
  19. package/Editor/Sprites/TextureResizerWizard.cs +4 -3
  20. package/Editor/Utils/ScriptableObjectSingletonCreator.cs +3 -3
  21. package/README.md +33 -18
  22. package/Runtime/Core/Attributes/BaseRelationalComponentAttribute.cs +147 -20
  23. package/Runtime/Core/Attributes/ChildComponentAttribute.cs +630 -117
  24. package/Runtime/Core/Attributes/NotNullAttribute.cs +5 -2
  25. package/Runtime/Core/Attributes/ParentComponentAttribute.cs +477 -103
  26. package/Runtime/Core/Attributes/RelationalComponentAssigner.cs +26 -3
  27. package/Runtime/Core/Attributes/RelationalComponentExtensions.cs +19 -3
  28. package/Runtime/Core/Attributes/SiblingComponentAttribute.cs +265 -92
  29. package/Runtime/Core/CodeGen.meta +8 -0
  30. package/Runtime/Core/DataStructure/ImmutableBitSet.cs +5 -20
  31. package/Runtime/Core/Extension/IListExtensions.cs +720 -12
  32. package/Runtime/Core/Helper/Logging/UnityLogTagFormatter.cs +11 -7
  33. package/Runtime/Core/Helper/Objects.cs +1 -1
  34. package/Runtime/Core/Helper/ReflectionHelpers.Factory.cs +5142 -0
  35. package/Runtime/Core/Helper/ReflectionHelpers.Factory.cs.meta +11 -0
  36. package/Runtime/Core/Helper/ReflectionHelpers.cs +1812 -1518
  37. package/Runtime/Core/Helper/UnityMainThreadDispatcher.cs +2 -3
  38. package/Runtime/Core/Math/Line2D.cs +2 -4
  39. package/Runtime/Core/Math/Line3D.cs +2 -4
  40. package/Runtime/Core/Random/AbstractRandom.cs +52 -5
  41. package/Runtime/Core/Random/DotNetRandom.cs +3 -3
  42. package/Runtime/Core/Random/FlurryBurstRandom.cs +279 -0
  43. package/Runtime/Core/Random/FlurryBurstRandom.cs.meta +3 -0
  44. package/Runtime/Core/Random/IllusionFlow.cs +3 -3
  45. package/Runtime/Core/Random/LinearCongruentialGenerator.cs +3 -3
  46. package/Runtime/Core/Random/PcgRandom.cs +6 -6
  47. package/Runtime/Core/Random/PhotonSpinRandom.cs +387 -0
  48. package/Runtime/Core/Random/PhotonSpinRandom.cs.meta +3 -0
  49. package/Runtime/Core/Random/RomuDuo.cs +3 -3
  50. package/Runtime/Core/Random/SplitMix64.cs +3 -3
  51. package/Runtime/Core/Random/SquirrelRandom.cs +6 -4
  52. package/Runtime/Core/Random/StormDropRandom.cs +271 -0
  53. package/Runtime/Core/Random/StormDropRandom.cs.meta +3 -0
  54. package/Runtime/Core/Random/UnityRandom.cs +3 -3
  55. package/Runtime/Core/Random/WyRandom.cs +6 -4
  56. package/Runtime/Core/Random/XorShiftRandom.cs +3 -3
  57. package/Runtime/Core/Random/XoroShiroRandom.cs +3 -3
  58. package/Runtime/Tags/AttributeMetadataCache.cs +316 -9
  59. package/Runtime/Tags/CosmeticEffectData.cs +1 -1
  60. package/Runtime/Visuals/UIToolkit/MultiFileSelectorElement.cs +3 -3
  61. package/Tests/Editor/Helper/HelpersTests.cs +2 -2
  62. package/Tests/Editor/Helper/ReflectionHelpersTypedEditorTests.cs +87 -0
  63. package/Tests/Editor/Helper/ReflectionHelpersTypedEditorTests.cs.meta +11 -0
  64. package/Tests/Editor/Helper/SpriteHelpersTests.cs +1 -1
  65. package/Tests/Editor/PrefabCheckerReportTests.cs +3 -3
  66. package/Tests/Editor/Sprites/AnimationCopierFilterTests.cs +18 -12
  67. package/Tests/Editor/Sprites/AnimationCopierWindowTests.cs +8 -7
  68. package/Tests/Editor/Sprites/AnimationViewerWindowTests.cs +2 -1
  69. package/Tests/Editor/Sprites/ScriptableSpriteAtlasEditorTests.cs +6 -5
  70. package/Tests/Editor/Sprites/SpriteCropperAdditionalTests.cs +2 -1
  71. package/Tests/Editor/Sprites/SpriteCropperTests.cs +7 -6
  72. package/Tests/Editor/Sprites/SpritePivotAdjusterAdditionalTests.cs +2 -1
  73. package/Tests/Editor/Sprites/SpritePivotAdjusterTests.cs +4 -3
  74. package/Tests/Editor/Sprites/TextureResizerWizardTests.cs +10 -9
  75. package/Tests/Editor/Sprites/TextureSettingsApplierAPITests.cs +2 -1
  76. package/Tests/Editor/Tags/AttributeMetadataCacheTests.cs +192 -0
  77. package/Tests/Editor/Tags/AttributeMetadataCacheTests.cs.meta +11 -0
  78. package/Tests/Editor/Tags.meta +8 -0
  79. package/Tests/Runtime/Extensions/IListExtensionTests.cs +187 -1
  80. package/Tests/Runtime/Helper/ObjectsTests.cs +4 -4
  81. package/Tests/Runtime/Helper/ReflectionHelperCapabilityMatrixTests.cs +2923 -0
  82. package/Tests/Runtime/Helper/ReflectionHelperCapabilityMatrixTests.cs.meta +11 -0
  83. package/Tests/Runtime/Helper/ReflectionHelperTests.cs +660 -0
  84. package/Tests/Runtime/Integrations/Reflex/RelationalComponentsReflexTests.cs +2 -2
  85. package/Tests/Runtime/Performance/IListSortingPerformanceTests.cs +346 -0
  86. package/Tests/Runtime/Performance/IListSortingPerformanceTests.cs.meta +11 -0
  87. package/Tests/Runtime/Performance/RandomPerformanceTests.cs +3 -0
  88. package/Tests/Runtime/Performance/ReflectionPerformanceTests.cs +1238 -0
  89. package/Tests/Runtime/Performance/ReflectionPerformanceTests.cs.meta +11 -0
  90. package/Tests/Runtime/Performance/RelationalComponentBenchmarkTests.cs +832 -0
  91. package/Tests/Runtime/Performance/RelationalComponentBenchmarkTests.cs.meta +11 -0
  92. package/Tests/Runtime/Random/FlurryBurstRandomTests.cs +12 -0
  93. package/Tests/Runtime/Random/FlurryBurstRandomTests.cs.meta +3 -0
  94. package/Tests/Runtime/Random/PhotonSpinRandomTests.cs +12 -0
  95. package/Tests/Runtime/Random/PhotonSpinRandomTests.cs.meta +3 -0
  96. package/Tests/Runtime/Random/RandomProtoSerializationTests.cs +14 -0
  97. package/Tests/Runtime/Random/RandomTestBase.cs +39 -4
  98. package/Tests/Runtime/Random/StormDropRandomTests.cs +12 -0
  99. package/Tests/Runtime/Random/StormDropRandomTests.cs.meta +3 -0
  100. package/Tests/Runtime/Serialization/ProtoInterfaceResolutionEdgeTests.cs +2 -2
  101. package/Tests/Runtime/Serialization/ProtoRootRegistrationTests.cs +1 -1
  102. package/Tests/Runtime/Serialization/ProtoSerializeBehaviorTests.cs +1 -1
  103. package/Tests/Runtime/Tags/PeriodicEffectDefinitionSerializationTests.cs +2 -2
  104. package/package.json +1 -1
  105. package/Tests/Runtime/Performance/RelationComponentPerformanceTests.cs +0 -60
  106. package/Tests/Runtime/Performance/RelationComponentPerformanceTests.cs.meta +0 -3
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 0f060e72b0e4c904188001528bceb7c9
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -0,0 +1,12 @@
1
+ namespace WallstopStudios.UnityHelpers.Tests.Random
2
+ {
3
+ using WallstopStudios.UnityHelpers.Core.Random;
4
+
5
+ public sealed class FlurryBurstRandomTests : RandomTestBase
6
+ {
7
+ protected override IRandom NewRandom()
8
+ {
9
+ return new FlurryBurstRandom();
10
+ }
11
+ }
12
+ }
@@ -0,0 +1,3 @@
1
+ fileFormatVersion: 2
2
+ guid: a8708ba817fc4d00a3ef31b68f550aba
3
+ timeCreated: 1761435962
@@ -0,0 +1,12 @@
1
+ namespace WallstopStudios.UnityHelpers.Tests.Random
2
+ {
3
+ using WallstopStudios.UnityHelpers.Core.Random;
4
+
5
+ public sealed class PhotonSpinRandomTests : RandomTestBase
6
+ {
7
+ protected override IRandom NewRandom()
8
+ {
9
+ return new PhotonSpinRandom();
10
+ }
11
+ }
12
+ }
@@ -0,0 +1,3 @@
1
+ fileFormatVersion: 2
2
+ guid: d55cf2508f694064a195df1829686813
3
+ timeCreated: 1761435962
@@ -171,6 +171,20 @@ namespace WallstopStudios.UnityHelpers.Tests.Random
171
171
  Assert.AreEqual(random.InternalState.State2, deserialized.InternalState.State2);
172
172
  }
173
173
 
174
+ [Test]
175
+ public void PhotonSpinRandomSerializesAndDeserializes()
176
+ {
177
+ PhotonSpinRandom random = new(Guid.Parse("0AF7CF4F-44F6-421E-B7DC-1ADEF9F27E19"));
178
+ VerifySerializationAndGeneration(random);
179
+ }
180
+
181
+ [Test]
182
+ public void StormDropRandomSerializesAndDeserializes()
183
+ {
184
+ StormDropRandom random = new(987654321u);
185
+ VerifySerializationAndGeneration(random);
186
+ }
187
+
174
188
  [Test]
175
189
  public void UnityRandomSerializesAndDeserializes()
176
190
  {
@@ -514,19 +514,54 @@ namespace WallstopStudios.UnityHelpers.Tests.Random
514
514
 
515
515
  [Test]
516
516
  [Parallelizable]
517
- public void Json()
517
+ public void JsonSerialization()
518
518
  {
519
519
  IRandom random = NewRandom();
520
520
  string json = random.ToJson();
521
521
  IRandom deserialized = Serializer.JsonDeserialize<IRandom>(json, random.GetType());
522
522
  Assert.AreEqual(random.InternalState, deserialized.InternalState);
523
523
 
524
- if (NewRandom() is not UnityRandom)
524
+ if (random is not UnityRandom)
525
525
  {
526
526
  for (int i = 0; i < NumGeneratorChecks; ++i)
527
527
  {
528
- Assert.AreEqual(random.Next(), deserialized.Next());
529
- Assert.AreEqual(random.InternalState, deserialized.InternalState);
528
+ Assert.AreEqual(random.Next(), deserialized.Next(), "Iteration: " + i);
529
+ Assert.AreEqual(
530
+ random.InternalState,
531
+ deserialized.InternalState,
532
+ "Iteration: " + i
533
+ );
534
+ }
535
+ }
536
+ }
537
+
538
+ [Test]
539
+ [Parallelizable]
540
+ public void JsonSerializationWithMix()
541
+ {
542
+ for (int preMix = 1; preMix < 10; ++preMix)
543
+ {
544
+ IRandom random = NewRandom();
545
+ for (int j = 0; j < preMix; ++j)
546
+ {
547
+ _ = random.Next();
548
+ }
549
+
550
+ string json = random.ToJson();
551
+ IRandom deserialized = Serializer.JsonDeserialize<IRandom>(json, random.GetType());
552
+ Assert.AreEqual(random.InternalState, deserialized.InternalState);
553
+
554
+ if (random is not UnityRandom)
555
+ {
556
+ for (int i = 0; i < NumGeneratorChecks; ++i)
557
+ {
558
+ Assert.AreEqual(random.Next(), deserialized.Next(), "Iteration: " + i);
559
+ Assert.AreEqual(
560
+ random.InternalState,
561
+ deserialized.InternalState,
562
+ "Iteration: " + i
563
+ );
564
+ }
530
565
  }
531
566
  }
532
567
  }
@@ -0,0 +1,12 @@
1
+ namespace WallstopStudios.UnityHelpers.Tests.Random
2
+ {
3
+ using WallstopStudios.UnityHelpers.Core.Random;
4
+
5
+ public sealed class StormDropRandomTests : RandomTestBase
6
+ {
7
+ protected override IRandom NewRandom()
8
+ {
9
+ return new StormDropRandom();
10
+ }
11
+ }
12
+ }
@@ -0,0 +1,3 @@
1
+ fileFormatVersion: 2
2
+ guid: a1b35b62f8104abf94ed3a48e79d303f
3
+ timeCreated: 1761441026
@@ -23,7 +23,7 @@ namespace WallstopStudios.UnityHelpers.Tests.Serialization
23
23
  public void SingleImplementationRequiresRegistration()
24
24
  {
25
25
  IWidget original = new Widget { Id = 3, Label = "ok" };
26
- byte[] data = Serializer.ProtoSerialize<IWidget>(original);
26
+ byte[] data = Serializer.ProtoSerialize(original);
27
27
 
28
28
  Assert.Throws<ProtoException>(
29
29
  () => Serializer.ProtoDeserialize<IWidget>(data),
@@ -65,7 +65,7 @@ namespace WallstopStudios.UnityHelpers.Tests.Serialization
65
65
  public void AbstractBaseWithoutRegistrationThrows()
66
66
  {
67
67
  AbstractBase original = new DerivedA { Common = 9, ExtraA = "x" };
68
- byte[] data = Serializer.ProtoSerialize<AbstractBase>(original, forceRuntimeType: true);
68
+ byte[] data = Serializer.ProtoSerialize(original, forceRuntimeType: true);
69
69
 
70
70
  Assert.Throws<ProtoException>(
71
71
  () => Serializer.ProtoDeserialize<AbstractBase>(data),
@@ -37,7 +37,7 @@ namespace WallstopStudios.UnityHelpers.Tests.Serialization
37
37
  {
38
38
  IAnimal original = new Dog { Age = 5, Name = "Rex" };
39
39
 
40
- byte[] data = Serializer.ProtoSerialize<IAnimal>(original);
40
+ byte[] data = Serializer.ProtoSerialize(original);
41
41
  Serializer.RegisterProtobufRoot<IAnimal, Dog>();
42
42
 
43
43
  IAnimal round = Serializer.ProtoDeserialize<IAnimal>(data);
@@ -51,7 +51,7 @@ namespace WallstopStudios.UnityHelpers.Tests.Serialization
51
51
  public void ObjectDeclaredUsesRuntimeTypeByDefault()
52
52
  {
53
53
  object original = new DerivedMsg { A = 42, B = "obj" };
54
- byte[] data = Serializer.ProtoSerialize<object>(original);
54
+ byte[] data = Serializer.ProtoSerialize(original);
55
55
  DerivedMsg round = Serializer.ProtoDeserialize<DerivedMsg>(data);
56
56
 
57
57
  Assert.IsNotNull(round, "Deserialized instance should not be null");
@@ -45,13 +45,13 @@ namespace WallstopStudios.UnityHelpers.Tests.Tags
45
45
  maxTicks = 6,
46
46
  modifications = new List<AttributeModification>
47
47
  {
48
- new AttributeModification
48
+ new()
49
49
  {
50
50
  attribute = "health",
51
51
  action = ModificationAction.Addition,
52
52
  value = -7.5f,
53
53
  },
54
- new AttributeModification
54
+ new()
55
55
  {
56
56
  attribute = "armor",
57
57
  action = ModificationAction.Multiplication,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "com.wallstop-studios.unity-helpers",
3
- "version": "2.1.0",
3
+ "version": "2.1.2",
4
4
  "displayName": "Unity Helpers",
5
5
  "description": "Various Unity Helper Library",
6
6
  "dependencies": {},
@@ -1,60 +0,0 @@
1
- namespace WallstopStudios.UnityHelpers.Tests.Performance
2
- {
3
- using System;
4
- using System.Diagnostics;
5
- using NUnit.Framework;
6
- using UnityEngine;
7
- using WallstopStudios.UnityHelpers.Core.Attributes;
8
- using WallstopStudios.UnityHelpers.Tests.Attributes.Components;
9
-
10
- public sealed class RelationComponentPerformanceTests
11
- {
12
- [Test]
13
- public void RelationalPerformanceComplexTest()
14
- {
15
- int count = 0;
16
-
17
- GameObject go = new("Test", typeof(RelationalComponentTesterComplex));
18
- RelationalComponentTesterComplex tester =
19
- go.GetComponent<RelationalComponentTesterComplex>();
20
- // Pre-warm
21
- tester.AssignRelationalComponents();
22
-
23
- TimeSpan timeout = TimeSpan.FromSeconds(10);
24
- Stopwatch timer = Stopwatch.StartNew();
25
- do
26
- {
27
- tester.AssignRelationalComponents();
28
- ++count;
29
- } while (timer.Elapsed < timeout);
30
-
31
- UnityEngine.Debug.Log($"Averaged {count / timeout.TotalSeconds} operations / second.");
32
-
33
- Assert.AreNotEqual(0, tester._childColliders.Length);
34
- Assert.AreNotEqual(0, tester._parentColliders.Length);
35
- Assert.AreNotEqual(0, tester._siblingColliders.Length);
36
- }
37
-
38
- [Test]
39
- public void RelationalPerformanceSimpleTest()
40
- {
41
- int count = 0;
42
-
43
- GameObject go = new("Test", typeof(RelationalComponentTesterSimple));
44
- RelationalComponentTesterSimple tester =
45
- go.GetComponent<RelationalComponentTesterSimple>();
46
- // Pre-warm
47
- tester.AssignRelationalComponents();
48
-
49
- TimeSpan timeout = TimeSpan.FromSeconds(10);
50
- Stopwatch timer = Stopwatch.StartNew();
51
- do
52
- {
53
- tester.AssignRelationalComponents();
54
- ++count;
55
- } while (timer.Elapsed < timeout);
56
-
57
- UnityEngine.Debug.Log($"Averaged {count / timeout.TotalSeconds} operations / second.");
58
- }
59
- }
60
- }
@@ -1,3 +0,0 @@
1
- fileFormatVersion: 2
2
- guid: 08f1585008ba43b0b666e27eb45f0768
3
- timeCreated: 1742065801