1 /**
2 A scripted Visual Script node.
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.visualscriptcustomnode;
14 import std.meta : AliasSeq, staticIndexOf;
15 import std.traits : Unqual;
16 import godot.d.meta;
17 import godot.core;
18 import godot.c;
19 import godot.d.bind;
20 import godot.d.reference;
21 import godot.object;
22 import godot.classdb;
23 import godot.visualscriptnode;
24 import godot.resource;
25 import godot.reference;
26 /**
27 A scripted Visual Script node.
28 
29 A custom Visual Script node which can be scripted in powerful ways.
30 */
31 @GodotBaseClass struct VisualScriptCustomNode
32 {
33 	enum string _GODOT_internal_name = "VisualScriptCustomNode";
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 _classBinding
41 	{
42 		__gshared:
43 		@GodotName("_get_output_sequence_port_count") GodotMethod!(long) _getOutputSequencePortCount;
44 		@GodotName("_has_input_sequence_port") GodotMethod!(bool) _hasInputSequencePort;
45 		@GodotName("_get_output_sequence_port_text") GodotMethod!(String, long) _getOutputSequencePortText;
46 		@GodotName("_get_input_value_port_count") GodotMethod!(long) _getInputValuePortCount;
47 		@GodotName("_get_output_value_port_count") GodotMethod!(long) _getOutputValuePortCount;
48 		@GodotName("_get_input_value_port_type") GodotMethod!(long, long) _getInputValuePortType;
49 		@GodotName("_get_input_value_port_name") GodotMethod!(String, long) _getInputValuePortName;
50 		@GodotName("_get_output_value_port_type") GodotMethod!(long, long) _getOutputValuePortType;
51 		@GodotName("_get_output_value_port_name") GodotMethod!(String, long) _getOutputValuePortName;
52 		@GodotName("_get_caption") GodotMethod!(String) _getCaption;
53 		@GodotName("_get_text") GodotMethod!(String) _getText;
54 		@GodotName("_get_category") GodotMethod!(String) _getCategory;
55 		@GodotName("_get_working_memory_size") GodotMethod!(long) _getWorkingMemorySize;
56 		@GodotName("_step") GodotMethod!(Variant, Array, Array, long, Array) _step;
57 		@GodotName("_script_changed") GodotMethod!(void) _scriptChanged;
58 	}
59 	bool opEquals(in VisualScriptCustomNode other) const { return _godot_object.ptr is other._godot_object.ptr; }
60 	VisualScriptCustomNode opAssign(T : typeof(null))(T n) { _godot_object.ptr = null; }
61 	bool opEquals(typeof(null) n) const { return _godot_object.ptr is null; }
62 	mixin baseCasts;
63 	static VisualScriptCustomNode _new()
64 	{
65 		static godot_class_constructor constructor;
66 		if(constructor is null) constructor = _godot_api.godot_get_class_constructor("VisualScriptCustomNode");
67 		if(constructor is null) return typeof(this).init;
68 		return cast(VisualScriptCustomNode)(constructor());
69 	}
70 	@disable new(size_t s);
71 	/// 
72 	enum StartMode : int
73 	{
74 		/**
75 		The start mode used the first time when $(D _step) is called.
76 		*/
77 		startModeBeginSequence = 0,
78 		/**
79 		The start mode used when $(D _step) is called after coming back from a STEP_PUSH_STACK_BIT.
80 		*/
81 		startModeContinueSequence = 1,
82 		/**
83 		The start mode used when $(D _step) is called after resuming from STEP_YIELD_BIT.
84 		*/
85 		startModeResumeYield = 2,
86 	}
87 	/// 
88 	enum Constants : int
89 	{
90 		startModeBeginSequence = 0,
91 		startModeContinueSequence = 1,
92 		startModeResumeYield = 2,
93 		/**
94 		Hint used by $(D _step) to tell that control should return to it when there is no other node left to execute.
95 		This is used by $(D VisualScriptCondition) to redirect the sequence to the "Done" port after the true/false branch has finished execution.
96 		*/
97 		stepPushStackBit = 16777216,
98 		/**
99 		Hint used by $(D _step) to tell that control should return back, either hitting a previous STEP_PUSH_STACK_BIT or exiting the function.
100 		*/
101 		stepGoBackBit = 33554432,
102 		/**
103 		
104 		*/
105 		stepNoAdvanceBit = 67108864,
106 		/**
107 		Hint used by $(D _step) to tell that control should stop and exit the function.
108 		*/
109 		stepExitFunctionBit = 134217728,
110 		/**
111 		Hint used by $(D _step) to tell that the function should be yielded.
112 		Using this requires you to have at least one working memory slot, which is used for the $(D VisualScriptFunctionState).
113 		*/
114 		stepYieldBit = 268435456,
115 	}
116 	/**
117 	Return the amount of output $(B sequence) ports.
118 	*/
119 	long _getOutputSequencePortCount()
120 	{
121 		Array _GODOT_args = Array.empty_array;
122 		String _GODOT_method_name = String("_get_output_sequence_port_count");
123 		return this.callv(_GODOT_method_name, _GODOT_args).as!(RefOrT!long);
124 	}
125 	/**
126 	Return whether the custom node has an input $(B sequence) port.
127 	*/
128 	bool _hasInputSequencePort()
129 	{
130 		Array _GODOT_args = Array.empty_array;
131 		String _GODOT_method_name = String("_has_input_sequence_port");
132 		return this.callv(_GODOT_method_name, _GODOT_args).as!(RefOrT!bool);
133 	}
134 	/**
135 	Return the specified $(B sequence) output's name.
136 	*/
137 	String _getOutputSequencePortText(in long idx)
138 	{
139 		Array _GODOT_args = Array.empty_array;
140 		_GODOT_args.append(idx);
141 		String _GODOT_method_name = String("_get_output_sequence_port_text");
142 		return this.callv(_GODOT_method_name, _GODOT_args).as!(RefOrT!String);
143 	}
144 	/**
145 	Return the count of input value ports.
146 	*/
147 	long _getInputValuePortCount()
148 	{
149 		Array _GODOT_args = Array.empty_array;
150 		String _GODOT_method_name = String("_get_input_value_port_count");
151 		return this.callv(_GODOT_method_name, _GODOT_args).as!(RefOrT!long);
152 	}
153 	/**
154 	Return the amount of output value ports.
155 	*/
156 	long _getOutputValuePortCount()
157 	{
158 		Array _GODOT_args = Array.empty_array;
159 		String _GODOT_method_name = String("_get_output_value_port_count");
160 		return this.callv(_GODOT_method_name, _GODOT_args).as!(RefOrT!long);
161 	}
162 	/**
163 	Return the specified input port's type. See the TYPE_* enum in $(D @GlobalScope).
164 	*/
165 	long _getInputValuePortType(in long idx)
166 	{
167 		Array _GODOT_args = Array.empty_array;
168 		_GODOT_args.append(idx);
169 		String _GODOT_method_name = String("_get_input_value_port_type");
170 		return this.callv(_GODOT_method_name, _GODOT_args).as!(RefOrT!long);
171 	}
172 	/**
173 	Return the specified input port's name.
174 	*/
175 	String _getInputValuePortName(in long idx)
176 	{
177 		Array _GODOT_args = Array.empty_array;
178 		_GODOT_args.append(idx);
179 		String _GODOT_method_name = String("_get_input_value_port_name");
180 		return this.callv(_GODOT_method_name, _GODOT_args).as!(RefOrT!String);
181 	}
182 	/**
183 	Return the specified output's type. See the TYPE_* enum in $(D @GlobalScope).
184 	*/
185 	long _getOutputValuePortType(in long idx)
186 	{
187 		Array _GODOT_args = Array.empty_array;
188 		_GODOT_args.append(idx);
189 		String _GODOT_method_name = String("_get_output_value_port_type");
190 		return this.callv(_GODOT_method_name, _GODOT_args).as!(RefOrT!long);
191 	}
192 	/**
193 	Return the specified output's name.
194 	*/
195 	String _getOutputValuePortName(in long idx)
196 	{
197 		Array _GODOT_args = Array.empty_array;
198 		_GODOT_args.append(idx);
199 		String _GODOT_method_name = String("_get_output_value_port_name");
200 		return this.callv(_GODOT_method_name, _GODOT_args).as!(RefOrT!String);
201 	}
202 	/**
203 	Return the node's title.
204 	*/
205 	String _getCaption()
206 	{
207 		Array _GODOT_args = Array.empty_array;
208 		String _GODOT_method_name = String("_get_caption");
209 		return this.callv(_GODOT_method_name, _GODOT_args).as!(RefOrT!String);
210 	}
211 	/**
212 	Return the custom node's text, which is shown right next to the input $(B sequence) port (if there is none, on the place that is usually taken by it).
213 	*/
214 	String _getText()
215 	{
216 		Array _GODOT_args = Array.empty_array;
217 		String _GODOT_method_name = String("_get_text");
218 		return this.callv(_GODOT_method_name, _GODOT_args).as!(RefOrT!String);
219 	}
220 	/**
221 	Return the node's category.
222 	*/
223 	String _getCategory()
224 	{
225 		Array _GODOT_args = Array.empty_array;
226 		String _GODOT_method_name = String("_get_category");
227 		return this.callv(_GODOT_method_name, _GODOT_args).as!(RefOrT!String);
228 	}
229 	/**
230 	Return the size of the custom node's working memory. See $(D _step) for more details.
231 	*/
232 	long _getWorkingMemorySize()
233 	{
234 		Array _GODOT_args = Array.empty_array;
235 		String _GODOT_method_name = String("_get_working_memory_size");
236 		return this.callv(_GODOT_method_name, _GODOT_args).as!(RefOrT!long);
237 	}
238 	/**
239 	Execute the custom node's logic, returning the index of the output sequence port to use or a $(D String) when there is an error.
240 	
241 	The `inputs` array contains the values of the input ports.
242 	`outputs` is an array whose indices should be set to the respective outputs.
243 	The `start_mode` is usually `START_MODE_BEGIN_SEQUENCE`, unless you have used the STEP_* constants.
244 	`working_mem` is an array which can be used to persist information between runs of the custom node.
245 	
246 	When returning, you can mask the returned value with one of the STEP_* constants.
247 	*/
248 	Variant _step(in Array inputs, in Array outputs, in long start_mode, in Array working_mem)
249 	{
250 		Array _GODOT_args = Array.empty_array;
251 		_GODOT_args.append(inputs);
252 		_GODOT_args.append(outputs);
253 		_GODOT_args.append(start_mode);
254 		_GODOT_args.append(working_mem);
255 		String _GODOT_method_name = String("_step");
256 		return this.callv(_GODOT_method_name, _GODOT_args);
257 	}
258 	/**
259 	
260 	*/
261 	void _scriptChanged()
262 	{
263 		Array _GODOT_args = Array.empty_array;
264 		String _GODOT_method_name = String("_script_changed");
265 		this.callv(_GODOT_method_name, _GODOT_args);
266 	}
267 }