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:
parent
b70a83a2b9
commit
20d72e462b
4 changed files with 38 additions and 0 deletions
|
@ -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();
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in a new issue