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.cs128
1 files changed, 68 insertions, 60 deletions
diff --git a/modules/mono/glue/Managed/Files/GD.cs b/modules/mono/glue/Managed/Files/GD.cs
index 75a35a9eea..2068099ac6 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);
}
@@ -82,7 +83,7 @@ namespace Godot
public static void Print(params object[] what)
{
- godot_icall_GD_print(what);
+ godot_icall_GD_print(Array.ConvertAll(what, x => x.ToString()));
}
public static void PrintStack()
@@ -92,89 +93,80 @@ namespace Godot
public static void PrintErr(params object[] what)
{
- godot_icall_GD_printerr(what);
+ godot_icall_GD_printerr(Array.ConvertAll(what, x => x.ToString()));
}
public static void PrintRaw(params object[] what)
{
- godot_icall_GD_printraw(what);
+ godot_icall_GD_printraw(Array.ConvertAll(what, x => x.ToString()));
}
public static void PrintS(params object[] what)
{
- godot_icall_GD_prints(what);
+ godot_icall_GD_prints(Array.ConvertAll(what, x => x.ToString()));
}
public static void PrintT(params object[] what)
{
- godot_icall_GD_printt(what);
+ godot_icall_GD_printt(Array.ConvertAll(what, x => x.ToString()));
}
- public static int[] Range(int length)
+ public static float 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,23 @@ 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 float 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 +252,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);