visual_script_nodes.h 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070
  1. /**************************************************************************/
  2. /* visual_script_nodes.h */
  3. /**************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /**************************************************************************/
  8. /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
  9. /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /**************************************************************************/
  30. #ifndef VISUAL_SCRIPT_NODES_H
  31. #define VISUAL_SCRIPT_NODES_H
  32. #include "visual_script.h"
  33. class VisualScriptFunction : public VisualScriptNode {
  34. GDCLASS(VisualScriptFunction, VisualScriptNode);
  35. struct Argument {
  36. String name;
  37. Variant::Type type;
  38. PropertyHint hint;
  39. String hint_string;
  40. };
  41. Vector<Argument> arguments;
  42. bool stack_less;
  43. int stack_size;
  44. MultiplayerAPI::RPCMode rpc_mode;
  45. bool sequenced;
  46. protected:
  47. bool _set(const StringName &p_name, const Variant &p_value);
  48. bool _get(const StringName &p_name, Variant &r_ret) const;
  49. void _get_property_list(List<PropertyInfo> *p_list) const;
  50. public:
  51. virtual int get_output_sequence_port_count() const;
  52. virtual bool has_input_sequence_port() const;
  53. virtual String get_output_sequence_port_text(int p_port) const;
  54. virtual int get_input_value_port_count() const;
  55. virtual int get_output_value_port_count() const;
  56. virtual PropertyInfo get_input_value_port_info(int p_idx) const;
  57. virtual PropertyInfo get_output_value_port_info(int p_idx) const;
  58. virtual String get_caption() const;
  59. virtual String get_text() const;
  60. virtual String get_category() const { return "flow_control"; }
  61. void add_argument(Variant::Type p_type, const String &p_name, int p_index = -1, const PropertyHint p_hint = PROPERTY_HINT_NONE, const String &p_hint_string = String(""));
  62. void set_argument_type(int p_argidx, Variant::Type p_type);
  63. Variant::Type get_argument_type(int p_argidx) const;
  64. void set_argument_name(int p_argidx, const String &p_name);
  65. String get_argument_name(int p_argidx) const;
  66. void remove_argument(int p_argidx);
  67. int get_argument_count() const;
  68. void set_stack_less(bool p_enable);
  69. bool is_stack_less() const;
  70. void set_sequenced(bool p_enable);
  71. bool is_sequenced() const;
  72. void set_stack_size(int p_size);
  73. int get_stack_size() const;
  74. void set_rpc_mode(MultiplayerAPI::RPCMode p_mode);
  75. MultiplayerAPI::RPCMode get_rpc_mode() const;
  76. virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance);
  77. VisualScriptFunction();
  78. };
  79. class VisualScriptLists : public VisualScriptNode {
  80. GDCLASS(VisualScriptLists, VisualScriptNode)
  81. struct Port {
  82. String name;
  83. Variant::Type type;
  84. };
  85. protected:
  86. Vector<Port> inputports;
  87. Vector<Port> outputports;
  88. enum {
  89. OUTPUT_EDITABLE = 0x0001,
  90. OUTPUT_NAME_EDITABLE = 0x0002,
  91. OUTPUT_TYPE_EDITABLE = 0x0004,
  92. INPUT_EDITABLE = 0x0008,
  93. INPUT_NAME_EDITABLE = 0x000F,
  94. INPUT_TYPE_EDITABLE = 0x0010,
  95. };
  96. int flags;
  97. bool sequenced;
  98. bool _set(const StringName &p_name, const Variant &p_value);
  99. bool _get(const StringName &p_name, Variant &r_ret) const;
  100. void _get_property_list(List<PropertyInfo> *p_list) const;
  101. static void _bind_methods();
  102. public:
  103. virtual bool is_output_port_editable() const;
  104. virtual bool is_output_port_name_editable() const;
  105. virtual bool is_output_port_type_editable() const;
  106. virtual bool is_input_port_editable() const;
  107. virtual bool is_input_port_name_editable() const;
  108. virtual bool is_input_port_type_editable() const;
  109. virtual int get_output_sequence_port_count() const;
  110. virtual bool has_input_sequence_port() const;
  111. virtual String get_output_sequence_port_text(int p_port) const;
  112. virtual int get_input_value_port_count() const;
  113. virtual int get_output_value_port_count() const;
  114. virtual PropertyInfo get_input_value_port_info(int p_idx) const;
  115. virtual PropertyInfo get_output_value_port_info(int p_idx) const;
  116. virtual String get_caption() const = 0;
  117. virtual String get_text() const = 0;
  118. virtual String get_category() const = 0;
  119. void add_input_data_port(Variant::Type p_type, const String &p_name, int p_index = -1);
  120. void set_input_data_port_type(int p_idx, Variant::Type p_type);
  121. void set_input_data_port_name(int p_idx, const String &p_name);
  122. void remove_input_data_port(int p_argidx);
  123. void add_output_data_port(Variant::Type p_type, const String &p_name, int p_index = -1);
  124. void set_output_data_port_type(int p_idx, Variant::Type p_type);
  125. void set_output_data_port_name(int p_idx, const String &p_name);
  126. void remove_output_data_port(int p_argidx);
  127. void set_sequenced(bool p_enable);
  128. bool is_sequenced() const;
  129. VisualScriptLists();
  130. };
  131. class VisualScriptComposeArray : public VisualScriptLists {
  132. GDCLASS(VisualScriptComposeArray, VisualScriptLists)
  133. public:
  134. virtual int get_output_sequence_port_count() const;
  135. virtual bool has_input_sequence_port() const;
  136. virtual String get_output_sequence_port_text(int p_port) const;
  137. virtual int get_input_value_port_count() const;
  138. virtual int get_output_value_port_count() const;
  139. virtual PropertyInfo get_input_value_port_info(int p_idx) const;
  140. virtual PropertyInfo get_output_value_port_info(int p_idx) const;
  141. virtual String get_caption() const;
  142. virtual String get_text() const;
  143. virtual String get_category() const { return "functions"; }
  144. virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance);
  145. VisualScriptComposeArray();
  146. };
  147. class VisualScriptOperator : public VisualScriptNode {
  148. GDCLASS(VisualScriptOperator, VisualScriptNode);
  149. Variant::Type typed;
  150. Variant::Operator op;
  151. protected:
  152. static void _bind_methods();
  153. public:
  154. virtual int get_output_sequence_port_count() const;
  155. virtual bool has_input_sequence_port() const;
  156. virtual String get_output_sequence_port_text(int p_port) const;
  157. virtual int get_input_value_port_count() const;
  158. virtual int get_output_value_port_count() const;
  159. virtual PropertyInfo get_input_value_port_info(int p_idx) const;
  160. virtual PropertyInfo get_output_value_port_info(int p_idx) const;
  161. virtual String get_caption() const;
  162. virtual String get_category() const { return "operators"; }
  163. void set_operator(Variant::Operator p_op);
  164. Variant::Operator get_operator() const;
  165. void set_typed(Variant::Type p_op);
  166. Variant::Type get_typed() const;
  167. virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance);
  168. VisualScriptOperator();
  169. };
  170. class VisualScriptSelect : public VisualScriptNode {
  171. GDCLASS(VisualScriptSelect, VisualScriptNode);
  172. Variant::Type typed;
  173. protected:
  174. static void _bind_methods();
  175. public:
  176. virtual int get_output_sequence_port_count() const;
  177. virtual bool has_input_sequence_port() const;
  178. virtual String get_output_sequence_port_text(int p_port) const;
  179. virtual int get_input_value_port_count() const;
  180. virtual int get_output_value_port_count() const;
  181. virtual PropertyInfo get_input_value_port_info(int p_idx) const;
  182. virtual PropertyInfo get_output_value_port_info(int p_idx) const;
  183. virtual String get_caption() const;
  184. virtual String get_text() const;
  185. virtual String get_category() const { return "operators"; }
  186. void set_typed(Variant::Type p_op);
  187. Variant::Type get_typed() const;
  188. virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance);
  189. VisualScriptSelect();
  190. };
  191. class VisualScriptVariableGet : public VisualScriptNode {
  192. GDCLASS(VisualScriptVariableGet, VisualScriptNode);
  193. StringName variable;
  194. protected:
  195. virtual void _validate_property(PropertyInfo &property) const;
  196. static void _bind_methods();
  197. public:
  198. virtual int get_output_sequence_port_count() const;
  199. virtual bool has_input_sequence_port() const;
  200. virtual String get_output_sequence_port_text(int p_port) const;
  201. virtual int get_input_value_port_count() const;
  202. virtual int get_output_value_port_count() const;
  203. virtual PropertyInfo get_input_value_port_info(int p_idx) const;
  204. virtual PropertyInfo get_output_value_port_info(int p_idx) const;
  205. virtual String get_caption() const;
  206. virtual String get_category() const { return "data"; }
  207. void set_variable(StringName p_variable);
  208. StringName get_variable() const;
  209. virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance);
  210. VisualScriptVariableGet();
  211. };
  212. class VisualScriptVariableSet : public VisualScriptNode {
  213. GDCLASS(VisualScriptVariableSet, VisualScriptNode);
  214. StringName variable;
  215. protected:
  216. virtual void _validate_property(PropertyInfo &property) const;
  217. static void _bind_methods();
  218. public:
  219. virtual int get_output_sequence_port_count() const;
  220. virtual bool has_input_sequence_port() const;
  221. virtual String get_output_sequence_port_text(int p_port) const;
  222. virtual int get_input_value_port_count() const;
  223. virtual int get_output_value_port_count() const;
  224. virtual PropertyInfo get_input_value_port_info(int p_idx) const;
  225. virtual PropertyInfo get_output_value_port_info(int p_idx) const;
  226. virtual String get_caption() const;
  227. virtual String get_category() const { return "data"; }
  228. void set_variable(StringName p_variable);
  229. StringName get_variable() const;
  230. virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance);
  231. VisualScriptVariableSet();
  232. };
  233. class VisualScriptConstant : public VisualScriptNode {
  234. GDCLASS(VisualScriptConstant, VisualScriptNode);
  235. Variant::Type type;
  236. Variant value;
  237. protected:
  238. virtual void _validate_property(PropertyInfo &property) const;
  239. static void _bind_methods();
  240. public:
  241. virtual int get_output_sequence_port_count() const;
  242. virtual bool has_input_sequence_port() const;
  243. virtual String get_output_sequence_port_text(int p_port) const;
  244. virtual int get_input_value_port_count() const;
  245. virtual int get_output_value_port_count() const;
  246. virtual PropertyInfo get_input_value_port_info(int p_idx) const;
  247. virtual PropertyInfo get_output_value_port_info(int p_idx) const;
  248. virtual String get_caption() const;
  249. virtual String get_category() const { return "constants"; }
  250. void set_constant_type(Variant::Type p_type);
  251. Variant::Type get_constant_type() const;
  252. void set_constant_value(Variant p_value);
  253. Variant get_constant_value() const;
  254. virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance);
  255. VisualScriptConstant();
  256. };
  257. class VisualScriptPreload : public VisualScriptNode {
  258. GDCLASS(VisualScriptPreload, VisualScriptNode);
  259. Ref<Resource> preload;
  260. protected:
  261. static void _bind_methods();
  262. public:
  263. virtual int get_output_sequence_port_count() const;
  264. virtual bool has_input_sequence_port() const;
  265. virtual String get_output_sequence_port_text(int p_port) const;
  266. virtual int get_input_value_port_count() const;
  267. virtual int get_output_value_port_count() const;
  268. virtual PropertyInfo get_input_value_port_info(int p_idx) const;
  269. virtual PropertyInfo get_output_value_port_info(int p_idx) const;
  270. virtual String get_caption() const;
  271. virtual String get_category() const { return "data"; }
  272. void set_preload(const Ref<Resource> &p_preload);
  273. Ref<Resource> get_preload() const;
  274. virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance);
  275. VisualScriptPreload();
  276. };
  277. class VisualScriptIndexGet : public VisualScriptNode {
  278. GDCLASS(VisualScriptIndexGet, VisualScriptNode);
  279. public:
  280. virtual int get_output_sequence_port_count() const;
  281. virtual bool has_input_sequence_port() const;
  282. virtual String get_output_sequence_port_text(int p_port) const;
  283. virtual int get_input_value_port_count() const;
  284. virtual int get_output_value_port_count() const;
  285. virtual PropertyInfo get_input_value_port_info(int p_idx) const;
  286. virtual PropertyInfo get_output_value_port_info(int p_idx) const;
  287. virtual String get_caption() const;
  288. virtual String get_category() const { return "operators"; }
  289. virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance);
  290. VisualScriptIndexGet();
  291. };
  292. class VisualScriptIndexSet : public VisualScriptNode {
  293. GDCLASS(VisualScriptIndexSet, VisualScriptNode);
  294. public:
  295. virtual int get_output_sequence_port_count() const;
  296. virtual bool has_input_sequence_port() const;
  297. virtual String get_output_sequence_port_text(int p_port) const;
  298. virtual int get_input_value_port_count() const;
  299. virtual int get_output_value_port_count() const;
  300. virtual PropertyInfo get_input_value_port_info(int p_idx) const;
  301. virtual PropertyInfo get_output_value_port_info(int p_idx) const;
  302. virtual String get_caption() const;
  303. virtual String get_category() const { return "operators"; }
  304. virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance);
  305. VisualScriptIndexSet();
  306. };
  307. class VisualScriptGlobalConstant : public VisualScriptNode {
  308. GDCLASS(VisualScriptGlobalConstant, VisualScriptNode);
  309. int index;
  310. static void _bind_methods();
  311. public:
  312. virtual int get_output_sequence_port_count() const;
  313. virtual bool has_input_sequence_port() const;
  314. virtual String get_output_sequence_port_text(int p_port) const;
  315. virtual int get_input_value_port_count() const;
  316. virtual int get_output_value_port_count() const;
  317. virtual PropertyInfo get_input_value_port_info(int p_idx) const;
  318. virtual PropertyInfo get_output_value_port_info(int p_idx) const;
  319. virtual String get_caption() const;
  320. virtual String get_category() const { return "constants"; }
  321. void set_global_constant(int p_which);
  322. int get_global_constant();
  323. virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance);
  324. VisualScriptGlobalConstant();
  325. };
  326. class VisualScriptClassConstant : public VisualScriptNode {
  327. GDCLASS(VisualScriptClassConstant, VisualScriptNode);
  328. StringName base_type;
  329. StringName name;
  330. protected:
  331. static void _bind_methods();
  332. virtual void _validate_property(PropertyInfo &property) const;
  333. public:
  334. virtual int get_output_sequence_port_count() const;
  335. virtual bool has_input_sequence_port() const;
  336. virtual String get_output_sequence_port_text(int p_port) const;
  337. virtual int get_input_value_port_count() const;
  338. virtual int get_output_value_port_count() const;
  339. virtual PropertyInfo get_input_value_port_info(int p_idx) const;
  340. virtual PropertyInfo get_output_value_port_info(int p_idx) const;
  341. virtual String get_caption() const;
  342. virtual String get_category() const { return "constants"; }
  343. void set_class_constant(const StringName &p_which);
  344. StringName get_class_constant();
  345. void set_base_type(const StringName &p_which);
  346. StringName get_base_type();
  347. virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance);
  348. VisualScriptClassConstant();
  349. };
  350. class VisualScriptBasicTypeConstant : public VisualScriptNode {
  351. GDCLASS(VisualScriptBasicTypeConstant, VisualScriptNode);
  352. Variant::Type type;
  353. StringName name;
  354. protected:
  355. static void _bind_methods();
  356. virtual void _validate_property(PropertyInfo &property) const;
  357. public:
  358. virtual int get_output_sequence_port_count() const;
  359. virtual bool has_input_sequence_port() const;
  360. virtual String get_output_sequence_port_text(int p_port) const;
  361. virtual int get_input_value_port_count() const;
  362. virtual int get_output_value_port_count() const;
  363. virtual PropertyInfo get_input_value_port_info(int p_idx) const;
  364. virtual PropertyInfo get_output_value_port_info(int p_idx) const;
  365. virtual String get_caption() const;
  366. virtual String get_text() const;
  367. virtual String get_category() const { return "constants"; }
  368. void set_basic_type_constant(const StringName &p_which);
  369. StringName get_basic_type_constant() const;
  370. void set_basic_type(Variant::Type p_which);
  371. Variant::Type get_basic_type() const;
  372. virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance);
  373. VisualScriptBasicTypeConstant();
  374. };
  375. class VisualScriptMathConstant : public VisualScriptNode {
  376. GDCLASS(VisualScriptMathConstant, VisualScriptNode);
  377. public:
  378. enum MathConstant {
  379. MATH_CONSTANT_ONE,
  380. MATH_CONSTANT_PI,
  381. MATH_CONSTANT_HALF_PI,
  382. MATH_CONSTANT_TAU,
  383. MATH_CONSTANT_E,
  384. MATH_CONSTANT_SQRT2,
  385. MATH_CONSTANT_INF,
  386. MATH_CONSTANT_NAN,
  387. MATH_CONSTANT_MAX
  388. };
  389. private:
  390. static const char *const_name[MATH_CONSTANT_MAX];
  391. static double const_value[MATH_CONSTANT_MAX];
  392. MathConstant constant;
  393. protected:
  394. static void _bind_methods();
  395. public:
  396. virtual int get_output_sequence_port_count() const;
  397. virtual bool has_input_sequence_port() const;
  398. virtual String get_output_sequence_port_text(int p_port) const;
  399. virtual int get_input_value_port_count() const;
  400. virtual int get_output_value_port_count() const;
  401. virtual PropertyInfo get_input_value_port_info(int p_idx) const;
  402. virtual PropertyInfo get_output_value_port_info(int p_idx) const;
  403. virtual String get_caption() const;
  404. virtual String get_category() const { return "constants"; }
  405. void set_math_constant(MathConstant p_which);
  406. MathConstant get_math_constant();
  407. virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance);
  408. VisualScriptMathConstant();
  409. };
  410. VARIANT_ENUM_CAST(VisualScriptMathConstant::MathConstant)
  411. class VisualScriptEngineSingleton : public VisualScriptNode {
  412. GDCLASS(VisualScriptEngineSingleton, VisualScriptNode);
  413. String singleton;
  414. protected:
  415. void _validate_property(PropertyInfo &property) const;
  416. static void _bind_methods();
  417. public:
  418. virtual int get_output_sequence_port_count() const;
  419. virtual bool has_input_sequence_port() const;
  420. virtual String get_output_sequence_port_text(int p_port) const;
  421. virtual int get_input_value_port_count() const;
  422. virtual int get_output_value_port_count() const;
  423. virtual PropertyInfo get_input_value_port_info(int p_idx) const;
  424. virtual PropertyInfo get_output_value_port_info(int p_idx) const;
  425. virtual String get_caption() const;
  426. virtual String get_category() const { return "data"; }
  427. void set_singleton(const String &p_string);
  428. String get_singleton();
  429. virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance);
  430. virtual TypeGuess guess_output_type(TypeGuess *p_inputs, int p_output) const;
  431. VisualScriptEngineSingleton();
  432. };
  433. class VisualScriptSceneNode : public VisualScriptNode {
  434. GDCLASS(VisualScriptSceneNode, VisualScriptNode);
  435. NodePath path;
  436. protected:
  437. virtual void _validate_property(PropertyInfo &property) const;
  438. static void _bind_methods();
  439. public:
  440. virtual int get_output_sequence_port_count() const;
  441. virtual bool has_input_sequence_port() const;
  442. virtual String get_output_sequence_port_text(int p_port) const;
  443. virtual int get_input_value_port_count() const;
  444. virtual int get_output_value_port_count() const;
  445. virtual PropertyInfo get_input_value_port_info(int p_idx) const;
  446. virtual PropertyInfo get_output_value_port_info(int p_idx) const;
  447. virtual String get_caption() const;
  448. virtual String get_category() const { return "data"; }
  449. void set_node_path(const NodePath &p_path);
  450. NodePath get_node_path();
  451. virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance);
  452. virtual TypeGuess guess_output_type(TypeGuess *p_inputs, int p_output) const;
  453. VisualScriptSceneNode();
  454. };
  455. class VisualScriptSceneTree : public VisualScriptNode {
  456. GDCLASS(VisualScriptSceneTree, VisualScriptNode);
  457. protected:
  458. virtual void _validate_property(PropertyInfo &property) const;
  459. static void _bind_methods();
  460. public:
  461. virtual int get_output_sequence_port_count() const;
  462. virtual bool has_input_sequence_port() const;
  463. virtual String get_output_sequence_port_text(int p_port) const;
  464. virtual int get_input_value_port_count() const;
  465. virtual int get_output_value_port_count() const;
  466. virtual PropertyInfo get_input_value_port_info(int p_idx) const;
  467. virtual PropertyInfo get_output_value_port_info(int p_idx) const;
  468. virtual String get_caption() const;
  469. virtual String get_category() const { return "data"; }
  470. virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance);
  471. virtual TypeGuess guess_output_type(TypeGuess *p_inputs, int p_output) const;
  472. VisualScriptSceneTree();
  473. };
  474. class VisualScriptResourcePath : public VisualScriptNode {
  475. GDCLASS(VisualScriptResourcePath, VisualScriptNode);
  476. String path;
  477. protected:
  478. static void _bind_methods();
  479. public:
  480. virtual int get_output_sequence_port_count() const;
  481. virtual bool has_input_sequence_port() const;
  482. virtual String get_output_sequence_port_text(int p_port) const;
  483. virtual int get_input_value_port_count() const;
  484. virtual int get_output_value_port_count() const;
  485. virtual PropertyInfo get_input_value_port_info(int p_idx) const;
  486. virtual PropertyInfo get_output_value_port_info(int p_idx) const;
  487. virtual String get_caption() const;
  488. virtual String get_category() const { return "data"; }
  489. void set_resource_path(const String &p_path);
  490. String get_resource_path();
  491. virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance);
  492. VisualScriptResourcePath();
  493. };
  494. class VisualScriptSelf : public VisualScriptNode {
  495. GDCLASS(VisualScriptSelf, VisualScriptNode);
  496. protected:
  497. static void _bind_methods();
  498. public:
  499. virtual int get_output_sequence_port_count() const;
  500. virtual bool has_input_sequence_port() const;
  501. virtual String get_output_sequence_port_text(int p_port) const;
  502. virtual int get_input_value_port_count() const;
  503. virtual int get_output_value_port_count() const;
  504. virtual PropertyInfo get_input_value_port_info(int p_idx) const;
  505. virtual PropertyInfo get_output_value_port_info(int p_idx) const;
  506. virtual String get_caption() const;
  507. virtual String get_category() const { return "data"; }
  508. virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance);
  509. virtual TypeGuess guess_output_type(TypeGuess *p_inputs, int p_output) const;
  510. VisualScriptSelf();
  511. };
  512. class VisualScriptCustomNode : public VisualScriptNode {
  513. GDCLASS(VisualScriptCustomNode, VisualScriptNode);
  514. protected:
  515. static void _bind_methods();
  516. public:
  517. enum StartMode { //replicated for step
  518. START_MODE_BEGIN_SEQUENCE,
  519. START_MODE_CONTINUE_SEQUENCE,
  520. START_MODE_RESUME_YIELD
  521. };
  522. enum { //replicated for step
  523. STEP_SHIFT = 1 << 24,
  524. STEP_MASK = STEP_SHIFT - 1,
  525. STEP_PUSH_STACK_BIT = STEP_SHIFT, //push bit to stack
  526. STEP_GO_BACK_BIT = STEP_SHIFT << 1, //go back to previous node
  527. STEP_NO_ADVANCE_BIT = STEP_SHIFT << 2, //do not advance past this node
  528. STEP_EXIT_FUNCTION_BIT = STEP_SHIFT << 3, //return from function
  529. STEP_YIELD_BIT = STEP_SHIFT << 4, //yield (will find VisualScriptFunctionState state in first working memory)
  530. };
  531. virtual int get_output_sequence_port_count() const;
  532. virtual bool has_input_sequence_port() const;
  533. virtual String get_output_sequence_port_text(int p_port) const;
  534. virtual int get_input_value_port_count() const;
  535. virtual int get_output_value_port_count() const;
  536. virtual PropertyInfo get_input_value_port_info(int p_idx) const;
  537. virtual PropertyInfo get_output_value_port_info(int p_idx) const;
  538. virtual String get_caption() const;
  539. virtual String get_text() const;
  540. virtual String get_category() const;
  541. virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance);
  542. virtual TypeGuess guess_output_type(TypeGuess *p_inputs, int p_output) const;
  543. void _script_changed();
  544. VisualScriptCustomNode();
  545. };
  546. VARIANT_ENUM_CAST(VisualScriptCustomNode::StartMode);
  547. class VisualScriptSubCall : public VisualScriptNode {
  548. GDCLASS(VisualScriptSubCall, VisualScriptNode);
  549. protected:
  550. static void _bind_methods();
  551. public:
  552. virtual int get_output_sequence_port_count() const;
  553. virtual bool has_input_sequence_port() const;
  554. virtual String get_output_sequence_port_text(int p_port) const;
  555. virtual int get_input_value_port_count() const;
  556. virtual int get_output_value_port_count() const;
  557. virtual PropertyInfo get_input_value_port_info(int p_idx) const;
  558. virtual PropertyInfo get_output_value_port_info(int p_idx) const;
  559. virtual String get_caption() const;
  560. virtual String get_text() const;
  561. virtual String get_category() const;
  562. virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance);
  563. VisualScriptSubCall();
  564. };
  565. class VisualScriptComment : public VisualScriptNode {
  566. GDCLASS(VisualScriptComment, VisualScriptNode);
  567. String title;
  568. String description;
  569. Size2 size;
  570. protected:
  571. static void _bind_methods();
  572. public:
  573. virtual int get_output_sequence_port_count() const;
  574. virtual bool has_input_sequence_port() const;
  575. virtual String get_output_sequence_port_text(int p_port) const;
  576. virtual int get_input_value_port_count() const;
  577. virtual int get_output_value_port_count() const;
  578. virtual PropertyInfo get_input_value_port_info(int p_idx) const;
  579. virtual PropertyInfo get_output_value_port_info(int p_idx) const;
  580. virtual String get_caption() const;
  581. virtual String get_text() const;
  582. virtual String get_category() const;
  583. void set_title(const String &p_title);
  584. String get_title() const;
  585. void set_description(const String &p_description);
  586. String get_description() const;
  587. void set_size(const Size2 &p_size);
  588. Size2 get_size() const;
  589. virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance);
  590. VisualScriptComment();
  591. };
  592. class VisualScriptConstructor : public VisualScriptNode {
  593. GDCLASS(VisualScriptConstructor, VisualScriptNode);
  594. Variant::Type type;
  595. MethodInfo constructor;
  596. protected:
  597. static void _bind_methods();
  598. public:
  599. virtual int get_output_sequence_port_count() const;
  600. virtual bool has_input_sequence_port() const;
  601. virtual String get_output_sequence_port_text(int p_port) const;
  602. virtual int get_input_value_port_count() const;
  603. virtual int get_output_value_port_count() const;
  604. virtual PropertyInfo get_input_value_port_info(int p_idx) const;
  605. virtual PropertyInfo get_output_value_port_info(int p_idx) const;
  606. virtual String get_caption() const;
  607. virtual String get_category() const;
  608. void set_constructor_type(Variant::Type p_type);
  609. Variant::Type get_constructor_type() const;
  610. void set_constructor(const Dictionary &p_info);
  611. Dictionary get_constructor() const;
  612. virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance);
  613. VisualScriptConstructor();
  614. };
  615. class VisualScriptLocalVar : public VisualScriptNode {
  616. GDCLASS(VisualScriptLocalVar, VisualScriptNode);
  617. StringName name;
  618. Variant::Type type;
  619. protected:
  620. static void _bind_methods();
  621. public:
  622. virtual int get_output_sequence_port_count() const;
  623. virtual bool has_input_sequence_port() const;
  624. virtual String get_output_sequence_port_text(int p_port) const;
  625. virtual int get_input_value_port_count() const;
  626. virtual int get_output_value_port_count() const;
  627. virtual PropertyInfo get_input_value_port_info(int p_idx) const;
  628. virtual PropertyInfo get_output_value_port_info(int p_idx) const;
  629. virtual String get_caption() const;
  630. virtual String get_category() const;
  631. void set_var_name(const StringName &p_name);
  632. StringName get_var_name() const;
  633. void set_var_type(Variant::Type p_type);
  634. Variant::Type get_var_type() const;
  635. virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance);
  636. VisualScriptLocalVar();
  637. };
  638. class VisualScriptLocalVarSet : public VisualScriptNode {
  639. GDCLASS(VisualScriptLocalVarSet, VisualScriptNode);
  640. StringName name;
  641. Variant::Type type;
  642. protected:
  643. static void _bind_methods();
  644. public:
  645. virtual int get_output_sequence_port_count() const;
  646. virtual bool has_input_sequence_port() const;
  647. virtual String get_output_sequence_port_text(int p_port) const;
  648. virtual int get_input_value_port_count() const;
  649. virtual int get_output_value_port_count() const;
  650. virtual PropertyInfo get_input_value_port_info(int p_idx) const;
  651. virtual PropertyInfo get_output_value_port_info(int p_idx) const;
  652. virtual String get_caption() const;
  653. virtual String get_text() const;
  654. virtual String get_category() const;
  655. void set_var_name(const StringName &p_name);
  656. StringName get_var_name() const;
  657. void set_var_type(Variant::Type p_type);
  658. Variant::Type get_var_type() const;
  659. virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance);
  660. VisualScriptLocalVarSet();
  661. };
  662. class VisualScriptInputAction : public VisualScriptNode {
  663. GDCLASS(VisualScriptInputAction, VisualScriptNode);
  664. public:
  665. enum Mode {
  666. MODE_PRESSED,
  667. MODE_RELEASED,
  668. MODE_JUST_PRESSED,
  669. MODE_JUST_RELEASED,
  670. };
  671. StringName name;
  672. Mode mode;
  673. protected:
  674. virtual void _validate_property(PropertyInfo &property) const;
  675. static void _bind_methods();
  676. public:
  677. virtual int get_output_sequence_port_count() const;
  678. virtual bool has_input_sequence_port() const;
  679. virtual String get_output_sequence_port_text(int p_port) const;
  680. virtual int get_input_value_port_count() const;
  681. virtual int get_output_value_port_count() const;
  682. virtual PropertyInfo get_input_value_port_info(int p_idx) const;
  683. virtual PropertyInfo get_output_value_port_info(int p_idx) const;
  684. virtual String get_caption() const;
  685. virtual String get_category() const;
  686. void set_action_name(const StringName &p_name);
  687. StringName get_action_name() const;
  688. void set_action_mode(Mode p_mode);
  689. Mode get_action_mode() const;
  690. virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance);
  691. VisualScriptInputAction();
  692. };
  693. VARIANT_ENUM_CAST(VisualScriptInputAction::Mode)
  694. class VisualScriptDeconstruct : public VisualScriptNode {
  695. GDCLASS(VisualScriptDeconstruct, VisualScriptNode);
  696. struct Element {
  697. StringName name;
  698. Variant::Type type;
  699. };
  700. Vector<Element> elements;
  701. void _update_elements();
  702. Variant::Type type;
  703. void _set_elem_cache(const Array &p_elements);
  704. Array _get_elem_cache() const;
  705. virtual void _validate_property(PropertyInfo &property) const;
  706. protected:
  707. static void _bind_methods();
  708. public:
  709. virtual int get_output_sequence_port_count() const;
  710. virtual bool has_input_sequence_port() const;
  711. virtual String get_output_sequence_port_text(int p_port) const;
  712. virtual int get_input_value_port_count() const;
  713. virtual int get_output_value_port_count() const;
  714. virtual PropertyInfo get_input_value_port_info(int p_idx) const;
  715. virtual PropertyInfo get_output_value_port_info(int p_idx) const;
  716. virtual String get_caption() const;
  717. virtual String get_category() const;
  718. void set_deconstruct_type(Variant::Type p_type);
  719. Variant::Type get_deconstruct_type() const;
  720. virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance);
  721. VisualScriptDeconstruct();
  722. };
  723. void register_visual_script_nodes();
  724. void unregister_visual_script_nodes();
  725. #ifdef TOOLS_ENABLED
  726. namespace NSVisualScript {
  727. Node *_find_script_node(Node *p_edited_scene, Node *p_current_node, const Ref<Script> &script);
  728. }
  729. #endif
  730. #endif // VISUAL_SCRIPT_NODES_H