Implement Deconstruct methods for C# vectors

See https://docs.microsoft.com/en-us/dotnet/csharp/fundamentals/functional/deconstruct#user-defined-types
This commit is contained in:
Berke Kocaoğlu 2022-03-06 11:16:30 +03:00
parent b70a83a2b9
commit 20d72e462b
No known key found for this signature in database
GPG key ID: 52698453A8FF33A7
4 changed files with 38 additions and 0 deletions

View file

@ -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();

View file

@ -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>

View file

@ -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();

View file

@ -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>