2017-10-02 23:24:00 +02:00
|
|
|
using System;
|
|
|
|
|
|
|
|
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
|
|
|
{
|
|
|
|
return NativeCalls.godot_icall_Godot_bytes2var(bytes);
|
|
|
|
}
|
|
|
|
|
2017-11-21 23:32:19 +01:00
|
|
|
public static object Convert(object what, int type)
|
2017-10-02 23:24:00 +02:00
|
|
|
{
|
|
|
|
return NativeCalls.godot_icall_Godot_convert(what, type);
|
|
|
|
}
|
|
|
|
|
2017-11-21 23:32:19 +01:00
|
|
|
public static float Db2Linear(float db)
|
2017-10-02 23:24:00 +02:00
|
|
|
{
|
|
|
|
return (float)Math.Exp(db * 0.11512925464970228420089957273422);
|
|
|
|
}
|
|
|
|
|
2017-11-21 23:32:19 +01:00
|
|
|
public static float Dectime(float value, float amount, float step)
|
2017-10-02 23:24:00 +02:00
|
|
|
{
|
|
|
|
float sgn = value < 0 ? -1.0f : 1.0f;
|
2017-11-21 23:32:19 +01:00
|
|
|
float val = Mathf.Abs(value);
|
2017-10-02 23:24:00 +02:00
|
|
|
val -= amount * step;
|
|
|
|
if (val < 0.0f)
|
|
|
|
val = 0.0f;
|
|
|
|
return val * sgn;
|
|
|
|
}
|
|
|
|
|
2017-11-21 23:32:19 +01: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
|
|
|
{
|
|
|
|
return NativeCalls.godot_icall_Godot_hash(var);
|
|
|
|
}
|
|
|
|
|
2017-11-21 23:32:19 +01:00
|
|
|
public static Object InstanceFromId(int instanceId)
|
2017-10-02 23:24:00 +02:00
|
|
|
{
|
2017-11-21 23:32:19 +01:00
|
|
|
return NativeCalls.godot_icall_Godot_instance_from_id(instanceId);
|
2017-10-02 23:24:00 +02:00
|
|
|
}
|
|
|
|
|
2017-11-21 23:32:19 +01:00
|
|
|
public static double Linear2Db(double linear)
|
2017-10-02 23:24:00 +02:00
|
|
|
{
|
|
|
|
return Math.Log(linear) * 8.6858896380650365530225783783321;
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2017-11-21 23:32:19 +01:00
|
|
|
public static void Print(params object[] what)
|
2017-10-02 23:24:00 +02:00
|
|
|
{
|
|
|
|
NativeCalls.godot_icall_Godot_print(what);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2017-11-21 23:32:19 +01:00
|
|
|
public static void Printerr(params object[] what)
|
2017-10-02 23:24:00 +02:00
|
|
|
{
|
|
|
|
NativeCalls.godot_icall_Godot_printerr(what);
|
|
|
|
}
|
|
|
|
|
2017-11-21 23:32:19 +01:00
|
|
|
public static void Printraw(params object[] what)
|
2017-10-02 23:24:00 +02:00
|
|
|
{
|
|
|
|
NativeCalls.godot_icall_Godot_printraw(what);
|
|
|
|
}
|
|
|
|
|
2017-11-21 23:32:19 +01:00
|
|
|
public static void Prints(params object[] what)
|
2017-10-02 23:24:00 +02:00
|
|
|
{
|
|
|
|
NativeCalls.godot_icall_Godot_prints(what);
|
|
|
|
}
|
|
|
|
|
2017-11-21 23:32:19 +01:00
|
|
|
public static void Printt(params object[] what)
|
2017-10-02 23:24:00 +02:00
|
|
|
{
|
|
|
|
NativeCalls.godot_icall_Godot_printt(what);
|
|
|
|
}
|
|
|
|
|
2017-11-21 23:32:19 +01:00
|
|
|
public static int[] Range(int length)
|
2017-10-02 23:24:00 +02:00
|
|
|
{
|
|
|
|
int[] ret = new int[length];
|
|
|
|
|
|
|
|
for (int i = 0; i < length; i++)
|
|
|
|
{
|
|
|
|
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];
|
|
|
|
|
|
|
|
int[] ret = new int[to - from];
|
|
|
|
|
|
|
|
for (int i = from; i < to; i++)
|
|
|
|
{
|
|
|
|
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
|
|
|
|
int count = 0;
|
|
|
|
|
|
|
|
if (increment > 0)
|
|
|
|
count = ((to - from - 1) / increment) + 1;
|
|
|
|
else
|
|
|
|
count = ((from - to - 1) / -increment) + 1;
|
|
|
|
|
|
|
|
int[] ret = new int[count];
|
|
|
|
|
|
|
|
if (increment > 0)
|
|
|
|
{
|
|
|
|
int idx = 0;
|
|
|
|
for (int i = from; i < to; i += increment)
|
|
|
|
{
|
|
|
|
ret[idx++] = i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int idx = 0;
|
|
|
|
for (int i = from; i > to; i += increment)
|
|
|
|
{
|
|
|
|
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
|
|
|
{
|
|
|
|
NativeCalls.godot_icall_Godot_seed(seed);
|
|
|
|
}
|
|
|
|
|
2017-11-21 23:32:19 +01:00
|
|
|
public static string Str(params object[] what)
|
2017-10-02 23:24:00 +02:00
|
|
|
{
|
|
|
|
return NativeCalls.godot_icall_Godot_str(what);
|
|
|
|
}
|
|
|
|
|
2017-11-21 23:32:19 +01:00
|
|
|
public static object Str2Var(string str)
|
2017-10-02 23:24:00 +02:00
|
|
|
{
|
|
|
|
return NativeCalls.godot_icall_Godot_str2var(str);
|
|
|
|
}
|
|
|
|
|
2017-11-21 23:32:19 +01:00
|
|
|
public static bool TypeExists(string type)
|
2017-10-02 23:24:00 +02:00
|
|
|
{
|
|
|
|
return NativeCalls.godot_icall_Godot_type_exists(type);
|
|
|
|
}
|
|
|
|
|
2017-11-21 23:32:19 +01:00
|
|
|
public static byte[] Var2Bytes(object var)
|
2017-10-02 23:24:00 +02:00
|
|
|
{
|
|
|
|
return NativeCalls.godot_icall_Godot_var2bytes(var);
|
|
|
|
}
|
|
|
|
|
2017-11-21 23:32:19 +01:00
|
|
|
public static string Var2Str(object var)
|
2017-10-02 23:24:00 +02:00
|
|
|
{
|
|
|
|
return NativeCalls.godot_icall_Godot_var2str(var);
|
|
|
|
}
|
|
|
|
|
2017-11-21 23:32:19 +01:00
|
|
|
public static WeakRef Weakref(Object obj)
|
2017-10-02 23:24:00 +02:00
|
|
|
{
|
|
|
|
return NativeCalls.godot_icall_Godot_weakref(Object.GetPtr(obj));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|