Fix issues with the core cs types.

This commit is contained in:
Relintai 2023-06-01 14:30:06 +02:00
parent 9863e95b02
commit 98a4b63096
8 changed files with 97 additions and 74 deletions

View File

@ -47,10 +47,6 @@ namespace Godot
Row3[3] = 1;
}
public Projection() {
set_identity();
}
public Projection(Vector4 Row0, Vector4 Row1, Vector4 Row2, Vector4 Row3) {
this.Row0 = Row0;
this.Row1 = Row1;

View File

@ -9,21 +9,21 @@ using System.Runtime.InteropServices;
namespace Godot
{
/// <summary>
/// 2D axis-aligned bounding box. Rect2I consists of a position, a size, and
/// 2D axis-aligned bounding box. Rect2i consists of a position, a size, and
/// several utility functions. It is typically used for fast overlap tests.
/// </summary>
[Serializable]
[StructLayout(LayoutKind.Sequential)]
public struct Rect2I : IEquatable<Rect2I>
public struct Rect2i : IEquatable<Rect2i>
{
private Vector2I _position;
private Vector2I _size;
private Vector2i _position;
private Vector2i _size;
/// <summary>
/// Beginning corner. Typically has values lower than <see cref="End"/>.
/// </summary>
/// <value>Directly uses a private field.</value>
public Vector2I Position
public Vector2i Position
{
get { return _position; }
set { _position = value; }
@ -34,58 +34,58 @@ namespace Godot
/// If the size is negative, you can use <see cref="Abs"/> to fix it.
/// </summary>
/// <value>Directly uses a private field.</value>
public Vector2I Size
public Vector2i Size
{
get { return _size; }
set { _size = value; }
}
/// <summary>
/// Constructs a <see cref="Rect2I"/> from a position and size.
/// Constructs a <see cref="Rect2i"/> from a position and size.
/// </summary>
/// <param name="position">The position.</param>
/// <param name="size">The size.</param>
public Rect2I(Vector2I position, Vector2I size)
public Rect2i(Vector2i position, Vector2i size)
{
_position = position;
_size = size;
}
/// <summary>
/// Constructs a <see cref="Rect2I"/> from a position, width, and height.
/// Constructs a <see cref="Rect2i"/> from a position, width, and height.
/// </summary>
/// <param name="position">The position.</param>
/// <param name="width">The width.</param>
/// <param name="height">The height.</param>
public Rect2I(Vector2I position, real_t width, real_t height)
public Rect2i(Vector2i position, real_t width, real_t height)
{
_position = position;
_size = new Vector2I(width, height);
_size = new Vector2i(width, height);
}
/// <summary>
/// Constructs a <see cref="Rect2I"/> from x, y, and size.
/// Constructs a <see cref="Rect2i"/> from x, y, and size.
/// </summary>
/// <param name="x">The position's X coordinate.</param>
/// <param name="y">The position's Y coordinate.</param>
/// <param name="size">The size.</param>
public Rect2I(real_t x, real_t y, Vector2I size)
public Rect2i(real_t x, real_t y, Vector2i size)
{
_position = new Vector2I(x, y);
_position = new Vector2i(x, y);
_size = size;
}
/// <summary>
/// Constructs a <see cref="Rect2I"/> from x, y, width, and height.
/// Constructs a <see cref="Rect2i"/> from x, y, width, and height.
/// </summary>
/// <param name="x">The position's X coordinate.</param>
/// <param name="y">The position's Y coordinate.</param>
/// <param name="width">The width.</param>
/// <param name="height">The height.</param>
public Rect2I(real_t x, real_t y, real_t width, real_t height)
public Rect2i(real_t x, real_t y, real_t width, real_t height)
{
_position = new Vector2I(x, y);
_size = new Vector2I(width, height);
_position = new Vector2i(x, y);
_size = new Vector2i(width, height);
}
/// <summary>
@ -95,9 +95,9 @@ namespace Godot
/// <returns>Whether or not the rect and the other object are exactly equal.</returns>
public override bool Equals(object obj)
{
if (obj is Rect2I)
if (obj is Rect2i)
{
return Equals((Rect2I)obj);
return Equals((Rect2i)obj);
}
return false;
@ -108,13 +108,13 @@ namespace Godot
/// </summary>
/// <param name="other">The other rect to compare.</param>
/// <returns>Whether or not the rects are exactly equal.</returns>
public bool Equals(Rect2I other)
public bool Equals(Rect2i other)
{
return _position.Equals(other._position) && _size.Equals(other._size);
}
/// <summary>
/// Serves as the hash function for <see cref="Rect2I"/>.
/// Serves as the hash function for <see cref="Rect2i"/>.
/// </summary>
/// <returns>A hash code for this rect.</returns>
public override int GetHashCode()
@ -123,7 +123,7 @@ namespace Godot
}
/// <summary>
/// Converts this <see cref="Rect2I"/> to a string.
/// Converts this <see cref="Rect2i"/> to a string.
/// </summary>
/// <returns>A string representation of this rect.</returns>
public override string ToString()
@ -136,7 +136,7 @@ namespace Godot
}
/// <summary>
/// Converts this <see cref="Rect2I"/> to a string with the given <paramref name="format"/>.
/// Converts this <see cref="Rect2i"/> to a string with the given <paramref name="format"/>.
/// </summary>
/// <returns>A string representation of this rect.</returns>
public string ToString(string format)

View File

@ -3,7 +3,7 @@ using System.Runtime.CompilerServices;
namespace Godot
{
public sealed partial class StringName : IDisposable
public sealed partial class StringName : IDisposable, IEquatable<StringName>
{
private bool _disposed = false;
@ -94,11 +94,31 @@ namespace Godot
return godot_icall_StringName_operator_String(StringName.GetPtr(left), StringName.GetPtr(right));
}
public static bool operator !=(Rect2 left, Rect2 right)
public static bool operator !=(StringName left, StringName right)
{
return !left.Equals(right);
}
public override bool Equals(object obj)
{
if (obj is StringName)
{
return Equals((StringName)obj);
}
return false;
}
public bool Equals(StringName other)
{
return godot_icall_StringName_operator_String(StringName.GetPtr(left), StringName.GetPtr(right));
}
public override int GetHashCode()
{
return (int)ptr;
}
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern IntPtr godot_icall_StringName_Ctor();

View File

@ -1,7 +1,7 @@
#if REAL_T_IS_DOUBLE
using int = System.Double;
using real_t = System.Double;
#else
using int = System.Single;
using real_t = System.Single;
#endif
using System;
using System.Runtime.InteropServices;
@ -13,7 +13,7 @@ namespace Godot
/// </summary>
[Serializable]
[StructLayout(LayoutKind.Sequential)]
public struct Vector2I : IEquatable<Vector2I>
public struct Vector2i : IEquatable<Vector2i>
{
/// <summary>
/// The vector's X component. Also accessible by using the index position <c>[0]</c>.
@ -27,21 +27,21 @@ namespace Godot
/// <summary>
/// Constructs a new <see cref="Vector2I"/> with the given components.
/// Constructs a new <see cref="Vector2i"/> with the given components.
/// </summary>
/// <param name="x">The vector's X component.</param>
/// <param name="y">The vector's Y component.</param>
public Vector2I(int x, int y)
public Vector2i(int x, int y)
{
this.x = x;
this.y = y;
}
/// <summary>
/// Constructs a new <see cref="Vector2I"/> from an existing <see cref="Vector2I"/>.
/// Constructs a new <see cref="Vector2i"/> from an existing <see cref="Vector2i"/>.
/// </summary>
/// <param name="v">The existing <see cref="Vector2I"/>.</param>
public Vector2I(Vector2I v)
/// <param name="v">The existing <see cref="Vector2i"/>.</param>
public Vector2i(Vector2i v)
{
x = v.x;
y = v.y;
@ -57,9 +57,9 @@ namespace Godot
/// <returns>Whether or not the vector and the object are equal.</returns>
public override bool Equals(object obj)
{
if (obj is Vector2I)
if (obj is Vector2i)
{
return Equals((Vector2I)obj);
return Equals((Vector2i)obj);
}
return false;
}
@ -71,13 +71,13 @@ namespace Godot
/// </summary>
/// <param name="other">The other vector.</param>
/// <returns>Whether or not the vectors are exactly equal.</returns>
public bool Equals(Vector2I other)
public bool Equals(Vector2i other)
{
return x == other.x && y == other.y;
}
/// <summary>
/// Serves as the hash function for <see cref="Vector2I"/>.
/// Serves as the hash function for <see cref="Vector2i"/>.
/// </summary>
/// <returns>A hash code for this vector.</returns>
public override int GetHashCode()
@ -86,7 +86,7 @@ namespace Godot
}
/// <summary>
/// Converts this <see cref="Vector2I"/> to a string.
/// Converts this <see cref="Vector2i"/> to a string.
/// </summary>
/// <returns>A string representation of this vector.</returns>
public override string ToString()
@ -95,7 +95,7 @@ namespace Godot
}
/// <summary>
/// Converts this <see cref="Vector2I"/> to a string with the given <paramref name="format"/>.
/// Converts this <see cref="Vector2i"/> to a string with the given <paramref name="format"/>.
/// </summary>
/// <returns>A string representation of this vector.</returns>
public string ToString(string format)

View File

@ -1,7 +1,7 @@
#if REAL_T_IS_DOUBLE
using int = System.Double;
using real_t = System.Double;
#else
using int = System.Single;
using real_t = System.Single;
#endif
using System;
using System.Runtime.InteropServices;
@ -13,7 +13,7 @@ namespace Godot
/// </summary>
[Serializable]
[StructLayout(LayoutKind.Sequential)]
public struct Vector3I : IEquatable<Vector3I>
public struct Vector3i : IEquatable<Vector3i>
{
/// <summary>
/// The vector's X component. Also accessible by using the index position <c>[0]</c>.
@ -31,12 +31,12 @@ namespace Godot
public int z;
/// <summary>
/// Constructs a new <see cref="Vector3I"/> with the given components.
/// Constructs a new <see cref="Vector3i"/> with the given components.
/// </summary>
/// <param name="x">The vector's X component.</param>
/// <param name="y">The vector's Y component.</param>
/// <param name="z">The vector's Z component.</param>
public Vector3I(int x, int y, int z)
public Vector3i(int x, int y, int z)
{
this.x = x;
this.y = y;
@ -44,10 +44,10 @@ namespace Godot
}
/// <summary>
/// Constructs a new <see cref="Vector3I"/> from an existing <see cref="Vector3I"/>.
/// Constructs a new <see cref="Vector3i"/> from an existing <see cref="Vector3i"/>.
/// </summary>
/// <param name="v">The existing <see cref="Vector3I"/>.</param>
public Vector3I(Vector3I v)
/// <param name="v">The existing <see cref="Vector3i"/>.</param>
public Vector3i(Vector3i v)
{
x = v.x;
y = v.y;
@ -64,9 +64,9 @@ namespace Godot
/// <returns>Whether or not the vector and the object are equal.</returns>
public override bool Equals(object obj)
{
if (obj is Vector3I)
if (obj is Vector3i)
{
return Equals((Vector3I)obj);
return Equals((Vector3i)obj);
}
return false;
@ -79,13 +79,13 @@ namespace Godot
/// </summary>
/// <param name="other">The other vector.</param>
/// <returns>Whether or not the vectors are exactly equal.</returns>
public bool Equals(Vector3I other)
public bool Equals(Vector3i other)
{
return x == other.x && y == other.y && z == other.z;
}
/// <summary>
/// Serves as the hash function for <see cref="Vector3I"/>.
/// Serves as the hash function for <see cref="Vector3i"/>.
/// </summary>
/// <returns>A hash code for this vector.</returns>
public override int GetHashCode()
@ -94,7 +94,7 @@ namespace Godot
}
/// <summary>
/// Converts this <see cref="Vector3I"/> to a string.
/// Converts this <see cref="Vector3i"/> to a string.
/// </summary>
/// <returns>A string representation of this vector.</returns>
public override string ToString()
@ -103,7 +103,7 @@ namespace Godot
}
/// <summary>
/// Converts this <see cref="Vector3I"/> to a string with the given <paramref name="format"/>.
/// Converts this <see cref="Vector3i"/> to a string with the given <paramref name="format"/>.
/// </summary>
/// <returns>A string representation of this vector.</returns>
public string ToString(string format)

View File

@ -112,7 +112,7 @@ namespace Godot
/// <returns>A string representation of this vector.</returns>
public string ToString(string format)
{
return $"({x.ToString(format)}, {y.ToString(format)}, {z.ToString(format), {w.ToString(format)})";
return $"({x.ToString(format)}, {y.ToString(format)}, {z.ToString(format)}, {w.ToString(format)})";
}
}
}

View File

@ -1,7 +1,7 @@
#if REAL_T_IS_DOUBLE
using int = System.Double;
using real_t = System.Double;
#else
using int = System.Single;
using real_t = System.Single;
#endif
using System;
using System.Runtime.InteropServices;
@ -13,7 +13,7 @@ namespace Godot
/// </summary>
[Serializable]
[StructLayout(LayoutKind.Sequential)]
public struct Vector4I : IEquatable<Vector4I>
public struct Vector4i : IEquatable<Vector4i>
{
/// <summary>
/// The vector's X component. Also accessible by using the index position <c>[0]</c>.
@ -33,12 +33,12 @@ namespace Godot
public int w;
/// <summary>
/// Constructs a new <see cref="Vector4I"/> with the given components.
/// Constructs a new <see cref="Vector4i"/> with the given components.
/// </summary>
/// <param name="x">The vector's X component.</param>
/// <param name="y">The vector's Y component.</param>
/// <param name="z">The vector's Z component.</param>
public Vector4I(int x, int y, int z, int w)
public Vector4i(int x, int y, int z, int w)
{
this.x = x;
this.y = y;
@ -47,10 +47,10 @@ namespace Godot
}
/// <summary>
/// Constructs a new <see cref="Vector4I"/> from an existing <see cref="Vector4I"/>.
/// Constructs a new <see cref="Vector4i"/> from an existing <see cref="Vector4i"/>.
/// </summary>
/// <param name="v">The existing <see cref="Vector4I"/>.</param>
public Vector4I(Vector4I v)
/// <param name="v">The existing <see cref="Vector4i"/>.</param>
public Vector4i(Vector4i v)
{
x = v.x;
y = v.y;
@ -68,9 +68,9 @@ namespace Godot
/// <returns>Whether or not the vector and the object are equal.</returns>
public override bool Equals(object obj)
{
if (obj is Vector4I)
if (obj is Vector4i)
{
return Equals((Vector4I)obj);
return Equals((Vector4i)obj);
}
return false;
@ -83,13 +83,13 @@ namespace Godot
/// </summary>
/// <param name="other">The other vector.</param>
/// <returns>Whether or not the vectors are exactly equal.</returns>
public bool Equals(Vector4I other)
public bool Equals(Vector4i other)
{
return x == other.x && y == other.y && z == other.z && w == other.w;
}
/// <summary>
/// Serves as the hash function for <see cref="Vector4I"/>.
/// Serves as the hash function for <see cref="Vector4i"/>.
/// </summary>
/// <returns>A hash code for this vector.</returns>
public override int GetHashCode()
@ -98,7 +98,7 @@ namespace Godot
}
/// <summary>
/// Converts this <see cref="Vector4I"/> to a string.
/// Converts this <see cref="Vector4i"/> to a string.
/// </summary>
/// <returns>A string representation of this vector.</returns>
public override string ToString()
@ -107,12 +107,12 @@ namespace Godot
}
/// <summary>
/// Converts this <see cref="Vector4I"/> to a string with the given <paramref name="format"/>.
/// Converts this <see cref="Vector4i"/> to a string with the given <paramref name="format"/>.
/// </summary>
/// <returns>A string representation of this vector.</returns>
public string ToString(string format)
{
return $"({x.ToString(format)}, {y.ToString(format)}, {z.ToString(format), {w.ToString(format)})";
return $"({x.ToString(format)}, {y.ToString(format)}, {z.ToString(format)}, {w.ToString(format)})";
}
}
}

View File

@ -42,18 +42,25 @@
<Compile Include="Core\Mathf.cs" />
<Compile Include="Core\MathfEx.cs" />
<Compile Include="Core\NodePath.cs" />
<Compile Include="Core\StringName.cs" />
<Compile Include="Core\Object.base.cs" />
<Compile Include="Core\Plane.cs" />
<Compile Include="Core\Quaternion.cs" />
<Compile Include="Core\Rect2.cs" />
<Compile Include="Core\Rect2i.cs" />
<Compile Include="Core\RID.cs" />
<Compile Include="Core\SignalAwaiter.cs" />
<Compile Include="Core\StringExtensions.cs" />
<Compile Include="Core\Transform.cs" />
<Compile Include="Core\Transform2D.cs" />
<Compile Include="Core\Projection.cs" />
<Compile Include="Core\UnhandledExceptionArgs.cs" />
<Compile Include="Core\Vector2.cs" />
<Compile Include="Core\Vector2i.cs" />
<Compile Include="Core\Vector3.cs" />
<Compile Include="Core\Vector3i.cs" />
<Compile Include="Core\Vector4.cs" />
<Compile Include="Core\Vector4i.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<!--