[Mono] Improvements to GD.cs: PascalCasing and real_t

[Mono] Improvements to GD.cs: PascalCasing and real_t

(cherry picked from commit 174cf31d00)
This commit is contained in:
Aaron Franke 2018-07-21 16:40:34 -05:00 committed by Hein-Pieter van Braam
parent ba441c48b0
commit 3304c7620a
1 changed files with 20 additions and 15 deletions

View File

@ -1,4 +1,9 @@
using System; using System;
#if REAL_T_IS_DOUBLE
using real_t = System.Double;
#else
using real_t = System.Single;
#endif
// TODO: Add comments describing what this class does. It is not obvious. // TODO: Add comments describing what this class does. It is not obvious.
@ -16,22 +21,22 @@ namespace Godot
return NativeCalls.godot_icall_Godot_convert(what, type); return NativeCalls.godot_icall_Godot_convert(what, type);
} }
public static float Db2Linear(float db) public static real_t Db2Linear(real_t db)
{ {
return (float)Math.Exp(db * 0.11512925464970228420089957273422); return (real_t)Math.Exp(db * 0.11512925464970228420089957273422);
} }
public static float Dectime(float value, float amount, float step) public static real_t DecTime(real_t value, real_t amount, real_t step)
{ {
float sgn = value < 0 ? -1.0f : 1.0f; real_t sgn = Mathf.Sign(value);
float val = Mathf.Abs(value); real_t val = Mathf.Abs(value);
val -= amount * step; val -= amount * step;
if (val < 0.0f) if (val < 0)
val = 0.0f; val = 0;
return val * sgn; return val * sgn;
} }
public static FuncRef Funcref(Object instance, string funcname) public static FuncRef FuncRef(Object instance, string funcname)
{ {
var ret = new FuncRef(); var ret = new FuncRef();
ret.SetInstance(instance); ret.SetInstance(instance);
@ -49,9 +54,9 @@ namespace Godot
return NativeCalls.godot_icall_Godot_instance_from_id(instanceId); return NativeCalls.godot_icall_Godot_instance_from_id(instanceId);
} }
public static double Linear2Db(double linear) public static real_t Linear2Db(real_t linear)
{ {
return Math.Log(linear) * 8.6858896380650365530225783783321; return (real_t)(Math.Log(linear) * 8.6858896380650365530225783783321);
} }
public static Resource Load(string path) public static Resource Load(string path)
@ -69,22 +74,22 @@ namespace Godot
Print(System.Environment.StackTrace); Print(System.Environment.StackTrace);
} }
public static void Printerr(params object[] what) public static void PrintErr(params object[] what)
{ {
NativeCalls.godot_icall_Godot_printerr(what); NativeCalls.godot_icall_Godot_printerr(what);
} }
public static void Printraw(params object[] what) public static void PrintRaw(params object[] what)
{ {
NativeCalls.godot_icall_Godot_printraw(what); NativeCalls.godot_icall_Godot_printraw(what);
} }
public static void Prints(params object[] what) public static void PrintS(params object[] what)
{ {
NativeCalls.godot_icall_Godot_prints(what); NativeCalls.godot_icall_Godot_prints(what);
} }
public static void Printt(params object[] what) public static void PrintT(params object[] what)
{ {
NativeCalls.godot_icall_Godot_printt(what); NativeCalls.godot_icall_Godot_printt(what);
} }
@ -183,7 +188,7 @@ namespace Godot
return NativeCalls.godot_icall_Godot_var2str(var); return NativeCalls.godot_icall_Godot_var2str(var);
} }
public static WeakRef Weakref(Object obj) public static WeakRef WeakRef(Object obj)
{ {
return NativeCalls.godot_icall_Godot_weakref(Object.GetPtr(obj)); return NativeCalls.godot_icall_Godot_weakref(Object.GetPtr(obj));
} }