2017-10-02 23:24:00 +02:00
|
|
|
using System;
|
2018-09-04 05:40:41 +02:00
|
|
|
using System.Runtime.CompilerServices;
|
2018-07-21 23:40:34 +02:00
|
|
|
#if REAL_T_IS_DOUBLE
|
|
|
|
using real_t = System.Double;
|
|
|
|
#else
|
|
|
|
using real_t = System.Single;
|
|
|
|
#endif
|
2017-10-02 23:24:00 +02:00
|
|
|
|
2018-09-04 05:40:41 +02:00
|
|
|
// TODO: Add comments describing what this class does. It is not obvious.
|
2018-03-01 08:51:35 +01:00
|
|
|
|
2017-10-02 23:24:00 +02:00
|
|
|
namespace Godot
|
|
|
|
{
|
2017-12-24 03:17:48 +01:00
|
|
|
public static partial class GD
|
2017-10-02 23:24:00 +02:00
|
|
|
{
|
2017-11-21 23:32:19 +01:00
|
|
|
public static object Bytes2Var(byte[] bytes)
|
2017-10-02 23:24:00 +02:00
|
|
|
{
|
2018-09-04 05:40:41 +02:00
|
|
|
return godot_icall_GD_bytes2var(bytes);
|
2017-10-02 23:24:00 +02:00
|
|
|
}
|
|
|
|
|
2017-11-21 23:32:19 +01:00
|
|
|
public static object Convert(object what, int type)
|
2017-10-02 23:24:00 +02:00
|
|
|
{
|
2018-09-04 05:40:41 +02:00
|
|
|
return godot_icall_GD_convert(what, type);
|
2017-10-02 23:24:00 +02:00
|
|
|
}
|
|
|
|
|
2018-07-21 23:40:34 +02:00
|
|
|
public static real_t Db2Linear(real_t db)
|
2017-10-02 23:24:00 +02:00
|
|
|
{
|
2018-07-21 23:40:34 +02:00
|
|
|
return (real_t)Math.Exp(db * 0.11512925464970228420089957273422);
|
2017-10-02 23:24:00 +02:00
|
|
|
}
|
|
|
|
|
2018-07-21 23:40:34 +02:00
|
|
|
public static real_t DecTime(real_t value, real_t amount, real_t step)
|
2017-10-02 23:24:00 +02:00
|
|
|
{
|
2018-07-21 23:40:34 +02:00
|
|
|
real_t sgn = Mathf.Sign(value);
|
|
|
|
real_t val = Mathf.Abs(value);
|
2017-10-02 23:24:00 +02:00
|
|
|
val -= amount * step;
|
2018-07-21 23:40:34 +02:00
|
|
|
if (val < 0)
|
|
|
|
val = 0;
|
2017-10-02 23:24:00 +02:00
|
|
|
return val * sgn;
|
|
|
|
}
|
|
|
|
|
2018-07-21 23:40:34 +02:00
|
|
|
public static FuncRef FuncRef(Object instance, string funcname)
|
2017-10-02 23:24:00 +02:00
|
|
|
{
|
|
|
|
var ret = new FuncRef();
|
|
|
|
ret.SetInstance(instance);
|
|
|
|
ret.SetFunction(funcname);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2017-11-21 23:32:19 +01:00
|
|
|
public static int Hash(object var)
|
2017-10-02 23:24:00 +02:00
|
|
|
{
|
2018-09-04 05:40:41 +02:00
|
|
|
return godot_icall_GD_hash(var);
|
2017-10-02 23:24:00 +02:00
|
|
|
}
|
|
|
|
|
2017-11-21 23:32:19 +01:00
|
|
|
public static Object InstanceFromId(int instanceId)
|
2017-10-02 23:24:00 +02:00
|
|
|
{
|
2018-09-04 05:40:41 +02:00
|
|
|
return godot_icall_GD_instance_from_id(instanceId);
|
2017-10-02 23:24:00 +02:00
|
|
|
}
|
|
|
|
|
2018-07-21 23:40:34 +02:00
|
|
|
public static real_t Linear2Db(real_t linear)
|
2017-10-02 23:24:00 +02:00
|
|
|
{
|
2018-07-21 23:40:34 +02:00
|
|
|
return (real_t)(Math.Log(linear) * 8.6858896380650365530225783783321);
|
2017-10-02 23:24:00 +02:00
|
|
|
}
|
|
|
|
|
2017-11-21 23:32:19 +01:00
|
|
|
public static Resource Load(string path)
|
2017-10-02 23:24:00 +02:00
|
|
|
{
|
|
|
|
return ResourceLoader.Load(path);
|
|
|
|
}
|
|
|
|
|
2018-10-05 15:32:33 +02:00
|
|
|
public static T Load<T>(string path) where T : class
|
2018-07-30 13:35:48 +02:00
|
|
|
{
|
2018-10-05 19:39:11 +02:00
|
|
|
return ResourceLoader.Load<T>(path);
|
2018-07-30 13:35:48 +02:00
|
|
|
}
|
|
|
|
|
2018-10-31 19:30:01 +01:00
|
|
|
public static void PushError(string message)
|
2018-10-26 05:32:50 +02:00
|
|
|
{
|
2018-10-31 19:30:01 +01:00
|
|
|
godot_icall_GD_pusherror(message);
|
2018-10-26 05:32:50 +02:00
|
|
|
}
|
|
|
|
|
2018-10-31 19:30:01 +01:00
|
|
|
public static void PushWarning(string message)
|
2018-10-26 05:32:50 +02:00
|
|
|
{
|
2018-10-31 19:30:01 +01:00
|
|
|
godot_icall_GD_pushwarning(message);
|
2018-10-26 05:32:50 +02:00
|
|
|
}
|
|
|
|
|
2017-11-21 23:32:19 +01:00
|
|
|
public static void Print(params object[] what)
|
2017-10-02 23:24:00 +02:00
|
|
|
{
|
2018-09-04 05:40:41 +02:00
|
|
|
godot_icall_GD_print(what);
|
2017-10-02 23:24:00 +02:00
|
|
|
}
|
|
|
|
|
2017-11-21 23:32:19 +01:00
|
|
|
public static void PrintStack()
|
2017-10-02 23:24:00 +02:00
|
|
|
{
|
2017-11-21 23:32:19 +01:00
|
|
|
Print(System.Environment.StackTrace);
|
2017-10-02 23:24:00 +02:00
|
|
|
}
|
|
|
|
|
2018-07-21 23:40:34 +02:00
|
|
|
public static void PrintErr(params object[] what)
|
2017-10-02 23:24:00 +02:00
|
|
|
{
|
2018-09-04 05:40:41 +02:00
|
|
|
godot_icall_GD_printerr(what);
|
2017-10-02 23:24:00 +02:00
|
|
|
}
|
|
|
|
|
2018-07-21 23:40:34 +02:00
|
|
|
public static void PrintRaw(params object[] what)
|
2017-10-02 23:24:00 +02:00
|
|
|
{
|
2018-09-04 05:40:41 +02:00
|
|
|
godot_icall_GD_printraw(what);
|
2017-10-02 23:24:00 +02:00
|
|
|
}
|
|
|
|
|
2018-07-21 23:40:34 +02:00
|
|
|
public static void PrintS(params object[] what)
|
2017-10-02 23:24:00 +02:00
|
|
|
{
|
2018-09-04 05:40:41 +02:00
|
|
|
godot_icall_GD_prints(what);
|
2017-10-02 23:24:00 +02:00
|
|
|
}
|
|
|
|
|
2018-07-21 23:40:34 +02:00
|
|
|
public static void PrintT(params object[] what)
|
2017-10-02 23:24:00 +02:00
|
|
|
{
|
2018-09-04 05:40:41 +02:00
|
|
|
godot_icall_GD_printt(what);
|
2017-10-02 23:24:00 +02:00
|
|
|
}
|
|
|
|
|
2017-11-21 23:32:19 +01:00
|
|
|
public static int[] Range(int length)
|
2017-10-02 23:24:00 +02:00
|
|
|
{
|
2018-04-08 05:30:43 +02:00
|
|
|
var ret = new int[length];
|
2017-10-02 23:24:00 +02:00
|
|
|
|
2018-04-17 00:33:42 +02:00
|
|
|
for (int i = 0; i < length; i++)
|
2017-10-02 23:24:00 +02:00
|
|
|
{
|
|
|
|
ret[i] = i;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2017-11-21 23:32:19 +01:00
|
|
|
public static int[] Range(int from, int to)
|
2017-10-02 23:24:00 +02:00
|
|
|
{
|
|
|
|
if (to < from)
|
|
|
|
return new int[0];
|
|
|
|
|
2018-04-08 05:30:43 +02:00
|
|
|
var ret = new int[to - from];
|
2017-10-02 23:24:00 +02:00
|
|
|
|
2018-04-17 00:33:42 +02:00
|
|
|
for (int i = from; i < to; i++)
|
2017-10-02 23:24:00 +02:00
|
|
|
{
|
|
|
|
ret[i - from] = i;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2017-11-21 23:32:19 +01:00
|
|
|
public static int[] Range(int from, int to, int increment)
|
2017-10-02 23:24:00 +02:00
|
|
|
{
|
|
|
|
if (to < from && increment > 0)
|
|
|
|
return new int[0];
|
|
|
|
if (to > from && increment < 0)
|
|
|
|
return new int[0];
|
|
|
|
|
|
|
|
// Calculate count
|
2018-04-08 05:38:02 +02:00
|
|
|
int count;
|
2017-10-02 23:24:00 +02:00
|
|
|
|
|
|
|
if (increment > 0)
|
2018-04-08 05:49:19 +02:00
|
|
|
count = (to - from - 1) / increment + 1;
|
2017-10-02 23:24:00 +02:00
|
|
|
else
|
2018-04-08 05:49:19 +02:00
|
|
|
count = (from - to - 1) / -increment + 1;
|
2017-10-02 23:24:00 +02:00
|
|
|
|
2018-04-08 05:30:43 +02:00
|
|
|
var ret = new int[count];
|
2017-10-02 23:24:00 +02:00
|
|
|
|
|
|
|
if (increment > 0)
|
|
|
|
{
|
2018-04-17 00:53:27 +02:00
|
|
|
int idx = 0;
|
2018-04-17 00:33:42 +02:00
|
|
|
for (int i = from; i < to; i += increment)
|
2017-10-02 23:24:00 +02:00
|
|
|
{
|
|
|
|
ret[idx++] = i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-04-17 00:53:27 +02:00
|
|
|
int idx = 0;
|
2018-04-17 00:33:42 +02:00
|
|
|
for (int i = from; i > to; i += increment)
|
2017-10-02 23:24:00 +02:00
|
|
|
{
|
|
|
|
ret[idx++] = i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2017-11-21 23:32:19 +01:00
|
|
|
public static void Seed(int seed)
|
2017-10-02 23:24:00 +02:00
|
|
|
{
|
2018-09-04 05:40:41 +02:00
|
|
|
godot_icall_GD_seed(seed);
|
2017-10-02 23:24:00 +02:00
|
|
|
}
|
|
|
|
|
2017-11-21 23:32:19 +01:00
|
|
|
public static string Str(params object[] what)
|
2017-10-02 23:24:00 +02:00
|
|
|
{
|
2018-09-04 05:40:41 +02:00
|
|
|
return godot_icall_GD_str(what);
|
2017-10-02 23:24:00 +02:00
|
|
|
}
|
|
|
|
|
2017-11-21 23:32:19 +01:00
|
|
|
public static object Str2Var(string str)
|
2017-10-02 23:24:00 +02:00
|
|
|
{
|
2018-09-04 05:40:41 +02:00
|
|
|
return godot_icall_GD_str2var(str);
|
2017-10-02 23:24:00 +02:00
|
|
|
}
|
|
|
|
|
2017-11-21 23:32:19 +01:00
|
|
|
public static bool TypeExists(string type)
|
2017-10-02 23:24:00 +02:00
|
|
|
{
|
2018-09-04 05:40:41 +02:00
|
|
|
return godot_icall_GD_type_exists(type);
|
2017-10-02 23:24:00 +02:00
|
|
|
}
|
|
|
|
|
2017-11-21 23:32:19 +01:00
|
|
|
public static byte[] Var2Bytes(object var)
|
2017-10-02 23:24:00 +02:00
|
|
|
{
|
2018-09-04 05:40:41 +02:00
|
|
|
return godot_icall_GD_var2bytes(var);
|
2017-10-02 23:24:00 +02:00
|
|
|
}
|
|
|
|
|
2017-11-21 23:32:19 +01:00
|
|
|
public static string Var2Str(object var)
|
2017-10-02 23:24:00 +02:00
|
|
|
{
|
2018-09-04 05:40:41 +02:00
|
|
|
return godot_icall_GD_var2str(var);
|
2017-10-02 23:24:00 +02:00
|
|
|
}
|
2018-09-04 05:40:41 +02:00
|
|
|
|
|
|
|
[MethodImpl(MethodImplOptions.InternalCall)]
|
|
|
|
internal extern static object godot_icall_GD_bytes2var(byte[] bytes);
|
|
|
|
|
|
|
|
[MethodImpl(MethodImplOptions.InternalCall)]
|
|
|
|
internal extern static object godot_icall_GD_convert(object what, int 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);
|
|
|
|
|
|
|
|
[MethodImpl(MethodImplOptions.InternalCall)]
|
|
|
|
internal extern static void godot_icall_GD_print(object[] what);
|
|
|
|
|
|
|
|
[MethodImpl(MethodImplOptions.InternalCall)]
|
|
|
|
internal extern static void godot_icall_GD_printerr(object[] what);
|
|
|
|
|
|
|
|
[MethodImpl(MethodImplOptions.InternalCall)]
|
|
|
|
internal extern static void godot_icall_GD_printraw(object[] what);
|
|
|
|
|
|
|
|
[MethodImpl(MethodImplOptions.InternalCall)]
|
|
|
|
internal extern static void godot_icall_GD_prints(object[] what);
|
|
|
|
|
|
|
|
[MethodImpl(MethodImplOptions.InternalCall)]
|
|
|
|
internal extern static void godot_icall_GD_printt(object[] what);
|
|
|
|
|
|
|
|
[MethodImpl(MethodImplOptions.InternalCall)]
|
|
|
|
internal extern static void godot_icall_GD_seed(int seed);
|
|
|
|
|
|
|
|
[MethodImpl(MethodImplOptions.InternalCall)]
|
|
|
|
internal extern static string godot_icall_GD_str(object[] what);
|
|
|
|
|
|
|
|
[MethodImpl(MethodImplOptions.InternalCall)]
|
|
|
|
internal extern static object godot_icall_GD_str2var(string str);
|
|
|
|
|
|
|
|
[MethodImpl(MethodImplOptions.InternalCall)]
|
|
|
|
internal extern static bool godot_icall_GD_type_exists(string type);
|
|
|
|
|
|
|
|
[MethodImpl(MethodImplOptions.InternalCall)]
|
|
|
|
internal extern static byte[] godot_icall_GD_var2bytes(object what);
|
|
|
|
|
|
|
|
[MethodImpl(MethodImplOptions.InternalCall)]
|
|
|
|
internal extern static string godot_icall_GD_var2str(object var);
|
2018-10-26 05:32:50 +02:00
|
|
|
|
|
|
|
[MethodImpl(MethodImplOptions.InternalCall)]
|
2018-10-31 19:30:01 +01:00
|
|
|
internal extern static void godot_icall_GD_pusherror(string type);
|
2018-10-26 05:32:50 +02:00
|
|
|
|
|
|
|
[MethodImpl(MethodImplOptions.InternalCall)]
|
2018-10-31 19:30:01 +01:00
|
|
|
internal extern static void godot_icall_GD_pushwarning(string type);
|
2017-10-02 23:24:00 +02:00
|
|
|
}
|
|
|
|
}
|