mirror of
https://github.com/Relintai/mono.git
synced 2024-11-08 10:12:16 +01:00
Added classes for the new variant types.
This commit is contained in:
parent
e680d35108
commit
c2f86d2a07
@ -409,15 +409,17 @@ bool CSharpLanguage::supports_builtin_mode() const {
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
static String variant_type_to_managed_name(const String &p_var_type_name) {
|
||||
if (p_var_type_name.empty())
|
||||
if (p_var_type_name.empty()) {
|
||||
return "object";
|
||||
}
|
||||
|
||||
if (!ClassDB::class_exists(p_var_type_name)) {
|
||||
return p_var_type_name;
|
||||
}
|
||||
|
||||
if (p_var_type_name == Variant::get_type_name(Variant::OBJECT))
|
||||
if (p_var_type_name == Variant::get_type_name(Variant::OBJECT)) {
|
||||
return "Godot.Object";
|
||||
}
|
||||
|
||||
if (p_var_type_name == Variant::get_type_name(Variant::REAL)) {
|
||||
#ifdef REAL_T_IS_DOUBLE
|
||||
@ -427,19 +429,26 @@ static String variant_type_to_managed_name(const String &p_var_type_name) {
|
||||
#endif
|
||||
}
|
||||
|
||||
if (p_var_type_name == Variant::get_type_name(Variant::STRING))
|
||||
if (p_var_type_name == Variant::get_type_name(Variant::STRING)) {
|
||||
return "string"; // I prefer this one >:[
|
||||
}
|
||||
|
||||
if (p_var_type_name == Variant::get_type_name(Variant::DICTIONARY))
|
||||
if (p_var_type_name == Variant::get_type_name(Variant::DICTIONARY)) {
|
||||
return "Collections.Dictionary";
|
||||
}
|
||||
|
||||
if (p_var_type_name == Variant::get_type_name(Variant::ARRAY))
|
||||
if (p_var_type_name == Variant::get_type_name(Variant::ARRAY)) {
|
||||
return "Collections.Array";
|
||||
}
|
||||
|
||||
if (p_var_type_name == Variant::get_type_name(Variant::POOL_BYTE_ARRAY))
|
||||
if (p_var_type_name == Variant::get_type_name(Variant::POOL_BYTE_ARRAY)) {
|
||||
return "byte[]";
|
||||
if (p_var_type_name == Variant::get_type_name(Variant::POOL_INT_ARRAY))
|
||||
}
|
||||
|
||||
if (p_var_type_name == Variant::get_type_name(Variant::POOL_INT_ARRAY)) {
|
||||
return "int[]";
|
||||
}
|
||||
|
||||
if (p_var_type_name == Variant::get_type_name(Variant::POOL_REAL_ARRAY)) {
|
||||
#ifdef REAL_T_IS_DOUBLE
|
||||
return "double[]";
|
||||
@ -447,14 +456,21 @@ static String variant_type_to_managed_name(const String &p_var_type_name) {
|
||||
return "float[]";
|
||||
#endif
|
||||
}
|
||||
if (p_var_type_name == Variant::get_type_name(Variant::POOL_STRING_ARRAY))
|
||||
if (p_var_type_name == Variant::get_type_name(Variant::POOL_STRING_ARRAY)) {
|
||||
return "string[]";
|
||||
if (p_var_type_name == Variant::get_type_name(Variant::POOL_VECTOR2_ARRAY))
|
||||
}
|
||||
|
||||
if (p_var_type_name == Variant::get_type_name(Variant::POOL_VECTOR2_ARRAY)) {
|
||||
return "Vector2[]";
|
||||
if (p_var_type_name == Variant::get_type_name(Variant::POOL_VECTOR3_ARRAY))
|
||||
}
|
||||
|
||||
if (p_var_type_name == Variant::get_type_name(Variant::POOL_VECTOR3_ARRAY)) {
|
||||
return "Vector3[]";
|
||||
if (p_var_type_name == Variant::get_type_name(Variant::POOL_COLOR_ARRAY))
|
||||
}
|
||||
|
||||
if (p_var_type_name == Variant::get_type_name(Variant::POOL_COLOR_ARRAY)) {
|
||||
return "Color[]";
|
||||
}
|
||||
|
||||
Variant::Type var_types[] = {
|
||||
Variant::BOOL,
|
||||
@ -474,8 +490,9 @@ static String variant_type_to_managed_name(const String &p_var_type_name) {
|
||||
};
|
||||
|
||||
for (unsigned int i = 0; i < sizeof(var_types) / sizeof(Variant::Type); i++) {
|
||||
if (p_var_type_name == Variant::get_type_name(var_types[i]))
|
||||
if (p_var_type_name == Variant::get_type_name(var_types[i])) {
|
||||
return p_var_type_name;
|
||||
}
|
||||
}
|
||||
|
||||
return "object";
|
||||
|
109
glue/GodotSharp/GodotSharp/Core/Projection.cs
Normal file
109
glue/GodotSharp/GodotSharp/Core/Projection.cs
Normal file
@ -0,0 +1,109 @@
|
||||
#if REAL_T_IS_DOUBLE
|
||||
using real_t = System.Double;
|
||||
#else
|
||||
using real_t = System.Single;
|
||||
#endif
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Godot
|
||||
{
|
||||
[Serializable]
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Projection : IEquatable<Projection>
|
||||
{
|
||||
/// <summary>
|
||||
/// Row 0 of the basis matrix. Shows which vectors contribute
|
||||
/// to the X direction. Rows are not very useful for user code,
|
||||
/// but are more efficient for some internal calculations.
|
||||
/// </summary>
|
||||
public Vector4 Row0;
|
||||
|
||||
/// <summary>
|
||||
/// Row 1 of the basis matrix. Shows which vectors contribute
|
||||
/// to the Y direction. Rows are not very useful for user code,
|
||||
/// but are more efficient for some internal calculations.
|
||||
/// </summary>
|
||||
public Vector4 Row1;
|
||||
|
||||
/// <summary>
|
||||
/// Row 2 of the basis matrix. Shows which vectors contribute
|
||||
/// to the Z direction. Rows are not very useful for user code,
|
||||
/// but are more efficient for some internal calculations.
|
||||
/// </summary>
|
||||
public Vector4 Row2;
|
||||
|
||||
|
||||
public Vector4 Row3;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Returns <see langword="true"/> if the <see cref="Projection"/> is
|
||||
/// exactly equal to the given object (<see paramref="obj"/>).
|
||||
/// Note: Due to floating-point precision errors, consider using
|
||||
/// <see cref="IsEqualApprox"/> instead, which is more reliable.
|
||||
/// </summary>
|
||||
/// <param name="obj">The object to compare with.</param>
|
||||
/// <returns>Whether or not the basis matrix and the object are exactly equal.</returns>
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (obj is Projection)
|
||||
{
|
||||
return Equals((Projection)obj);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns <see langword="true"/> if the basis matrices are exactly
|
||||
/// equal. Note: Due to floating-point precision errors, consider using
|
||||
/// <see cref="IsEqualApprox"/> instead, which is more reliable.
|
||||
/// </summary>
|
||||
/// <param name="other">The other basis.</param>
|
||||
/// <returns>Whether or not the basis matrices are exactly equal.</returns>
|
||||
public bool Equals(Projection other)
|
||||
{
|
||||
return Row0.Equals(other.Row0) && Row1.Equals(other.Row1) && Row2.Equals(other.Row2) && Row3.Equals(other.Row2);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serves as the hash function for <see cref="Projection"/>.
|
||||
/// </summary>
|
||||
/// <returns>A hash code for this basis.</returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return Row0.GetHashCode() ^ Row1.GetHashCode() ^ Row2.GetHashCode()^ Row3.GetHashCode();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts this <see cref="Projection"/> to a string.
|
||||
/// </summary>
|
||||
/// <returns>A string representation of this basis.</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return String.Format("({0}, {1}, {2}, {3})", new object[]
|
||||
{
|
||||
Row0.ToString(),
|
||||
Row1.ToString(),
|
||||
Row2.ToString(),
|
||||
Row3.ToString()
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts this <see cref="Projection"/> to a string with the given <paramref name="format"/>.
|
||||
/// </summary>
|
||||
/// <returns>A string representation of this basis.</returns>
|
||||
public string ToString(string format)
|
||||
{
|
||||
return String.Format("({0}, {1}, {2}, {3})", new object[]
|
||||
{
|
||||
Row0.ToString(format),
|
||||
Row1.ToString(format),
|
||||
Row2.ToString(format),
|
||||
Row3.ToString(format)
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
151
glue/GodotSharp/GodotSharp/Core/Rect2I.cs
Normal file
151
glue/GodotSharp/GodotSharp/Core/Rect2I.cs
Normal file
@ -0,0 +1,151 @@
|
||||
#if REAL_T_IS_DOUBLE
|
||||
using real_t = System.Double;
|
||||
#else
|
||||
using real_t = System.Single;
|
||||
#endif
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Godot
|
||||
{
|
||||
/// <summary>
|
||||
/// 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>
|
||||
{
|
||||
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
|
||||
{
|
||||
get { return _position; }
|
||||
set { _position = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Size from <see cref="Position"/> to <see cref="End"/>. Typically all components are positive.
|
||||
/// 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
|
||||
{
|
||||
get { return _size; }
|
||||
set { _size = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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)
|
||||
{
|
||||
_position = position;
|
||||
_size = size;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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)
|
||||
{
|
||||
_position = position;
|
||||
_size = new Vector2I(width, height);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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)
|
||||
{
|
||||
_position = new Vector2I(x, y);
|
||||
_size = size;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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)
|
||||
{
|
||||
_position = new Vector2I(x, y);
|
||||
_size = new Vector2I(width, height);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns <see langword="true"/> if this rect and <paramref name="obj"/> are equal.
|
||||
/// </summary>
|
||||
/// <param name="obj">The other object to compare.</param>
|
||||
/// <returns>Whether or not the rect and the other object are exactly equal.</returns>
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (obj is Rect2I)
|
||||
{
|
||||
return Equals((Rect2I)obj);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns <see langword="true"/> if this rect and <paramref name="other"/> are equal.
|
||||
/// </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)
|
||||
{
|
||||
return _position.Equals(other._position) && _size.Equals(other._size);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serves as the hash function for <see cref="Rect2I"/>.
|
||||
/// </summary>
|
||||
/// <returns>A hash code for this rect.</returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return _position.GetHashCode() ^ _size.GetHashCode();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts this <see cref="Rect2I"/> to a string.
|
||||
/// </summary>
|
||||
/// <returns>A string representation of this rect.</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return String.Format("({0}, {1})", new object[]
|
||||
{
|
||||
_position.ToString(),
|
||||
_size.ToString()
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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)
|
||||
{
|
||||
return String.Format("({0}, {1})", new object[]
|
||||
{
|
||||
_position.ToString(format),
|
||||
_size.ToString(format)
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
117
glue/GodotSharp/GodotSharp/Core/StringName.cs
Normal file
117
glue/GodotSharp/GodotSharp/Core/StringName.cs
Normal file
@ -0,0 +1,117 @@
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace Godot
|
||||
{
|
||||
public sealed partial class StringName : IDisposable
|
||||
{
|
||||
private bool _disposed = false;
|
||||
|
||||
private IntPtr ptr;
|
||||
|
||||
internal static IntPtr GetPtr(StringName instance)
|
||||
{
|
||||
if (instance == null)
|
||||
throw new NullReferenceException($"The instance of type {nameof(StringName)} is null.");
|
||||
|
||||
if (instance._disposed)
|
||||
throw new ObjectDisposedException(instance.GetType().FullName);
|
||||
|
||||
return instance.ptr;
|
||||
}
|
||||
|
||||
~StringName()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Disposes of this <see cref="StringName"/>.
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
private void Dispose(bool disposing)
|
||||
{
|
||||
if (_disposed)
|
||||
return;
|
||||
|
||||
if (ptr != IntPtr.Zero)
|
||||
{
|
||||
godot_icall_StringName_Dtor(ptr);
|
||||
ptr = IntPtr.Zero;
|
||||
}
|
||||
|
||||
_disposed = true;
|
||||
}
|
||||
|
||||
internal StringName(IntPtr ptr)
|
||||
{
|
||||
this.ptr = ptr;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The pointer to the native instance of this <see cref="StringName"/>.
|
||||
/// </summary>
|
||||
public IntPtr NativeInstance
|
||||
{
|
||||
get { return ptr; }
|
||||
}
|
||||
|
||||
public StringName() {
|
||||
ptr = godot_icall_StringName_Ctor(path);
|
||||
}
|
||||
|
||||
public StringName(string path)
|
||||
{
|
||||
ptr = godot_icall_StringName_String_Ctor(path);
|
||||
}
|
||||
|
||||
public static implicit operator StringName(string from)
|
||||
{
|
||||
return new StringName(from);
|
||||
}
|
||||
|
||||
public static implicit operator string(StringName from)
|
||||
{
|
||||
return godot_icall_StringName_operator_String(StringName.GetPtr(from));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts this <see cref="StringName"/> to a string.
|
||||
/// </summary>
|
||||
/// <returns>A string representation of this <see cref="StringName"/>.</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return (string)this;
|
||||
}
|
||||
|
||||
public static bool operator ==(StringName left, StringName right)
|
||||
{
|
||||
return godot_icall_StringName_operator_String(StringName.GetPtr(left), StringName.GetPtr(right));
|
||||
}
|
||||
|
||||
public static bool operator !=(Rect2 left, Rect2 right)
|
||||
{
|
||||
return !left.Equals(right);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
private static extern IntPtr godot_icall_StringName_Ctor();
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
private static extern IntPtr godot_icall_StringName_String_Ctor(string path);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
private static extern void godot_icall_StringName_Dtor(IntPtr ptr);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
private static extern string godot_icall_StringName_operator_String(IntPtr ptr);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
private static extern bool godot_icall_StringName_operator_Equals(IntPtr ptr1, IntPtr ptr2);
|
||||
}
|
||||
}
|
106
glue/GodotSharp/GodotSharp/Core/Vector2I.cs
Normal file
106
glue/GodotSharp/GodotSharp/Core/Vector2I.cs
Normal file
@ -0,0 +1,106 @@
|
||||
#if REAL_T_IS_DOUBLE
|
||||
using int = System.Double;
|
||||
#else
|
||||
using int = System.Single;
|
||||
#endif
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Godot
|
||||
{
|
||||
/// <summary>
|
||||
/// 2-element structure that can be used to represent positions in 2D space or any other pair of numeric values.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Vector2I : IEquatable<Vector2I>
|
||||
{
|
||||
/// <summary>
|
||||
/// The vector's X component. Also accessible by using the index position <c>[0]</c>.
|
||||
/// </summary>
|
||||
public int x;
|
||||
|
||||
/// <summary>
|
||||
/// The vector's Y component. Also accessible by using the index position <c>[1]</c>.
|
||||
/// </summary>
|
||||
public int y;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 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)
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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)
|
||||
{
|
||||
x = v.x;
|
||||
y = v.y;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns <see langword="true"/> if the vector is exactly equal
|
||||
/// to the given object (<see paramref="obj"/>).
|
||||
/// Note: Due to floating-point precision errors, consider using
|
||||
/// <see cref="IsEqualApprox"/> instead, which is more reliable.
|
||||
/// </summary>
|
||||
/// <param name="obj">The object to compare with.</param>
|
||||
/// <returns>Whether or not the vector and the object are equal.</returns>
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (obj is Vector2I)
|
||||
{
|
||||
return Equals((Vector2I)obj);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns <see langword="true"/> if the vectors are exactly equal.
|
||||
/// Note: Due to floating-point precision errors, consider using
|
||||
/// <see cref="IsEqualApprox"/> instead, which is more reliable.
|
||||
/// </summary>
|
||||
/// <param name="other">The other vector.</param>
|
||||
/// <returns>Whether or not the vectors are exactly equal.</returns>
|
||||
public bool Equals(Vector2I other)
|
||||
{
|
||||
return x == other.x && y == other.y;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serves as the hash function for <see cref="Vector2I"/>.
|
||||
/// </summary>
|
||||
/// <returns>A hash code for this vector.</returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return y.GetHashCode() ^ x.GetHashCode();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts this <see cref="Vector2I"/> to a string.
|
||||
/// </summary>
|
||||
/// <returns>A string representation of this vector.</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return $"({x}, {y})";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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)
|
||||
{
|
||||
return $"({x.ToString(format)}, {y.ToString(format)})";
|
||||
}
|
||||
}
|
||||
}
|
114
glue/GodotSharp/GodotSharp/Core/Vector3I.cs
Normal file
114
glue/GodotSharp/GodotSharp/Core/Vector3I.cs
Normal file
@ -0,0 +1,114 @@
|
||||
#if REAL_T_IS_DOUBLE
|
||||
using int = System.Double;
|
||||
#else
|
||||
using int = System.Single;
|
||||
#endif
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Godot
|
||||
{
|
||||
/// <summary>
|
||||
/// 3-element structure that can be used to represent positions in 3D space or any other pair of numeric values.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Vector3I : IEquatable<Vector3I>
|
||||
{
|
||||
/// <summary>
|
||||
/// The vector's X component. Also accessible by using the index position <c>[0]</c>.
|
||||
/// </summary>
|
||||
public int x;
|
||||
|
||||
/// <summary>
|
||||
/// The vector's Y component. Also accessible by using the index position <c>[1]</c>.
|
||||
/// </summary>
|
||||
public int y;
|
||||
|
||||
/// <summary>
|
||||
/// The vector's Z component. Also accessible by using the index position <c>[2]</c>.
|
||||
/// </summary>
|
||||
public int z;
|
||||
|
||||
/// <summary>
|
||||
/// 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)
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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)
|
||||
{
|
||||
x = v.x;
|
||||
y = v.y;
|
||||
z = v.z;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns <see langword="true"/> if the vector is exactly equal
|
||||
/// to the given object (<see paramref="obj"/>).
|
||||
/// Note: Due to floating-point precision errors, consider using
|
||||
/// <see cref="IsEqualApprox"/> instead, which is more reliable.
|
||||
/// </summary>
|
||||
/// <param name="obj">The object to compare with.</param>
|
||||
/// <returns>Whether or not the vector and the object are equal.</returns>
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (obj is Vector3I)
|
||||
{
|
||||
return Equals((Vector3I)obj);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns <see langword="true"/> if the vectors are exactly equal.
|
||||
/// Note: Due to floating-point precision errors, consider using
|
||||
/// <see cref="IsEqualApprox"/> instead, which is more reliable.
|
||||
/// </summary>
|
||||
/// <param name="other">The other vector.</param>
|
||||
/// <returns>Whether or not the vectors are exactly equal.</returns>
|
||||
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"/>.
|
||||
/// </summary>
|
||||
/// <returns>A hash code for this vector.</returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return y.GetHashCode() ^ x.GetHashCode() ^ z.GetHashCode();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts this <see cref="Vector3I"/> to a string.
|
||||
/// </summary>
|
||||
/// <returns>A string representation of this vector.</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return $"({x}, {y}, {z})";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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)
|
||||
{
|
||||
return $"({x.ToString(format)}, {y.ToString(format)}, {z.ToString(format)})";
|
||||
}
|
||||
}
|
||||
}
|
118
glue/GodotSharp/GodotSharp/Core/Vector4.cs
Normal file
118
glue/GodotSharp/GodotSharp/Core/Vector4.cs
Normal file
@ -0,0 +1,118 @@
|
||||
#if REAL_T_IS_DOUBLE
|
||||
using real_t = System.Double;
|
||||
#else
|
||||
using real_t = System.Single;
|
||||
#endif
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Godot
|
||||
{
|
||||
/// <summary>
|
||||
/// 3-element structure that can be used to represent positions in 3D space or any other pair of numeric values.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Vector4 : IEquatable<Vector4>
|
||||
{
|
||||
/// <summary>
|
||||
/// The vector's X component. Also accessible by using the index position <c>[0]</c>.
|
||||
/// </summary>
|
||||
public real_t x;
|
||||
|
||||
/// <summary>
|
||||
/// The vector's Y component. Also accessible by using the index position <c>[1]</c>.
|
||||
/// </summary>
|
||||
public real_t y;
|
||||
|
||||
/// <summary>
|
||||
/// The vector's Z component. Also accessible by using the index position <c>[2]</c>.
|
||||
/// </summary>
|
||||
public real_t z;
|
||||
|
||||
public real_t w;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new <see cref="Vector4"/> 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 Vector4(real_t x, real_t y, real_t z, real_t w)
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.w = w;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new <see cref="Vector4"/> from an existing <see cref="Vector4"/>.
|
||||
/// </summary>
|
||||
/// <param name="v">The existing <see cref="Vector4"/>.</param>
|
||||
public Vector4(Vector4 v)
|
||||
{
|
||||
x = v.x;
|
||||
y = v.y;
|
||||
z = v.z;
|
||||
w = v.w;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns <see langword="true"/> if the vector is exactly equal
|
||||
/// to the given object (<see paramref="obj"/>).
|
||||
/// Note: Due to floating-point precision errors, consider using
|
||||
/// <see cref="IsEqualApprox"/> instead, which is more reliable.
|
||||
/// </summary>
|
||||
/// <param name="obj">The object to compare with.</param>
|
||||
/// <returns>Whether or not the vector and the object are equal.</returns>
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (obj is Vector4)
|
||||
{
|
||||
return Equals((Vector4)obj);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns <see langword="true"/> if the vectors are exactly equal.
|
||||
/// Note: Due to floating-point precision errors, consider using
|
||||
/// <see cref="IsEqualApprox"/> instead, which is more reliable.
|
||||
/// </summary>
|
||||
/// <param name="other">The other vector.</param>
|
||||
/// <returns>Whether or not the vectors are exactly equal.</returns>
|
||||
public bool Equals(Vector4 other)
|
||||
{
|
||||
return x == other.x && y == other.y && z == other.z && w == other.w;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serves as the hash function for <see cref="Vector4"/>.
|
||||
/// </summary>
|
||||
/// <returns>A hash code for this vector.</returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return y.GetHashCode() ^ x.GetHashCode() ^ z.GetHashCode() ^ w.GetHashCode();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts this <see cref="Vector4"/> to a string.
|
||||
/// </summary>
|
||||
/// <returns>A string representation of this vector.</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return $"({x}, {y}, {z}, {w})";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts this <see cref="Vector4"/> 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)})";
|
||||
}
|
||||
}
|
||||
}
|
118
glue/GodotSharp/GodotSharp/Core/Vector4I.cs
Normal file
118
glue/GodotSharp/GodotSharp/Core/Vector4I.cs
Normal file
@ -0,0 +1,118 @@
|
||||
#if REAL_T_IS_DOUBLE
|
||||
using int = System.Double;
|
||||
#else
|
||||
using int = System.Single;
|
||||
#endif
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Godot
|
||||
{
|
||||
/// <summary>
|
||||
/// 3-element structure that can be used to represent positions in 3D space or any other pair of numeric values.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Vector4I : IEquatable<Vector4I>
|
||||
{
|
||||
/// <summary>
|
||||
/// The vector's X component. Also accessible by using the index position <c>[0]</c>.
|
||||
/// </summary>
|
||||
public int x;
|
||||
|
||||
/// <summary>
|
||||
/// The vector's Y component. Also accessible by using the index position <c>[1]</c>.
|
||||
/// </summary>
|
||||
public int y;
|
||||
|
||||
/// <summary>
|
||||
/// The vector's Z component. Also accessible by using the index position <c>[2]</c>.
|
||||
/// </summary>
|
||||
public int z;
|
||||
|
||||
public int w;
|
||||
|
||||
/// <summary>
|
||||
/// 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)
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.w = w;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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)
|
||||
{
|
||||
x = v.x;
|
||||
y = v.y;
|
||||
z = v.z;
|
||||
w = v.w;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns <see langword="true"/> if the vector is exactly equal
|
||||
/// to the given object (<see paramref="obj"/>).
|
||||
/// Note: Due to floating-point precision errors, consider using
|
||||
/// <see cref="IsEqualApprox"/> instead, which is more reliable.
|
||||
/// </summary>
|
||||
/// <param name="obj">The object to compare with.</param>
|
||||
/// <returns>Whether or not the vector and the object are equal.</returns>
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (obj is Vector4I)
|
||||
{
|
||||
return Equals((Vector4I)obj);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns <see langword="true"/> if the vectors are exactly equal.
|
||||
/// Note: Due to floating-point precision errors, consider using
|
||||
/// <see cref="IsEqualApprox"/> instead, which is more reliable.
|
||||
/// </summary>
|
||||
/// <param name="other">The other vector.</param>
|
||||
/// <returns>Whether or not the vectors are exactly equal.</returns>
|
||||
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"/>.
|
||||
/// </summary>
|
||||
/// <returns>A hash code for this vector.</returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return y.GetHashCode() ^ x.GetHashCode() ^ z.GetHashCode() ^ w.GetHashCode();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts this <see cref="Vector4I"/> to a string.
|
||||
/// </summary>
|
||||
/// <returns>A string representation of this vector.</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return $"({x}, {y}, {z}, {w})";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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)})";
|
||||
}
|
||||
}
|
||||
}
|
@ -39,6 +39,7 @@
|
||||
#include "nodepath_glue.h"
|
||||
#include "rid_glue.h"
|
||||
#include "string_glue.h"
|
||||
#include "string_name_glue.h"
|
||||
|
||||
/**
|
||||
* Registers internal calls that were not generated. This function is called
|
||||
@ -51,6 +52,7 @@ void godot_register_glue_header_icalls() {
|
||||
godot_register_object_icalls();
|
||||
godot_register_rid_icalls();
|
||||
godot_register_string_icalls();
|
||||
godot_register_nodepath_icalls();
|
||||
}
|
||||
|
||||
// Used by the generated glue
|
||||
|
66
glue/string_name_glue.cpp
Normal file
66
glue/string_name_glue.cpp
Normal file
@ -0,0 +1,66 @@
|
||||
/**************************************************************************/
|
||||
/* nodepath_glue.cpp */
|
||||
/**************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/**************************************************************************/
|
||||
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
|
||||
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#include "string_name_glue.h"
|
||||
|
||||
#ifdef MONO_GLUE_ENABLED
|
||||
|
||||
#include "core/string/ustring.h"
|
||||
|
||||
StringName *godot_icall_StringName_Ctor() {
|
||||
return memnew(StringName());
|
||||
}
|
||||
|
||||
StringName *godot_icall_StringName_String_Ctor(MonoString *p_path) {
|
||||
return memnew(StringName(GDMonoMarshal::mono_string_to_godot(p_path)));
|
||||
}
|
||||
|
||||
void godot_icall_StringName_Dtor(StringName *p_ptr) {
|
||||
ERR_FAIL_NULL(p_ptr);
|
||||
memdelete(p_ptr);
|
||||
}
|
||||
|
||||
MonoString *godot_icall_StringName_operator_String(StringName *p_np) {
|
||||
return GDMonoMarshal::mono_string_from_godot(p_np->operator String());
|
||||
}
|
||||
|
||||
bool godot_icall_StringName_operator_Equals(StringName *p_sn1, StringName *p_sn2) {
|
||||
return p_sn1->operator==(*p_sn2);
|
||||
}
|
||||
|
||||
void godot_register_stringname_icalls() {
|
||||
GDMonoUtils::add_internal_call("Godot.StringName::godot_icall_StringName_Ctor", godot_icall_StringName_Ctor);
|
||||
GDMonoUtils::add_internal_call("Godot.StringName::godot_icall_StringName_String_Ctor", godot_icall_StringName_String_Ctor);
|
||||
GDMonoUtils::add_internal_call("Godot.StringName::godot_icall_StringName_Dtor", godot_icall_StringName_Dtor);
|
||||
GDMonoUtils::add_internal_call("Godot.StringName::godot_icall_StringName_operator_String", godot_icall_StringName_operator_String);
|
||||
GDMonoUtils::add_internal_call("Godot.StringName::godot_icall_StringName_operator_Equals", godot_icall_StringName_operator_Equals);
|
||||
}
|
||||
|
||||
#endif // MONO_GLUE_ENABLED
|
56
glue/string_name_glue.h
Normal file
56
glue/string_name_glue.h
Normal file
@ -0,0 +1,56 @@
|
||||
/**************************************************************************/
|
||||
/* nodepath_glue.h */
|
||||
/**************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/**************************************************************************/
|
||||
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
|
||||
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef NODEPATH_GLUE_H
|
||||
#define NODEPATH_GLUE_H
|
||||
|
||||
#ifdef MONO_GLUE_ENABLED
|
||||
|
||||
#include "core/string/string_name.h"
|
||||
|
||||
#include "../mono_gd/gd_mono_marshal.h"
|
||||
|
||||
StringName *godot_icall_StringName_Ctor();
|
||||
|
||||
StringName *godot_icall_StringName_String_Ctor(MonoString *p_path);
|
||||
|
||||
void godot_icall_StringName_Dtor(StringName *p_ptr);
|
||||
|
||||
MonoString *godot_icall_StringName_operator_String(StringName *p_np);
|
||||
|
||||
bool godot_icall_StringName_operator_Equals(StringName *p_sn1, StringName *p_sn2);
|
||||
|
||||
// Register internal calls
|
||||
|
||||
void godot_register_stringname_icalls();
|
||||
|
||||
#endif // MONO_GLUE_ENABLED
|
||||
|
||||
#endif // NODEPATH_GLUE_H
|
Loading…
Reference in New Issue
Block a user