Browse Source

Merge pull request #58827 from XPhyro/cs-deconstruct

Implement `Deconstruct` methods for C# vectors
Rémi Verschelde 3 years ago
parent
commit
47f1c4f900

+ 9 - 0
modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2.cs

@@ -81,6 +81,15 @@ namespace Godot
             }
         }
 
+        /// <summary>
+        /// Helper method for deconstruction into a tuple.
+        /// </summary>
+        public void Deconstruct(out real_t x, out real_t y)
+        {
+            x = this.x;
+            y = this.y;
+        }
+
         internal void Normalize()
         {
             real_t lengthsq = LengthSquared();

+ 9 - 0
modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2i.cs

@@ -81,6 +81,15 @@ namespace Godot
             }
         }
 
+        /// <summary>
+        /// Helper method for deconstruction into a tuple.
+        /// </summary>
+        public void Deconstruct(out int x, out int y)
+        {
+            x = this.x;
+            y = this.y;
+        }
+
         /// <summary>
         /// Returns a new vector with all components in absolute values (i.e. positive).
         /// </summary>

+ 10 - 0
modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3.cs

@@ -96,6 +96,16 @@ namespace Godot
             }
         }
 
+        /// <summary>
+        /// Helper method for deconstruction into a tuple.
+        /// </summary>
+        public void Deconstruct(out real_t x, out real_t y, out real_t z)
+        {
+            x = this.x;
+            y = this.y;
+            z = this.z;
+        }
+
         internal void Normalize()
         {
             real_t lengthsq = LengthSquared();

+ 10 - 0
modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3i.cs

@@ -96,6 +96,16 @@ namespace Godot
             }
         }
 
+        /// <summary>
+        /// Helper method for deconstruction into a tuple.
+        /// </summary>
+        public void Deconstruct(out int x, out int y, out int z)
+        {
+            x = this.x;
+            y = this.y;
+            z = this.z;
+        }
+
         /// <summary>
         /// Returns a new vector with all components in absolute values (i.e. positive).
         /// </summary>