summaryrefslogtreecommitdiff
path: root/modules/mono/glue/Managed/Files/GD.cs
diff options
context:
space:
mode:
Diffstat (limited to 'modules/mono/glue/Managed/Files/GD.cs')
-rw-r--r--modules/mono/glue/Managed/Files/GD.cs117
1 files changed, 62 insertions, 55 deletions
diff --git a/modules/mono/glue/Managed/Files/GD.cs b/modules/mono/glue/Managed/Files/GD.cs
index 75a35a9eea..d968f8a78f 100644
--- a/modules/mono/glue/Managed/Files/GD.cs
+++ b/modules/mono/glue/Managed/Files/GD.cs
@@ -1,4 +1,5 @@
using System;
+using System.Collections.Generic;
using System.Runtime.CompilerServices;
#if REAL_T_IS_DOUBLE
using real_t = System.Double;
@@ -12,12 +13,12 @@ namespace Godot
{
public static partial class GD
{
- public static object Bytes2Var(byte[] bytes)
+ public static object Bytes2Var(byte[] bytes, bool allow_objects = false)
{
- return godot_icall_GD_bytes2var(bytes);
+ return godot_icall_GD_bytes2var(bytes, allow_objects);
}
- public static object Convert(object what, int type)
+ public static object Convert(object what, Variant.Type type)
{
return godot_icall_GD_convert(what, type);
}
@@ -50,7 +51,7 @@ namespace Godot
return godot_icall_GD_hash(var);
}
- public static Object InstanceFromId(int instanceId)
+ public static Object InstanceFromId(ulong instanceId)
{
return godot_icall_GD_instance_from_id(instanceId);
}
@@ -110,71 +111,62 @@ namespace Godot
godot_icall_GD_printt(what);
}
- public static int[] Range(int length)
+ public static double Randf()
{
- var ret = new int[length];
-
- for (int i = 0; i < length; i++)
- {
- ret[i] = i;
- }
-
- return ret;
+ return godot_icall_GD_randf();
}
- public static int[] Range(int from, int to)
+ public static uint Randi()
{
- if (to < from)
- return new int[0];
+ return godot_icall_GD_randi();
+ }
- var ret = new int[to - from];
+ public static void Randomize()
+ {
+ godot_icall_GD_randomize();
+ }
- for (int i = from; i < to; i++)
- {
- ret[i - from] = i;
- }
+ public static double RandRange(double from, double to)
+ {
+ return godot_icall_GD_rand_range(from, to);
+ }
- return ret;
+ public static uint RandSeed(ulong seed, out ulong newSeed)
+ {
+ return godot_icall_GD_rand_seed(seed, out newSeed);
}
- public static int[] Range(int from, int to, int increment)
+ public static IEnumerable<int> Range(int end)
{
- if (to < from && increment > 0)
- return new int[0];
- if (to > from && increment < 0)
- return new int[0];
+ return Range(0, end, 1);
+ }
- // Calculate count
- int count;
+ public static IEnumerable<int> Range(int start, int end)
+ {
+ return Range(start, end, 1);
+ }
- if (increment > 0)
- count = (to - from - 1) / increment + 1;
- else
- count = (from - to - 1) / -increment + 1;
+ public static IEnumerable<int> Range(int start, int end, int step)
+ {
+ if (end < start && step > 0)
+ yield break;
- var ret = new int[count];
+ if (end > start && step < 0)
+ yield break;
- if (increment > 0)
+ if (step > 0)
{
- int idx = 0;
- for (int i = from; i < to; i += increment)
- {
- ret[idx++] = i;
- }
+ for (int i = start; i < end; i += step)
+ yield return i;
}
else
{
- int idx = 0;
- for (int i = from; i > to; i += increment)
- {
- ret[idx++] = i;
- }
+ for (int i = start; i > end; i += step)
+ yield return i;
}
-
- return ret;
}
- public static void Seed(int seed)
+ public static void Seed(ulong seed)
{
godot_icall_GD_seed(seed);
}
@@ -194,9 +186,9 @@ namespace Godot
return godot_icall_GD_type_exists(type);
}
- public static byte[] Var2Bytes(object var)
+ public static byte[] Var2Bytes(object var, bool full_objects = false)
{
- return godot_icall_GD_var2bytes(var);
+ return godot_icall_GD_var2bytes(var, full_objects);
}
public static string Var2Str(object var)
@@ -205,16 +197,16 @@ namespace Godot
}
[MethodImpl(MethodImplOptions.InternalCall)]
- internal extern static object godot_icall_GD_bytes2var(byte[] bytes);
+ internal extern static object godot_icall_GD_bytes2var(byte[] bytes, bool allow_objects);
[MethodImpl(MethodImplOptions.InternalCall)]
- internal extern static object godot_icall_GD_convert(object what, int type);
+ internal extern static object godot_icall_GD_convert(object what, Variant.Type type);
[MethodImpl(MethodImplOptions.InternalCall)]
internal extern static int godot_icall_GD_hash(object var);
[MethodImpl(MethodImplOptions.InternalCall)]
- internal extern static Object godot_icall_GD_instance_from_id(int instance_id);
+ internal extern static Object godot_icall_GD_instance_from_id(ulong instance_id);
[MethodImpl(MethodImplOptions.InternalCall)]
internal extern static void godot_icall_GD_print(object[] what);
@@ -232,7 +224,22 @@ namespace Godot
internal extern static void godot_icall_GD_printt(object[] what);
[MethodImpl(MethodImplOptions.InternalCall)]
- internal extern static void godot_icall_GD_seed(int seed);
+ internal extern static double godot_icall_GD_randf();
+
+ [MethodImpl(MethodImplOptions.InternalCall)]
+ internal extern static uint godot_icall_GD_randi();
+
+ [MethodImpl(MethodImplOptions.InternalCall)]
+ internal extern static void godot_icall_GD_randomize();
+
+ [MethodImpl(MethodImplOptions.InternalCall)]
+ internal extern static double godot_icall_GD_rand_range(double from, double to);
+
+ [MethodImpl(MethodImplOptions.InternalCall)]
+ internal extern static uint godot_icall_GD_rand_seed(ulong seed, out ulong newSeed);
+
+ [MethodImpl(MethodImplOptions.InternalCall)]
+ internal extern static void godot_icall_GD_seed(ulong seed);
[MethodImpl(MethodImplOptions.InternalCall)]
internal extern static string godot_icall_GD_str(object[] what);
@@ -244,7 +251,7 @@ namespace Godot
internal extern static bool godot_icall_GD_type_exists(string type);
[MethodImpl(MethodImplOptions.InternalCall)]
- internal extern static byte[] godot_icall_GD_var2bytes(object what);
+ internal extern static byte[] godot_icall_GD_var2bytes(object what, bool full_objects);
[MethodImpl(MethodImplOptions.InternalCall)]
internal extern static string godot_icall_GD_var2str(object var);