visual_script_flow_control.h 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. /*************************************************************************/
  2. /* visual_script_flow_control.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_FLOW_CONTROL_H
  31. #define VISUAL_SCRIPT_FLOW_CONTROL_H
  32. #include "visual_script.h"
  33. class VisualScriptReturn : public VisualScriptNode {
  34. GDCLASS(VisualScriptReturn, VisualScriptNode)
  35. Variant::Type type;
  36. bool with_value;
  37. protected:
  38. static void _bind_methods();
  39. public:
  40. virtual int get_output_sequence_port_count() const;
  41. virtual bool has_input_sequence_port() const;
  42. virtual String get_output_sequence_port_text(int p_port) const;
  43. virtual int get_input_value_port_count() const;
  44. virtual int get_output_value_port_count() const;
  45. virtual PropertyInfo get_input_value_port_info(int p_idx) const;
  46. virtual PropertyInfo get_output_value_port_info(int p_idx) const;
  47. virtual String get_caption() const;
  48. virtual String get_text() const;
  49. virtual String get_category() const { return "flow_control"; }
  50. void set_return_type(Variant::Type);
  51. Variant::Type get_return_type() const;
  52. void set_enable_return_value(bool p_enable);
  53. bool is_return_value_enabled() const;
  54. virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance);
  55. VisualScriptReturn();
  56. };
  57. class VisualScriptCondition : public VisualScriptNode {
  58. GDCLASS(VisualScriptCondition, VisualScriptNode)
  59. protected:
  60. static void _bind_methods();
  61. public:
  62. virtual int get_output_sequence_port_count() const;
  63. virtual bool has_input_sequence_port() const;
  64. virtual String get_output_sequence_port_text(int p_port) const;
  65. virtual int get_input_value_port_count() const;
  66. virtual int get_output_value_port_count() const;
  67. virtual PropertyInfo get_input_value_port_info(int p_idx) const;
  68. virtual PropertyInfo get_output_value_port_info(int p_idx) const;
  69. virtual String get_caption() const;
  70. virtual String get_text() const;
  71. virtual String get_category() const { return "flow_control"; }
  72. virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance);
  73. VisualScriptCondition();
  74. };
  75. class VisualScriptWhile : public VisualScriptNode {
  76. GDCLASS(VisualScriptWhile, VisualScriptNode)
  77. protected:
  78. static void _bind_methods();
  79. public:
  80. virtual int get_output_sequence_port_count() const;
  81. virtual bool has_input_sequence_port() const;
  82. virtual String get_output_sequence_port_text(int p_port) const;
  83. virtual int get_input_value_port_count() const;
  84. virtual int get_output_value_port_count() const;
  85. virtual PropertyInfo get_input_value_port_info(int p_idx) const;
  86. virtual PropertyInfo get_output_value_port_info(int p_idx) const;
  87. virtual String get_caption() const;
  88. virtual String get_text() const;
  89. virtual String get_category() const { return "flow_control"; }
  90. virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance);
  91. VisualScriptWhile();
  92. };
  93. class VisualScriptIterator : public VisualScriptNode {
  94. GDCLASS(VisualScriptIterator, VisualScriptNode)
  95. protected:
  96. static void _bind_methods();
  97. public:
  98. virtual int get_output_sequence_port_count() const;
  99. virtual bool has_input_sequence_port() const;
  100. virtual String get_output_sequence_port_text(int p_port) const;
  101. virtual int get_input_value_port_count() const;
  102. virtual int get_output_value_port_count() const;
  103. virtual PropertyInfo get_input_value_port_info(int p_idx) const;
  104. virtual PropertyInfo get_output_value_port_info(int p_idx) const;
  105. virtual String get_caption() const;
  106. virtual String get_text() const;
  107. virtual String get_category() const { return "flow_control"; }
  108. virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance);
  109. VisualScriptIterator();
  110. };
  111. class VisualScriptSequence : public VisualScriptNode {
  112. GDCLASS(VisualScriptSequence, VisualScriptNode)
  113. int steps;
  114. protected:
  115. static void _bind_methods();
  116. public:
  117. virtual int get_output_sequence_port_count() const;
  118. virtual bool has_input_sequence_port() const;
  119. virtual String get_output_sequence_port_text(int p_port) const;
  120. virtual int get_input_value_port_count() const;
  121. virtual int get_output_value_port_count() const;
  122. virtual PropertyInfo get_input_value_port_info(int p_idx) const;
  123. virtual PropertyInfo get_output_value_port_info(int p_idx) const;
  124. virtual String get_caption() const;
  125. virtual String get_text() const;
  126. virtual String get_category() const { return "flow_control"; }
  127. void set_steps(int p_steps);
  128. int get_steps() const;
  129. virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance);
  130. VisualScriptSequence();
  131. };
  132. class VisualScriptSwitch : public VisualScriptNode {
  133. GDCLASS(VisualScriptSwitch, VisualScriptNode)
  134. struct Case {
  135. Variant::Type type;
  136. Case() { type = Variant::NIL; }
  137. };
  138. Vector<Case> case_values;
  139. friend class VisualScriptNodeInstanceSwitch;
  140. protected:
  141. bool _set(const StringName &p_name, const Variant &p_value);
  142. bool _get(const StringName &p_name, Variant &r_ret) const;
  143. void _get_property_list(List<PropertyInfo> *p_list) const;
  144. static void _bind_methods();
  145. public:
  146. virtual int get_output_sequence_port_count() const;
  147. virtual bool has_input_sequence_port() const;
  148. virtual String get_output_sequence_port_text(int p_port) const;
  149. virtual bool has_mixed_input_and_sequence_ports() const { return true; }
  150. virtual int get_input_value_port_count() const;
  151. virtual int get_output_value_port_count() const;
  152. virtual PropertyInfo get_input_value_port_info(int p_idx) const;
  153. virtual PropertyInfo get_output_value_port_info(int p_idx) const;
  154. virtual String get_caption() const;
  155. virtual String get_text() const;
  156. virtual String get_category() const { return "flow_control"; }
  157. virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance);
  158. VisualScriptSwitch();
  159. };
  160. class VisualScriptTypeCast : public VisualScriptNode {
  161. GDCLASS(VisualScriptTypeCast, VisualScriptNode)
  162. StringName base_type;
  163. String script;
  164. protected:
  165. static void _bind_methods();
  166. public:
  167. virtual int get_output_sequence_port_count() const;
  168. virtual bool has_input_sequence_port() const;
  169. virtual String get_output_sequence_port_text(int p_port) const;
  170. virtual int get_input_value_port_count() const;
  171. virtual int get_output_value_port_count() const;
  172. virtual PropertyInfo get_input_value_port_info(int p_idx) const;
  173. virtual PropertyInfo get_output_value_port_info(int p_idx) const;
  174. virtual String get_caption() const;
  175. virtual String get_text() const;
  176. virtual String get_category() const { return "flow_control"; }
  177. void set_base_type(const StringName &p_type);
  178. StringName get_base_type() const;
  179. void set_base_script(const String &p_path);
  180. String get_base_script() const;
  181. virtual TypeGuess guess_output_type(TypeGuess *p_inputs, int p_output) const;
  182. virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance);
  183. VisualScriptTypeCast();
  184. };
  185. void register_visual_script_flow_control_nodes();
  186. #endif // VISUAL_SCRIPT_FLOW_CONTROL_H