virtualx-engine/modules/mono/glue/Managed/Files/GD.cs

267 lines
7.9 KiB
C#
Raw Normal View History

2017-10-02 23:24:00 +02:00
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
#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
// TODO: Add comments describing what this class does. It is not obvious.
2017-10-02 23:24:00 +02:00
namespace Godot
{
public static partial class GD
2017-10-02 23:24:00 +02:00
{
public static object Bytes2Var(byte[] bytes, bool allow_objects = false)
2017-10-02 23:24:00 +02:00
{
return godot_icall_GD_bytes2var(bytes, allow_objects);
2017-10-02 23:24:00 +02:00
}
public static object Convert(object what, Variant.Type type)
2017-10-02 23:24:00 +02:00
{
return godot_icall_GD_convert(what, type);
2017-10-02 23:24:00 +02:00
}
public static real_t Db2Linear(real_t db)
2017-10-02 23:24:00 +02:00
{
return (real_t)Math.Exp(db * 0.11512925464970228420089957273422);
2017-10-02 23:24:00 +02:00
}
public static real_t DecTime(real_t value, real_t amount, real_t step)
2017-10-02 23:24:00 +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;
if (val < 0)
val = 0;
2017-10-02 23:24:00 +02:00
return val * sgn;
}
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 godot_icall_GD_hash(var);
2017-10-02 23:24:00 +02:00
}
2019-02-19 00:35:19 +01:00
public static Object InstanceFromId(ulong instanceId)
2017-10-02 23:24:00 +02:00
{
return godot_icall_GD_instance_from_id(instanceId);
2017-10-02 23:24:00 +02:00
}
public static real_t Linear2Db(real_t linear)
2017-10-02 23:24:00 +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);
}
public static T Load<T>(string path) where T : class
{
return ResourceLoader.Load<T>(path);
}
public static void PushError(string message)
2018-10-26 05:32:50 +02:00
{
godot_icall_GD_pusherror(message);
2018-10-26 05:32:50 +02:00
}
public static void PushWarning(string message)
2018-10-26 05:32:50 +02: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
{
godot_icall_GD_print(Array.ConvertAll(what, x => x.ToString()));
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
}
public static void PrintErr(params object[] what)
2017-10-02 23:24:00 +02:00
{
godot_icall_GD_printerr(Array.ConvertAll(what, x => x.ToString()));
2017-10-02 23:24:00 +02:00
}
public static void PrintRaw(params object[] what)
2017-10-02 23:24:00 +02:00
{
godot_icall_GD_printraw(Array.ConvertAll(what, x => x.ToString()));
2017-10-02 23:24:00 +02:00
}
public static void PrintS(params object[] what)
2017-10-02 23:24:00 +02:00
{
godot_icall_GD_prints(Array.ConvertAll(what, x => x.ToString()));
2017-10-02 23:24:00 +02:00
}
public static void PrintT(params object[] what)
2017-10-02 23:24:00 +02:00
{
godot_icall_GD_printt(Array.ConvertAll(what, x => x.ToString()));
2017-10-02 23:24:00 +02:00
}
public static float Randf()
2019-02-19 00:35:19 +01:00
{
return godot_icall_GD_randf();
}
public static uint Randi()
{
return godot_icall_GD_randi();
}
public static void Randomize()
{
godot_icall_GD_randomize();
}
public static double RandRange(double from, double to)
2019-02-19 00:35:19 +01:00
{
return godot_icall_GD_rand_range(from, to);
}
public static uint RandSeed(ulong seed, out ulong newSeed)
{
return godot_icall_GD_rand_seed(seed, out newSeed);
}
public static IEnumerable<int> Range(int end)
2017-10-02 23:24:00 +02:00
{
return Range(0, end, 1);
2017-10-02 23:24:00 +02:00
}
public static IEnumerable<int> Range(int start, int end)
2017-10-02 23:24:00 +02:00
{
return Range(start, end, 1);
2017-10-02 23:24:00 +02:00
}
public static IEnumerable<int> Range(int start, int end, int step)
2017-10-02 23:24:00 +02:00
{
if (end < start && step > 0)
yield break;
2017-10-02 23:24:00 +02:00
if (end > start && step < 0)
yield break;
2017-10-02 23:24:00 +02:00
if (step > 0)
2017-10-02 23:24:00 +02:00
{
for (int i = start; i < end; i += step)
yield return i;
2017-10-02 23:24:00 +02:00
}
else
{
for (int i = start; i > end; i += step)
yield return i;
2017-10-02 23:24:00 +02:00
}
}
2019-02-19 00:35:19 +01:00
public static void Seed(ulong seed)
2017-10-02 23:24:00 +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
{
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
{
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
{
return godot_icall_GD_type_exists(type);
2017-10-02 23:24:00 +02:00
}
public static byte[] Var2Bytes(object var, bool full_objects = false)
2017-10-02 23:24:00 +02:00
{
return godot_icall_GD_var2bytes(var, full_objects);
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
{
return godot_icall_GD_var2str(var);
2017-10-02 23:24:00 +02:00
}
[MethodImpl(MethodImplOptions.InternalCall)]
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, Variant.Type type);
[MethodImpl(MethodImplOptions.InternalCall)]
internal extern static int godot_icall_GD_hash(object var);
[MethodImpl(MethodImplOptions.InternalCall)]
2019-02-19 00:35:19 +01:00
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);
[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 float godot_icall_GD_randf();
2019-02-19 00:35:19 +01:00
[MethodImpl(MethodImplOptions.InternalCall)]
internal extern static uint godot_icall_GD_randi();
[MethodImpl(MethodImplOptions.InternalCall)]
internal extern static void godot_icall_GD_randomize();
2019-02-19 00:35:19 +01:00
[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);
[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, bool full_objects);
[MethodImpl(MethodImplOptions.InternalCall)]
internal extern static string godot_icall_GD_var2str(object var);
2018-10-26 05:32:50 +02:00
[MethodImpl(MethodImplOptions.InternalCall)]
internal extern static void godot_icall_GD_pusherror(string type);
2018-10-26 05:32:50 +02:00
[MethodImpl(MethodImplOptions.InternalCall)]
internal extern static void godot_icall_GD_pushwarning(string type);
2017-10-02 23:24:00 +02:00
}
}