diff --git a/CHANGELOG.md b/CHANGELOG.md index a5caa91..ff52f08 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # Changelog +## 3.2.0 +### Added +- X10D: Added `Vector2.Deconstruct()` +- X10D: Added `Vector3.Deconstruct()` +- X10D: Added `Vector4.Deconstruct()` +- X10D.Unity: Added `Vector2.Deconstruct()` +- X10D.Unity: Added `Vector3.Deconstruct()` +- X10D.Unity: Added `Vector4.Deconstruct()` + ## [3.1.0] ### Added - Reintroduced Unity support diff --git a/X10D.Tests/src/Numerics/Vector2Tests.cs b/X10D.Tests/src/Numerics/Vector2Tests.cs index 72c1ddb..a32d225 100644 --- a/X10D.Tests/src/Numerics/Vector2Tests.cs +++ b/X10D.Tests/src/Numerics/Vector2Tests.cs @@ -7,6 +7,16 @@ namespace X10D.Tests.Numerics; [TestClass] public class Vector2Tests { + [TestMethod] + public void Deconstruct_ShouldReturnCorrectValues() + { + var vector = new Vector2(1, 2); + (float x, float y) = vector; + + Assert.AreEqual(1, x); + Assert.AreEqual(2, y); + } + [TestMethod] public void WithX_ShouldReturnVectorWithNewX_GivenVector() { diff --git a/X10D.Tests/src/Numerics/Vector3Tests.cs b/X10D.Tests/src/Numerics/Vector3Tests.cs index 285a253..037c944 100644 --- a/X10D.Tests/src/Numerics/Vector3Tests.cs +++ b/X10D.Tests/src/Numerics/Vector3Tests.cs @@ -7,6 +7,17 @@ namespace X10D.Tests.Numerics; [TestClass] public class Vector3Tests { + [TestMethod] + public void Deconstruct_ShouldReturnCorrectValues() + { + var vector = new Vector3(1, 2, 3); + (float x, float y, float z) = vector; + + Assert.AreEqual(1, x); + Assert.AreEqual(2, y); + Assert.AreEqual(3, z); + } + [TestMethod] public void WithX_ShouldReturnVectorWithNewX_GivenVector() { diff --git a/X10D.Tests/src/Numerics/Vector4Tests.cs b/X10D.Tests/src/Numerics/Vector4Tests.cs index 4a0b927..3b8e396 100644 --- a/X10D.Tests/src/Numerics/Vector4Tests.cs +++ b/X10D.Tests/src/Numerics/Vector4Tests.cs @@ -7,6 +7,18 @@ namespace X10D.Tests.Numerics; [TestClass] public class Vector4Tests { + [TestMethod] + public void Deconstruct_ShouldReturnCorrectValues() + { + var vector = new Vector4(1, 2, 3, 4); + (float x, float y, float z, float w) = vector; + + Assert.AreEqual(1, x); + Assert.AreEqual(2, y); + Assert.AreEqual(3, z); + Assert.AreEqual(4, w); + } + [TestMethod] public void WithW_ShouldReturnVectorWithNewW_GivenVector() { diff --git a/X10D.Unity.Tests/Assets/Tests/Numerics/Vector2Tests.cs b/X10D.Unity.Tests/Assets/Tests/Numerics/Vector2Tests.cs index 3fc09e2..3d13d40 100644 --- a/X10D.Unity.Tests/Assets/Tests/Numerics/Vector2Tests.cs +++ b/X10D.Unity.Tests/Assets/Tests/Numerics/Vector2Tests.cs @@ -10,6 +10,18 @@ namespace X10D.Unity.Tests.Numerics { public class Vector2Tests { + [UnityTest] + public IEnumerator Deconstruct_ShouldReturnCorrectValues() + { + var vector = new Vector2(1, 2); + (float x, float y) = vector; + + Assert.AreEqual(1, x); + Assert.AreEqual(2, y); + + yield break; + } + [UnityTest] public IEnumerator ToSystemVector_ShouldReturnVector_WithEqualComponents() { diff --git a/X10D.Unity.Tests/Assets/Tests/Numerics/Vector3Tests.cs b/X10D.Unity.Tests/Assets/Tests/Numerics/Vector3Tests.cs index f14c7e3..8eaf0c0 100644 --- a/X10D.Unity.Tests/Assets/Tests/Numerics/Vector3Tests.cs +++ b/X10D.Unity.Tests/Assets/Tests/Numerics/Vector3Tests.cs @@ -10,6 +10,19 @@ namespace X10D.Unity.Tests.Numerics { public class Vector3Tests { + [UnityTest] + public IEnumerator Deconstruct_ShouldReturnCorrectValues() + { + var vector = new Vector3(1, 2, 3); + (float x, float y, float z) = vector; + + Assert.AreEqual(1, x); + Assert.AreEqual(2, y); + Assert.AreEqual(3, z); + + yield break; + } + [UnityTest] public IEnumerator ToSystemVector_ShouldReturnVector_WithEqualComponents() { diff --git a/X10D.Unity.Tests/Assets/Tests/Numerics/Vector4Tests.cs b/X10D.Unity.Tests/Assets/Tests/Numerics/Vector4Tests.cs index d400512..886420d 100644 --- a/X10D.Unity.Tests/Assets/Tests/Numerics/Vector4Tests.cs +++ b/X10D.Unity.Tests/Assets/Tests/Numerics/Vector4Tests.cs @@ -10,6 +10,20 @@ namespace X10D.Unity.Tests.Numerics { public class Vector4Tests { + [UnityTest] + public IEnumerator Deconstruct_ShouldReturnCorrectValues() + { + var vector = new Vector4(1, 2, 3, 4); + (float x, float y, float z, float w) = vector; + + Assert.AreEqual(1, x); + Assert.AreEqual(2, y); + Assert.AreEqual(3, z); + Assert.AreEqual(4, w); + + yield break; + } + [UnityTest] public IEnumerator ToSystemVector_ShouldReturnVector_WithEqualComponents() { diff --git a/X10D.Unity/src/Numerics/Vector2Extensions.cs b/X10D.Unity/src/Numerics/Vector2Extensions.cs index 32ff372..83afaf6 100644 --- a/X10D.Unity/src/Numerics/Vector2Extensions.cs +++ b/X10D.Unity/src/Numerics/Vector2Extensions.cs @@ -9,6 +9,18 @@ namespace X10D.Unity.Numerics; /// public static class Vector2Extensions { + /// + /// Deconstructs the current into its components. + /// + /// The vector to deconstruct. + /// The X component value. + /// The Y component value. + public static void Deconstruct(this Vector2 vector, out float x, out float y) + { + x = vector.x; + y = vector.y; + } + /// /// Converts the current vector to a . /// diff --git a/X10D.Unity/src/Numerics/Vector3Extensions.cs b/X10D.Unity/src/Numerics/Vector3Extensions.cs index 1b725ce..2de1804 100644 --- a/X10D.Unity/src/Numerics/Vector3Extensions.cs +++ b/X10D.Unity/src/Numerics/Vector3Extensions.cs @@ -9,6 +9,20 @@ namespace X10D.Unity.Numerics; /// public static class Vector3Extensions { + /// + /// Deconstructs the current into its components. + /// + /// The vector to deconstruct. + /// The X component value. + /// The Y component value. + /// The Z component value. + public static void Deconstruct(this Vector3 vector, out float x, out float y, out float z) + { + x = vector.x; + y = vector.y; + z = vector.z; + } + /// /// Converts the current vector to a . /// diff --git a/X10D.Unity/src/Numerics/Vector4Extensions.cs b/X10D.Unity/src/Numerics/Vector4Extensions.cs index ca2587f..2ccef16 100644 --- a/X10D.Unity/src/Numerics/Vector4Extensions.cs +++ b/X10D.Unity/src/Numerics/Vector4Extensions.cs @@ -9,6 +9,22 @@ namespace X10D.Unity.Numerics; /// public static class Vector4Extensions { + /// + /// Deconstructs the current into its components. + /// + /// The vector to deconstruct. + /// The X component value. + /// The Y component value. + /// The Z component value. + /// The W component value. + public static void Deconstruct(this Vector4 vector, out float x, out float y, out float z, out float w) + { + x = vector.x; + y = vector.y; + z = vector.z; + w = vector.w; + } + /// /// Converts the current vector to a . /// diff --git a/X10D/src/Numerics/Vector2Extensions.cs b/X10D/src/Numerics/Vector2Extensions.cs index 8831e2c..eb032eb 100644 --- a/X10D/src/Numerics/Vector2Extensions.cs +++ b/X10D/src/Numerics/Vector2Extensions.cs @@ -9,6 +9,18 @@ namespace X10D.Numerics; /// public static class Vector2Extensions { + /// + /// Deconstructs the current into its components. + /// + /// The vector to deconstruct. + /// The X component value. + /// The Y component value. + public static void Deconstruct(this Vector2 vector, out float x, out float y) + { + x = vector.X; + y = vector.Y; + } + /// /// Returns a vector whose Y component is the same as the specified vector, and whose X component is a new value. /// diff --git a/X10D/src/Numerics/Vector3Extensions.cs b/X10D/src/Numerics/Vector3Extensions.cs index 0f906a9..78a87e8 100644 --- a/X10D/src/Numerics/Vector3Extensions.cs +++ b/X10D/src/Numerics/Vector3Extensions.cs @@ -9,6 +9,20 @@ namespace X10D.Numerics; /// public static class Vector3Extensions { + /// + /// Deconstructs the current into its components. + /// + /// The vector to deconstruct. + /// The X component value. + /// The Y component value. + /// The Z component value. + public static void Deconstruct(this Vector3 vector, out float x, out float y, out float z) + { + x = vector.X; + y = vector.Y; + z = vector.Z; + } + /// /// Returns a vector whose Y and Z components are the same as the specified vector, and whose X component is a new value. /// diff --git a/X10D/src/Numerics/Vector4Extensions.cs b/X10D/src/Numerics/Vector4Extensions.cs index 20390bd..7ab1085 100644 --- a/X10D/src/Numerics/Vector4Extensions.cs +++ b/X10D/src/Numerics/Vector4Extensions.cs @@ -9,6 +9,22 @@ namespace X10D.Numerics; /// public static class Vector4Extensions { + /// + /// Deconstructs the current into its components. + /// + /// The vector to deconstruct. + /// The X component value. + /// The Y component value. + /// The Z component value. + /// The W component value. + public static void Deconstruct(this Vector4 vector, out float x, out float y, out float z, out float w) + { + x = vector.X; + y = vector.Y; + z = vector.Z; + w = vector.W; + } + /// /// Returns a vector whose Y, Z, and W components are the same as the specified vector, and whose X component is a new /// value.