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.
- package/AGENTS.md +1 -0
- package/Docs/ILIST_SORTING_PERFORMANCE.md +92 -0
- package/{package-lock.json.meta → Docs/ILIST_SORTING_PERFORMANCE.md.meta} +1 -1
- package/Docs/INDEX.md +11 -1
- package/Docs/Images/random_generators.svg +7 -7
- package/Docs/RANDOM_PERFORMANCE.md +17 -14
- package/Docs/REFLECTION_HELPERS.md +84 -1
- package/Docs/REFLECTION_PERFORMANCE.md +169 -0
- package/Docs/REFLECTION_PERFORMANCE.md.meta +7 -0
- package/Docs/RELATIONAL_COMPONENTS.md +6 -0
- package/Docs/RELATIONAL_COMPONENT_PERFORMANCE.md +63 -0
- package/Docs/RELATIONAL_COMPONENT_PERFORMANCE.md.meta +7 -0
- package/Docs/SPATIAL_TREE_2D_PERFORMANCE.md +64 -64
- package/Docs/SPATIAL_TREE_3D_PERFORMANCE.md +64 -64
- package/Editor/Core/Helper/AnimationEventHelpers.cs +1 -1
- package/Editor/Sprites/AnimationCopier.cs +1 -1
- package/Editor/Sprites/AnimationViewerWindow.cs +4 -4
- package/Editor/Sprites/SpriteSettingsApplierAPI.cs +2 -1
- package/Editor/Sprites/TextureResizerWizard.cs +4 -3
- package/Editor/Utils/ScriptableObjectSingletonCreator.cs +3 -3
- package/README.md +33 -18
- package/Runtime/Core/Attributes/BaseRelationalComponentAttribute.cs +147 -20
- package/Runtime/Core/Attributes/ChildComponentAttribute.cs +630 -117
- package/Runtime/Core/Attributes/NotNullAttribute.cs +5 -2
- package/Runtime/Core/Attributes/ParentComponentAttribute.cs +477 -103
- package/Runtime/Core/Attributes/RelationalComponentAssigner.cs +26 -3
- package/Runtime/Core/Attributes/RelationalComponentExtensions.cs +19 -3
- package/Runtime/Core/Attributes/SiblingComponentAttribute.cs +265 -92
- package/Runtime/Core/CodeGen.meta +8 -0
- package/Runtime/Core/DataStructure/ImmutableBitSet.cs +5 -20
- package/Runtime/Core/Extension/IListExtensions.cs +720 -12
- package/Runtime/Core/Helper/Logging/UnityLogTagFormatter.cs +11 -7
- package/Runtime/Core/Helper/Objects.cs +1 -1
- package/Runtime/Core/Helper/ReflectionHelpers.Factory.cs +5142 -0
- package/Runtime/Core/Helper/ReflectionHelpers.Factory.cs.meta +11 -0
- package/Runtime/Core/Helper/ReflectionHelpers.cs +1812 -1518
- package/Runtime/Core/Helper/UnityMainThreadDispatcher.cs +2 -3
- package/Runtime/Core/Math/Line2D.cs +2 -4
- package/Runtime/Core/Math/Line3D.cs +2 -4
- package/Runtime/Core/Random/AbstractRandom.cs +52 -5
- package/Runtime/Core/Random/DotNetRandom.cs +3 -3
- package/Runtime/Core/Random/FlurryBurstRandom.cs +279 -0
- package/Runtime/Core/Random/FlurryBurstRandom.cs.meta +3 -0
- package/Runtime/Core/Random/IllusionFlow.cs +3 -3
- package/Runtime/Core/Random/LinearCongruentialGenerator.cs +3 -3
- package/Runtime/Core/Random/PcgRandom.cs +6 -6
- package/Runtime/Core/Random/PhotonSpinRandom.cs +387 -0
- package/Runtime/Core/Random/PhotonSpinRandom.cs.meta +3 -0
- package/Runtime/Core/Random/RomuDuo.cs +3 -3
- package/Runtime/Core/Random/SplitMix64.cs +3 -3
- package/Runtime/Core/Random/SquirrelRandom.cs +6 -4
- package/Runtime/Core/Random/StormDropRandom.cs +271 -0
- package/Runtime/Core/Random/StormDropRandom.cs.meta +3 -0
- package/Runtime/Core/Random/UnityRandom.cs +3 -3
- package/Runtime/Core/Random/WyRandom.cs +6 -4
- package/Runtime/Core/Random/XorShiftRandom.cs +3 -3
- package/Runtime/Core/Random/XoroShiroRandom.cs +3 -3
- package/Runtime/Tags/AttributeMetadataCache.cs +316 -9
- package/Runtime/Tags/CosmeticEffectData.cs +1 -1
- package/Runtime/Visuals/UIToolkit/MultiFileSelectorElement.cs +3 -3
- package/Tests/Editor/Helper/HelpersTests.cs +2 -2
- package/Tests/Editor/Helper/ReflectionHelpersTypedEditorTests.cs +87 -0
- package/Tests/Editor/Helper/ReflectionHelpersTypedEditorTests.cs.meta +11 -0
- package/Tests/Editor/Helper/SpriteHelpersTests.cs +1 -1
- package/Tests/Editor/PrefabCheckerReportTests.cs +3 -3
- package/Tests/Editor/Sprites/AnimationCopierFilterTests.cs +18 -12
- package/Tests/Editor/Sprites/AnimationCopierWindowTests.cs +8 -7
- package/Tests/Editor/Sprites/AnimationViewerWindowTests.cs +2 -1
- package/Tests/Editor/Sprites/ScriptableSpriteAtlasEditorTests.cs +6 -5
- package/Tests/Editor/Sprites/SpriteCropperAdditionalTests.cs +2 -1
- package/Tests/Editor/Sprites/SpriteCropperTests.cs +7 -6
- package/Tests/Editor/Sprites/SpritePivotAdjusterAdditionalTests.cs +2 -1
- package/Tests/Editor/Sprites/SpritePivotAdjusterTests.cs +4 -3
- package/Tests/Editor/Sprites/TextureResizerWizardTests.cs +10 -9
- package/Tests/Editor/Sprites/TextureSettingsApplierAPITests.cs +2 -1
- package/Tests/Editor/Tags/AttributeMetadataCacheTests.cs +192 -0
- package/Tests/Editor/Tags/AttributeMetadataCacheTests.cs.meta +11 -0
- package/Tests/Editor/Tags.meta +8 -0
- package/Tests/Runtime/Extensions/IListExtensionTests.cs +187 -1
- package/Tests/Runtime/Helper/ObjectsTests.cs +4 -4
- package/Tests/Runtime/Helper/ReflectionHelperCapabilityMatrixTests.cs +2923 -0
- package/Tests/Runtime/Helper/ReflectionHelperCapabilityMatrixTests.cs.meta +11 -0
- package/Tests/Runtime/Helper/ReflectionHelperTests.cs +660 -0
- package/Tests/Runtime/Integrations/Reflex/RelationalComponentsReflexTests.cs +2 -2
- package/Tests/Runtime/Performance/IListSortingPerformanceTests.cs +346 -0
- package/Tests/Runtime/Performance/IListSortingPerformanceTests.cs.meta +11 -0
- package/Tests/Runtime/Performance/RandomPerformanceTests.cs +3 -0
- package/Tests/Runtime/Performance/ReflectionPerformanceTests.cs +1238 -0
- package/Tests/Runtime/Performance/ReflectionPerformanceTests.cs.meta +11 -0
- package/Tests/Runtime/Performance/RelationalComponentBenchmarkTests.cs +832 -0
- package/Tests/Runtime/Performance/RelationalComponentBenchmarkTests.cs.meta +11 -0
- package/Tests/Runtime/Random/FlurryBurstRandomTests.cs +12 -0
- package/Tests/Runtime/Random/FlurryBurstRandomTests.cs.meta +3 -0
- package/Tests/Runtime/Random/PhotonSpinRandomTests.cs +12 -0
- package/Tests/Runtime/Random/PhotonSpinRandomTests.cs.meta +3 -0
- package/Tests/Runtime/Random/RandomProtoSerializationTests.cs +14 -0
- package/Tests/Runtime/Random/RandomTestBase.cs +39 -4
- package/Tests/Runtime/Random/StormDropRandomTests.cs +12 -0
- package/Tests/Runtime/Random/StormDropRandomTests.cs.meta +3 -0
- package/Tests/Runtime/Serialization/ProtoInterfaceResolutionEdgeTests.cs +2 -2
- package/Tests/Runtime/Serialization/ProtoRootRegistrationTests.cs +1 -1
- package/Tests/Runtime/Serialization/ProtoSerializeBehaviorTests.cs +1 -1
- package/Tests/Runtime/Tags/PeriodicEffectDefinitionSerializationTests.cs +2 -2
- package/package.json +1 -1
- package/Tests/Runtime/Performance/RelationComponentPerformanceTests.cs +0 -60
- package/Tests/Runtime/Performance/RelationComponentPerformanceTests.cs.meta +0 -3
|
@@ -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,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
|
+
}
|
|
@@ -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
|
|
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 (
|
|
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(
|
|
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
|
+
}
|
|
@@ -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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
48
|
+
new()
|
|
49
49
|
{
|
|
50
50
|
attribute = "health",
|
|
51
51
|
action = ModificationAction.Addition,
|
|
52
52
|
value = -7.5f,
|
|
53
53
|
},
|
|
54
|
-
new
|
|
54
|
+
new()
|
|
55
55
|
{
|
|
56
56
|
attribute = "armor",
|
|
57
57
|
action = ModificationAction.Multiplication,
|
package/package.json
CHANGED
|
@@ -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
|
-
}
|