1 /**
2 A Visual Script node used to call built-in functions.
3 
4 Copyright:
5 Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur.  
6 Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md)  
7 Copyright (c) 2017-2018 Godot-D contributors  
8 
9 License: $(LINK2 https://opensource.org/licenses/MIT, MIT License)
10 
11 
12 */
13 module godot.visualscriptbuiltinfunc;
14 import std.meta : AliasSeq, staticIndexOf;
15 import std.traits : Unqual;
16 import godot.d.traits;
17 import godot.core;
18 import godot.c;
19 import godot.d.bind;
20 import godot.d.reference;
21 import godot.globalenums;
22 import godot.object;
23 import godot.classdb;
24 import godot.visualscriptnode;
25 /**
26 A Visual Script node used to call built-in functions.
27 
28 A built-in function used inside a $(D VisualScript). It is usually a math function or an utility function.
29 See also $(D @GDScript), for the same functions in the GDScript language.
30 */
31 @GodotBaseClass struct VisualScriptBuiltinFunc
32 {
33 	package(godot) enum string _GODOT_internal_name = "VisualScriptBuiltinFunc";
34 public:
35 @nogc nothrow:
36 	union { /** */ godot_object _godot_object; /** */ VisualScriptNode _GODOT_base; }
37 	alias _GODOT_base this;
38 	alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses);
39 	package(godot) __gshared bool _classBindingInitialized = false;
40 	package(godot) static struct GDNativeClassBinding
41 	{
42 		__gshared:
43 		@GodotName("get_func") GodotMethod!(VisualScriptBuiltinFunc.BuiltinFunc) getFunc;
44 		@GodotName("set_func") GodotMethod!(void, long) setFunc;
45 	}
46 	/// 
47 	pragma(inline, true) bool opEquals(in VisualScriptBuiltinFunc other) const
48 	{ return _godot_object.ptr is other._godot_object.ptr; }
49 	/// 
50 	pragma(inline, true) typeof(null) opAssign(typeof(null) n)
51 	{ _godot_object.ptr = n; return null; }
52 	/// 
53 	pragma(inline, true) bool opEquals(typeof(null) n) const
54 	{ return _godot_object.ptr is n; }
55 	/// 
56 	size_t toHash() const @trusted { return cast(size_t)_godot_object.ptr; }
57 	mixin baseCasts;
58 	/// Construct a new instance of VisualScriptBuiltinFunc.
59 	/// Note: use `memnew!VisualScriptBuiltinFunc` instead.
60 	static VisualScriptBuiltinFunc _new()
61 	{
62 		static godot_class_constructor constructor;
63 		if(constructor is null) constructor = _godot_api.godot_get_class_constructor("VisualScriptBuiltinFunc");
64 		if(constructor is null) return typeof(this).init;
65 		return cast(VisualScriptBuiltinFunc)(constructor());
66 	}
67 	@disable new(size_t s);
68 	/// 
69 	enum BuiltinFunc : int
70 	{
71 		/**
72 		Return the sine of the input.
73 		*/
74 		mathSin = 0,
75 		/**
76 		Return the cosine of the input.
77 		*/
78 		mathCos = 1,
79 		/**
80 		Return the tangent of the input.
81 		*/
82 		mathTan = 2,
83 		/**
84 		Return the hyperbolic sine of the input.
85 		*/
86 		mathSinh = 3,
87 		/**
88 		Return the hyperbolic cosine of the input.
89 		*/
90 		mathCosh = 4,
91 		/**
92 		Return the hyperbolic tangent of the input.
93 		*/
94 		mathTanh = 5,
95 		/**
96 		Return the arc sine of the input.
97 		*/
98 		mathAsin = 6,
99 		/**
100 		Return the arc cosine of the input.
101 		*/
102 		mathAcos = 7,
103 		/**
104 		Return the arc tangent of the input.
105 		*/
106 		mathAtan = 8,
107 		/**
108 		Return the arc tangent of the input, using the signs of both parameters to determine the exact angle.
109 		*/
110 		mathAtan2 = 9,
111 		/**
112 		Return the square root of the input.
113 		*/
114 		mathSqrt = 10,
115 		/**
116 		Return the remainder of one input divided by the other, using floating-point numbers.
117 		*/
118 		mathFmod = 11,
119 		/**
120 		Return the positive remainder of one input divided by the other, using floating-point numbers.
121 		*/
122 		mathFposmod = 12,
123 		/**
124 		Return the input rounded down.
125 		*/
126 		mathFloor = 13,
127 		/**
128 		Return the input rounded up.
129 		*/
130 		mathCeil = 14,
131 		/**
132 		Return the input rounded to the nearest integer.
133 		*/
134 		mathRound = 15,
135 		/**
136 		Return the absolute value of the input.
137 		*/
138 		mathAbs = 16,
139 		/**
140 		Return the sign of the input, turning it into 1, -1, or 0. Useful to determine if the input is positive or negative.
141 		*/
142 		mathSign = 17,
143 		/**
144 		Return the input raised to a given power.
145 		*/
146 		mathPow = 18,
147 		/**
148 		Return the natural logarithm of the input. Note that this is not the typical base-10 logarithm function calculators use.
149 		*/
150 		mathLog = 19,
151 		/**
152 		Return the mathematical constant $(B e) raised to the specified power of the input. $(B e) has an approximate value of 2.71828.
153 		*/
154 		mathExp = 20,
155 		/**
156 		Return whether the input is NaN (Not a Number) or not. NaN is usually produced by dividing 0 by 0, though other ways exist.
157 		*/
158 		mathIsnan = 21,
159 		/**
160 		Return whether the input is an infinite floating-point number or not. Infinity is usually produced by dividing a number by 0, though other ways exist.
161 		*/
162 		mathIsinf = 22,
163 		/**
164 		Easing function, based on exponent. 0 is constant, 1 is linear, 0 to 1 is ease-in, 1+ is ease out. Negative values are in-out/out in.
165 		*/
166 		mathEase = 23,
167 		/**
168 		Return the number of digit places after the decimal that the first non-zero digit occurs.
169 		*/
170 		mathDecimals = 24,
171 		/**
172 		Return the input snapped to a given step.
173 		*/
174 		mathStepify = 25,
175 		/**
176 		Return a number linearly interpolated between the first two inputs, based on the third input. Uses the formula `a + (a - b) * t`.
177 		*/
178 		mathLerp = 26,
179 		/**
180 		
181 		*/
182 		mathInverseLerp = 27,
183 		/**
184 		
185 		*/
186 		mathRangeLerp = 28,
187 		/**
188 		Moves the number toward a value, based on the third input.
189 		*/
190 		mathMoveToward = 29,
191 		/**
192 		Return the result of `value` decreased by `step` * `amount`.
193 		*/
194 		mathDectime = 30,
195 		/**
196 		Randomize the seed (or the internal state) of the random number generator. Current implementation reseeds using a number based on time.
197 		*/
198 		mathRandomize = 31,
199 		/**
200 		Return a random 32 bits integer value. To obtain a random value between 0 to N (where N is smaller than 2^32 - 1), you can use it with the remainder function.
201 		*/
202 		mathRand = 32,
203 		/**
204 		Return a random floating-point value between 0 and 1. To obtain a random value between 0 to N, you can use it with multiplication.
205 		*/
206 		mathRandf = 33,
207 		/**
208 		Return a random floating-point value between the two inputs.
209 		*/
210 		mathRandom = 34,
211 		/**
212 		Set the seed for the random number generator.
213 		*/
214 		mathSeed = 35,
215 		/**
216 		Return a random value from the given seed, along with the new seed.
217 		*/
218 		mathRandseed = 36,
219 		/**
220 		Convert the input from degrees to radians.
221 		*/
222 		mathDeg2rad = 37,
223 		/**
224 		Convert the input from radians to degrees.
225 		*/
226 		mathRad2deg = 38,
227 		/**
228 		Convert the input from linear volume to decibel volume.
229 		*/
230 		mathLinear2db = 39,
231 		/**
232 		Convert the input from decibel volume to linear volume.
233 		*/
234 		mathDb2linear = 40,
235 		/**
236 		Converts a 2D point expressed in the polar coordinate system (a distance from the origin `r` and an angle `th`) to the cartesian coordinate system (X and Y axis).
237 		*/
238 		mathPolar2cartesian = 41,
239 		/**
240 		Converts a 2D point expressed in the cartesian coordinate system (X and Y axis) to the polar coordinate system (a distance from the origin and an angle).
241 		*/
242 		mathCartesian2polar = 42,
243 		/**
244 		
245 		*/
246 		mathWrap = 43,
247 		/**
248 		
249 		*/
250 		mathWrapf = 44,
251 		/**
252 		Return the greater of the two numbers, also known as their maximum.
253 		*/
254 		logicMax = 45,
255 		/**
256 		Return the lesser of the two numbers, also known as their minimum.
257 		*/
258 		logicMin = 46,
259 		/**
260 		Return the input clamped inside the given range, ensuring the result is never outside it. Equivalent to `min(max(input, range_low), range_high)`.
261 		*/
262 		logicClamp = 47,
263 		/**
264 		Return the nearest power of 2 to the input.
265 		*/
266 		logicNearestPo2 = 48,
267 		/**
268 		Create a $(D WeakRef) from the input.
269 		*/
270 		objWeakref = 49,
271 		/**
272 		Create a $(D FuncRef) from the input.
273 		*/
274 		funcFuncref = 50,
275 		/**
276 		Convert between types.
277 		*/
278 		typeConvert = 51,
279 		/**
280 		Return the type of the input as an integer. Check $(D Variant.type) for the integers that might be returned.
281 		*/
282 		typeOf = 52,
283 		/**
284 		Checks if a type is registered in the $(D ClassDB).
285 		*/
286 		typeExists = 53,
287 		/**
288 		Return a character with the given ascii value.
289 		*/
290 		textChar = 54,
291 		/**
292 		Convert the input to a string.
293 		*/
294 		textStr = 55,
295 		/**
296 		Print the given string to the output window.
297 		*/
298 		textPrint = 56,
299 		/**
300 		Print the given string to the standard error output.
301 		*/
302 		textPrinterr = 57,
303 		/**
304 		Print the given string to the standard output, without adding a newline.
305 		*/
306 		textPrintraw = 58,
307 		/**
308 		Serialize a $(D Variant) to a string.
309 		*/
310 		varToStr = 59,
311 		/**
312 		Deserialize a $(D Variant) from a string serialized using $(D constant VAR_TO_STR).
313 		*/
314 		strToVar = 60,
315 		/**
316 		Serialize a $(D Variant) to a $(D PoolByteArray).
317 		*/
318 		varToBytes = 61,
319 		/**
320 		Deserialize a $(D Variant) from a $(D PoolByteArray) serialized using $(D constant VAR_TO_BYTES).
321 		*/
322 		bytesToVar = 62,
323 		/**
324 		Return the $(D Color) with the given name and alpha ranging from 0 to 1.
325 		$(B Note:) Names are defined in `color_names.inc`.
326 		*/
327 		colorn = 63,
328 		/**
329 		Return a number smoothly interpolated between the first two inputs, based on the third input. Similar to $(D constant MATH_LERP), but interpolates faster at the beginning and slower at the end. Using Hermite interpolation formula:
330 		
331 		
332 		var t = clamp((weight - from) / (to - from), 0.0, 1.0)
333 		return t * t * (3.0 - 2.0 * t)
334 		
335 		
336 		*/
337 		mathSmoothstep = 64,
338 		/**
339 		
340 		*/
341 		mathPosmod = 65,
342 		/**
343 		
344 		*/
345 		mathLerpAngle = 66,
346 		/**
347 		
348 		*/
349 		textOrd = 67,
350 		/**
351 		Represents the size of the $(D builtinfunc) enum.
352 		*/
353 		funcMax = 68,
354 	}
355 	/// 
356 	enum Constants : int
357 	{
358 		mathSin = 0,
359 		mathCos = 1,
360 		mathTan = 2,
361 		mathSinh = 3,
362 		mathCosh = 4,
363 		mathTanh = 5,
364 		mathAsin = 6,
365 		mathAcos = 7,
366 		mathAtan = 8,
367 		mathAtan2 = 9,
368 		mathSqrt = 10,
369 		mathFmod = 11,
370 		mathFposmod = 12,
371 		mathFloor = 13,
372 		mathCeil = 14,
373 		mathRound = 15,
374 		mathAbs = 16,
375 		mathSign = 17,
376 		mathPow = 18,
377 		mathLog = 19,
378 		mathExp = 20,
379 		mathIsnan = 21,
380 		mathIsinf = 22,
381 		mathEase = 23,
382 		mathDecimals = 24,
383 		mathStepify = 25,
384 		mathLerp = 26,
385 		mathInverseLerp = 27,
386 		mathRangeLerp = 28,
387 		mathMoveToward = 29,
388 		mathDectime = 30,
389 		mathRandomize = 31,
390 		mathRand = 32,
391 		mathRandf = 33,
392 		mathRandom = 34,
393 		mathSeed = 35,
394 		mathRandseed = 36,
395 		mathDeg2rad = 37,
396 		mathRad2deg = 38,
397 		mathLinear2db = 39,
398 		mathDb2linear = 40,
399 		mathPolar2cartesian = 41,
400 		mathCartesian2polar = 42,
401 		mathWrap = 43,
402 		mathWrapf = 44,
403 		logicMax = 45,
404 		logicMin = 46,
405 		logicClamp = 47,
406 		logicNearestPo2 = 48,
407 		objWeakref = 49,
408 		funcFuncref = 50,
409 		typeConvert = 51,
410 		typeOf = 52,
411 		typeExists = 53,
412 		textChar = 54,
413 		textStr = 55,
414 		textPrint = 56,
415 		textPrinterr = 57,
416 		textPrintraw = 58,
417 		varToStr = 59,
418 		strToVar = 60,
419 		varToBytes = 61,
420 		bytesToVar = 62,
421 		colorn = 63,
422 		mathSmoothstep = 64,
423 		mathPosmod = 65,
424 		mathLerpAngle = 66,
425 		textOrd = 67,
426 		funcMax = 68,
427 	}
428 	/**
429 	
430 	*/
431 	VisualScriptBuiltinFunc.BuiltinFunc getFunc()
432 	{
433 		checkClassBinding!(typeof(this))();
434 		return ptrcall!(VisualScriptBuiltinFunc.BuiltinFunc)(GDNativeClassBinding.getFunc, _godot_object);
435 	}
436 	/**
437 	
438 	*/
439 	void setFunc(in long which)
440 	{
441 		checkClassBinding!(typeof(this))();
442 		ptrcall!(void)(GDNativeClassBinding.setFunc, _godot_object, which);
443 	}
444 	/**
445 	The function to be executed.
446 	*/
447 	@property VisualScriptBuiltinFunc.BuiltinFunc _function()
448 	{
449 		return getFunc();
450 	}
451 	/// ditto
452 	@property void _function(long v)
453 	{
454 		setFunc(v);
455 	}
456 }