From 98a4b63096a92b29a1ea0b60110de1543d9dbd2b Mon Sep 17 00:00:00 2001 From: Relintai Date: Thu, 1 Jun 2023 14:30:06 +0200 Subject: [PATCH] Fix issues with the core cs types. --- glue/GodotSharp/GodotSharp/Core/Projection.cs | 4 -- .../GodotSharp/Core/{Rect2I.cs => Rect2i.cs} | 48 +++++++++---------- glue/GodotSharp/GodotSharp/Core/StringName.cs | 24 +++++++++- .../Core/{Vector2I.cs => Vector2i.cs} | 28 +++++------ .../Core/{Vector3I.cs => Vector3i.cs} | 28 +++++------ glue/GodotSharp/GodotSharp/Core/Vector4.cs | 2 +- .../Core/{Vector4I.cs => Vector4i.cs} | 30 ++++++------ glue/GodotSharp/GodotSharp/GodotSharp.csproj | 7 +++ 8 files changed, 97 insertions(+), 74 deletions(-) rename glue/GodotSharp/GodotSharp/Core/{Rect2I.cs => Rect2i.cs} (76%) rename glue/GodotSharp/GodotSharp/Core/{Vector2I.cs => Vector2i.cs} (79%) rename glue/GodotSharp/GodotSharp/Core/{Vector3I.cs => Vector3i.cs} (81%) rename glue/GodotSharp/GodotSharp/Core/{Vector4I.cs => Vector4i.cs} (80%) diff --git a/glue/GodotSharp/GodotSharp/Core/Projection.cs b/glue/GodotSharp/GodotSharp/Core/Projection.cs index eb6ec3b..3fe9dd4 100644 --- a/glue/GodotSharp/GodotSharp/Core/Projection.cs +++ b/glue/GodotSharp/GodotSharp/Core/Projection.cs @@ -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; diff --git a/glue/GodotSharp/GodotSharp/Core/Rect2I.cs b/glue/GodotSharp/GodotSharp/Core/Rect2i.cs similarity index 76% rename from glue/GodotSharp/GodotSharp/Core/Rect2I.cs rename to glue/GodotSharp/GodotSharp/Core/Rect2i.cs index 48af36a..134109e 100644 --- a/glue/GodotSharp/GodotSharp/Core/Rect2I.cs +++ b/glue/GodotSharp/GodotSharp/Core/Rect2i.cs @@ -9,21 +9,21 @@ using System.Runtime.InteropServices; namespace Godot { /// - /// 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. /// [Serializable] [StructLayout(LayoutKind.Sequential)] - public struct Rect2I : IEquatable + public struct Rect2i : IEquatable { - private Vector2I _position; - private Vector2I _size; + private Vector2i _position; + private Vector2i _size; /// /// Beginning corner. Typically has values lower than . /// /// Directly uses a private field. - 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 to fix it. /// /// Directly uses a private field. - public Vector2I Size + public Vector2i Size { get { return _size; } set { _size = value; } } /// - /// Constructs a from a position and size. + /// Constructs a from a position and size. /// /// The position. /// The size. - public Rect2I(Vector2I position, Vector2I size) + public Rect2i(Vector2i position, Vector2i size) { _position = position; _size = size; } /// - /// Constructs a from a position, width, and height. + /// Constructs a from a position, width, and height. /// /// The position. /// The width. /// The height. - 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); } /// - /// Constructs a from x, y, and size. + /// Constructs a from x, y, and size. /// /// The position's X coordinate. /// The position's Y coordinate. /// The size. - 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; } /// - /// Constructs a from x, y, width, and height. + /// Constructs a from x, y, width, and height. /// /// The position's X coordinate. /// The position's Y coordinate. /// The width. /// The height. - 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); } /// @@ -95,9 +95,9 @@ namespace Godot /// Whether or not the rect and the other object are exactly equal. 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 /// /// The other rect to compare. /// Whether or not the rects are exactly equal. - public bool Equals(Rect2I other) + public bool Equals(Rect2i other) { return _position.Equals(other._position) && _size.Equals(other._size); } /// - /// Serves as the hash function for . + /// Serves as the hash function for . /// /// A hash code for this rect. public override int GetHashCode() @@ -123,7 +123,7 @@ namespace Godot } /// - /// Converts this to a string. + /// Converts this to a string. /// /// A string representation of this rect. public override string ToString() @@ -136,7 +136,7 @@ namespace Godot } /// - /// Converts this to a string with the given . + /// Converts this to a string with the given . /// /// A string representation of this rect. public string ToString(string format) diff --git a/glue/GodotSharp/GodotSharp/Core/StringName.cs b/glue/GodotSharp/GodotSharp/Core/StringName.cs index 4a19bf0..7154ad0 100644 --- a/glue/GodotSharp/GodotSharp/Core/StringName.cs +++ b/glue/GodotSharp/GodotSharp/Core/StringName.cs @@ -3,7 +3,7 @@ using System.Runtime.CompilerServices; namespace Godot { - public sealed partial class StringName : IDisposable + public sealed partial class StringName : IDisposable, IEquatable { 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(); diff --git a/glue/GodotSharp/GodotSharp/Core/Vector2I.cs b/glue/GodotSharp/GodotSharp/Core/Vector2i.cs similarity index 79% rename from glue/GodotSharp/GodotSharp/Core/Vector2I.cs rename to glue/GodotSharp/GodotSharp/Core/Vector2i.cs index 417a7d6..4d7eedc 100644 --- a/glue/GodotSharp/GodotSharp/Core/Vector2I.cs +++ b/glue/GodotSharp/GodotSharp/Core/Vector2i.cs @@ -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 /// [Serializable] [StructLayout(LayoutKind.Sequential)] - public struct Vector2I : IEquatable + public struct Vector2i : IEquatable { /// /// The vector's X component. Also accessible by using the index position [0]. @@ -27,21 +27,21 @@ namespace Godot /// - /// Constructs a new with the given components. + /// Constructs a new with the given components. /// /// The vector's X component. /// The vector's Y component. - public Vector2I(int x, int y) + public Vector2i(int x, int y) { this.x = x; this.y = y; } /// - /// Constructs a new from an existing . + /// Constructs a new from an existing . /// - /// The existing . - public Vector2I(Vector2I v) + /// The existing . + public Vector2i(Vector2i v) { x = v.x; y = v.y; @@ -57,9 +57,9 @@ namespace Godot /// Whether or not the vector and the object are equal. 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 /// /// The other vector. /// Whether or not the vectors are exactly equal. - public bool Equals(Vector2I other) + public bool Equals(Vector2i other) { return x == other.x && y == other.y; } /// - /// Serves as the hash function for . + /// Serves as the hash function for . /// /// A hash code for this vector. public override int GetHashCode() @@ -86,7 +86,7 @@ namespace Godot } /// - /// Converts this to a string. + /// Converts this to a string. /// /// A string representation of this vector. public override string ToString() @@ -95,7 +95,7 @@ namespace Godot } /// - /// Converts this to a string with the given . + /// Converts this to a string with the given . /// /// A string representation of this vector. public string ToString(string format) diff --git a/glue/GodotSharp/GodotSharp/Core/Vector3I.cs b/glue/GodotSharp/GodotSharp/Core/Vector3i.cs similarity index 81% rename from glue/GodotSharp/GodotSharp/Core/Vector3I.cs rename to glue/GodotSharp/GodotSharp/Core/Vector3i.cs index 513ab19..f820201 100644 --- a/glue/GodotSharp/GodotSharp/Core/Vector3I.cs +++ b/glue/GodotSharp/GodotSharp/Core/Vector3i.cs @@ -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 /// [Serializable] [StructLayout(LayoutKind.Sequential)] - public struct Vector3I : IEquatable + public struct Vector3i : IEquatable { /// /// The vector's X component. Also accessible by using the index position [0]. @@ -31,12 +31,12 @@ namespace Godot public int z; /// - /// Constructs a new with the given components. + /// Constructs a new with the given components. /// /// The vector's X component. /// The vector's Y component. /// The vector's Z component. - 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 } /// - /// Constructs a new from an existing . + /// Constructs a new from an existing . /// - /// The existing . - public Vector3I(Vector3I v) + /// The existing . + public Vector3i(Vector3i v) { x = v.x; y = v.y; @@ -64,9 +64,9 @@ namespace Godot /// Whether or not the vector and the object are equal. 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 /// /// The other vector. /// Whether or not the vectors are exactly equal. - public bool Equals(Vector3I other) + public bool Equals(Vector3i other) { return x == other.x && y == other.y && z == other.z; } /// - /// Serves as the hash function for . + /// Serves as the hash function for . /// /// A hash code for this vector. public override int GetHashCode() @@ -94,7 +94,7 @@ namespace Godot } /// - /// Converts this to a string. + /// Converts this to a string. /// /// A string representation of this vector. public override string ToString() @@ -103,7 +103,7 @@ namespace Godot } /// - /// Converts this to a string with the given . + /// Converts this to a string with the given . /// /// A string representation of this vector. public string ToString(string format) diff --git a/glue/GodotSharp/GodotSharp/Core/Vector4.cs b/glue/GodotSharp/GodotSharp/Core/Vector4.cs index c124d06..6fe054b 100644 --- a/glue/GodotSharp/GodotSharp/Core/Vector4.cs +++ b/glue/GodotSharp/GodotSharp/Core/Vector4.cs @@ -112,7 +112,7 @@ namespace Godot /// A string representation of this vector. 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)})"; } } } diff --git a/glue/GodotSharp/GodotSharp/Core/Vector4I.cs b/glue/GodotSharp/GodotSharp/Core/Vector4i.cs similarity index 80% rename from glue/GodotSharp/GodotSharp/Core/Vector4I.cs rename to glue/GodotSharp/GodotSharp/Core/Vector4i.cs index 7117224..3b269d5 100644 --- a/glue/GodotSharp/GodotSharp/Core/Vector4I.cs +++ b/glue/GodotSharp/GodotSharp/Core/Vector4i.cs @@ -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 /// [Serializable] [StructLayout(LayoutKind.Sequential)] - public struct Vector4I : IEquatable + public struct Vector4i : IEquatable { /// /// The vector's X component. Also accessible by using the index position [0]. @@ -33,12 +33,12 @@ namespace Godot public int w; /// - /// Constructs a new with the given components. + /// Constructs a new with the given components. /// /// The vector's X component. /// The vector's Y component. /// The vector's Z component. - 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 } /// - /// Constructs a new from an existing . + /// Constructs a new from an existing . /// - /// The existing . - public Vector4I(Vector4I v) + /// The existing . + public Vector4i(Vector4i v) { x = v.x; y = v.y; @@ -68,9 +68,9 @@ namespace Godot /// Whether or not the vector and the object are equal. 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 /// /// The other vector. /// Whether or not the vectors are exactly equal. - public bool Equals(Vector4I other) + public bool Equals(Vector4i other) { return x == other.x && y == other.y && z == other.z && w == other.w; } /// - /// Serves as the hash function for . + /// Serves as the hash function for . /// /// A hash code for this vector. public override int GetHashCode() @@ -98,7 +98,7 @@ namespace Godot } /// - /// Converts this to a string. + /// Converts this to a string. /// /// A string representation of this vector. public override string ToString() @@ -107,12 +107,12 @@ namespace Godot } /// - /// Converts this to a string with the given . + /// Converts this to a string with the given . /// /// A string representation of this vector. 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)})"; } } } diff --git a/glue/GodotSharp/GodotSharp/GodotSharp.csproj b/glue/GodotSharp/GodotSharp/GodotSharp.csproj index 868b281..f53f49a 100644 --- a/glue/GodotSharp/GodotSharp/GodotSharp.csproj +++ b/glue/GodotSharp/GodotSharp/GodotSharp.csproj @@ -42,18 +42,25 @@ + + + + + + +