visual_script_nodes.h 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994
  1. /*************************************************************************/
  2. /* visual_script_nodes.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
  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_return_type_enabled(bool p_returns);
  75. bool is_return_type_enabled() const;
  76. void set_return_type(Variant::Type p_type);
  77. Variant::Type get_return_type() const;
  78. void set_rpc_mode(MultiplayerAPI::RPCMode p_mode);
  79. MultiplayerAPI::RPCMode get_rpc_mode() const;
  80. virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance);
  81. VisualScriptFunction();
  82. };
  83. class VisualScriptOperator : public VisualScriptNode {
  84. GDCLASS(VisualScriptOperator, VisualScriptNode)
  85. Variant::Type typed;
  86. Variant::Operator op;
  87. protected:
  88. static void _bind_methods();
  89. public:
  90. virtual int get_output_sequence_port_count() const;
  91. virtual bool has_input_sequence_port() const;
  92. virtual String get_output_sequence_port_text(int p_port) const;
  93. virtual int get_input_value_port_count() const;
  94. virtual int get_output_value_port_count() const;
  95. virtual PropertyInfo get_input_value_port_info(int p_idx) const;
  96. virtual PropertyInfo get_output_value_port_info(int p_idx) const;
  97. virtual String get_caption() const;
  98. virtual String get_category() const { return "operators"; }
  99. void set_operator(Variant::Operator p_op);
  100. Variant::Operator get_operator() const;
  101. void set_typed(Variant::Type p_op);
  102. Variant::Type get_typed() const;
  103. virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance);
  104. VisualScriptOperator();
  105. };
  106. class VisualScriptSelect : public VisualScriptNode {
  107. GDCLASS(VisualScriptSelect, VisualScriptNode)
  108. Variant::Type typed;
  109. protected:
  110. static void _bind_methods();
  111. public:
  112. virtual int get_output_sequence_port_count() const;
  113. virtual bool has_input_sequence_port() const;
  114. virtual String get_output_sequence_port_text(int p_port) const;
  115. virtual int get_input_value_port_count() const;
  116. virtual int get_output_value_port_count() const;
  117. virtual PropertyInfo get_input_value_port_info(int p_idx) const;
  118. virtual PropertyInfo get_output_value_port_info(int p_idx) const;
  119. virtual String get_caption() const;
  120. virtual String get_text() const;
  121. virtual String get_category() const { return "operators"; }
  122. void set_typed(Variant::Type p_op);
  123. Variant::Type get_typed() const;
  124. virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance);
  125. VisualScriptSelect();
  126. };
  127. class VisualScriptVariableGet : public VisualScriptNode {
  128. GDCLASS(VisualScriptVariableGet, VisualScriptNode)
  129. StringName variable;
  130. protected:
  131. virtual void _validate_property(PropertyInfo &property) const;
  132. static void _bind_methods();
  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_category() const { return "data"; }
  143. void set_variable(StringName p_variable);
  144. StringName get_variable() const;
  145. virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance);
  146. VisualScriptVariableGet();
  147. };
  148. class VisualScriptVariableSet : public VisualScriptNode {
  149. GDCLASS(VisualScriptVariableSet, VisualScriptNode)
  150. StringName variable;
  151. protected:
  152. virtual void _validate_property(PropertyInfo &property) const;
  153. static void _bind_methods();
  154. public:
  155. virtual int get_output_sequence_port_count() const;
  156. virtual bool has_input_sequence_port() const;
  157. virtual String get_output_sequence_port_text(int p_port) const;
  158. virtual int get_input_value_port_count() const;
  159. virtual int get_output_value_port_count() const;
  160. virtual PropertyInfo get_input_value_port_info(int p_idx) const;
  161. virtual PropertyInfo get_output_value_port_info(int p_idx) const;
  162. virtual String get_caption() const;
  163. virtual String get_category() const { return "data"; }
  164. void set_variable(StringName p_variable);
  165. StringName get_variable() const;
  166. virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance);
  167. VisualScriptVariableSet();
  168. };
  169. class VisualScriptConstant : public VisualScriptNode {
  170. GDCLASS(VisualScriptConstant, VisualScriptNode)
  171. Variant::Type type;
  172. Variant value;
  173. protected:
  174. virtual void _validate_property(PropertyInfo &property) const;
  175. static void _bind_methods();
  176. public:
  177. virtual int get_output_sequence_port_count() const;
  178. virtual bool has_input_sequence_port() const;
  179. virtual String get_output_sequence_port_text(int p_port) const;
  180. virtual int get_input_value_port_count() const;
  181. virtual int get_output_value_port_count() const;
  182. virtual PropertyInfo get_input_value_port_info(int p_idx) const;
  183. virtual PropertyInfo get_output_value_port_info(int p_idx) const;
  184. virtual String get_caption() const;
  185. virtual String get_category() const { return "constants"; }
  186. void set_constant_type(Variant::Type p_type);
  187. Variant::Type get_constant_type() const;
  188. void set_constant_value(Variant p_value);
  189. Variant get_constant_value() const;
  190. virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance);
  191. VisualScriptConstant();
  192. };
  193. class VisualScriptPreload : public VisualScriptNode {
  194. GDCLASS(VisualScriptPreload, VisualScriptNode)
  195. Ref<Resource> preload;
  196. protected:
  197. static void _bind_methods();
  198. public:
  199. virtual int get_output_sequence_port_count() const;
  200. virtual bool has_input_sequence_port() const;
  201. virtual String get_output_sequence_port_text(int p_port) const;
  202. virtual int get_input_value_port_count() const;
  203. virtual int get_output_value_port_count() const;
  204. virtual PropertyInfo get_input_value_port_info(int p_idx) const;
  205. virtual PropertyInfo get_output_value_port_info(int p_idx) const;
  206. virtual String get_caption() const;
  207. virtual String get_category() const { return "data"; }
  208. void set_preload(const Ref<Resource> &p_preload);
  209. Ref<Resource> get_preload() const;
  210. virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance);
  211. VisualScriptPreload();
  212. };
  213. class VisualScriptIndexGet : public VisualScriptNode {
  214. GDCLASS(VisualScriptIndexGet, VisualScriptNode)
  215. public:
  216. virtual int get_output_sequence_port_count() const;
  217. virtual bool has_input_sequence_port() const;
  218. virtual String get_output_sequence_port_text(int p_port) const;
  219. virtual int get_input_value_port_count() const;
  220. virtual int get_output_value_port_count() const;
  221. virtual PropertyInfo get_input_value_port_info(int p_idx) const;
  222. virtual PropertyInfo get_output_value_port_info(int p_idx) const;
  223. virtual String get_caption() const;
  224. virtual String get_category() const { return "operators"; }
  225. virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance);
  226. VisualScriptIndexGet();
  227. };
  228. class VisualScriptIndexSet : public VisualScriptNode {
  229. GDCLASS(VisualScriptIndexSet, VisualScriptNode)
  230. public:
  231. virtual int get_output_sequence_port_count() const;
  232. virtual bool has_input_sequence_port() const;
  233. virtual String get_output_sequence_port_text(int p_port) const;
  234. virtual int get_input_value_port_count() const;
  235. virtual int get_output_value_port_count() const;
  236. virtual PropertyInfo get_input_value_port_info(int p_idx) const;
  237. virtual PropertyInfo get_output_value_port_info(int p_idx) const;
  238. virtual String get_caption() const;
  239. virtual String get_category() const { return "operators"; }
  240. virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance);
  241. VisualScriptIndexSet();
  242. };
  243. class VisualScriptGlobalConstant : public VisualScriptNode {
  244. GDCLASS(VisualScriptGlobalConstant, VisualScriptNode)
  245. int index;
  246. static void _bind_methods();
  247. public:
  248. virtual int get_output_sequence_port_count() const;
  249. virtual bool has_input_sequence_port() const;
  250. virtual String get_output_sequence_port_text(int p_port) const;
  251. virtual int get_input_value_port_count() const;
  252. virtual int get_output_value_port_count() const;
  253. virtual PropertyInfo get_input_value_port_info(int p_idx) const;
  254. virtual PropertyInfo get_output_value_port_info(int p_idx) const;
  255. virtual String get_caption() const;
  256. virtual String get_category() const { return "constants"; }
  257. void set_global_constant(int p_which);
  258. int get_global_constant();
  259. virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance);
  260. VisualScriptGlobalConstant();
  261. };
  262. class VisualScriptClassConstant : public VisualScriptNode {
  263. GDCLASS(VisualScriptClassConstant, VisualScriptNode)
  264. StringName base_type;
  265. StringName name;
  266. protected:
  267. static void _bind_methods();
  268. virtual void _validate_property(PropertyInfo &property) const;
  269. public:
  270. virtual int get_output_sequence_port_count() const;
  271. virtual bool has_input_sequence_port() const;
  272. virtual String get_output_sequence_port_text(int p_port) const;
  273. virtual int get_input_value_port_count() const;
  274. virtual int get_output_value_port_count() const;
  275. virtual PropertyInfo get_input_value_port_info(int p_idx) const;
  276. virtual PropertyInfo get_output_value_port_info(int p_idx) const;
  277. virtual String get_caption() const;
  278. virtual String get_category() const { return "constants"; }
  279. void set_class_constant(const StringName &p_which);
  280. StringName get_class_constant();
  281. void set_base_type(const StringName &p_which);
  282. StringName get_base_type();
  283. virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance);
  284. VisualScriptClassConstant();
  285. };
  286. class VisualScriptBasicTypeConstant : public VisualScriptNode {
  287. GDCLASS(VisualScriptBasicTypeConstant, VisualScriptNode)
  288. Variant::Type type;
  289. StringName name;
  290. protected:
  291. static void _bind_methods();
  292. virtual void _validate_property(PropertyInfo &property) const;
  293. public:
  294. virtual int get_output_sequence_port_count() const;
  295. virtual bool has_input_sequence_port() const;
  296. virtual String get_output_sequence_port_text(int p_port) const;
  297. virtual int get_input_value_port_count() const;
  298. virtual int get_output_value_port_count() const;
  299. virtual PropertyInfo get_input_value_port_info(int p_idx) const;
  300. virtual PropertyInfo get_output_value_port_info(int p_idx) const;
  301. virtual String get_caption() const;
  302. virtual String get_text() const;
  303. virtual String get_category() const { return "constants"; }
  304. void set_basic_type_constant(const StringName &p_which);
  305. StringName get_basic_type_constant() const;
  306. void set_basic_type(Variant::Type p_which);
  307. Variant::Type get_basic_type() const;
  308. virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance);
  309. VisualScriptBasicTypeConstant();
  310. };
  311. class VisualScriptMathConstant : public VisualScriptNode {
  312. GDCLASS(VisualScriptMathConstant, VisualScriptNode)
  313. public:
  314. enum MathConstant {
  315. MATH_CONSTANT_ONE,
  316. MATH_CONSTANT_PI,
  317. MATH_CONSTANT_HALF_PI,
  318. MATH_CONSTANT_TAU,
  319. MATH_CONSTANT_E,
  320. MATH_CONSTANT_SQRT2,
  321. MATH_CONSTANT_INF,
  322. MATH_CONSTANT_NAN,
  323. MATH_CONSTANT_MAX
  324. };
  325. private:
  326. static const char *const_name[MATH_CONSTANT_MAX];
  327. static double const_value[MATH_CONSTANT_MAX];
  328. MathConstant constant;
  329. protected:
  330. static void _bind_methods();
  331. public:
  332. virtual int get_output_sequence_port_count() const;
  333. virtual bool has_input_sequence_port() const;
  334. virtual String get_output_sequence_port_text(int p_port) const;
  335. virtual int get_input_value_port_count() const;
  336. virtual int get_output_value_port_count() const;
  337. virtual PropertyInfo get_input_value_port_info(int p_idx) const;
  338. virtual PropertyInfo get_output_value_port_info(int p_idx) const;
  339. virtual String get_caption() const;
  340. virtual String get_category() const { return "constants"; }
  341. void set_math_constant(MathConstant p_which);
  342. MathConstant get_math_constant();
  343. virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance);
  344. VisualScriptMathConstant();
  345. };
  346. VARIANT_ENUM_CAST(VisualScriptMathConstant::MathConstant)
  347. class VisualScriptEngineSingleton : public VisualScriptNode {
  348. GDCLASS(VisualScriptEngineSingleton, VisualScriptNode)
  349. String singleton;
  350. static void _bind_methods();
  351. public:
  352. virtual int get_output_sequence_port_count() const;
  353. virtual bool has_input_sequence_port() const;
  354. virtual String get_output_sequence_port_text(int p_port) const;
  355. virtual int get_input_value_port_count() const;
  356. virtual int get_output_value_port_count() const;
  357. virtual PropertyInfo get_input_value_port_info(int p_idx) const;
  358. virtual PropertyInfo get_output_value_port_info(int p_idx) const;
  359. virtual String get_caption() const;
  360. virtual String get_category() const { return "data"; }
  361. void set_singleton(const String &p_string);
  362. String get_singleton();
  363. virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance);
  364. virtual TypeGuess guess_output_type(TypeGuess *p_inputs, int p_output) const;
  365. VisualScriptEngineSingleton();
  366. };
  367. class VisualScriptSceneNode : public VisualScriptNode {
  368. GDCLASS(VisualScriptSceneNode, VisualScriptNode)
  369. NodePath path;
  370. protected:
  371. virtual void _validate_property(PropertyInfo &property) const;
  372. static void _bind_methods();
  373. public:
  374. virtual int get_output_sequence_port_count() const;
  375. virtual bool has_input_sequence_port() const;
  376. virtual String get_output_sequence_port_text(int p_port) const;
  377. virtual int get_input_value_port_count() const;
  378. virtual int get_output_value_port_count() const;
  379. virtual PropertyInfo get_input_value_port_info(int p_idx) const;
  380. virtual PropertyInfo get_output_value_port_info(int p_idx) const;
  381. virtual String get_caption() const;
  382. virtual String get_category() const { return "data"; }
  383. void set_node_path(const NodePath &p_path);
  384. NodePath get_node_path();
  385. virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance);
  386. virtual TypeGuess guess_output_type(TypeGuess *p_inputs, int p_output) const;
  387. VisualScriptSceneNode();
  388. };
  389. class VisualScriptSceneTree : public VisualScriptNode {
  390. GDCLASS(VisualScriptSceneTree, VisualScriptNode)
  391. protected:
  392. virtual void _validate_property(PropertyInfo &property) const;
  393. static void _bind_methods();
  394. public:
  395. virtual int get_output_sequence_port_count() const;
  396. virtual bool has_input_sequence_port() const;
  397. virtual String get_output_sequence_port_text(int p_port) const;
  398. virtual int get_input_value_port_count() const;
  399. virtual int get_output_value_port_count() const;
  400. virtual PropertyInfo get_input_value_port_info(int p_idx) const;
  401. virtual PropertyInfo get_output_value_port_info(int p_idx) const;
  402. virtual String get_caption() const;
  403. virtual String get_category() const { return "data"; }
  404. virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance);
  405. virtual TypeGuess guess_output_type(TypeGuess *p_inputs, int p_output) const;
  406. VisualScriptSceneTree();
  407. };
  408. class VisualScriptResourcePath : public VisualScriptNode {
  409. GDCLASS(VisualScriptResourcePath, VisualScriptNode)
  410. String path;
  411. protected:
  412. static void _bind_methods();
  413. public:
  414. virtual int get_output_sequence_port_count() const;
  415. virtual bool has_input_sequence_port() const;
  416. virtual String get_output_sequence_port_text(int p_port) const;
  417. virtual int get_input_value_port_count() const;
  418. virtual int get_output_value_port_count() const;
  419. virtual PropertyInfo get_input_value_port_info(int p_idx) const;
  420. virtual PropertyInfo get_output_value_port_info(int p_idx) const;
  421. virtual String get_caption() const;
  422. virtual String get_category() const { return "data"; }
  423. void set_resource_path(const String &p_path);
  424. String get_resource_path();
  425. virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance);
  426. VisualScriptResourcePath();
  427. };
  428. class VisualScriptSelf : public VisualScriptNode {
  429. GDCLASS(VisualScriptSelf, VisualScriptNode)
  430. protected:
  431. static void _bind_methods();
  432. public:
  433. virtual int get_output_sequence_port_count() const;
  434. virtual bool has_input_sequence_port() const;
  435. virtual String get_output_sequence_port_text(int p_port) const;
  436. virtual int get_input_value_port_count() const;
  437. virtual int get_output_value_port_count() const;
  438. virtual PropertyInfo get_input_value_port_info(int p_idx) const;
  439. virtual PropertyInfo get_output_value_port_info(int p_idx) const;
  440. virtual String get_caption() const;
  441. virtual String get_category() const { return "data"; }
  442. virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance);
  443. virtual TypeGuess guess_output_type(TypeGuess *p_inputs, int p_output) const;
  444. VisualScriptSelf();
  445. };
  446. class VisualScriptCustomNode : public VisualScriptNode {
  447. GDCLASS(VisualScriptCustomNode, VisualScriptNode)
  448. protected:
  449. static void _bind_methods();
  450. public:
  451. enum StartMode { //replicated for step
  452. START_MODE_BEGIN_SEQUENCE,
  453. START_MODE_CONTINUE_SEQUENCE,
  454. START_MODE_RESUME_YIELD
  455. };
  456. enum { //replicated for step
  457. STEP_SHIFT = 1 << 24,
  458. STEP_MASK = STEP_SHIFT - 1,
  459. STEP_PUSH_STACK_BIT = STEP_SHIFT, //push bit to stack
  460. STEP_GO_BACK_BIT = STEP_SHIFT << 1, //go back to previous node
  461. STEP_NO_ADVANCE_BIT = STEP_SHIFT << 2, //do not advance past this node
  462. STEP_EXIT_FUNCTION_BIT = STEP_SHIFT << 3, //return from function
  463. STEP_YIELD_BIT = STEP_SHIFT << 4, //yield (will find VisualScriptFunctionState state in first working memory)
  464. };
  465. virtual int get_output_sequence_port_count() const;
  466. virtual bool has_input_sequence_port() const;
  467. virtual String get_output_sequence_port_text(int p_port) const;
  468. virtual int get_input_value_port_count() const;
  469. virtual int get_output_value_port_count() const;
  470. virtual PropertyInfo get_input_value_port_info(int p_idx) const;
  471. virtual PropertyInfo get_output_value_port_info(int p_idx) const;
  472. virtual String get_caption() const;
  473. virtual String get_text() const;
  474. virtual String get_category() const;
  475. virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance);
  476. void _script_changed();
  477. VisualScriptCustomNode();
  478. };
  479. VARIANT_ENUM_CAST(VisualScriptCustomNode::StartMode);
  480. class VisualScriptSubCall : public VisualScriptNode {
  481. GDCLASS(VisualScriptSubCall, VisualScriptNode)
  482. protected:
  483. static void _bind_methods();
  484. public:
  485. virtual int get_output_sequence_port_count() const;
  486. virtual bool has_input_sequence_port() const;
  487. virtual String get_output_sequence_port_text(int p_port) const;
  488. virtual int get_input_value_port_count() const;
  489. virtual int get_output_value_port_count() const;
  490. virtual PropertyInfo get_input_value_port_info(int p_idx) const;
  491. virtual PropertyInfo get_output_value_port_info(int p_idx) const;
  492. virtual String get_caption() const;
  493. virtual String get_text() const;
  494. virtual String get_category() const;
  495. virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance);
  496. VisualScriptSubCall();
  497. };
  498. class VisualScriptComment : public VisualScriptNode {
  499. GDCLASS(VisualScriptComment, VisualScriptNode)
  500. String title;
  501. String description;
  502. Size2 size;
  503. protected:
  504. static void _bind_methods();
  505. public:
  506. virtual int get_output_sequence_port_count() const;
  507. virtual bool has_input_sequence_port() const;
  508. virtual String get_output_sequence_port_text(int p_port) const;
  509. virtual int get_input_value_port_count() const;
  510. virtual int get_output_value_port_count() const;
  511. virtual PropertyInfo get_input_value_port_info(int p_idx) const;
  512. virtual PropertyInfo get_output_value_port_info(int p_idx) const;
  513. virtual String get_caption() const;
  514. virtual String get_text() const;
  515. virtual String get_category() const;
  516. void set_title(const String &p_title);
  517. String get_title() const;
  518. void set_description(const String &p_description);
  519. String get_description() const;
  520. void set_size(const Size2 &p_size);
  521. Size2 get_size() const;
  522. virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance);
  523. VisualScriptComment();
  524. };
  525. class VisualScriptConstructor : public VisualScriptNode {
  526. GDCLASS(VisualScriptConstructor, VisualScriptNode)
  527. Variant::Type type;
  528. MethodInfo constructor;
  529. protected:
  530. static void _bind_methods();
  531. public:
  532. virtual int get_output_sequence_port_count() const;
  533. virtual bool has_input_sequence_port() const;
  534. virtual String get_output_sequence_port_text(int p_port) const;
  535. virtual int get_input_value_port_count() const;
  536. virtual int get_output_value_port_count() const;
  537. virtual PropertyInfo get_input_value_port_info(int p_idx) const;
  538. virtual PropertyInfo get_output_value_port_info(int p_idx) const;
  539. virtual String get_caption() const;
  540. virtual String get_category() const;
  541. void set_constructor_type(Variant::Type p_type);
  542. Variant::Type get_constructor_type() const;
  543. void set_constructor(const Dictionary &p_info);
  544. Dictionary get_constructor() const;
  545. virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance);
  546. VisualScriptConstructor();
  547. };
  548. class VisualScriptLocalVar : public VisualScriptNode {
  549. GDCLASS(VisualScriptLocalVar, VisualScriptNode)
  550. StringName name;
  551. Variant::Type type;
  552. protected:
  553. static void _bind_methods();
  554. public:
  555. virtual int get_output_sequence_port_count() const;
  556. virtual bool has_input_sequence_port() const;
  557. virtual String get_output_sequence_port_text(int p_port) const;
  558. virtual int get_input_value_port_count() const;
  559. virtual int get_output_value_port_count() const;
  560. virtual PropertyInfo get_input_value_port_info(int p_idx) const;
  561. virtual PropertyInfo get_output_value_port_info(int p_idx) const;
  562. virtual String get_caption() const;
  563. virtual String get_category() const;
  564. void set_var_name(const StringName &p_name);
  565. StringName get_var_name() const;
  566. void set_var_type(Variant::Type p_type);
  567. Variant::Type get_var_type() const;
  568. virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance);
  569. VisualScriptLocalVar();
  570. };
  571. class VisualScriptLocalVarSet : public VisualScriptNode {
  572. GDCLASS(VisualScriptLocalVarSet, VisualScriptNode)
  573. StringName name;
  574. Variant::Type type;
  575. protected:
  576. static void _bind_methods();
  577. public:
  578. virtual int get_output_sequence_port_count() const;
  579. virtual bool has_input_sequence_port() const;
  580. virtual String get_output_sequence_port_text(int p_port) const;
  581. virtual int get_input_value_port_count() const;
  582. virtual int get_output_value_port_count() const;
  583. virtual PropertyInfo get_input_value_port_info(int p_idx) const;
  584. virtual PropertyInfo get_output_value_port_info(int p_idx) const;
  585. virtual String get_caption() const;
  586. virtual String get_text() const;
  587. virtual String get_category() const;
  588. void set_var_name(const StringName &p_name);
  589. StringName get_var_name() const;
  590. void set_var_type(Variant::Type p_type);
  591. Variant::Type get_var_type() const;
  592. virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance);
  593. VisualScriptLocalVarSet();
  594. };
  595. class VisualScriptInputAction : public VisualScriptNode {
  596. GDCLASS(VisualScriptInputAction, VisualScriptNode)
  597. public:
  598. enum Mode {
  599. MODE_PRESSED,
  600. MODE_RELEASED,
  601. MODE_JUST_PRESSED,
  602. MODE_JUST_RELEASED,
  603. };
  604. StringName name;
  605. Mode mode;
  606. protected:
  607. virtual void _validate_property(PropertyInfo &property) const;
  608. static void _bind_methods();
  609. public:
  610. virtual int get_output_sequence_port_count() const;
  611. virtual bool has_input_sequence_port() const;
  612. virtual String get_output_sequence_port_text(int p_port) const;
  613. virtual int get_input_value_port_count() const;
  614. virtual int get_output_value_port_count() const;
  615. virtual PropertyInfo get_input_value_port_info(int p_idx) const;
  616. virtual PropertyInfo get_output_value_port_info(int p_idx) const;
  617. virtual String get_caption() const;
  618. virtual String get_category() const;
  619. void set_action_name(const StringName &p_name);
  620. StringName get_action_name() const;
  621. void set_action_mode(Mode p_mode);
  622. Mode get_action_mode() const;
  623. virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance);
  624. VisualScriptInputAction();
  625. };
  626. VARIANT_ENUM_CAST(VisualScriptInputAction::Mode)
  627. class VisualScriptDeconstruct : public VisualScriptNode {
  628. GDCLASS(VisualScriptDeconstruct, VisualScriptNode)
  629. struct Element {
  630. StringName name;
  631. Variant::Type type;
  632. };
  633. Vector<Element> elements;
  634. void _update_elements();
  635. Variant::Type type;
  636. void _set_elem_cache(const Array &p_elements);
  637. Array _get_elem_cache() const;
  638. virtual void _validate_property(PropertyInfo &property) const;
  639. protected:
  640. static void _bind_methods();
  641. public:
  642. virtual int get_output_sequence_port_count() const;
  643. virtual bool has_input_sequence_port() const;
  644. virtual String get_output_sequence_port_text(int p_port) const;
  645. virtual int get_input_value_port_count() const;
  646. virtual int get_output_value_port_count() const;
  647. virtual PropertyInfo get_input_value_port_info(int p_idx) const;
  648. virtual PropertyInfo get_output_value_port_info(int p_idx) const;
  649. virtual String get_caption() const;
  650. virtual String get_category() const;
  651. void set_deconstruct_type(Variant::Type p_type);
  652. Variant::Type get_deconstruct_type() const;
  653. virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance);
  654. VisualScriptDeconstruct();
  655. };
  656. void register_visual_script_nodes();
  657. void unregister_visual_script_nodes();
  658. #endif // VISUAL_SCRIPT_NODES_H