Remove VisualScript module for 4.0

As announced in https://godotengine.org/article/godot-4-will-discontinue-visual-scripting,
Godot maintainers have agreed to discontinue the current implementation of
our VisualScript language.

The way it had been designed was not user-friendly enough and we did not
succeed in improving its usability to actually make it a good low-code
solution for users who need one.

So we prefer to remove it for Godot 4.0 and leave the door open for new,
innovative ideas around visual scripting, to be developed as plugins or
extensions now that Godot provides sufficient functionality for this
(notably via GDExtension and the godot-cpp C++ bindings).

The current module has been moved to a dedicated repository (with full Git
history extracted with `git filter-branch`):

https://github.com/godotengine/godot-visual-script

It can still be compiled as a C++ module (for now, but will likely require
work to be kept in sync with the engine repository), but our hope is that
contributors will port it to GDExtension (which is quite compatibile with
the existing C++ module code when using the godot-cpp C++ bindings).
This commit is contained in:
Rémi Verschelde 2022-08-24 12:05:37 +02:00
parent 0626ce50cf
commit b1f392c25e
77 changed files with 5 additions and 25444 deletions

View File

@ -74,10 +74,10 @@ if your ZIP file isn't accepted by GitHub because it's too large.
We recommend always attaching a minimal reproduction project, even if the issue
may seem simple to reproduce manually.
**Note for C# users:** If your issue is not Mono-specific, please upload a
minimal reproduction project written in GDScript or VisualScript.
**Note for C# users:** If your issue is not .NET-specific, please upload a
minimal reproduction project written in GDScript.
This will make it easier for contributors to reproduce the issue
locally as not everyone has a Mono setup available.
locally as not everyone has a .NET setup available.
**If you've been asked by a maintainer to upload a minimal reproduction project,
you *must* do so within 7 days.** Otherwise, your bug report will be closed as

View File

@ -1303,10 +1303,8 @@
<member name="TranslationServer" type="TranslationServer" setter="" getter="">
The [TranslationServer] singleton.
</member>
<member name="VisualScriptCustomNodes" type="VisualScriptCustomNodes" setter="" getter="">
The [VisualScriptCustomNodes] singleton.
</member>
<member name="WorkerThreadPool" type="WorkerThreadPool" setter="" getter="">
The [WorkerThreadPool] singleton.
</member>
<member name="XRServer" type="XRServer" setter="" getter="">
The [XRServer] singleton.

View File

@ -5,7 +5,7 @@
</brief_description>
<description>
Every class which is not a built-in type inherits from this class.
You can construct Objects from scripting languages, using [code]Object.new()[/code] in GDScript, [code]new Object[/code] in C#, or the "Construct Object" node in VisualScript.
You can construct Objects from scripting languages, using [code]Object.new()[/code] in GDScript, or [code]new Object[/code] in C#.
Objects do not manage memory. If a class inherits from Object, you will have to delete instances of it manually. To do so, call the [method free] method from your script or delete the instance from C++.
Some classes that extend Object add memory management. This is the case of [RefCounted], which counts references and deletes itself automatically when no longer referenced. [Node], another fundamental type, deletes all its children when freed from memory.
Objects export properties, which are mainly useful for storage and editing, but not really so much in programming. Properties are exported in [method _get_property_list] and handled in [method _get] and [method _set]. However, scripting languages and C++ have simpler means to export them.

View File

@ -464,9 +464,6 @@
<member name="debug/settings/stdout/verbose_stdout" type="bool" setter="" getter="" default="false">
Print more information to standard output when running. It displays information such as memory leaks, which scenes and resources are being loaded, etc. This can also be enabled using the [code]--verbose[/code] or [code]-v[/code] command line argument, even on an exported project. See also [method OS.is_stdout_verbose] and [method @GlobalScope.print_verbose].
</member>
<member name="debug/settings/visual_script/max_call_stack" type="int" setter="" getter="" default="1024">
Maximum call stack in visual scripting, to avoid infinite recursion.
</member>
<member name="debug/shapes/collision/contact_color" type="Color" setter="" getter="" default="Color(1, 0.2, 0.1, 0.8)">
Color of the contact points between collision shapes, visible when "Visible Collision Shapes" is enabled in the Debug menu.
</member>

View File

@ -23,7 +23,6 @@
[/codeblocks]
Godot tracks all scripting API variables within Variants. Without even realizing it, you use Variants all the time. When a particular language enforces its own rules for keeping data typed, then that language is applying its own custom logic over the base Variant scripting API.
- GDScript automatically wrap values in them. It keeps all data in plain Variants by default and then optionally enforces custom static typing rules on variable types.
- VisualScript tracks properties inside Variants as well, but it also uses static typing. The GUI interface enforces that properties have a particular type that doesn't change over time.
- C# is statically typed, but uses the Mono [code]object[/code] type in place of Godot's Variant class when it needs to represent a dynamic value. [code]object[/code] is the Mono runtime's equivalent of the same concept.
The global [method @GlobalScope.typeof] function returns the enumerated value of the Variant type stored in the current variable (see [enum Variant.Type]).
[codeblocks]

View File

@ -49,7 +49,6 @@
#include "editor/find_in_files.h"
#include "editor/node_dock.h"
#include "editor/plugins/shader_editor_plugin.h"
#include "modules/visual_script/editor/visual_script_editor.h"
#include "scene/main/window.h"
#include "scene/scene_string_names.h"
#include "script_text_editor.h"

View File

@ -1,11 +0,0 @@
#!/usr/bin/env python
Import("env")
Import("env_modules")
env_vs = env_modules.Clone()
env_vs.add_source_files(env.modules_sources, "*.cpp")
if env["tools"]:
env_vs.add_source_files(env.modules_sources, "editor/*.cpp")

View File

@ -1,63 +0,0 @@
def can_build(env, platform):
return True
def configure(env):
pass
def get_doc_classes():
return [
"VisualScriptBasicTypeConstant",
"VisualScriptBuiltinFunc",
"VisualScriptClassConstant",
"VisualScriptComment",
"VisualScriptComposeArray",
"VisualScriptCondition",
"VisualScriptConstant",
"VisualScriptConstructor",
"VisualScriptCustomNode",
"VisualScriptCustomNodes",
"VisualScriptDeconstruct",
"VisualScriptEditor",
"VisualScriptEmitSignal",
"VisualScriptEngineSingleton",
"VisualScriptExpression",
"VisualScriptFunctionCall",
"VisualScriptFunctionState",
"VisualScriptFunction",
"VisualScriptGlobalConstant",
"VisualScriptIndexGet",
"VisualScriptIndexSet",
"VisualScriptInputAction",
"VisualScriptIterator",
"VisualScriptLists",
"VisualScriptLocalVarSet",
"VisualScriptLocalVar",
"VisualScriptMathConstant",
"VisualScriptNode",
"VisualScriptOperator",
"VisualScriptPreload",
"VisualScriptPropertyGet",
"VisualScriptPropertySet",
"VisualScriptResourcePath",
"VisualScriptReturn",
"VisualScriptSceneNode",
"VisualScriptSceneTree",
"VisualScriptSelect",
"VisualScriptSelf",
"VisualScriptSequence",
"VisualScriptSubCall",
"VisualScriptSwitch",
"VisualScriptTypeCast",
"VisualScriptVariableGet",
"VisualScriptVariableSet",
"VisualScriptWhile",
"VisualScript",
"VisualScriptYieldSignal",
"VisualScriptYield",
]
def get_doc_path():
return "doc_classes"

View File

@ -1,357 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="VisualScript" inherits="Script" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<brief_description>
A script implemented in the Visual Script programming environment.
</brief_description>
<description>
A script implemented in the Visual Script programming environment. The script extends the functionality of all objects that instance it.
[method Object.set_script] extends an existing object, if that object's class matches one of the script's base classes.
You are most likely to use this class via the Visual Script editor or when writing plugins for it.
</description>
<tutorials>
<link title="VisualScript documentation index">$DOCS_URL/tutorials/scripting/visual_script/index.html</link>
</tutorials>
<methods>
<method name="add_custom_signal">
<return type="void" />
<param index="0" name="name" type="StringName" />
<description>
Add a custom signal with the specified name to the VisualScript.
</description>
</method>
<method name="add_function">
<return type="void" />
<param index="0" name="name" type="StringName" />
<param index="1" name="func_node_id" type="int" />
<description>
Add a function with the specified name to the VisualScript, and assign the root [VisualScriptFunction] node's id as [code]func_node_id[/code].
</description>
</method>
<method name="add_node">
<return type="void" />
<param index="0" name="id" type="int" />
<param index="1" name="node" type="VisualScriptNode" />
<param index="2" name="position" type="Vector2" default="Vector2(0, 0)" />
<description>
Add a node to the VisualScript.
</description>
</method>
<method name="add_variable">
<return type="void" />
<param index="0" name="name" type="StringName" />
<param index="1" name="default_value" type="Variant" default="null" />
<param index="2" name="export" type="bool" default="false" />
<description>
Add a variable to the VisualScript, optionally giving it a default value or marking it as exported.
</description>
</method>
<method name="custom_signal_add_argument">
<return type="void" />
<param index="0" name="name" type="StringName" />
<param index="1" name="type" type="int" enum="Variant.Type" />
<param index="2" name="argname" type="String" />
<param index="3" name="index" type="int" default="-1" />
<description>
Add an argument to a custom signal added with [method add_custom_signal].
</description>
</method>
<method name="custom_signal_get_argument_count" qualifiers="const">
<return type="int" />
<param index="0" name="name" type="StringName" />
<description>
Get the count of a custom signal's arguments.
</description>
</method>
<method name="custom_signal_get_argument_name" qualifiers="const">
<return type="String" />
<param index="0" name="name" type="StringName" />
<param index="1" name="argidx" type="int" />
<description>
Get the name of a custom signal's argument.
</description>
</method>
<method name="custom_signal_get_argument_type" qualifiers="const">
<return type="int" enum="Variant.Type" />
<param index="0" name="name" type="StringName" />
<param index="1" name="argidx" type="int" />
<description>
Get the type of a custom signal's argument.
</description>
</method>
<method name="custom_signal_remove_argument">
<return type="void" />
<param index="0" name="name" type="StringName" />
<param index="1" name="argidx" type="int" />
<description>
Remove a specific custom signal's argument.
</description>
</method>
<method name="custom_signal_set_argument_name">
<return type="void" />
<param index="0" name="name" type="StringName" />
<param index="1" name="argidx" type="int" />
<param index="2" name="argname" type="String" />
<description>
Rename a custom signal's argument.
</description>
</method>
<method name="custom_signal_set_argument_type">
<return type="void" />
<param index="0" name="name" type="StringName" />
<param index="1" name="argidx" type="int" />
<param index="2" name="type" type="int" enum="Variant.Type" />
<description>
Change the type of a custom signal's argument.
</description>
</method>
<method name="custom_signal_swap_argument">
<return type="void" />
<param index="0" name="name" type="StringName" />
<param index="1" name="argidx" type="int" />
<param index="2" name="withidx" type="int" />
<description>
Swap two of the arguments of a custom signal.
</description>
</method>
<method name="data_connect">
<return type="void" />
<param index="0" name="from_node" type="int" />
<param index="1" name="from_port" type="int" />
<param index="2" name="to_node" type="int" />
<param index="3" name="to_port" type="int" />
<description>
Connect two data ports. The value of [code]from_node[/code]'s [code]from_port[/code] would be fed into [code]to_node[/code]'s [code]to_port[/code].
</description>
</method>
<method name="data_disconnect">
<return type="void" />
<param index="0" name="from_node" type="int" />
<param index="1" name="from_port" type="int" />
<param index="2" name="to_node" type="int" />
<param index="3" name="to_port" type="int" />
<description>
Disconnect two data ports previously connected with [method data_connect].
</description>
</method>
<method name="get_function_node_id" qualifiers="const">
<return type="int" />
<param index="0" name="name" type="StringName" />
<description>
Returns the id of a function's entry point node.
</description>
</method>
<method name="get_node" qualifiers="const">
<return type="VisualScriptNode" />
<param index="0" name="id" type="int" />
<description>
Returns a node given its id.
</description>
</method>
<method name="get_node_position" qualifiers="const">
<return type="Vector2" />
<param index="0" name="id" type="int" />
<description>
Returns a node's position in pixels.
</description>
</method>
<method name="get_scroll" qualifiers="const">
<return type="Vector2" />
<description>
Returns the current position of the center of the screen.
</description>
</method>
<method name="get_variable_default_value" qualifiers="const">
<return type="Variant" />
<param index="0" name="name" type="StringName" />
<description>
Returns the default (initial) value of a variable.
</description>
</method>
<method name="get_variable_export" qualifiers="const">
<return type="bool" />
<param index="0" name="name" type="StringName" />
<description>
Returns whether a variable is exported.
</description>
</method>
<method name="get_variable_info" qualifiers="const">
<return type="Dictionary" />
<param index="0" name="name" type="StringName" />
<description>
Returns the information for a given variable as a dictionary. The information includes its name, type, hint and usage.
</description>
</method>
<method name="has_custom_signal" qualifiers="const">
<return type="bool" />
<param index="0" name="name" type="StringName" />
<description>
Returns whether a signal exists with the specified name.
</description>
</method>
<method name="has_data_connection" qualifiers="const">
<return type="bool" />
<param index="0" name="from_node" type="int" />
<param index="1" name="from_port" type="int" />
<param index="2" name="to_node" type="int" />
<param index="3" name="to_port" type="int" />
<description>
Returns whether the specified data ports are connected.
</description>
</method>
<method name="has_function" qualifiers="const">
<return type="bool" />
<param index="0" name="name" type="StringName" />
<description>
Returns whether a function exists with the specified name.
</description>
</method>
<method name="has_node" qualifiers="const">
<return type="bool" />
<param index="0" name="id" type="int" />
<description>
Returns whether a node exists with the given id.
</description>
</method>
<method name="has_sequence_connection" qualifiers="const">
<return type="bool" />
<param index="0" name="from_node" type="int" />
<param index="1" name="from_output" type="int" />
<param index="2" name="to_node" type="int" />
<description>
Returns whether the specified sequence ports are connected.
</description>
</method>
<method name="has_variable" qualifiers="const">
<return type="bool" />
<param index="0" name="name" type="StringName" />
<description>
Returns whether a variable exists with the specified name.
</description>
</method>
<method name="remove_custom_signal">
<return type="void" />
<param index="0" name="name" type="StringName" />
<description>
Remove a custom signal with the given name.
</description>
</method>
<method name="remove_function">
<return type="void" />
<param index="0" name="name" type="StringName" />
<description>
Remove a specific function and its nodes from the script.
</description>
</method>
<method name="remove_node">
<return type="void" />
<param index="0" name="id" type="int" />
<description>
Remove the node with the specified id.
</description>
</method>
<method name="remove_variable">
<return type="void" />
<param index="0" name="name" type="StringName" />
<description>
Remove a variable with the given name.
</description>
</method>
<method name="rename_custom_signal">
<return type="void" />
<param index="0" name="name" type="StringName" />
<param index="1" name="new_name" type="StringName" />
<description>
Change the name of a custom signal.
</description>
</method>
<method name="rename_function">
<return type="void" />
<param index="0" name="name" type="StringName" />
<param index="1" name="new_name" type="StringName" />
<description>
Change the name of a function.
</description>
</method>
<method name="rename_variable">
<return type="void" />
<param index="0" name="name" type="StringName" />
<param index="1" name="new_name" type="StringName" />
<description>
Change the name of a variable.
</description>
</method>
<method name="sequence_connect">
<return type="void" />
<param index="0" name="from_node" type="int" />
<param index="1" name="from_output" type="int" />
<param index="2" name="to_node" type="int" />
<description>
Connect two sequence ports. The execution will flow from of [code]from_node[/code]'s [code]from_output[/code] into [code]to_node[/code].
Unlike [method data_connect], there isn't a [code]to_port[/code], since the target node can have only one sequence port.
</description>
</method>
<method name="sequence_disconnect">
<return type="void" />
<param index="0" name="from_node" type="int" />
<param index="1" name="from_output" type="int" />
<param index="2" name="to_node" type="int" />
<description>
Disconnect two sequence ports previously connected with [method sequence_connect].
</description>
</method>
<method name="set_instance_base_type">
<return type="void" />
<param index="0" name="type" type="StringName" />
<description>
Set the base type of the script.
</description>
</method>
<method name="set_node_position">
<return type="void" />
<param index="0" name="id" type="int" />
<param index="1" name="position" type="Vector2" />
<description>
Set the node position in the VisualScript graph.
</description>
</method>
<method name="set_scroll">
<return type="void" />
<param index="0" name="offset" type="Vector2" />
<description>
Set the screen center to the given position.
</description>
</method>
<method name="set_variable_default_value">
<return type="void" />
<param index="0" name="name" type="StringName" />
<param index="1" name="value" type="Variant" />
<description>
Change the default (initial) value of a variable.
</description>
</method>
<method name="set_variable_export">
<return type="void" />
<param index="0" name="name" type="StringName" />
<param index="1" name="enable" type="bool" />
<description>
Change whether a variable is exported.
</description>
</method>
<method name="set_variable_info">
<return type="void" />
<param index="0" name="name" type="StringName" />
<param index="1" name="value" type="Dictionary" />
<description>
Set a variable's info, using the same format as [method get_variable_info].
</description>
</method>
</methods>
<signals>
<signal name="node_ports_changed">
<param index="0" name="id" type="int" />
<description>
Emitted when the ports of a node are changed.
</description>
</signal>
</signals>
</class>

View File

@ -1,19 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="VisualScriptBasicTypeConstant" inherits="VisualScriptNode" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<brief_description>
A Visual Script node representing a constant from the base types.
</brief_description>
<description>
A Visual Script node representing a constant from base types, such as [constant Vector3.AXIS_X].
</description>
<tutorials>
</tutorials>
<members>
<member name="basic_type" type="int" setter="set_basic_type" getter="get_basic_type" enum="Variant.Type" default="0">
The type to get the constant from.
</member>
<member name="constant" type="StringName" setter="set_basic_type_constant" getter="get_basic_type_constant">
The name of the constant to return.
</member>
</members>
</class>

View File

@ -1,221 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="VisualScriptBuiltinFunc" inherits="VisualScriptNode" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<brief_description>
A Visual Script node used to call built-in functions.
</brief_description>
<description>
A built-in function used inside a [VisualScript]. It is usually a math function or an utility function.
See also [@GDScript], for the same functions in the GDScript language.
</description>
<tutorials>
</tutorials>
<members>
<member name="function" type="int" setter="set_func" getter="get_func" enum="VisualScriptBuiltinFunc.BuiltinFunc" default="0">
The function to be executed.
</member>
</members>
<constants>
<constant name="MATH_SIN" value="0" enum="BuiltinFunc">
Returns the sine of the input.
</constant>
<constant name="MATH_COS" value="1" enum="BuiltinFunc">
Returns the cosine of the input.
</constant>
<constant name="MATH_TAN" value="2" enum="BuiltinFunc">
Returns the tangent of the input.
</constant>
<constant name="MATH_SINH" value="3" enum="BuiltinFunc">
Returns the hyperbolic sine of the input.
</constant>
<constant name="MATH_COSH" value="4" enum="BuiltinFunc">
Returns the hyperbolic cosine of the input.
</constant>
<constant name="MATH_TANH" value="5" enum="BuiltinFunc">
Returns the hyperbolic tangent of the input.
</constant>
<constant name="MATH_ASIN" value="6" enum="BuiltinFunc">
Returns the arc sine of the input.
</constant>
<constant name="MATH_ACOS" value="7" enum="BuiltinFunc">
Returns the arc cosine of the input.
</constant>
<constant name="MATH_ATAN" value="8" enum="BuiltinFunc">
Returns the arc tangent of the input.
</constant>
<constant name="MATH_ATAN2" value="9" enum="BuiltinFunc">
Returns the arc tangent of the input, using the signs of both parameters to determine the exact angle.
</constant>
<constant name="MATH_SQRT" value="10" enum="BuiltinFunc">
Returns the square root of the input.
</constant>
<constant name="MATH_FMOD" value="11" enum="BuiltinFunc">
Returns the remainder of one input divided by the other, using floating-point numbers.
</constant>
<constant name="MATH_FPOSMOD" value="12" enum="BuiltinFunc">
Returns the positive remainder of one input divided by the other, using floating-point numbers.
</constant>
<constant name="MATH_FLOOR" value="13" enum="BuiltinFunc">
Returns the input rounded down.
</constant>
<constant name="MATH_CEIL" value="14" enum="BuiltinFunc">
Returns the input rounded up.
</constant>
<constant name="MATH_ROUND" value="15" enum="BuiltinFunc">
Returns the input rounded to the nearest integer.
</constant>
<constant name="MATH_ABS" value="16" enum="BuiltinFunc">
Returns the absolute value of the input.
</constant>
<constant name="MATH_SIGN" value="17" enum="BuiltinFunc">
Returns the sign of the input, turning it into 1, -1, or 0. Useful to determine if the input is positive or negative.
</constant>
<constant name="MATH_POW" value="18" enum="BuiltinFunc">
Returns the input raised to a given power.
</constant>
<constant name="MATH_LOG" value="19" enum="BuiltinFunc">
Returns the natural logarithm of the input. Note that this is not the typical base-10 logarithm function calculators use.
</constant>
<constant name="MATH_EXP" value="20" enum="BuiltinFunc">
Returns the mathematical constant [b]e[/b] raised to the specified power of the input. [b]e[/b] has an approximate value of 2.71828.
</constant>
<constant name="MATH_ISNAN" value="21" enum="BuiltinFunc">
Returns whether the input is NaN (Not a Number) or not. NaN is usually produced by dividing 0 by 0, though other ways exist.
</constant>
<constant name="MATH_ISINF" value="22" enum="BuiltinFunc">
Returns whether the input is an infinite floating-point number or not. Infinity is usually produced by dividing a number by 0, though other ways exist.
</constant>
<constant name="MATH_EASE" value="23" enum="BuiltinFunc">
Easing function, based on exponent. 0 is constant, 1 is linear, 0 to 1 is ease-in, 1+ is ease out. Negative values are in-out/out in.
</constant>
<constant name="MATH_STEP_DECIMALS" value="24" enum="BuiltinFunc">
Returns the number of digit places after the decimal that the first non-zero digit occurs.
</constant>
<constant name="MATH_SNAPPED" value="25" enum="BuiltinFunc">
Returns the input snapped to a given step.
</constant>
<constant name="MATH_LERP" value="26" enum="BuiltinFunc">
Returns a number linearly interpolated between the first two inputs, based on the third input. Uses the formula [code]a + (a - b) * t[/code].
</constant>
<constant name="MATH_CUBIC_INTERPOLATE" value="27" enum="BuiltinFunc">
</constant>
<constant name="MATH_INVERSE_LERP" value="28" enum="BuiltinFunc">
</constant>
<constant name="MATH_RANGE_LERP" value="29" enum="BuiltinFunc">
</constant>
<constant name="MATH_MOVE_TOWARD" value="30" enum="BuiltinFunc">
Moves the number toward a value, based on the third input.
</constant>
<constant name="MATH_RANDOMIZE" value="31" enum="BuiltinFunc">
Randomize the seed (or the internal state) of the random number generator. Current implementation reseeds using a number based on time.
</constant>
<constant name="MATH_RANDI" value="32" enum="BuiltinFunc">
Returns a random 32 bits integer value. To obtain a random value between 0 to N (where N is smaller than 2^32 - 1), you can use it with the remainder function.
</constant>
<constant name="MATH_RANDF" value="33" enum="BuiltinFunc">
Returns a random floating-point value between 0 and 1. To obtain a random value between 0 to N, you can use it with multiplication.
</constant>
<constant name="MATH_RANDI_RANGE" value="34" enum="BuiltinFunc">
Returns a random 32-bit integer value between the two inputs.
</constant>
<constant name="MATH_RANDF_RANGE" value="35" enum="BuiltinFunc">
Returns a random floating-point value between the two inputs.
</constant>
<constant name="MATH_RANDFN" value="36" enum="BuiltinFunc">
Returns a normally-distributed pseudo-random number, using Box-Muller transform with the specified mean and a standard deviation. This is also called Gaussian distribution.
</constant>
<constant name="MATH_SEED" value="37" enum="BuiltinFunc">
Set the seed for the random number generator.
</constant>
<constant name="MATH_RANDSEED" value="38" enum="BuiltinFunc">
Returns a random value from the given seed, along with the new seed.
</constant>
<constant name="MATH_DEG2RAD" value="39" enum="BuiltinFunc">
Convert the input from degrees to radians.
</constant>
<constant name="MATH_RAD2DEG" value="40" enum="BuiltinFunc">
Convert the input from radians to degrees.
</constant>
<constant name="MATH_LINEAR2DB" value="41" enum="BuiltinFunc">
Convert the input from linear volume to decibel volume.
</constant>
<constant name="MATH_DB2LINEAR" value="42" enum="BuiltinFunc">
Convert the input from decibel volume to linear volume.
</constant>
<constant name="MATH_WRAP" value="43" enum="BuiltinFunc">
</constant>
<constant name="MATH_WRAPF" value="44" enum="BuiltinFunc">
</constant>
<constant name="MATH_PINGPONG" value="45" enum="BuiltinFunc">
Returns the [code]value[/code] wrapped between [code]0[/code] and the [code]length[/code]. If the limit is reached, the next value the function returned is decreased to the [code]0[/code] side or increased to the [code]length[/code] side (like a triangle wave). If [code]length[/code] is less than zero, it becomes positive.
</constant>
<constant name="LOGIC_MAX" value="46" enum="BuiltinFunc">
Returns the greater of the two numbers, also known as their maximum.
</constant>
<constant name="LOGIC_MIN" value="47" enum="BuiltinFunc">
Returns the lesser of the two numbers, also known as their minimum.
</constant>
<constant name="LOGIC_CLAMP" value="48" enum="BuiltinFunc">
Returns the input clamped inside the given range, ensuring the result is never outside it. Equivalent to [code]min(max(input, range_low), range_high)[/code].
</constant>
<constant name="LOGIC_NEAREST_PO2" value="49" enum="BuiltinFunc">
Returns the nearest power of 2 to the input.
</constant>
<constant name="OBJ_WEAKREF" value="50" enum="BuiltinFunc">
Create a [WeakRef] from the input.
</constant>
<constant name="TYPE_CONVERT" value="51" enum="BuiltinFunc">
Convert between types.
</constant>
<constant name="TYPE_OF" value="52" enum="BuiltinFunc">
Returns the type of the input as an integer. Check [enum Variant.Type] for the integers that might be returned.
</constant>
<constant name="TYPE_EXISTS" value="53" enum="BuiltinFunc">
Checks if a type is registered in the [ClassDB].
</constant>
<constant name="TEXT_CHAR" value="54" enum="BuiltinFunc">
Returns a character with the given ascii value.
</constant>
<constant name="TEXT_STR" value="55" enum="BuiltinFunc">
Convert the input to a string.
</constant>
<constant name="TEXT_PRINT" value="56" enum="BuiltinFunc">
Print the given string to the output window.
</constant>
<constant name="TEXT_PRINTERR" value="57" enum="BuiltinFunc">
Print the given string to the standard error output.
</constant>
<constant name="TEXT_PRINTRAW" value="58" enum="BuiltinFunc">
Print the given string to the standard output, without adding a newline.
</constant>
<constant name="TEXT_PRINT_VERBOSE" value="59" enum="BuiltinFunc">
</constant>
<constant name="VAR_TO_STR" value="60" enum="BuiltinFunc">
Serialize a [Variant] to a string.
</constant>
<constant name="STR_TO_VAR" value="61" enum="BuiltinFunc">
Deserialize a [Variant] from a string serialized using [constant VAR_TO_STR].
</constant>
<constant name="VAR_TO_BYTES" value="62" enum="BuiltinFunc">
Serialize a [Variant] to a [PackedByteArray].
</constant>
<constant name="BYTES_TO_VAR" value="63" enum="BuiltinFunc">
Deserialize a [Variant] from a [PackedByteArray] serialized using [constant VAR_TO_BYTES].
</constant>
<constant name="MATH_SMOOTHSTEP" value="64" enum="BuiltinFunc">
Returns a number smoothly interpolated between the first two inputs, based on the third input. Similar to [constant MATH_LERP], but interpolates faster at the beginning and slower at the end. Using Hermite interpolation formula:
[codeblock]
var t = clamp((weight - from) / (to - from), 0.0, 1.0)
return t * t * (3.0 - 2.0 * t)
[/codeblock]
</constant>
<constant name="MATH_POSMOD" value="65" enum="BuiltinFunc">
</constant>
<constant name="MATH_LERP_ANGLE" value="66" enum="BuiltinFunc">
</constant>
<constant name="TEXT_ORD" value="67" enum="BuiltinFunc">
</constant>
<constant name="FUNC_MAX" value="68" enum="BuiltinFunc">
Represents the size of the [enum BuiltinFunc] enum.
</constant>
</constants>
</class>

View File

@ -1,23 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="VisualScriptClassConstant" inherits="VisualScriptNode" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<brief_description>
Gets a constant from a given class.
</brief_description>
<description>
This node returns a constant from a given class, such as [constant TYPE_INT]. See the given class' documentation for available constants.
[b]Input Ports:[/b]
none
[b]Output Ports:[/b]
- Data (variant): [code]value[/code]
</description>
<tutorials>
</tutorials>
<members>
<member name="base_type" type="StringName" setter="set_base_type" getter="get_base_type" default="&amp;&quot;Object&quot;">
The constant's parent class.
</member>
<member name="constant" type="StringName" setter="set_class_constant" getter="get_class_constant" default="&amp;&quot;&quot;">
The constant to return. See the given class for its available constants.
</member>
</members>
</class>

View File

@ -1,23 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="VisualScriptComment" inherits="VisualScriptNode" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<brief_description>
A Visual Script node used to annotate the script.
</brief_description>
<description>
A Visual Script node used to display annotations in the script, so that code may be documented.
Comment nodes can be resized so they encompass a group of nodes.
</description>
<tutorials>
</tutorials>
<members>
<member name="description" type="String" setter="set_description" getter="get_description" default="&quot;&quot;">
The text inside the comment node.
</member>
<member name="size" type="Vector2" setter="set_size" getter="get_size" default="Vector2(150, 150)">
The comment node's size (in pixels).
</member>
<member name="title" type="String" setter="set_title" getter="get_title" default="&quot;Comment&quot;">
The comment node's title.
</member>
</members>
</class>

View File

@ -1,11 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="VisualScriptComposeArray" inherits="VisualScriptLists" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<brief_description>
A Visual Script Node used to create array from a list of items.
</brief_description>
<description>
A Visual Script Node used to compose array from the list of elements provided with custom in-graph UI hard coded in the VisualScript Editor.
</description>
<tutorials>
</tutorials>
</class>

View File

@ -1,18 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="VisualScriptCondition" inherits="VisualScriptNode" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<brief_description>
A Visual Script node which branches the flow.
</brief_description>
<description>
A Visual Script node that checks a [bool] input port. If [code]true[/code], it will exit via the "true" sequence port. If [code]false[/code], it will exit via the "false" sequence port. After exiting either, it exits via the "done" port. Sequence ports may be left disconnected.
[b]Input Ports:[/b]
- Sequence: [code]if (cond) is[/code]
- Data (boolean): [code]cond[/code]
[b]Output Ports:[/b]
- Sequence: [code]true[/code]
- Sequence: [code]false[/code]
- Sequence: [code]done[/code]
</description>
<tutorials>
</tutorials>
</class>

View File

@ -1,23 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="VisualScriptConstant" inherits="VisualScriptNode" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<brief_description>
Gets a contant's value.
</brief_description>
<description>
This node returns a constant's value.
[b]Input Ports:[/b]
none
[b]Output Ports:[/b]
- Data (variant): [code]get[/code]
</description>
<tutorials>
</tutorials>
<members>
<member name="type" type="int" setter="set_constant_type" getter="get_constant_type" enum="Variant.Type" default="0">
The constant's type.
</member>
<member name="value" type="Variant" setter="set_constant_value" getter="get_constant_value">
The constant's value.
</member>
</members>
</class>

View File

@ -1,35 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="VisualScriptConstructor" inherits="VisualScriptNode" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<brief_description>
A Visual Script node which calls a base type constructor.
</brief_description>
<description>
A Visual Script node which calls a base type constructor. It can be used for type conversion as well.
</description>
<tutorials>
</tutorials>
<methods>
<method name="get_constructor" qualifiers="const">
<return type="Dictionary" />
<description>
</description>
</method>
<method name="get_constructor_type" qualifiers="const">
<return type="int" enum="Variant.Type" />
<description>
</description>
</method>
<method name="set_constructor">
<return type="void" />
<param index="0" name="constructor" type="Dictionary" />
<description>
</description>
</method>
<method name="set_constructor_type">
<return type="void" />
<param index="0" name="type" type="int" enum="Variant.Type" />
<description>
</description>
</method>
</methods>
</class>

View File

@ -1,166 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="VisualScriptCustomNode" inherits="VisualScriptNode" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<brief_description>
A scripted Visual Script node.
</brief_description>
<description>
A custom Visual Script node which can be scripted in powerful ways.
</description>
<tutorials>
</tutorials>
<methods>
<method name="_get_caption" qualifiers="virtual const">
<return type="String" />
<description>
Returns the node's title.
</description>
</method>
<method name="_get_category" qualifiers="virtual const">
<return type="String" />
<description>
Returns the node's category.
</description>
</method>
<method name="_get_input_value_port_count" qualifiers="virtual const">
<return type="int" />
<description>
Returns the count of input value ports.
</description>
</method>
<method name="_get_input_value_port_hint" qualifiers="virtual const">
<return type="int" />
<param index="0" name="input_idx" type="int" />
<description>
Returns the specified input port's hint. See the [enum @GlobalScope.PropertyHint] hints.
</description>
</method>
<method name="_get_input_value_port_hint_string" qualifiers="virtual const">
<return type="String" />
<param index="0" name="input_idx" type="int" />
<description>
Returns the specified input port's hint string.
</description>
</method>
<method name="_get_input_value_port_name" qualifiers="virtual const">
<return type="String" />
<param index="0" name="input_idx" type="int" />
<description>
Returns the specified input port's name.
</description>
</method>
<method name="_get_input_value_port_type" qualifiers="virtual const">
<return type="int" />
<param index="0" name="input_idx" type="int" />
<description>
Returns the specified input port's type. See the [enum Variant.Type] values.
</description>
</method>
<method name="_get_output_sequence_port_count" qualifiers="virtual const">
<return type="int" />
<description>
Returns the amount of output [b]sequence[/b] ports.
</description>
</method>
<method name="_get_output_sequence_port_text" qualifiers="virtual const">
<return type="String" />
<param index="0" name="seq_idx" type="int" />
<description>
Returns the specified [b]sequence[/b] output's name.
</description>
</method>
<method name="_get_output_value_port_count" qualifiers="virtual const">
<return type="int" />
<description>
Returns the amount of output value ports.
</description>
</method>
<method name="_get_output_value_port_hint" qualifiers="virtual const">
<return type="int" />
<param index="0" name="output_idx" type="int" />
<description>
Returns the specified output port's hint. See the [enum @GlobalScope.PropertyHint] hints.
</description>
</method>
<method name="_get_output_value_port_hint_string" qualifiers="virtual const">
<return type="String" />
<param index="0" name="output_idx" type="int" />
<description>
Returns the specified output port's hint string.
</description>
</method>
<method name="_get_output_value_port_name" qualifiers="virtual const">
<return type="String" />
<param index="0" name="output_idx" type="int" />
<description>
Returns the specified output port's name.
</description>
</method>
<method name="_get_output_value_port_type" qualifiers="virtual const">
<return type="int" />
<param index="0" name="output_idx" type="int" />
<description>
Returns the specified output port's type. See the [enum Variant.Type] values.
</description>
</method>
<method name="_get_text" qualifiers="virtual const">
<return type="String" />
<description>
Returns the custom node's text, which is shown right next to the input [b]sequence[/b] port (if there is none, on the place that is usually taken by it).
</description>
</method>
<method name="_get_working_memory_size" qualifiers="virtual const">
<return type="int" />
<description>
Returns the size of the custom node's working memory. See [method _step] for more details.
</description>
</method>
<method name="_has_input_sequence_port" qualifiers="virtual const">
<return type="bool" />
<description>
Returns whether the custom node has an input [b]sequence[/b] port.
</description>
</method>
<method name="_step" qualifiers="virtual const">
<return type="Variant" />
<param index="0" name="inputs" type="Array" />
<param index="1" name="outputs" type="Array" />
<param index="2" name="start_mode" type="int" />
<param index="3" name="working_mem" type="Array" />
<description>
Execute the custom node's logic, returning the index of the output sequence port to use or a [String] when there is an error.
The [code]inputs[/code] array contains the values of the input ports.
[code]outputs[/code] is an array whose indices should be set to the respective outputs.
The [code]start_mode[/code] is usually [constant START_MODE_BEGIN_SEQUENCE], unless you have used the [code]STEP_*[/code] constants.
[code]working_mem[/code] is an array which can be used to persist information between runs of the custom node. The size needs to be predefined using [method _get_working_memory_size].
When returning, you can mask the returned value with one of the [code]STEP_*[/code] constants.
</description>
</method>
</methods>
<constants>
<constant name="START_MODE_BEGIN_SEQUENCE" value="0" enum="StartMode">
The start mode used the first time when [method _step] is called.
</constant>
<constant name="START_MODE_CONTINUE_SEQUENCE" value="1" enum="StartMode">
The start mode used when [method _step] is called after coming back from a [constant STEP_PUSH_STACK_BIT].
</constant>
<constant name="START_MODE_RESUME_YIELD" value="2" enum="StartMode">
The start mode used when [method _step] is called after resuming from [constant STEP_YIELD_BIT].
</constant>
<constant name="STEP_PUSH_STACK_BIT" value="16777216">
Hint used by [method _step] to tell that control should return to it when there is no other node left to execute.
This is used by [VisualScriptCondition] to redirect the sequence to the "Done" port after the [code]true[/code]/[code]false[/code] branch has finished execution.
</constant>
<constant name="STEP_GO_BACK_BIT" value="33554432">
Hint used by [method _step] to tell that control should return back, either hitting a previous [constant STEP_PUSH_STACK_BIT] or exiting the function.
</constant>
<constant name="STEP_NO_ADVANCE_BIT" value="67108864">
</constant>
<constant name="STEP_EXIT_FUNCTION_BIT" value="134217728">
Hint used by [method _step] to tell that control should stop and exit the function.
</constant>
<constant name="STEP_YIELD_BIT" value="268435456">
Hint used by [method _step] to tell that the function should be yielded.
Using this requires you to have at least one working memory slot, which is used for the [VisualScriptFunctionState].
</constant>
</constants>
</class>

View File

@ -1,37 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="VisualScriptCustomNodes" inherits="Object" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<brief_description>
Manages custom nodes for the Visual Script editor.
</brief_description>
<description>
This singleton can be used to manage (i.e., add or remove) custom nodes for the Visual Script editor.
</description>
<tutorials>
</tutorials>
<methods>
<method name="add_custom_node">
<return type="void" />
<param index="0" name="name" type="String" />
<param index="1" name="category" type="String" />
<param index="2" name="script" type="Script" />
<description>
Add a custom Visual Script node to the editor. It'll be placed under "Custom Nodes" with the [code]category[/code] as the parameter.
</description>
</method>
<method name="remove_custom_node">
<return type="void" />
<param index="0" name="name" type="String" />
<param index="1" name="category" type="String" />
<description>
Remove a custom Visual Script node from the editor. Custom nodes already placed on scripts won't be removed.
</description>
</method>
</methods>
<signals>
<signal name="custom_nodes_updated">
<description>
Emitted when a custom Visual Script node is added or removed.
</description>
</signal>
</signals>
</class>

View File

@ -1,16 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="VisualScriptDeconstruct" inherits="VisualScriptNode" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<brief_description>
A Visual Script node which deconstructs a base type instance into its parts.
</brief_description>
<description>
A Visual Script node which deconstructs a base type instance into its parts.
</description>
<tutorials>
</tutorials>
<members>
<member name="type" type="int" setter="set_deconstruct_type" getter="get_deconstruct_type" enum="Variant.Type" default="0">
The type to deconstruct.
</member>
</members>
</class>

View File

@ -1,20 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="VisualScriptEmitSignal" inherits="VisualScriptNode" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<brief_description>
Emits a specified signal.
</brief_description>
<description>
Emits a specified signal when it is executed.
[b]Input Ports:[/b]
- Sequence: [code]emit[/code]
[b]Output Ports:[/b]
- Sequence
</description>
<tutorials>
</tutorials>
<members>
<member name="signal" type="StringName" setter="set_signal" getter="get_signal" default="&amp;&quot;&quot;">
The signal to emit.
</member>
</members>
</class>

View File

@ -1,16 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="VisualScriptEngineSingleton" inherits="VisualScriptNode" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<brief_description>
A Visual Script node returning a singleton from [@GlobalScope].
</brief_description>
<description>
A Visual Script node returning a singleton from [@GlobalScope].
</description>
<tutorials>
</tutorials>
<members>
<member name="constant" type="String" setter="set_singleton" getter="get_singleton" default="&quot;&quot;">
The singleton's name.
</member>
</members>
</class>

View File

@ -1,11 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="VisualScriptExpression" inherits="VisualScriptNode" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<brief_description>
A Visual Script node that can execute a custom expression.
</brief_description>
<description>
A Visual Script node that can execute a custom expression. Values can be provided for the input and the expression result can be retrieved from the output.
</description>
<tutorials>
</tutorials>
</class>

View File

@ -1,11 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="VisualScriptFunction" inherits="VisualScriptNode" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<brief_description>
A Visual Script node representing a function.
</brief_description>
<description>
[VisualScriptFunction] represents a function header. It is the starting point for the function body and can be used to tweak the function's properties (e.g. RPC mode).
</description>
<tutorials>
</tutorials>
</class>

View File

@ -1,75 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="VisualScriptFunctionCall" inherits="VisualScriptNode" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<brief_description>
A Visual Script node for calling a function.
</brief_description>
<description>
[VisualScriptFunctionCall] is created when you add or drag and drop a function onto the Visual Script graph. It allows to tweak parameters of the call, e.g. what object the function is called on.
</description>
<tutorials>
</tutorials>
<members>
<member name="base_script" type="String" setter="set_base_script" getter="get_base_script">
The script to be used when [member call_mode] is set to [constant CALL_MODE_INSTANCE].
</member>
<member name="base_type" type="StringName" setter="set_base_type" getter="get_base_type" default="&amp;&quot;Object&quot;">
The base type to be used when [member call_mode] is set to [constant CALL_MODE_INSTANCE].
</member>
<member name="basic_type" type="int" setter="set_basic_type" getter="get_basic_type" enum="Variant.Type">
The type to be used when [member call_mode] is set to [constant CALL_MODE_BASIC_TYPE].
</member>
<member name="call_mode" type="int" setter="set_call_mode" getter="get_call_mode" enum="VisualScriptFunctionCall.CallMode" default="0">
[code]call_mode[/code] determines the target object on which the method will be called. See [enum CallMode] for options.
</member>
<member name="function" type="StringName" setter="set_function" getter="get_function" default="&amp;&quot;&quot;">
The name of the function to be called.
</member>
<member name="node_path" type="NodePath" setter="set_base_path" getter="get_base_path">
The node path to use when [member call_mode] is set to [constant CALL_MODE_NODE_PATH].
</member>
<member name="rpc_call_mode" type="int" setter="set_rpc_call_mode" getter="get_rpc_call_mode" enum="VisualScriptFunctionCall.RPCCallMode" default="0">
The mode for RPC calls. See [method Node.rpc] for more details and [enum RPCCallMode] for available options.
</member>
<member name="singleton" type="StringName" setter="set_singleton" getter="get_singleton">
The singleton to call the method on. Used when [member call_mode] is set to [constant CALL_MODE_SINGLETON].
</member>
<member name="use_default_args" type="int" setter="set_use_default_args" getter="get_use_default_args">
Number of default arguments that will be used when calling the function. Can't be higher than the number of available default arguments in the method's declaration.
</member>
<member name="validate" type="bool" setter="set_validate" getter="get_validate" default="true">
If [code]false[/code], call errors (e.g. wrong number of arguments) will be ignored.
</member>
</members>
<constants>
<constant name="CALL_MODE_SELF" value="0" enum="CallMode">
The method will be called on this [Object].
</constant>
<constant name="CALL_MODE_NODE_PATH" value="1" enum="CallMode">
The method will be called on the given [Node] in the scene tree.
</constant>
<constant name="CALL_MODE_INSTANCE" value="2" enum="CallMode">
The method will be called on an instanced node with the given type and script.
</constant>
<constant name="CALL_MODE_BASIC_TYPE" value="3" enum="CallMode">
The method will be called on a GDScript basic type (e.g. [Vector2]).
</constant>
<constant name="CALL_MODE_SINGLETON" value="4" enum="CallMode">
The method will be called on a singleton.
</constant>
<constant name="RPC_DISABLED" value="0" enum="RPCCallMode">
The method will be called locally.
</constant>
<constant name="RPC_RELIABLE" value="1" enum="RPCCallMode">
The method will be called remotely.
</constant>
<constant name="RPC_UNRELIABLE" value="2" enum="RPCCallMode">
The method will be called remotely using an unreliable protocol.
</constant>
<constant name="RPC_RELIABLE_TO_ID" value="3" enum="RPCCallMode">
The method will be called remotely for the given peer.
</constant>
<constant name="RPC_UNRELIABLE_TO_ID" value="4" enum="RPCCallMode">
The method will be called remotely for the given peer, using an unreliable protocol.
</constant>
</constants>
</class>

View File

@ -1,35 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="VisualScriptFunctionState" inherits="RefCounted" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<brief_description>
A Visual Script node representing a function state.
</brief_description>
<description>
[VisualScriptFunctionState] is returned from [VisualScriptYield] and can be used to resume a paused function call.
</description>
<tutorials>
</tutorials>
<methods>
<method name="connect_to_signal">
<return type="void" />
<param index="0" name="obj" type="Object" />
<param index="1" name="signals" type="String" />
<param index="2" name="args" type="Array" />
<description>
Connects this [VisualScriptFunctionState] to a signal in the given object to automatically resume when it's emitted.
</description>
</method>
<method name="is_valid" qualifiers="const">
<return type="bool" />
<description>
Returns whether the function state is valid.
</description>
</method>
<method name="resume">
<return type="Variant" />
<param index="0" name="args" type="Array" default="[]" />
<description>
Resumes the function to run from the point it was yielded.
</description>
</method>
</methods>
</class>

View File

@ -1,16 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="VisualScriptGlobalConstant" inherits="VisualScriptNode" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<brief_description>
A Visual Script node returning a constant from [@GlobalScope].
</brief_description>
<description>
A Visual Script node returning a constant from [@GlobalScope].
</description>
<tutorials>
</tutorials>
<members>
<member name="constant" type="int" setter="set_global_constant" getter="get_global_constant" default="0">
The constant to be used.
</member>
</members>
</class>

View File

@ -1,11 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="VisualScriptIndexGet" inherits="VisualScriptNode" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<brief_description>
A Visual Script node for getting a value from an array or a dictionary.
</brief_description>
<description>
[VisualScriptIndexGet] will return the value stored in an array or a dictionary under the given index.
</description>
<tutorials>
</tutorials>
</class>

View File

@ -1,11 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="VisualScriptIndexSet" inherits="VisualScriptNode" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<brief_description>
A Visual Script node for setting a value in an array or a dictionary.
</brief_description>
<description>
[VisualScriptIndexSet] will set the value stored in an array or a dictionary under the given index to the provided new value.
</description>
<tutorials>
</tutorials>
</class>

View File

@ -1,33 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="VisualScriptInputAction" inherits="VisualScriptNode" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<brief_description>
A Visual Script node returning a state of an action.
</brief_description>
<description>
[VisualScriptInputAction] can be used to check if an action is pressed or released.
</description>
<tutorials>
</tutorials>
<members>
<member name="action" type="StringName" setter="set_action_name" getter="get_action_name" default="&amp;&quot;&quot;">
Name of the action.
</member>
<member name="mode" type="int" setter="set_action_mode" getter="get_action_mode" enum="VisualScriptInputAction.Mode" default="0">
State of the action to check. See [enum Mode] for options.
</member>
</members>
<constants>
<constant name="MODE_PRESSED" value="0" enum="Mode">
[code]True[/code] if action is pressed.
</constant>
<constant name="MODE_RELEASED" value="1" enum="Mode">
[code]True[/code] if action is released (i.e. not pressed).
</constant>
<constant name="MODE_JUST_PRESSED" value="2" enum="Mode">
[code]True[/code] on the frame the action was pressed.
</constant>
<constant name="MODE_JUST_RELEASED" value="3" enum="Mode">
[code]True[/code] on the frame the action was released.
</constant>
</constants>
</class>

View File

@ -1,18 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="VisualScriptIterator" inherits="VisualScriptNode" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<brief_description>
Steps through items in a given input.
</brief_description>
<description>
This node steps through each item in a given input. Input can be any sequence data type, such as an [Array] or [String]. When each item has been processed, execution passed out the [code]exit[/code] Sequence port.
[b]Input Ports:[/b]
- Sequence: [code]for (elem) in (input)[/code]
- Data (variant): [code]input[/code]
[b]Output Ports:[/b]
- Sequence: [code]each[/code]
- Sequence: [code]exit[/code]
- Data (variant): [code]elem[/code]
</description>
<tutorials>
</tutorials>
</class>

View File

@ -1,77 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="VisualScriptLists" inherits="VisualScriptNode" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<brief_description>
A Visual Script virtual class for in-graph editable nodes.
</brief_description>
<description>
A Visual Script virtual class that defines the shape and the default behavior of the nodes that have to be in-graph editable nodes.
</description>
<tutorials>
</tutorials>
<methods>
<method name="add_input_data_port">
<return type="void" />
<param index="0" name="type" type="int" enum="Variant.Type" />
<param index="1" name="name" type="String" />
<param index="2" name="index" type="int" />
<description>
Adds an input port to the Visual Script node.
</description>
</method>
<method name="add_output_data_port">
<return type="void" />
<param index="0" name="type" type="int" enum="Variant.Type" />
<param index="1" name="name" type="String" />
<param index="2" name="index" type="int" />
<description>
Adds an output port to the Visual Script node.
</description>
</method>
<method name="remove_input_data_port">
<return type="void" />
<param index="0" name="index" type="int" />
<description>
Removes an input port from the Visual Script node.
</description>
</method>
<method name="remove_output_data_port">
<return type="void" />
<param index="0" name="index" type="int" />
<description>
Removes an output port from the Visual Script node.
</description>
</method>
<method name="set_input_data_port_name">
<return type="void" />
<param index="0" name="index" type="int" />
<param index="1" name="name" type="String" />
<description>
Sets the name of an input port.
</description>
</method>
<method name="set_input_data_port_type">
<return type="void" />
<param index="0" name="index" type="int" />
<param index="1" name="type" type="int" enum="Variant.Type" />
<description>
Sets the type of an input port.
</description>
</method>
<method name="set_output_data_port_name">
<return type="void" />
<param index="0" name="index" type="int" />
<param index="1" name="name" type="String" />
<description>
Sets the name of an output port.
</description>
</method>
<method name="set_output_data_port_type">
<return type="void" />
<param index="0" name="index" type="int" />
<param index="1" name="type" type="int" enum="Variant.Type" />
<description>
Sets the type of an output port.
</description>
</method>
</methods>
</class>

View File

@ -1,23 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="VisualScriptLocalVar" inherits="VisualScriptNode" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<brief_description>
Gets a local variable's value.
</brief_description>
<description>
Returns a local variable's value. "Var Name" must be supplied, with an optional type.
[b]Input Ports:[/b]
none
[b]Output Ports:[/b]
- Data (variant): [code]get[/code]
</description>
<tutorials>
</tutorials>
<members>
<member name="type" type="int" setter="set_var_type" getter="get_var_type" enum="Variant.Type" default="0">
The local variable's type.
</member>
<member name="var_name" type="StringName" setter="set_var_name" getter="get_var_name" default="&amp;&quot;new_local&quot;">
The local variable's name.
</member>
</members>
</class>

View File

@ -1,25 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="VisualScriptLocalVarSet" inherits="VisualScriptNode" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<brief_description>
Changes a local variable's value.
</brief_description>
<description>
Changes a local variable's value to the given input. The new value is also provided on an output Data port.
[b]Input Ports:[/b]
- Sequence
- Data (variant): [code]set[/code]
[b]Output Ports:[/b]
- Sequence
- Data (variant): [code]get[/code]
</description>
<tutorials>
</tutorials>
<members>
<member name="type" type="int" setter="set_var_type" getter="get_var_type" enum="Variant.Type" default="0">
The local variable's type.
</member>
<member name="var_name" type="StringName" setter="set_var_name" getter="get_var_name" default="&amp;&quot;new_local&quot;">
The local variable's name.
</member>
</members>
</class>

View File

@ -1,49 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="VisualScriptMathConstant" inherits="VisualScriptNode" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<brief_description>
Commonly used mathematical constants.
</brief_description>
<description>
Provides common math constants, such as Pi, on an output Data port.
[b]Input Ports:[/b]
none
[b]Output Ports:[/b]
- Data (variant): [code]get[/code]
</description>
<tutorials>
</tutorials>
<members>
<member name="constant" type="int" setter="set_math_constant" getter="get_math_constant" enum="VisualScriptMathConstant.MathConstant" default="0">
The math constant.
</member>
</members>
<constants>
<constant name="MATH_CONSTANT_ONE" value="0" enum="MathConstant">
Unity: [code]1[/code].
</constant>
<constant name="MATH_CONSTANT_PI" value="1" enum="MathConstant">
Pi: [code]3.141593[/code].
</constant>
<constant name="MATH_CONSTANT_HALF_PI" value="2" enum="MathConstant">
Pi divided by two: [code]1.570796[/code].
</constant>
<constant name="MATH_CONSTANT_TAU" value="3" enum="MathConstant">
Tau: [code]6.283185[/code].
</constant>
<constant name="MATH_CONSTANT_E" value="4" enum="MathConstant">
Mathematical constant [code]e[/code], the natural log base: [code]2.718282[/code].
</constant>
<constant name="MATH_CONSTANT_SQRT2" value="5" enum="MathConstant">
Square root of two: [code]1.414214[/code].
</constant>
<constant name="MATH_CONSTANT_INF" value="6" enum="MathConstant">
Infinity: [code]inf[/code].
</constant>
<constant name="MATH_CONSTANT_NAN" value="7" enum="MathConstant">
Not a number: [code]nan[/code].
</constant>
<constant name="MATH_CONSTANT_MAX" value="8" enum="MathConstant">
Represents the size of the [enum MathConstant] enum.
</constant>
</constants>
</class>

View File

@ -1,47 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="VisualScriptNode" inherits="Resource" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<brief_description>
A node which is part of a [VisualScript].
</brief_description>
<description>
A node which is part of a [VisualScript]. Not to be confused with [Node], which is a part of a [SceneTree].
</description>
<tutorials>
</tutorials>
<methods>
<method name="get_default_input_value" qualifiers="const">
<return type="Variant" />
<param index="0" name="port_idx" type="int" />
<description>
Returns the default value of a given port. The default value is used when nothing is connected to the port.
</description>
</method>
<method name="get_visual_script" qualifiers="const">
<return type="VisualScript" />
<description>
Returns the [VisualScript] instance the node is bound to.
</description>
</method>
<method name="ports_changed_notify">
<return type="void" />
<description>
Notify that the node's ports have changed. Usually used in conjunction with [VisualScriptCustomNode] .
</description>
</method>
<method name="set_default_input_value">
<return type="void" />
<param index="0" name="port_idx" type="int" />
<param index="1" name="value" type="Variant" />
<description>
Change the default value of a given port.
</description>
</method>
</methods>
<signals>
<signal name="ports_changed">
<description>
Emitted when the available input/output ports are changed.
</description>
</signal>
</signals>
</class>

View File

@ -1,23 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="VisualScriptOperator" inherits="VisualScriptNode" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<brief_description>
A Visual Script node that performs an operation on two values.
</brief_description>
<description>
[b]Input Ports:[/b]
- Data (variant): [code]A[/code]
- Data (variant): [code]B[/code]
[b]Output Ports:[/b]
- Data (variant): [code]result[/code]
</description>
<tutorials>
</tutorials>
<members>
<member name="operator" type="int" setter="set_operator" getter="get_operator" enum="Variant.Operator" default="6">
The operation to be performed. See [enum Variant.Operator] for available options.
</member>
<member name="type" type="int" setter="set_typed" getter="get_typed" enum="Variant.Type" default="0">
The type of the values for this operation. See [enum Variant.Type] for available options.
</member>
</members>
</class>

View File

@ -1,20 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="VisualScriptPreload" inherits="VisualScriptNode" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<brief_description>
Creates a new [Resource] or loads one from the filesystem.
</brief_description>
<description>
Creates a new [Resource] or loads one from the filesystem.
[b]Input Ports:[/b]
none
[b]Output Ports:[/b]
- Data (object): [code]res[/code]
</description>
<tutorials>
</tutorials>
<members>
<member name="resource" type="Resource" setter="set_preload" getter="get_preload">
The [Resource] to load.
</member>
</members>
</class>

View File

@ -1,48 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="VisualScriptPropertyGet" inherits="VisualScriptNode" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<brief_description>
A Visual Script node returning a value of a property from an [Object].
</brief_description>
<description>
[VisualScriptPropertyGet] can return a value of any property from the current object or other objects.
</description>
<tutorials>
</tutorials>
<members>
<member name="base_script" type="String" setter="set_base_script" getter="get_base_script">
The script to be used when [member set_mode] is set to [constant CALL_MODE_INSTANCE].
</member>
<member name="base_type" type="StringName" setter="set_base_type" getter="get_base_type" default="&amp;&quot;Object&quot;">
The base type to be used when [member set_mode] is set to [constant CALL_MODE_INSTANCE].
</member>
<member name="basic_type" type="int" setter="set_basic_type" getter="get_basic_type" enum="Variant.Type">
The type to be used when [member set_mode] is set to [constant CALL_MODE_BASIC_TYPE].
</member>
<member name="index" type="StringName" setter="set_index" getter="get_index">
The indexed name of the property to retrieve. See [method Object.get_indexed] for details.
</member>
<member name="node_path" type="NodePath" setter="set_base_path" getter="get_base_path">
The node path to use when [member set_mode] is set to [constant CALL_MODE_NODE_PATH].
</member>
<member name="property" type="StringName" setter="set_property" getter="get_property" default="&amp;&quot;&quot;">
The name of the property to retrieve. Changing this will clear [member index].
</member>
<member name="set_mode" type="int" setter="set_call_mode" getter="get_call_mode" enum="VisualScriptPropertyGet.CallMode" default="0">
[code]set_mode[/code] determines the target object from which the property will be retrieved. See [enum CallMode] for options.
</member>
</members>
<constants>
<constant name="CALL_MODE_SELF" value="0" enum="CallMode">
The property will be retrieved from this [Object].
</constant>
<constant name="CALL_MODE_NODE_PATH" value="1" enum="CallMode">
The property will be retrieved from the given [Node] in the scene tree.
</constant>
<constant name="CALL_MODE_INSTANCE" value="2" enum="CallMode">
The property will be retrieved from an instanced node with the given type and script.
</constant>
<constant name="CALL_MODE_BASIC_TYPE" value="3" enum="CallMode">
The property will be retrieved from a GDScript basic type (e.g. [Vector2]).
</constant>
</constants>
</class>

View File

@ -1,84 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="VisualScriptPropertySet" inherits="VisualScriptNode" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<brief_description>
A Visual Script node that sets a property of an [Object].
</brief_description>
<description>
[VisualScriptPropertySet] can set the value of any property from the current object or other objects.
</description>
<tutorials>
</tutorials>
<members>
<member name="assign_op" type="int" setter="set_assign_op" getter="get_assign_op" enum="VisualScriptPropertySet.AssignOp" default="0">
The additional operation to perform when assigning. See [enum AssignOp] for options.
</member>
<member name="base_script" type="String" setter="set_base_script" getter="get_base_script">
The script to be used when [member set_mode] is set to [constant CALL_MODE_INSTANCE].
</member>
<member name="base_type" type="StringName" setter="set_base_type" getter="get_base_type" default="&amp;&quot;Object&quot;">
The base type to be used when [member set_mode] is set to [constant CALL_MODE_INSTANCE].
</member>
<member name="basic_type" type="int" setter="set_basic_type" getter="get_basic_type" enum="Variant.Type">
The type to be used when [member set_mode] is set to [constant CALL_MODE_BASIC_TYPE].
</member>
<member name="index" type="StringName" setter="set_index" getter="get_index">
The indexed name of the property to set. See [method Object.set_indexed] for details.
</member>
<member name="node_path" type="NodePath" setter="set_base_path" getter="get_base_path">
The node path to use when [member set_mode] is set to [constant CALL_MODE_NODE_PATH].
</member>
<member name="property" type="StringName" setter="set_property" getter="get_property" default="&amp;&quot;&quot;">
The name of the property to set. Changing this will clear [member index].
</member>
<member name="set_mode" type="int" setter="set_call_mode" getter="get_call_mode" enum="VisualScriptPropertySet.CallMode" default="0">
[code]set_mode[/code] determines the target object on which the property will be set. See [enum CallMode] for options.
</member>
</members>
<constants>
<constant name="CALL_MODE_SELF" value="0" enum="CallMode">
The property will be set on this [Object].
</constant>
<constant name="CALL_MODE_NODE_PATH" value="1" enum="CallMode">
The property will be set on the given [Node] in the scene tree.
</constant>
<constant name="CALL_MODE_INSTANCE" value="2" enum="CallMode">
The property will be set on an instanced node with the given type and script.
</constant>
<constant name="CALL_MODE_BASIC_TYPE" value="3" enum="CallMode">
The property will be set on a GDScript basic type (e.g. [Vector2]).
</constant>
<constant name="ASSIGN_OP_NONE" value="0" enum="AssignOp">
The property will be assigned regularly.
</constant>
<constant name="ASSIGN_OP_ADD" value="1" enum="AssignOp">
The value will be added to the property. Equivalent of doing [code]+=[/code].
</constant>
<constant name="ASSIGN_OP_SUB" value="2" enum="AssignOp">
The value will be subtracted from the property. Equivalent of doing [code]-=[/code].
</constant>
<constant name="ASSIGN_OP_MUL" value="3" enum="AssignOp">
The property will be multiplied by the value. Equivalent of doing [code]*=[/code].
</constant>
<constant name="ASSIGN_OP_DIV" value="4" enum="AssignOp">
The property will be divided by the value. Equivalent of doing [code]/=[/code].
</constant>
<constant name="ASSIGN_OP_MOD" value="5" enum="AssignOp">
A modulo operation will be performed on the property and the value. Equivalent of doing [code]%=[/code].
</constant>
<constant name="ASSIGN_OP_SHIFT_LEFT" value="6" enum="AssignOp">
The property will be binarly shifted to the left by the given value. Equivalent of doing [code]&lt;&lt;[/code].
</constant>
<constant name="ASSIGN_OP_SHIFT_RIGHT" value="7" enum="AssignOp">
The property will be binarly shifted to the right by the given value. Equivalent of doing [code]&gt;&gt;[/code].
</constant>
<constant name="ASSIGN_OP_BIT_AND" value="8" enum="AssignOp">
A binary [code]AND[/code] operation will be performed on the property. Equivalent of doing [code]&amp;=[/code].
</constant>
<constant name="ASSIGN_OP_BIT_OR" value="9" enum="AssignOp">
A binary [code]OR[/code] operation will be performed on the property. Equivalent of doing [code]|=[/code].
</constant>
<constant name="ASSIGN_OP_BIT_XOR" value="10" enum="AssignOp">
A binary [code]XOR[/code] operation will be performed on the property. Equivalent of doing [code]^=[/code].
</constant>
</constants>
</class>

View File

@ -1,13 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="VisualScriptResourcePath" inherits="VisualScriptNode" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<brief_description>
</brief_description>
<description>
</description>
<tutorials>
</tutorials>
<members>
<member name="path" type="String" setter="set_resource_path" getter="get_resource_path" default="&quot;&quot;">
</member>
</members>
</class>

View File

@ -1,24 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="VisualScriptReturn" inherits="VisualScriptNode" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<brief_description>
Exits a function and returns an optional value.
</brief_description>
<description>
Ends the execution of a function and returns control to the calling function. Optionally, it can return a [Variant] value.
[b]Input Ports:[/b]
- Sequence
- Data (variant): [code]result[/code] (optional)
[b]Output Ports:[/b]
none
</description>
<tutorials>
</tutorials>
<members>
<member name="return_enabled" type="bool" setter="set_enable_return_value" getter="is_return_value_enabled" default="false">
If [code]true[/code], the [code]return[/code] input port is available.
</member>
<member name="return_type" type="int" setter="set_return_type" getter="get_return_type" enum="Variant.Type" default="0">
The return value's data type.
</member>
</members>
</class>

View File

@ -1,20 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="VisualScriptSceneNode" inherits="VisualScriptNode" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<brief_description>
Node reference.
</brief_description>
<description>
A direct reference to a node.
[b]Input Ports:[/b]
none
[b]Output Ports:[/b]
- Data: [code]node[/code] (obj)
</description>
<tutorials>
</tutorials>
<members>
<member name="node_path" type="NodePath" setter="set_node_path" getter="get_node_path" default="NodePath(&quot;.&quot;)">
The node's path in the scene tree.
</member>
</members>
</class>

View File

@ -1,11 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="VisualScriptSceneTree" inherits="VisualScriptNode" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<brief_description>
A Visual Script node for accessing [SceneTree] methods.
</brief_description>
<description>
A Visual Script node for accessing [SceneTree] methods.
</description>
<tutorials>
</tutorials>
</class>

View File

@ -1,22 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="VisualScriptSelect" inherits="VisualScriptNode" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<brief_description>
Chooses between two input values.
</brief_description>
<description>
Chooses between two input values based on a Boolean condition.
[b]Input Ports:[/b]
- Data (boolean): [code]cond[/code]
- Data (variant): [code]a[/code]
- Data (variant): [code]b[/code]
[b]Output Ports:[/b]
- Data (variant): [code]out[/code]
</description>
<tutorials>
</tutorials>
<members>
<member name="type" type="int" setter="set_typed" getter="get_typed" enum="Variant.Type" default="0">
The input variables' type.
</member>
</members>
</class>

View File

@ -1,15 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="VisualScriptSelf" inherits="VisualScriptNode" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<brief_description>
Outputs a reference to the current instance.
</brief_description>
<description>
Provides a reference to the node running the visual script.
[b]Input Ports:[/b]
none
[b]Output Ports:[/b]
- Data (object): [code]instance[/code]
</description>
<tutorials>
</tutorials>
</class>

View File

@ -1,22 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="VisualScriptSequence" inherits="VisualScriptNode" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<brief_description>
Executes a series of Sequence ports.
</brief_description>
<description>
Steps through a series of one or more output Sequence ports. The [code]current[/code] data port outputs the currently executing item.
[b]Input Ports:[/b]
- Sequence: [code]in order[/code]
[b]Output Ports:[/b]
- Sequence: [code]1[/code]
- Sequence: [code]2 - n[/code] (optional)
- Data (int): [code]current[/code]
</description>
<tutorials>
</tutorials>
<members>
<member name="steps" type="int" setter="set_steps" getter="get_steps" default="1">
The number of steps in the sequence.
</member>
</members>
</class>

View File

@ -1,11 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="VisualScriptSubCall" inherits="VisualScriptNode" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<brief_description>
Calls a method called [code]_subcall[/code] in this object.
</brief_description>
<description>
[VisualScriptSubCall] will call method named [code]_subcall[/code] in the current script. It will fail if the method doesn't exist or the provided arguments are wrong.
</description>
<tutorials>
</tutorials>
</class>

View File

@ -1,20 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="VisualScriptSwitch" inherits="VisualScriptNode" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<brief_description>
Branches program flow based on a given input's value.
</brief_description>
<description>
Branches the flow based on an input's value. Use [b]Case Count[/b] in the Inspector to set the number of branches and each comparison's optional type.
[b]Input Ports:[/b]
- Sequence: [code]'input' is[/code]
- Data (variant): [code]=[/code]
- Data (variant): [code]=[/code] (optional)
- Data (variant): [code]input[/code]
[b]Output Ports:[/b]
- Sequence
- Sequence (optional)
- Sequence: [code]done[/code]
</description>
<tutorials>
</tutorials>
</class>

View File

@ -1,19 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="VisualScriptTypeCast" inherits="VisualScriptNode" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<brief_description>
A Visual Script node that casts the given value to another type.
</brief_description>
<description>
[VisualScriptTypeCast] will perform a type conversion to an [Object]-derived type.
</description>
<tutorials>
</tutorials>
<members>
<member name="base_script" type="String" setter="set_base_script" getter="get_base_script" default="&quot;&quot;">
The target script class to be converted to. If none, only the [member base_type] will be used.
</member>
<member name="base_type" type="StringName" setter="set_base_type" getter="get_base_type" default="&amp;&quot;Object&quot;">
The target type to be converted to.
</member>
</members>
</class>

View File

@ -1,20 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="VisualScriptVariableGet" inherits="VisualScriptNode" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<brief_description>
Gets a variable's value.
</brief_description>
<description>
Returns a variable's value. "Var Name" must be supplied, with an optional type.
[b]Input Ports:[/b]
none
[b]Output Ports:[/b]
- Data (variant): [code]value[/code]
</description>
<tutorials>
</tutorials>
<members>
<member name="var_name" type="StringName" setter="set_variable" getter="get_variable" default="&amp;&quot;&quot;">
The variable's name.
</member>
</members>
</class>

View File

@ -1,21 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="VisualScriptVariableSet" inherits="VisualScriptNode" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<brief_description>
Changes a variable's value.
</brief_description>
<description>
Changes a variable's value to the given input.
[b]Input Ports:[/b]
- Sequence
- Data (variant): [code]set[/code]
[b]Output Ports:[/b]
- Sequence
</description>
<tutorials>
</tutorials>
<members>
<member name="var_name" type="StringName" setter="set_variable" getter="get_variable" default="&amp;&quot;&quot;">
The variable's name.
</member>
</members>
</class>

View File

@ -1,17 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="VisualScriptWhile" inherits="VisualScriptNode" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<brief_description>
Conditional loop.
</brief_description>
<description>
Loops while a condition is [code]true[/code]. Execution continues out the [code]exit[/code] Sequence port when the loop terminates.
[b]Input Ports:[/b]
- Sequence: [code]while(cond)[/code]
- Data (bool): [code]cond[/code]
[b]Output Ports:[/b]
- Sequence: [code]repeat[/code]
- Sequence: [code]exit[/code]
</description>
<tutorials>
</tutorials>
</class>

View File

@ -1,30 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="VisualScriptYield" inherits="VisualScriptNode" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<brief_description>
A Visual Script node used to pause a function execution.
</brief_description>
<description>
[VisualScriptYield] will pause the function call and return [VisualScriptFunctionState], which can be used to resume the function.
</description>
<tutorials>
</tutorials>
<members>
<member name="mode" type="int" setter="set_yield_mode" getter="get_yield_mode" enum="VisualScriptYield.YieldMode" default="1">
The mode to use for yielding. See [enum YieldMode] for available options.
</member>
<member name="wait_time" type="float" setter="set_wait_time" getter="get_wait_time">
The time to wait when [member mode] is set to [constant YIELD_WAIT].
</member>
</members>
<constants>
<constant name="YIELD_FRAME" value="1" enum="YieldMode">
Yields during an idle frame.
</constant>
<constant name="YIELD_PHYSICS_FRAME" value="2" enum="YieldMode">
Yields during a physics frame.
</constant>
<constant name="YIELD_WAIT" value="3" enum="YieldMode">
Yields a function and waits the given time.
</constant>
</constants>
</class>

View File

@ -1,36 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="VisualScriptYieldSignal" inherits="VisualScriptNode" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<brief_description>
A Visual Script node yielding for a signal.
</brief_description>
<description>
[VisualScriptYieldSignal] will pause the function execution until the provided signal is emitted.
</description>
<tutorials>
</tutorials>
<members>
<member name="base_type" type="StringName" setter="set_base_type" getter="get_base_type" default="&amp;&quot;Object&quot;">
The base type to be used when [member call_mode] is set to [constant CALL_MODE_INSTANCE].
</member>
<member name="call_mode" type="int" setter="set_call_mode" getter="get_call_mode" enum="VisualScriptYieldSignal.CallMode" default="0">
[code]call_mode[/code] determines the target object to wait for the signal emission. See [enum CallMode] for options.
</member>
<member name="node_path" type="NodePath" setter="set_base_path" getter="get_base_path">
The node path to use when [member call_mode] is set to [constant CALL_MODE_NODE_PATH].
</member>
<member name="signal" type="StringName" setter="set_signal" getter="get_signal" default="&amp;&quot;&quot;">
The signal name to be waited for.
</member>
</members>
<constants>
<constant name="CALL_MODE_SELF" value="0" enum="CallMode">
A signal from this [Object] will be used.
</constant>
<constant name="CALL_MODE_NODE_PATH" value="1" enum="CallMode">
A signal from the given [Node] in the scene tree will be used.
</constant>
<constant name="CALL_MODE_INSTANCE" value="2" enum="CallMode">
A signal from an instanced node with the given type will be used.
</constant>
</constants>
</class>

File diff suppressed because it is too large Load Diff

View File

@ -1,395 +0,0 @@
/*************************************************************************/
/* visual_script_editor.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef VISUAL_SCRIPT_EDITOR_H
#define VISUAL_SCRIPT_EDITOR_H
#include "../visual_script.h"
#include "editor/create_dialog.h"
#include "editor/plugins/script_editor_plugin.h"
#include "visual_script_property_selector.h"
class GraphEdit;
class EditorUndoRedoManager;
class VisualScriptEditorSignalEdit;
class VisualScriptEditorVariableEdit;
#ifdef TOOLS_ENABLED
class VisualScriptEditedProperty : public RefCounted {
GDCLASS(VisualScriptEditedProperty, RefCounted);
private:
Variant edited_property;
protected:
static void _bind_methods();
public:
void set_edited_property(Variant p_variant);
Variant get_edited_property() const;
VisualScriptEditedProperty() {}
};
// TODO: Maybe this class should be refactored.
// See https://github.com/godotengine/godot/issues/51913
class VisualScriptEditor : public ScriptEditorBase {
GDCLASS(VisualScriptEditor, ScriptEditorBase);
enum {
TYPE_SEQUENCE = 1000,
INDEX_BASE_SEQUENCE = 1024
};
enum {
EDIT_ADD_NODE,
EDIT_SEPARATOR, // popup menu separator - ignored
EDIT_CUT_NODES,
EDIT_COPY_NODES,
EDIT_PASTE_NODES,
EDIT_DELETE_NODES,
EDIT_DUPLICATE_NODES,
EDIT_CLEAR_COPY_BUFFER,
EDIT_CREATE_FUNCTION,
EDIT_TOGGLE_BREAKPOINT,
EDIT_FIND_NODE_TYPE,
REFRESH_GRAPH,
};
enum PortAction {
CREATE_CALL_SET_GET,
CREATE_ACTION,
};
enum MemberAction {
MEMBER_EDIT,
MEMBER_REMOVE
};
enum MemberType {
MEMBER_FUNCTION,
MEMBER_VARIABLE,
MEMBER_SIGNAL
};
VBoxContainer *members_section = nullptr;
MenuButton *edit_menu = nullptr;
Ref<VisualScript> script;
Button *base_type_select = nullptr;
LineEdit *func_name_box = nullptr;
ScrollContainer *func_input_scroll = nullptr;
VBoxContainer *func_input_vbox = nullptr;
ConfirmationDialog *function_create_dialog = nullptr;
GraphEdit *graph = nullptr;
HBoxContainer *status_bar = nullptr;
Button *toggle_scripts_button = nullptr;
VisualScriptEditorSignalEdit *signal_editor = nullptr;
AcceptDialog *edit_signal_dialog = nullptr;
EditorInspector *edit_signal_edit = nullptr;
VisualScriptPropertySelector *method_select = nullptr;
VisualScriptPropertySelector *new_connect_node_select = nullptr;
VisualScriptPropertySelector *new_virtual_method_select = nullptr;
VisualScriptEditorVariableEdit *variable_editor = nullptr;
AcceptDialog *edit_variable_dialog = nullptr;
EditorInspector *edit_variable_edit = nullptr;
PopupPanel *default_property_editor_popup = nullptr;
EditorProperty *default_property_editor = nullptr;
Ref<VisualScriptEditedProperty> edited_default_property_holder;
Ref<EditorUndoRedoManager> undo_redo;
Tree *members = nullptr;
AcceptDialog *function_name_edit = nullptr;
LineEdit *function_name_box = nullptr;
Label *hint_text = nullptr;
Timer *hint_text_timer = nullptr;
Label *select_func_text = nullptr;
bool updating_graph = false;
void _show_hint(const String &p_hint);
void _hide_timer();
CreateDialog *select_base_type = nullptr;
struct VirtualInMenu {
String name;
Variant::Type ret;
bool ret_variant;
Vector<Pair<Variant::Type, String>> args;
};
HashMap<StringName, Color> node_colors;
HashMap<StringName, Ref<StyleBox>> node_styles;
HashMap<StringName, Variant::Type> base_type_map;
void _update_graph_connections();
void _update_graph(int p_only_id = -1);
bool updating_members = false;
void _update_members();
String _sanitized_variant_text(const StringName &property_name);
StringName selected;
String _validate_name(const String &p_name) const;
struct Clipboard {
HashMap<int, Ref<VisualScriptNode>> nodes;
HashMap<int, Vector2> nodes_positions;
RBSet<VisualScript::SequenceConnection> sequence_connections;
RBSet<VisualScript::DataConnection> data_connections;
};
static Clipboard *clipboard;
PopupMenu *popup_menu = nullptr;
PopupMenu *member_popup = nullptr;
MemberType member_type;
String member_name;
PortAction port_action;
int port_action_node = 0;
int port_action_output = 0;
Vector2 port_action_pos;
int port_action_new_node = 0;
bool saved_pos_dirty = false;
Vector2 mouse_up_position;
void _port_action_menu(int p_option);
void connect_data(Ref<VisualScriptNode> vnode_old, Ref<VisualScriptNode> vnode, int new_id);
NodePath drop_path;
Node *drop_node = nullptr;
Vector2 drop_position;
void _selected_connect_node(const String &p_text, const String &p_category, const bool p_connecting = true);
void connect_seq(Ref<VisualScriptNode> vnode_old, Ref<VisualScriptNode> vnode_new, int new_id);
void _cancel_connect_node();
int _create_new_node_from_name(const String &p_text, const Vector2 &p_point);
void _selected_new_virtual_method(const String &p_text, const String &p_category, const bool p_connecting);
int error_line = -1;
void _node_selected(Node *p_node);
void _center_on_node(int p_id);
void _node_filter_changed(const String &p_text);
void _change_base_type_callback();
void _change_base_type();
void _toggle_tool_script();
void _member_selected();
void _member_edited();
void _begin_node_move();
void _end_node_move();
void _move_node(int p_id, const Vector2 &p_to);
void _get_ends(int p_node, const List<VisualScript::SequenceConnection> &p_seqs, const RBSet<int> &p_selected, RBSet<int> &r_end_nodes);
void _node_moved(Vector2 p_from, Vector2 p_to, int p_id);
void _remove_node(int p_id);
void _graph_connected(const String &p_from, int p_from_slot, const String &p_to, int p_to_slot);
void _graph_disconnected(const String &p_from, int p_from_slot, const String &p_to, int p_to_slot);
void _graph_connect_to_empty(const String &p_from, int p_from_slot, const Vector2 &p_release_pos);
void _node_ports_changed(int p_id);
void _node_create();
void _update_available_nodes();
void _member_button(Object *p_item, int p_column, int p_button, MouseButton p_mouse_button);
void _expression_text_changed(const String &p_text, int p_id);
void _add_input_port(int p_id);
void _add_output_port(int p_id);
void _remove_input_port(int p_id, int p_port);
void _remove_output_port(int p_id, int p_port);
void _change_port_type(int p_select, int p_id, int p_port, bool is_input);
void _update_node_size(int p_id);
void _port_name_focus_out(const Node *p_name_box, int p_id, int p_port, bool is_input);
Vector2 _get_pos_in_graph(Vector2 p_point) const;
Vector2 _get_available_pos(bool p_centered = true, Vector2 p_pos = Vector2()) const;
bool node_has_sequence_connections(int p_id);
void _generic_search(Vector2 pos = Vector2(), bool node_centered = false);
virtual void input(const Ref<InputEvent> &p_event) override;
void _graph_gui_input(const Ref<InputEvent> &p_event);
void _members_gui_input(const Ref<InputEvent> &p_event);
void _fn_name_box_input(const Ref<InputEvent> &p_event);
void _on_fn_name_box_confirmed();
void _rename_function(const String &p_name, const String &p_new_name);
void _create_function_dialog();
void _create_function();
void _add_func_input();
void _remove_func_input(Node *p_node);
void _deselect_input_names();
void _add_node_dialog();
void _node_item_selected();
void _node_item_unselected();
void _on_nodes_copy();
void _on_nodes_paste();
void _on_nodes_delete();
void _on_nodes_duplicate();
Variant get_drag_data_fw(const Point2 &p_point, Control *p_from);
bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const;
void drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from);
int editing_id = 0;
int editing_input = 0;
bool can_swap = false;
int data_disconnect_node = 0;
int data_disconnect_port = 0;
void _default_value_changed(const StringName &p_property, const Variant &p_value, const String &p_field, bool p_changing);
void _default_value_edited(Node *p_button, int p_id, int p_input_port);
void _menu_option(int p_what);
void _graph_ofs_changed(const Vector2 &p_ofs);
void _comment_node_resized(const Vector2 &p_new_size, int p_node);
void _draw_color_over_button(Object *obj, Color p_color);
void _button_resource_previewed(const String &p_path, const Ref<Texture2D> &p_preview, const Ref<Texture2D> &p_small_preview, Variant p_ud);
VisualScriptNode::TypeGuess _guess_output_type(int p_port_action_node, int p_port_action_output, RBSet<int> &p_visited_nodes);
void _member_rmb_selected(const Vector2 &p_pos, MouseButton p_button);
void _member_option(int p_option);
void _toggle_scripts_pressed();
protected:
void _notification(int p_what);
static void _bind_methods();
public:
virtual void add_syntax_highlighter(Ref<EditorSyntaxHighlighter> p_highlighter) override;
virtual void set_syntax_highlighter(Ref<EditorSyntaxHighlighter> p_highlighter) override;
virtual void apply_code() override;
virtual Ref<Resource> get_edited_resource() const override;
virtual void set_edited_resource(const Ref<Resource> &p_res) override;
virtual void enable_editor() override;
virtual Vector<String> get_functions() override;
virtual void reload_text() override;
virtual String get_name() override;
virtual Ref<Texture2D> get_theme_icon() override;
virtual bool is_unsaved() override;
virtual Variant get_edit_state() override;
virtual void set_edit_state(const Variant &p_state) override;
virtual void goto_line(int p_line, bool p_with_error = false) override;
virtual void set_executing_line(int p_line) override;
virtual void clear_executing_line() override;
virtual void trim_trailing_whitespace() override;
virtual void insert_final_newline() override;
virtual void convert_indent_to_spaces() override;
virtual void convert_indent_to_tabs() override;
virtual void ensure_focus() override;
virtual void tag_saved_version() override;
virtual void reload(bool p_soft) override;
virtual PackedInt32Array get_breakpoints() override;
virtual void set_breakpoint(int p_line, bool p_enable) override{};
virtual void clear_breakpoints() override{};
virtual void add_callback(const String &p_function, PackedStringArray p_args) override;
virtual void update_settings() override;
virtual bool show_members_overview() override;
virtual void set_debugger_active(bool p_active) override;
virtual void set_tooltip_request_func(const Callable &p_toolip_callback) override;
virtual Control *get_edit_menu() override;
virtual void clear_edit_menu() override;
virtual void set_find_replace_bar(FindReplaceBar *p_bar) override { p_bar->hide(); }; // Not needed here.
virtual bool can_lose_focus_on_node_selection() override { return false; }
virtual void validate() override;
virtual Control *get_base_editor() const override;
static void register_editor();
static void free_clipboard();
void update_toggle_scripts_button() override;
VisualScriptEditor();
~VisualScriptEditor();
};
// Singleton
class VisualScriptCustomNodes : public Object {
GDCLASS(VisualScriptCustomNodes, Object);
friend class VisualScriptLanguage;
protected:
static void _bind_methods();
static VisualScriptCustomNodes *singleton;
static HashMap<String, Ref<RefCounted>> custom_nodes;
static Ref<VisualScriptNode> create_node_custom(const String &p_name);
public:
static VisualScriptCustomNodes *get_singleton() { return singleton; }
void add_custom_node(const String &p_name, const String &p_category, const Ref<Script> &p_script);
void remove_custom_node(const String &p_name, const String &p_category);
VisualScriptCustomNodes();
~VisualScriptCustomNodes();
};
#endif
#endif // VISUAL_SCRIPT_EDITOR_H

View File

@ -1,229 +0,0 @@
/*************************************************************************/
/* visual_script_property_selector.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef VISUAL_SCRIPT_PROPERTY_SELECTOR_H
#define VISUAL_SCRIPT_PROPERTY_SELECTOR_H
#include "../visual_script.h"
#include "editor/editor_help.h"
#include "scene/gui/rich_text_label.h"
#include "scene/gui/tree.h"
class VisualScriptPropertySelector : public ConfirmationDialog {
GDCLASS(VisualScriptPropertySelector, ConfirmationDialog);
enum SearchFlags {
SEARCH_CLASSES = 1 << 0,
SEARCH_CONSTRUCTORS = 1 << 1,
SEARCH_METHODS = 1 << 2,
SEARCH_OPERATORS = 1 << 3,
SEARCH_SIGNALS = 1 << 4,
SEARCH_CONSTANTS = 1 << 5,
SEARCH_PROPERTIES = 1 << 6,
SEARCH_THEME_ITEMS = 1 << 7,
SEARCH_VISUAL_SCRIPT_NODES = 1 << 8,
SEARCH_ALL = SEARCH_CLASSES | SEARCH_CONSTRUCTORS | SEARCH_METHODS | SEARCH_OPERATORS | SEARCH_SIGNALS | SEARCH_CONSTANTS | SEARCH_PROPERTIES | SEARCH_THEME_ITEMS,
SEARCH_CASE_SENSITIVE = 1 << 29,
SEARCH_SHOW_HIERARCHY = 1 << 30,
};
enum ScopeFlags {
SCOPE_BASE = 1 << 0,
SCOPE_INHERITERS = 1 << 1,
SCOPE_UNRELATED = 1 << 2,
SCOPE_RELATED = SCOPE_BASE | SCOPE_INHERITERS,
SCOPE_ALL = SCOPE_BASE | SCOPE_INHERITERS | SCOPE_UNRELATED
};
enum ScopeCombo {
COMBO_RELATED,
COMBO_SEPARATOR,
COMBO_BASE,
COMBO_INHERITERS,
COMBO_UNRELATED,
COMBO_ALL,
};
LineEdit *search_box = nullptr;
Button *case_sensitive_button = nullptr;
Button *hierarchy_button = nullptr;
Button *search_visual_script_nodes = nullptr;
Button *search_classes = nullptr;
Button *search_operators = nullptr;
Button *search_methods = nullptr;
Button *search_signals = nullptr;
Button *search_constants = nullptr;
Button *search_properties = nullptr;
Button *search_theme_items = nullptr;
OptionButton *scope_combo = nullptr;
Tree *results_tree = nullptr;
class SearchRunner;
Ref<SearchRunner> search_runner;
void _update_icons();
void _sbox_input(const Ref<InputEvent> &p_ie);
void _update_results_i(int p_int);
void _update_results_s(String p_string);
void _update_results_search_all();
void _update_results();
void _confirmed();
void _item_selected();
void _hide_requested();
EditorHelpBit *help_bit = nullptr;
bool properties = false;
bool visual_script_generic = false;
bool connecting = false;
String selected;
Variant::Type type;
String base_type;
String base_script;
ObjectID script;
Object *instance = nullptr;
bool virtuals_only = false;
VBoxContainer *vbox = nullptr;
protected:
void _notification(int p_what);
static void _bind_methods();
public:
void select_method_from_base_type(const String &p_base, const bool p_virtuals_only = false, const bool p_connecting = true, bool clear_text = true);
void select_from_base_type(const String &p_base, const String &p_base_script = "", bool p_virtuals_only = false, const bool p_connecting = true, bool clear_text = true);
void select_from_script(const Ref<Script> &p_script, const bool p_connecting = true, bool clear_text = true);
void select_from_basic_type(Variant::Type p_type, const bool p_connecting = true, bool clear_text = true);
void select_from_action(const String &p_type, const bool p_connecting = true, bool clear_text = true);
void select_from_instance(Object *p_instance, const bool p_connecting = true, bool clear_text = true);
void select_from_visual_script(const Ref<Script> &p_script, bool clear_text = true);
void show_window(float p_screen_ratio);
VisualScriptPropertySelector();
};
class VisualScriptPropertySelector::SearchRunner : public RefCounted {
enum Phase {
PHASE_INIT,
PHASE_MATCH_CLASSES_INIT,
PHASE_NODE_CLASSES_INIT,
PHASE_NODE_CLASSES_BUILD,
PHASE_MATCH_CLASSES,
PHASE_CLASS_ITEMS_INIT,
PHASE_CLASS_ITEMS,
PHASE_MEMBER_ITEMS_INIT,
PHASE_MEMBER_ITEMS,
PHASE_SELECT_MATCH,
PHASE_MAX
};
int phase = 0;
struct ClassMatch {
DocData::ClassDoc *doc;
bool name = false;
String category = "";
Vector<DocData::MethodDoc *> constructors;
Vector<DocData::MethodDoc *> methods;
Vector<DocData::MethodDoc *> operators;
Vector<DocData::MethodDoc *> signals;
Vector<DocData::ConstantDoc *> constants;
Vector<DocData::PropertyDoc *> properties;
Vector<DocData::ThemeItemDoc *> theme_properties;
bool required() {
return name || methods.size() || signals.size() || constants.size() || properties.size() || theme_properties.size();
}
};
VisualScriptPropertySelector *selector_ui = nullptr;
Control *ui_service = nullptr;
Tree *results_tree = nullptr;
String term;
int search_flags = 0;
int scope_flags = 0;
Ref<Texture2D> empty_icon;
Color disabled_color;
HashMap<String, DocData::ClassDoc>::Iterator iterator_doc;
HashMap<String, ClassMatch> matches;
HashMap<String, ClassMatch>::Iterator iterator_match;
TreeItem *root_item = nullptr;
HashMap<String, TreeItem *> class_items;
TreeItem *matched_item = nullptr;
float match_highest_score = 0;
HashMap<String, DocData::ClassDoc> combined_docs;
List<String> vs_nodes;
bool _is_class_disabled_by_feature_profile(const StringName &p_class);
bool _is_class_disabled_by_scope(const StringName &p_class);
bool _slice();
bool _phase_init();
bool _phase_match_classes_init();
bool _phase_node_classes_init();
bool _phase_node_classes_build();
bool _phase_match_classes();
bool _phase_class_items_init();
bool _phase_class_items();
bool _phase_member_items_init();
bool _phase_member_items();
bool _phase_select_match();
bool _match_string(const String &p_term, const String &p_string) const;
bool _match_visual_script(DocData::ClassDoc &class_doc);
bool _match_is_hidden(DocData::ClassDoc &class_doc);
void _match_item(TreeItem *p_item, const String &p_text);
void _add_class_doc(String class_name, String inherits, String category);
DocData::MethodDoc _get_method_doc(MethodInfo method_info);
TreeItem *_create_class_hierarchy(const ClassMatch &p_match);
TreeItem *_create_class_item(TreeItem *p_parent, const DocData::ClassDoc *p_doc, bool p_gray);
TreeItem *_create_method_item(TreeItem *p_parent, const DocData::ClassDoc *p_class_doc, const String &p_text, const DocData::MethodDoc *p_doc);
TreeItem *_create_signal_item(TreeItem *p_parent, const DocData::ClassDoc *p_class_doc, const DocData::MethodDoc *p_doc);
TreeItem *_create_constant_item(TreeItem *p_parent, const DocData::ClassDoc *p_class_doc, const DocData::ConstantDoc *p_doc);
TreeItem *_create_property_item(TreeItem *p_parent, const DocData::ClassDoc *p_class_doc, const DocData::PropertyDoc *p_doc);
TreeItem *_create_theme_property_item(TreeItem *p_parent, const DocData::ClassDoc *p_class_doc, const DocData::ThemeItemDoc *p_doc);
TreeItem *_create_member_item(TreeItem *p_parent, const String &p_class_name, const String &p_icon, const String &p_name, const String &p_text, const String &p_type, const String &p_metatype, const String &p_tooltip, const String &p_description);
public:
bool work(uint64_t slot = 100000);
SearchRunner(VisualScriptPropertySelector *p_selector_ui, Tree *p_results_tree);
};
#endif // VISUAL_SCRIPT_PROPERTY_SELECTOR_H

View File

@ -1 +0,0 @@
<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><g transform="translate(0 -1036.4)"><ellipse cx="3" cy="1039.4" fill="#e0e0e0"/><path d="m7 1-.56445 2.2578a5 5 0 0 0 -.68945.2793l-1.9883-1.1934-1.4141 1.4141 1.1953 1.9941a5 5 0 0 0 -.28516.68555l-2.2539.5625v2h5.2715a2 2 0 0 1 -.27148-1 2 2 0 0 1 2-2 2 2 0 0 1 2 2 2 2 0 0 1 -.26953 1h5.2695v-2l-2.2578-.56445a5 5 0 0 0 -.2793-.6875l1.1934-1.9902-1.4141-1.4141-1.9941 1.1953a5 5 0 0 0 -.68555-.28516l-.5625-2.2539h-2zm-4 9v6h2a3 3 0 0 0 3-3v-3h-2v3a1 1 0 0 1 -1 1v-4zm8 0a2 2 0 0 0 -1.7324 1 2 2 0 0 0 0 2 2 2 0 0 0 1.7324 1h-2v2h2a2 2 0 0 0 1.7324-1 2 2 0 0 0 0-2 2 2 0 0 0 -1.7324-1h2v-2z" fill="#e0e0e0" transform="translate(0 1036.4)"/></g></svg>

Before

Width:  |  Height:  |  Size: 737 B

View File

@ -1 +0,0 @@
<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><circle cx="3" cy="3.000024" fill="#e0e0e0" r="0"/><path d="m11 10a2 2 0 0 0 -1.7324 1 2 2 0 0 0 0 2 2 2 0 0 0 1.7324 1h-2v2h2a2 2 0 0 0 1.7324-1 2 2 0 0 0 0-2 2 2 0 0 0 -1.7324-1h2v-2z" fill="#e0e0e0"/><path d="m3 10v6h2a3 3 0 0 0 3-3v-3h-2v3a1 1 0 0 1 -1 1v-4z" fill="#e0e0e0"/><path d="m7 1-.56445 2.2578a5 5 0 0 0 -.68945.2793l-1.9883-1.1934-1.4141 1.4141 1.1953 1.9941a5 5 0 0 0 -.28516.68555l-2.2539.5625v2h5.2715a2 2 0 0 1 -.27148-1 2 2 0 0 1 2-2 2 2 0 0 1 2 2 2 2 0 0 1 -.26953 1h5.2695v-2l-2.2578-.56445a5 5 0 0 0 -.2793-.6875l1.1934-1.9902-1.4141-1.4141-1.9941 1.1953a5 5 0 0 0 -.68555-.28516l-.5625-2.2539h-2z" fill="none" stroke="#e0e0e0"/></svg>

Before

Width:  |  Height:  |  Size: 742 B

View File

@ -1,150 +0,0 @@
/*************************************************************************/
/* register_types.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "register_types.h"
#include "core/config/engine.h"
#include "core/io/resource_loader.h"
#include "visual_script.h"
#include "visual_script_builtin_funcs.h"
#include "visual_script_expression.h"
#include "visual_script_flow_control.h"
#include "visual_script_func_nodes.h"
#include "visual_script_nodes.h"
#include "visual_script_yield_nodes.h"
VisualScriptLanguage *visual_script_language = nullptr;
#ifdef TOOLS_ENABLED
#include "editor/visual_script_editor.h"
static VisualScriptCustomNodes *vs_custom_nodes_singleton = nullptr;
#endif
void initialize_visual_script_module(ModuleInitializationLevel p_level) {
if (p_level == MODULE_INITIALIZATION_LEVEL_SERVERS) {
visual_script_language = memnew(VisualScriptLanguage);
//script_language_gd->init();
ScriptServer::register_language(visual_script_language);
GDREGISTER_CLASS(VisualScript);
GDREGISTER_ABSTRACT_CLASS(VisualScriptNode);
GDREGISTER_CLASS(VisualScriptFunctionState);
GDREGISTER_CLASS(VisualScriptFunction);
GDREGISTER_ABSTRACT_CLASS(VisualScriptLists);
GDREGISTER_CLASS(VisualScriptComposeArray);
GDREGISTER_CLASS(VisualScriptOperator);
GDREGISTER_CLASS(VisualScriptVariableSet);
GDREGISTER_CLASS(VisualScriptVariableGet);
GDREGISTER_CLASS(VisualScriptConstant);
GDREGISTER_CLASS(VisualScriptIndexGet);
GDREGISTER_CLASS(VisualScriptIndexSet);
GDREGISTER_CLASS(VisualScriptGlobalConstant);
GDREGISTER_CLASS(VisualScriptClassConstant);
GDREGISTER_CLASS(VisualScriptMathConstant);
GDREGISTER_CLASS(VisualScriptBasicTypeConstant);
GDREGISTER_CLASS(VisualScriptEngineSingleton);
GDREGISTER_CLASS(VisualScriptSceneNode);
GDREGISTER_CLASS(VisualScriptSceneTree);
GDREGISTER_CLASS(VisualScriptResourcePath);
GDREGISTER_CLASS(VisualScriptSelf);
GDREGISTER_CLASS(VisualScriptCustomNode);
GDREGISTER_CLASS(VisualScriptSubCall);
GDREGISTER_CLASS(VisualScriptComment);
GDREGISTER_CLASS(VisualScriptConstructor);
GDREGISTER_CLASS(VisualScriptLocalVar);
GDREGISTER_CLASS(VisualScriptLocalVarSet);
GDREGISTER_CLASS(VisualScriptInputAction);
GDREGISTER_CLASS(VisualScriptDeconstruct);
GDREGISTER_CLASS(VisualScriptPreload);
GDREGISTER_CLASS(VisualScriptTypeCast);
GDREGISTER_CLASS(VisualScriptFunctionCall);
GDREGISTER_CLASS(VisualScriptPropertySet);
GDREGISTER_CLASS(VisualScriptPropertyGet);
//ClassDB::register_type<VisualScriptScriptCall>();
GDREGISTER_CLASS(VisualScriptEmitSignal);
GDREGISTER_CLASS(VisualScriptReturn);
GDREGISTER_CLASS(VisualScriptCondition);
GDREGISTER_CLASS(VisualScriptWhile);
GDREGISTER_CLASS(VisualScriptIterator);
GDREGISTER_CLASS(VisualScriptSequence);
//GDREGISTER_CLASS(VisualScriptInputFilter);
GDREGISTER_CLASS(VisualScriptSwitch);
GDREGISTER_CLASS(VisualScriptSelect);
GDREGISTER_CLASS(VisualScriptYield);
GDREGISTER_CLASS(VisualScriptYieldSignal);
GDREGISTER_CLASS(VisualScriptBuiltinFunc);
GDREGISTER_CLASS(VisualScriptExpression);
register_visual_script_nodes();
register_visual_script_func_nodes();
register_visual_script_builtin_func_node();
register_visual_script_flow_control_nodes();
register_visual_script_yield_nodes();
register_visual_script_expression_node();
}
#ifdef TOOLS_ENABLED
if (p_level == MODULE_INITIALIZATION_LEVEL_EDITOR) {
ClassDB::set_current_api(ClassDB::API_EDITOR);
GDREGISTER_CLASS(VisualScriptCustomNodes);
ClassDB::set_current_api(ClassDB::API_CORE);
vs_custom_nodes_singleton = memnew(VisualScriptCustomNodes);
Engine::get_singleton()->add_singleton(Engine::Singleton("VisualScriptCustomNodes", VisualScriptCustomNodes::get_singleton()));
VisualScriptEditor::register_editor();
}
#endif
}
void uninitialize_visual_script_module(ModuleInitializationLevel p_level) {
if (p_level == MODULE_INITIALIZATION_LEVEL_SERVERS) {
unregister_visual_script_nodes();
ScriptServer::unregister_language(visual_script_language);
if (visual_script_language) {
memdelete(visual_script_language);
}
}
#ifdef TOOLS_ENABLED
if (p_level == MODULE_INITIALIZATION_LEVEL_EDITOR) {
VisualScriptEditor::free_clipboard();
if (vs_custom_nodes_singleton) {
memdelete(vs_custom_nodes_singleton);
}
}
#endif
}

View File

@ -1,39 +0,0 @@
/*************************************************************************/
/* register_types.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef VISUAL_SCRIPT_REGISTER_TYPES_H
#define VISUAL_SCRIPT_REGISTER_TYPES_H
#include "modules/register_module_types.h"
void initialize_visual_script_module(ModuleInitializationLevel p_level);
void uninitialize_visual_script_module(ModuleInitializationLevel p_level);
#endif // VISUAL_SCRIPT_REGISTER_TYPES_H

File diff suppressed because it is too large Load Diff

View File

@ -1,630 +0,0 @@
/*************************************************************************/
/* visual_script.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef VISUAL_SCRIPT_H
#define VISUAL_SCRIPT_H
#include "core/debugger/engine_debugger.h"
#include "core/debugger/script_debugger.h"
#include "core/doc_data.h"
#include "core/object/script_language.h"
#include "core/os/thread.h"
#include "core/templates/rb_set.h"
class VisualScriptInstance;
class VisualScriptNodeInstance;
class VisualScript;
class VisualScriptNode : public Resource {
GDCLASS(VisualScriptNode, Resource);
friend class VisualScript;
Ref<VisualScript> script_used;
Array default_input_values;
bool breakpoint = false;
void _set_default_input_values(Array p_values);
Array _get_default_input_values() const;
void validate_input_default_values();
protected:
void ports_changed_notify();
static void _bind_methods();
public:
Ref<VisualScript> get_visual_script() const;
virtual int get_output_sequence_port_count() const = 0;
virtual bool has_input_sequence_port() const = 0;
virtual String get_output_sequence_port_text(int p_port) const = 0;
virtual bool has_mixed_input_and_sequence_ports() const { return false; }
virtual int get_input_value_port_count() const = 0;
virtual int get_output_value_port_count() const = 0;
virtual PropertyInfo get_input_value_port_info(int p_idx) const = 0;
virtual PropertyInfo get_output_value_port_info(int p_idx) const = 0;
void set_default_input_value(int p_port, const Variant &p_value);
Variant get_default_input_value(int p_port) const;
virtual String get_caption() const = 0;
virtual String get_text() const;
virtual String get_category() const = 0;
// Used by editor, this is not really saved.
void set_breakpoint(bool p_breakpoint);
bool is_breakpoint() const;
virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) = 0;
struct TypeGuess {
Variant::Type type = Variant::NIL;
StringName gdclass;
Ref<Script> script;
};
virtual TypeGuess guess_output_type(TypeGuess *p_inputs, int p_output) const;
VisualScriptNode();
};
class VisualScriptNodeInstance {
friend class VisualScriptInstance;
friend class VisualScriptLanguage; // For debugger.
enum { // Input argument addressing.
INPUT_SHIFT = 1 << 24,
INPUT_MASK = INPUT_SHIFT - 1,
INPUT_DEFAULT_VALUE_BIT = INPUT_SHIFT, // from unassigned input port, using default value (edited by user)
};
int id = 0;
int sequence_index = 0;
VisualScriptNodeInstance **sequence_outputs = nullptr;
int sequence_output_count = 0;
Vector<VisualScriptNodeInstance *> dependencies;
int *input_ports = nullptr;
int input_port_count = 0;
int *output_ports = nullptr;
int output_port_count = 0;
int working_mem_idx = 0;
int pass_idx = 0;
VisualScriptNode *base = nullptr;
public:
enum StartMode {
START_MODE_BEGIN_SEQUENCE,
START_MODE_CONTINUE_SEQUENCE,
START_MODE_RESUME_YIELD
};
enum {
STEP_SHIFT = 1 << 24,
STEP_MASK = STEP_SHIFT - 1,
STEP_FLAG_PUSH_STACK_BIT = STEP_SHIFT, // push bit to stack
STEP_FLAG_GO_BACK_BIT = STEP_SHIFT << 1, // go back to previous node
STEP_NO_ADVANCE_BIT = STEP_SHIFT << 2, // do not advance past this node
STEP_EXIT_FUNCTION_BIT = STEP_SHIFT << 3, // return from function
STEP_YIELD_BIT = STEP_SHIFT << 4, // yield (will find VisualScriptFunctionState state in first working memory)
FLOW_STACK_PUSHED_BIT = 1 << 30, // in flow stack, means bit was pushed (must go back here if end of sequence)
FLOW_STACK_MASK = FLOW_STACK_PUSHED_BIT - 1
};
_FORCE_INLINE_ int get_input_port_count() const { return input_port_count; }
_FORCE_INLINE_ int get_output_port_count() const { return output_port_count; }
_FORCE_INLINE_ int get_sequence_output_count() const { return sequence_output_count; }
_FORCE_INLINE_ int get_id() const { return id; }
virtual int get_working_memory_size() const { return 0; }
virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) = 0; // Do a step, return which sequence port to go out.
Ref<VisualScriptNode> get_base_node() { return Ref<VisualScriptNode>(base); }
VisualScriptNodeInstance();
virtual ~VisualScriptNodeInstance();
};
class VisualScript : public Script {
GDCLASS(VisualScript, Script);
RES_BASE_EXTENSION("vs");
public:
struct SequenceConnection {
union {
struct {
uint64_t from_node : 24;
uint64_t from_output : 16;
uint64_t to_node : 24;
};
uint64_t id = 0;
};
bool operator<(const SequenceConnection &p_connection) const {
return id < p_connection.id;
}
};
struct DataConnection {
union {
struct {
uint64_t from_node : 24;
uint64_t from_port : 8;
uint64_t to_node : 24;
uint64_t to_port : 8;
};
uint64_t id = 0;
};
bool operator<(const DataConnection &p_connection) const {
return id < p_connection.id;
}
};
private:
friend class VisualScriptInstance;
StringName base_type;
struct Argument {
String name;
Variant::Type type = Variant::Type::NIL;
};
struct NodeData {
Point2 pos;
Ref<VisualScriptNode> node;
};
HashMap<int, NodeData> nodes; // Can be a sparse map.
RBSet<SequenceConnection> sequence_connections;
RBSet<DataConnection> data_connections;
Vector2 scroll;
struct Function {
int func_id;
Function() { func_id = -1; }
};
struct Variable {
PropertyInfo info;
Variant default_value;
bool _export = false;
// Add getter & setter options here.
};
HashMap<StringName, Function> functions;
HashMap<StringName, Variable> variables;
HashMap<StringName, Vector<Argument>> custom_signals;
Dictionary rpc_functions;
HashMap<Object *, VisualScriptInstance *> instances;
bool is_tool_script;
#ifdef TOOLS_ENABLED
RBSet<PlaceHolderScriptInstance *> placeholders;
// void _update_placeholder(PlaceHolderScriptInstance *p_placeholder);
virtual void _placeholder_erased(PlaceHolderScriptInstance *p_placeholder) override;
void _update_placeholders();
#endif
void _set_variable_info(const StringName &p_name, const Dictionary &p_info);
Dictionary _get_variable_info(const StringName &p_name) const;
void _set_data(const Dictionary &p_data);
Dictionary _get_data() const;
protected:
void _node_ports_changed(int p_id);
static void _bind_methods();
public:
bool inherits_script(const Ref<Script> &p_script) const override;
void set_scroll(const Vector2 &p_scroll);
Vector2 get_scroll() const;
void add_function(const StringName &p_name, int p_func_node_id);
bool has_function(const StringName &p_name) const;
void remove_function(const StringName &p_name);
void rename_function(const StringName &p_name, const StringName &p_new_name);
void get_function_list(List<StringName> *r_functions) const;
int get_function_node_id(const StringName &p_name) const;
void set_tool_enabled(bool p_enabled);
void add_node(int p_id, const Ref<VisualScriptNode> &p_node, const Point2 &p_pos = Point2());
void remove_node(int p_id);
bool has_node(int p_id) const;
Ref<VisualScriptNode> get_node(int p_id) const;
void set_node_position(int p_id, const Point2 &p_pos);
Point2 get_node_position(int p_id) const;
void get_node_list(List<int> *r_nodes) const;
void sequence_connect(int p_from_node, int p_from_output, int p_to_node);
void sequence_disconnect(int p_from_node, int p_from_output, int p_to_node);
bool has_sequence_connection(int p_from_node, int p_from_output, int p_to_node) const;
void get_sequence_connection_list(List<SequenceConnection> *r_connection) const;
RBSet<int> get_output_sequence_ports_connected(int from_node);
void data_connect(int p_from_node, int p_from_port, int p_to_node, int p_to_port);
void data_disconnect(int p_from_node, int p_from_port, int p_to_node, int p_to_port);
bool has_data_connection(int p_from_node, int p_from_port, int p_to_node, int p_to_port) const;
void get_data_connection_list(List<DataConnection> *r_connection) const;
bool is_input_value_port_connected(int p_node, int p_port) const;
bool get_input_value_port_connection_source(int p_node, int p_port, int *r_node, int *r_port) const;
void add_variable(const StringName &p_name, const Variant &p_default_value = Variant(), bool p_export = false);
bool has_variable(const StringName &p_name) const;
void remove_variable(const StringName &p_name);
void set_variable_default_value(const StringName &p_name, const Variant &p_value);
Variant get_variable_default_value(const StringName &p_name) const;
void set_variable_info(const StringName &p_name, const PropertyInfo &p_info);
PropertyInfo get_variable_info(const StringName &p_name) const;
void set_variable_export(const StringName &p_name, bool p_export);
bool get_variable_export(const StringName &p_name) const;
void get_variable_list(List<StringName> *r_variables) const;
void rename_variable(const StringName &p_name, const StringName &p_new_name);
void add_custom_signal(const StringName &p_name);
bool has_custom_signal(const StringName &p_name) const;
void custom_signal_add_argument(const StringName &p_func, Variant::Type p_type, const String &p_name, int p_index = -1);
void custom_signal_set_argument_type(const StringName &p_func, int p_argidx, Variant::Type p_type);
Variant::Type custom_signal_get_argument_type(const StringName &p_func, int p_argidx) const;
void custom_signal_set_argument_name(const StringName &p_func, int p_argidx, const String &p_name);
String custom_signal_get_argument_name(const StringName &p_func, int p_argidx) const;
void custom_signal_remove_argument(const StringName &p_func, int p_argidx);
int custom_signal_get_argument_count(const StringName &p_func) const;
void custom_signal_swap_argument(const StringName &p_func, int p_argidx, int p_with_argidx);
void remove_custom_signal(const StringName &p_name);
void rename_custom_signal(const StringName &p_name, const StringName &p_new_name);
RBSet<int> get_output_sequence_ports_connected(const String &edited_func, int from_node);
void get_custom_signal_list(List<StringName> *r_custom_signals) const;
int get_available_id() const;
void set_instance_base_type(const StringName &p_type);
virtual bool can_instantiate() const override;
virtual Ref<Script> get_base_script() const override;
virtual StringName get_instance_base_type() const override;
virtual ScriptInstance *instance_create(Object *p_this) override;
virtual bool instance_has(const Object *p_this) const override;
virtual bool has_source_code() const override;
virtual String get_source_code() const override;
virtual void set_source_code(const String &p_code) override;
virtual Error reload(bool p_keep_state = false) override;
#ifdef TOOLS_ENABLED
virtual Vector<DocData::ClassDoc> get_documentation() const override {
Vector<DocData::ClassDoc> docs;
return docs;
}
#endif // TOOLS_ENABLED
virtual bool is_tool() const override;
virtual bool is_valid() const override;
virtual ScriptLanguage *get_language() const override;
virtual bool has_script_signal(const StringName &p_signal) const override;
virtual void get_script_signal_list(List<MethodInfo> *r_signals) const override;
virtual bool get_property_default_value(const StringName &p_property, Variant &r_value) const override;
virtual void get_script_method_list(List<MethodInfo> *p_list) const override;
virtual bool has_method(const StringName &p_method) const override;
virtual MethodInfo get_method_info(const StringName &p_method) const override;
virtual void get_script_property_list(List<PropertyInfo> *p_list) const override;
virtual int get_member_line(const StringName &p_member) const override;
virtual const Variant get_rpc_config() const override;
#ifdef TOOLS_ENABLED
virtual bool are_subnodes_edited() const;
#endif
VisualScript();
~VisualScript();
};
class VisualScriptInstance : public ScriptInstance {
Object *owner = nullptr;
Ref<VisualScript> script;
HashMap<StringName, Variant> variables; // Using variable path, not script.
HashMap<int, VisualScriptNodeInstance *> instances;
struct Function {
int node = 0;
int max_stack = 0;
int trash_pos = 0;
int flow_stack_size = 0;
int pass_stack_size = 0;
int node_count = 0;
int argument_count = 0;
};
HashMap<StringName, Function> functions;
Vector<Variant> default_values;
int max_input_args = 0;
int max_output_args = 0;
StringName source;
void _dependency_step(VisualScriptNodeInstance *node, int p_pass, int *pass_stack, const Variant **input_args, Variant **output_args, Variant *variant_stack, Callable::CallError &r_error, String &error_str, VisualScriptNodeInstance **r_error_node);
Variant _call_internal(const StringName &p_method, void *p_stack, int p_stack_size, VisualScriptNodeInstance *p_node, int p_flow_stack_pos, int p_pass, bool p_resuming_yield, Callable::CallError &r_error);
friend class VisualScriptFunctionState; // For yield.
friend class VisualScriptLanguage; // For debugger.
public:
virtual bool set(const StringName &p_name, const Variant &p_value);
virtual bool get(const StringName &p_name, Variant &r_ret) const;
virtual void get_property_list(List<PropertyInfo> *p_properties) const;
virtual Variant::Type get_property_type(const StringName &p_name, bool *r_is_valid = nullptr) const;
virtual bool property_can_revert(const StringName &p_name) const { return false; };
virtual bool property_get_revert(const StringName &p_name, Variant &r_ret) const { return false; };
virtual void get_method_list(List<MethodInfo> *p_list) const;
virtual bool has_method(const StringName &p_method) const;
virtual Variant callp(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error);
virtual void notification(int p_notification);
String to_string(bool *r_valid);
bool set_variable(const StringName &p_variable, const Variant &p_value) {
HashMap<StringName, Variant>::Iterator E = variables.find(p_variable);
if (!E) {
return false;
}
E->value = p_value;
return true;
}
bool get_variable(const StringName &p_variable, Variant *r_variable) const {
HashMap<StringName, Variant>::ConstIterator E = variables.find(p_variable);
if (!E) {
return false;
}
*r_variable = E->value;
return true;
}
virtual Ref<Script> get_script() const;
_FORCE_INLINE_ VisualScript *get_script_ptr() { return script.ptr(); }
_FORCE_INLINE_ Object *get_owner_ptr() { return owner; }
void create(const Ref<VisualScript> &p_script, Object *p_owner);
virtual ScriptLanguage *get_language();
virtual const Variant get_rpc_config() const;
VisualScriptInstance();
~VisualScriptInstance();
};
class VisualScriptFunctionState : public RefCounted {
GDCLASS(VisualScriptFunctionState, RefCounted);
friend class VisualScriptInstance;
ObjectID instance_id;
ObjectID script_id;
VisualScriptInstance *instance = nullptr;
StringName function;
Vector<uint8_t> stack;
int working_mem_index = 0;
int variant_stack_size = 0;
VisualScriptNodeInstance *node = nullptr;
int flow_stack_pos = 0;
int pass = 0;
Variant _signal_callback(const Variant **p_args, int p_argcount, Callable::CallError &r_error);
protected:
static void _bind_methods();
public:
void connect_to_signal(Object *p_obj, const String &p_signal, Array p_binds);
bool is_valid() const;
Variant resume(Array p_args);
VisualScriptFunctionState();
~VisualScriptFunctionState();
};
typedef Ref<VisualScriptNode> (*VisualScriptNodeRegisterFunc)(const String &p_type);
class VisualScriptLanguage : public ScriptLanguage {
HashMap<String, VisualScriptNodeRegisterFunc> register_funcs;
struct CallLevel {
Variant *stack = nullptr;
Variant **work_mem = nullptr;
const StringName *function = nullptr;
VisualScriptInstance *instance = nullptr;
int *current_id = nullptr;
};
int _debug_parse_err_node = -1;
String _debug_parse_err_file = "";
String _debug_error;
int _debug_call_stack_pos = 0;
int _debug_max_call_stack;
CallLevel *_call_stack = nullptr;
public:
StringName notification = "_notification";
StringName _get_output_port_unsequenced;
StringName _step = "_step";
StringName _subcall = "_subcall";
static VisualScriptLanguage *singleton;
Mutex lock;
bool debug_break(const String &p_error, bool p_allow_continue = true);
bool debug_break_parse(const String &p_file, int p_node, const String &p_error);
_FORCE_INLINE_ void enter_function(VisualScriptInstance *p_instance, const StringName *p_function, Variant *p_stack, Variant **p_work_mem, int *current_id) {
if (Thread::get_main_id() != Thread::get_caller_id()) {
return; // No support for other threads than main for now.
}
if (EngineDebugger::get_script_debugger()->get_lines_left() > 0 && EngineDebugger::get_script_debugger()->get_depth() >= 0) {
EngineDebugger::get_script_debugger()->set_depth(EngineDebugger::get_script_debugger()->get_depth() + 1);
}
if (_debug_call_stack_pos >= _debug_max_call_stack) {
// Stack overflow.
_debug_error = vformat("Stack overflow (stack size: %s). Check for infinite recursion in your script.", _debug_max_call_stack);
EngineDebugger::get_script_debugger()->debug(this);
return;
}
_call_stack[_debug_call_stack_pos].stack = p_stack;
_call_stack[_debug_call_stack_pos].instance = p_instance;
_call_stack[_debug_call_stack_pos].function = p_function;
_call_stack[_debug_call_stack_pos].work_mem = p_work_mem;
_call_stack[_debug_call_stack_pos].current_id = current_id;
_debug_call_stack_pos++;
}
_FORCE_INLINE_ void exit_function() {
if (Thread::get_main_id() != Thread::get_caller_id()) {
return; // No support for other threads than main for now.
}
if (EngineDebugger::get_script_debugger()->get_lines_left() > 0 && EngineDebugger::get_script_debugger()->get_depth() >= 0) {
EngineDebugger::get_script_debugger()->set_depth(EngineDebugger::get_script_debugger()->get_depth() - 1);
}
if (_debug_call_stack_pos == 0) {
_debug_error = "Stack underflow (engine bug), please report.";
EngineDebugger::get_script_debugger()->debug(this);
return;
}
_debug_call_stack_pos--;
}
//////////////////////////////////////
virtual String get_name() const override;
/* LANGUAGE FUNCTIONS */
virtual void init() override;
virtual String get_type() const override;
virtual String get_extension() const override;
virtual Error execute_file(const String &p_path) override;
virtual void finish() override;
/* EDITOR FUNCTIONS */
virtual void get_reserved_words(List<String> *p_words) const override;
virtual bool is_control_flow_keyword(String p_keyword) const override;
virtual void get_comment_delimiters(List<String> *p_delimiters) const override;
virtual void get_string_delimiters(List<String> *p_delimiters) const override;
virtual bool is_using_templates() override;
virtual Ref<Script> make_template(const String &p_template, const String &p_class_name, const String &p_base_class_name) const override;
virtual bool validate(const String &p_script, const String &p_path = "", List<String> *r_functions = nullptr, List<ScriptLanguage::ScriptError> *r_errors = nullptr, List<ScriptLanguage::Warning> *r_warnings = nullptr, HashSet<int> *r_safe_lines = nullptr) const override;
virtual Script *create_script() const override;
virtual bool has_named_classes() const override;
virtual bool supports_builtin_mode() const override;
virtual int find_function(const String &p_function, const String &p_code) const override;
virtual String make_function(const String &p_class, const String &p_name, const PackedStringArray &p_args) const override;
virtual void auto_indent_code(String &p_code, int p_from_line, int p_to_line) const override;
virtual void add_global_constant(const StringName &p_variable, const Variant &p_value) override;
/* DEBUGGER FUNCTIONS */
virtual String debug_get_error() const override;
virtual int debug_get_stack_level_count() const override;
virtual int debug_get_stack_level_line(int p_level) const override;
virtual String debug_get_stack_level_function(int p_level) const override;
virtual String debug_get_stack_level_source(int p_level) const override;
virtual void debug_get_stack_level_locals(int p_level, List<String> *p_locals, List<Variant> *p_values, int p_max_subitems = -1, int p_max_depth = -1) override;
virtual void debug_get_stack_level_members(int p_level, List<String> *p_members, List<Variant> *p_values, int p_max_subitems = -1, int p_max_depth = -1) override;
virtual void debug_get_globals(List<String> *p_locals, List<Variant> *p_values, int p_max_subitems = -1, int p_max_depth = -1) override;
virtual String debug_parse_stack_level_expression(int p_level, const String &p_expression, int p_max_subitems = -1, int p_max_depth = -1) override;
virtual void reload_all_scripts() override;
virtual void reload_tool_script(const Ref<Script> &p_script, bool p_soft_reload) override;
/* LOADER FUNCTIONS */
virtual void get_recognized_extensions(List<String> *p_extensions) const override;
virtual void get_public_functions(List<MethodInfo> *p_functions) const override;
virtual void get_public_constants(List<Pair<String, Variant>> *p_constants) const override;
virtual void get_public_annotations(List<MethodInfo> *p_annotations) const override;
virtual void profiling_start() override;
virtual void profiling_stop() override;
virtual int profiling_get_accumulated_data(ProfilingInfo *p_info_arr, int p_info_max) override;
virtual int profiling_get_frame_data(ProfilingInfo *p_info_arr, int p_info_max) override;
void add_register_func(const String &p_name, VisualScriptNodeRegisterFunc p_func);
void remove_register_func(const String &p_name);
Ref<VisualScriptNode> create_node_from_name(const String &p_name);
void get_registered_node_names(List<String> *r_names);
VisualScriptLanguage();
~VisualScriptLanguage();
};
// Aid for registering.
template <class T>
static Ref<VisualScriptNode> create_node_generic(const String &p_name) {
Ref<T> node;
node.instantiate();
return node;
}
#endif // VISUAL_SCRIPT_H

File diff suppressed because it is too large Load Diff

View File

@ -1,153 +0,0 @@
/*************************************************************************/
/* visual_script_builtin_funcs.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef VISUAL_SCRIPT_BUILTIN_FUNCS_H
#define VISUAL_SCRIPT_BUILTIN_FUNCS_H
#include "visual_script.h"
class VisualScriptBuiltinFunc : public VisualScriptNode {
GDCLASS(VisualScriptBuiltinFunc, VisualScriptNode);
public:
enum BuiltinFunc {
MATH_SIN,
MATH_COS,
MATH_TAN,
MATH_SINH,
MATH_COSH,
MATH_TANH,
MATH_ASIN,
MATH_ACOS,
MATH_ATAN,
MATH_ATAN2,
MATH_SQRT,
MATH_FMOD,
MATH_FPOSMOD,
MATH_FLOOR,
MATH_CEIL,
MATH_ROUND,
MATH_ABS,
MATH_SIGN,
MATH_POW,
MATH_LOG,
MATH_EXP,
MATH_ISNAN,
MATH_ISINF,
MATH_EASE,
MATH_STEP_DECIMALS,
MATH_SNAPPED,
MATH_LERP,
MATH_CUBIC_INTERPOLATE,
MATH_INVERSE_LERP,
MATH_RANGE_LERP,
MATH_MOVE_TOWARD,
MATH_RANDOMIZE,
MATH_RANDI,
MATH_RANDF,
MATH_RANDI_RANGE,
MATH_RANDF_RANGE,
MATH_RANDFN,
MATH_SEED,
MATH_RANDSEED,
MATH_DEG2RAD,
MATH_RAD2DEG,
MATH_LINEAR2DB,
MATH_DB2LINEAR,
MATH_WRAP,
MATH_WRAPF,
MATH_PINGPONG,
LOGIC_MAX,
LOGIC_MIN,
LOGIC_CLAMP,
LOGIC_NEAREST_PO2,
OBJ_WEAKREF,
TYPE_CONVERT,
TYPE_OF,
TYPE_EXISTS,
TEXT_CHAR,
TEXT_STR,
TEXT_PRINT,
TEXT_PRINTERR,
TEXT_PRINTRAW,
TEXT_PRINT_VERBOSE,
VAR_TO_STR,
STR_TO_VAR,
VAR_TO_BYTES,
BYTES_TO_VAR,
MATH_SMOOTHSTEP,
MATH_POSMOD,
MATH_LERP_ANGLE,
TEXT_ORD,
FUNC_MAX
};
static int get_func_argument_count(BuiltinFunc p_func);
static String get_func_name(BuiltinFunc p_func);
static void exec_func(BuiltinFunc p_func, const Variant **p_inputs, Variant *r_return, Callable::CallError &r_error, String &r_error_str);
static BuiltinFunc find_function(const String &p_string);
private:
static const char *func_name[FUNC_MAX];
BuiltinFunc func;
protected:
static void _bind_methods();
public:
virtual int get_output_sequence_port_count() const override;
virtual bool has_input_sequence_port() const override;
virtual String get_output_sequence_port_text(int p_port) const override;
virtual int get_input_value_port_count() const override;
virtual int get_output_value_port_count() const override;
virtual PropertyInfo get_input_value_port_info(int p_idx) const override;
virtual PropertyInfo get_output_value_port_info(int p_idx) const override;
virtual String get_caption() const override;
//virtual String get_text() const;
virtual String get_category() const override { return "functions"; }
void set_func(BuiltinFunc p_which);
BuiltinFunc get_func();
virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
VisualScriptBuiltinFunc(VisualScriptBuiltinFunc::BuiltinFunc func);
VisualScriptBuiltinFunc();
};
VARIANT_ENUM_CAST(VisualScriptBuiltinFunc::BuiltinFunc)
void register_visual_script_builtin_func_node();
#endif // VISUAL_SCRIPT_BUILTIN_FUNCS_H

File diff suppressed because it is too large Load Diff

View File

@ -1,284 +0,0 @@
/*************************************************************************/
/* visual_script_expression.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef VISUAL_SCRIPT_EXPRESSION_H
#define VISUAL_SCRIPT_EXPRESSION_H
#include "visual_script.h"
#include "visual_script_builtin_funcs.h"
class VisualScriptExpression : public VisualScriptNode {
GDCLASS(VisualScriptExpression, VisualScriptNode);
friend class VisualScriptNodeInstanceExpression;
struct Input {
Variant::Type type = Variant::NIL;
String name;
};
Vector<Input> inputs;
Variant::Type output_type = Variant::NIL;
String expression;
bool sequenced = false;
int str_ofs = 0;
bool expression_dirty = true;
bool _compile_expression();
enum TokenType {
TK_CURLY_BRACKET_OPEN,
TK_CURLY_BRACKET_CLOSE,
TK_BRACKET_OPEN,
TK_BRACKET_CLOSE,
TK_PARENTHESIS_OPEN,
TK_PARENTHESIS_CLOSE,
TK_IDENTIFIER,
TK_BUILTIN_FUNC,
TK_SELF,
TK_CONSTANT,
TK_BASIC_TYPE,
TK_COLON,
TK_COMMA,
TK_PERIOD,
TK_OP_IN,
TK_OP_EQUAL,
TK_OP_NOT_EQUAL,
TK_OP_LESS,
TK_OP_LESS_EQUAL,
TK_OP_GREATER,
TK_OP_GREATER_EQUAL,
TK_OP_AND,
TK_OP_OR,
TK_OP_NOT,
TK_OP_ADD,
TK_OP_SUB,
TK_OP_MUL,
TK_OP_DIV,
TK_OP_MOD,
TK_OP_SHIFT_LEFT,
TK_OP_SHIFT_RIGHT,
TK_OP_BIT_AND,
TK_OP_BIT_OR,
TK_OP_BIT_XOR,
TK_OP_BIT_INVERT,
TK_EOF,
TK_ERROR,
TK_MAX
};
static const char *token_name[TK_MAX];
struct Token {
TokenType type;
Variant value;
};
void _set_error(const String &p_err) {
if (error_set) {
return;
}
error_str = p_err;
error_set = true;
}
Error _get_token(Token &r_token);
String error_str;
bool error_set = true;
struct ENode {
enum Type {
TYPE_INPUT,
TYPE_CONSTANT,
TYPE_SELF,
TYPE_OPERATOR,
TYPE_INDEX,
TYPE_NAMED_INDEX,
TYPE_ARRAY,
TYPE_DICTIONARY,
TYPE_CONSTRUCTOR,
TYPE_BUILTIN_FUNC,
TYPE_CALL
};
ENode *next = nullptr;
Type type = Type::TYPE_SELF;
virtual ~ENode() {
if (next) {
memdelete(next);
}
}
};
struct Expression {
bool is_op = false;
union {
Variant::Operator op;
ENode *node = nullptr;
};
};
ENode *_parse_expression();
struct InputNode : public ENode {
int index = 0;
InputNode() {
type = TYPE_INPUT;
}
};
struct ConstantNode : public ENode {
Variant value;
ConstantNode() {
type = TYPE_CONSTANT;
}
};
struct OperatorNode : public ENode {
Variant::Operator op = Variant::Operator::OP_ADD;
ENode *nodes[2] = { nullptr, nullptr };
OperatorNode() {
type = TYPE_OPERATOR;
}
};
struct SelfNode : public ENode {
SelfNode() {
type = TYPE_SELF;
}
};
struct IndexNode : public ENode {
ENode *base = nullptr;
ENode *index = nullptr;
IndexNode() {
type = TYPE_INDEX;
}
};
struct NamedIndexNode : public ENode {
ENode *base = nullptr;
StringName name;
NamedIndexNode() {
type = TYPE_NAMED_INDEX;
}
};
struct ConstructorNode : public ENode {
Variant::Type data_type = Variant::Type::NIL;
Vector<ENode *> arguments;
ConstructorNode() {
type = TYPE_CONSTRUCTOR;
}
};
struct CallNode : public ENode {
ENode *base = nullptr;
StringName method;
Vector<ENode *> arguments;
CallNode() {
type = TYPE_CALL;
}
};
struct ArrayNode : public ENode {
Vector<ENode *> array;
ArrayNode() {
type = TYPE_ARRAY;
}
};
struct DictionaryNode : public ENode {
Vector<ENode *> dict;
DictionaryNode() {
type = TYPE_DICTIONARY;
}
};
struct BuiltinFuncNode : public ENode {
VisualScriptBuiltinFunc::BuiltinFunc func = VisualScriptBuiltinFunc::BuiltinFunc::BYTES_TO_VAR;
Vector<ENode *> arguments;
BuiltinFuncNode() {
type = TYPE_BUILTIN_FUNC;
}
};
template <class T>
T *alloc_node() {
T *node = memnew(T);
node->next = nodes;
nodes = node;
return node;
}
ENode *root = nullptr;
ENode *nodes = nullptr;
protected:
bool _set(const StringName &p_name, const Variant &p_value);
bool _get(const StringName &p_name, Variant &r_ret) const;
void _get_property_list(List<PropertyInfo> *p_list) const;
public:
virtual void reset_state() override;
virtual int get_output_sequence_port_count() const override;
virtual bool has_input_sequence_port() const override;
virtual String get_output_sequence_port_text(int p_port) const override;
virtual int get_input_value_port_count() const override;
virtual int get_output_value_port_count() const override;
virtual PropertyInfo get_input_value_port_info(int p_idx) const override;
virtual PropertyInfo get_output_value_port_info(int p_idx) const override;
virtual String get_caption() const override;
virtual String get_text() const override;
virtual String get_category() const override { return "operators"; }
virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
VisualScriptExpression();
~VisualScriptExpression();
};
void register_visual_script_expression_node();
#endif // VISUAL_SCRIPT_EXPRESSION_H

View File

@ -1,880 +0,0 @@
/*************************************************************************/
/* visual_script_flow_control.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "visual_script_flow_control.h"
#include "core/config/project_settings.h"
#include "core/io/resource_loader.h"
#include "core/os/keyboard.h"
//////////////////////////////////////////
////////////////RETURN////////////////////
//////////////////////////////////////////
int VisualScriptReturn::get_output_sequence_port_count() const {
return 0;
}
bool VisualScriptReturn::has_input_sequence_port() const {
return true;
}
int VisualScriptReturn::get_input_value_port_count() const {
return with_value ? 1 : 0;
}
int VisualScriptReturn::get_output_value_port_count() const {
return 0;
}
String VisualScriptReturn::get_output_sequence_port_text(int p_port) const {
return String();
}
PropertyInfo VisualScriptReturn::get_input_value_port_info(int p_idx) const {
PropertyInfo pinfo;
pinfo.name = "result";
pinfo.type = type;
return pinfo;
}
PropertyInfo VisualScriptReturn::get_output_value_port_info(int p_idx) const {
return PropertyInfo();
}
String VisualScriptReturn::get_caption() const {
return RTR("Return");
}
String VisualScriptReturn::get_text() const {
return get_name();
}
void VisualScriptReturn::set_return_type(Variant::Type p_type) {
if (type == p_type) {
return;
}
type = p_type;
ports_changed_notify();
}
Variant::Type VisualScriptReturn::get_return_type() const {
return type;
}
void VisualScriptReturn::set_enable_return_value(bool p_enable) {
if (with_value == p_enable) {
return;
}
with_value = p_enable;
ports_changed_notify();
}
bool VisualScriptReturn::is_return_value_enabled() const {
return with_value;
}
void VisualScriptReturn::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_return_type", "type"), &VisualScriptReturn::set_return_type);
ClassDB::bind_method(D_METHOD("get_return_type"), &VisualScriptReturn::get_return_type);
ClassDB::bind_method(D_METHOD("set_enable_return_value", "enable"), &VisualScriptReturn::set_enable_return_value);
ClassDB::bind_method(D_METHOD("is_return_value_enabled"), &VisualScriptReturn::is_return_value_enabled);
String argt = "Any";
for (int i = 1; i < Variant::VARIANT_MAX; i++) {
argt += "," + Variant::get_type_name(Variant::Type(i));
}
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "return_enabled"), "set_enable_return_value", "is_return_value_enabled");
ADD_PROPERTY(PropertyInfo(Variant::INT, "return_type", PROPERTY_HINT_ENUM, argt), "set_return_type", "get_return_type");
}
class VisualScriptNodeInstanceReturn : public VisualScriptNodeInstance {
public:
VisualScriptReturn *node = nullptr;
VisualScriptInstance *instance = nullptr;
bool with_value = false;
virtual int get_working_memory_size() const override { return 1; }
//virtual bool is_output_port_unsequenced(int p_idx) const { return false; }
//virtual bool get_output_port_unsequenced(int p_idx,Variant* r_value,Variant* p_working_mem,String &r_error) const { return true; }
virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) override {
if (with_value) {
*p_working_mem = *p_inputs[0];
return STEP_EXIT_FUNCTION_BIT;
} else {
*p_working_mem = Variant();
return 0;
}
}
};
VisualScriptNodeInstance *VisualScriptReturn::instantiate(VisualScriptInstance *p_instance) {
VisualScriptNodeInstanceReturn *instance = memnew(VisualScriptNodeInstanceReturn);
instance->node = this;
instance->instance = p_instance;
instance->with_value = with_value;
return instance;
}
VisualScriptReturn::VisualScriptReturn() {
with_value = false;
type = Variant::NIL;
}
template <bool with_value>
static Ref<VisualScriptNode> create_return_node(const String &p_name) {
Ref<VisualScriptReturn> node;
node.instantiate();
node->set_enable_return_value(with_value);
return node;
}
//////////////////////////////////////////
////////////////CONDITION/////////////////
//////////////////////////////////////////
int VisualScriptCondition::get_output_sequence_port_count() const {
return 3;
}
bool VisualScriptCondition::has_input_sequence_port() const {
return true;
}
int VisualScriptCondition::get_input_value_port_count() const {
return 1;
}
int VisualScriptCondition::get_output_value_port_count() const {
return 0;
}
String VisualScriptCondition::get_output_sequence_port_text(int p_port) const {
if (p_port == 0) {
return "true";
} else if (p_port == 1) {
return "false";
} else {
return "done";
}
}
PropertyInfo VisualScriptCondition::get_input_value_port_info(int p_idx) const {
PropertyInfo pinfo;
pinfo.name = "cond";
pinfo.type = Variant::BOOL;
return pinfo;
}
PropertyInfo VisualScriptCondition::get_output_value_port_info(int p_idx) const {
return PropertyInfo();
}
String VisualScriptCondition::get_caption() const {
return RTR("Condition");
}
String VisualScriptCondition::get_text() const {
return RTR("if (cond) is:");
}
void VisualScriptCondition::_bind_methods() {
}
class VisualScriptNodeInstanceCondition : public VisualScriptNodeInstance {
public:
VisualScriptCondition *node = nullptr;
VisualScriptInstance *instance = nullptr;
//virtual int get_working_memory_size() const override { return 1; }
//virtual bool is_output_port_unsequenced(int p_idx) const { return false; }
//virtual bool get_output_port_unsequenced(int p_idx,Variant* r_value,Variant* p_working_mem,String &r_error) const { return true; }
virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) override {
if (p_start_mode == START_MODE_CONTINUE_SEQUENCE) {
return 2;
} else if (p_inputs[0]->operator bool()) {
return 0 | STEP_FLAG_PUSH_STACK_BIT;
} else {
return 1 | STEP_FLAG_PUSH_STACK_BIT;
}
}
};
VisualScriptNodeInstance *VisualScriptCondition::instantiate(VisualScriptInstance *p_instance) {
VisualScriptNodeInstanceCondition *instance = memnew(VisualScriptNodeInstanceCondition);
instance->node = this;
instance->instance = p_instance;
return instance;
}
VisualScriptCondition::VisualScriptCondition() {
}
//////////////////////////////////////////
////////////////WHILE/////////////////
//////////////////////////////////////////
int VisualScriptWhile::get_output_sequence_port_count() const {
return 2;
}
bool VisualScriptWhile::has_input_sequence_port() const {
return true;
}
int VisualScriptWhile::get_input_value_port_count() const {
return 1;
}
int VisualScriptWhile::get_output_value_port_count() const {
return 0;
}
String VisualScriptWhile::get_output_sequence_port_text(int p_port) const {
if (p_port == 0) {
return "repeat";
} else {
return "exit";
}
}
PropertyInfo VisualScriptWhile::get_input_value_port_info(int p_idx) const {
PropertyInfo pinfo;
pinfo.name = "cond";
pinfo.type = Variant::BOOL;
return pinfo;
}
PropertyInfo VisualScriptWhile::get_output_value_port_info(int p_idx) const {
return PropertyInfo();
}
String VisualScriptWhile::get_caption() const {
return RTR("While");
}
String VisualScriptWhile::get_text() const {
return RTR("while (cond):");
}
void VisualScriptWhile::_bind_methods() {
}
class VisualScriptNodeInstanceWhile : public VisualScriptNodeInstance {
public:
VisualScriptWhile *node = nullptr;
VisualScriptInstance *instance = nullptr;
//virtual int get_working_memory_size() const override { return 1; }
//virtual bool is_output_port_unsequenced(int p_idx) const { return false; }
//virtual bool get_output_port_unsequenced(int p_idx,Variant* r_value,Variant* p_working_mem,String &r_error) const { return true; }
virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) override {
bool keep_going = p_inputs[0]->operator bool();
if (keep_going) {
return 0 | STEP_FLAG_PUSH_STACK_BIT;
} else {
return 1;
}
}
};
VisualScriptNodeInstance *VisualScriptWhile::instantiate(VisualScriptInstance *p_instance) {
VisualScriptNodeInstanceWhile *instance = memnew(VisualScriptNodeInstanceWhile);
instance->node = this;
instance->instance = p_instance;
return instance;
}
VisualScriptWhile::VisualScriptWhile() {
}
//////////////////////////////////////////
////////////////ITERATOR/////////////////
//////////////////////////////////////////
int VisualScriptIterator::get_output_sequence_port_count() const {
return 2;
}
bool VisualScriptIterator::has_input_sequence_port() const {
return true;
}
int VisualScriptIterator::get_input_value_port_count() const {
return 1;
}
int VisualScriptIterator::get_output_value_port_count() const {
return 1;
}
String VisualScriptIterator::get_output_sequence_port_text(int p_port) const {
if (p_port == 0) {
return "each";
} else {
return "exit";
}
}
PropertyInfo VisualScriptIterator::get_input_value_port_info(int p_idx) const {
PropertyInfo pinfo;
pinfo.name = "input";
pinfo.type = Variant::NIL;
return pinfo;
}
PropertyInfo VisualScriptIterator::get_output_value_port_info(int p_idx) const {
PropertyInfo pinfo;
pinfo.name = "elem";
pinfo.type = Variant::NIL;
return pinfo;
}
String VisualScriptIterator::get_caption() const {
return RTR("Iterator");
}
String VisualScriptIterator::get_text() const {
return RTR("for (elem) in (input):");
}
void VisualScriptIterator::_bind_methods() {
}
class VisualScriptNodeInstanceIterator : public VisualScriptNodeInstance {
public:
VisualScriptIterator *node = nullptr;
VisualScriptInstance *instance = nullptr;
virtual int get_working_memory_size() const override { return 2; }
//virtual bool is_output_port_unsequenced(int p_idx) const { return false; }
//virtual bool get_output_port_unsequenced(int p_idx,Variant* r_value,Variant* p_working_mem,String &r_error) const { return true; }
virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) override {
if (p_start_mode == START_MODE_BEGIN_SEQUENCE) {
p_working_mem[0] = *p_inputs[0];
bool valid;
bool can_iter = p_inputs[0]->iter_init(p_working_mem[1], valid);
if (!valid) {
r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
r_error_str = RTR("Input type not iterable:") + " " + Variant::get_type_name(p_inputs[0]->get_type());
return 0;
}
if (!can_iter) {
return 1; //nothing to iterate
}
*p_outputs[0] = p_working_mem[0].iter_get(p_working_mem[1], valid);
if (!valid) {
r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
r_error_str = RTR("Iterator became invalid");
return 0;
}
} else { //continue sequence
bool valid;
bool can_iter = p_working_mem[0].iter_next(p_working_mem[1], valid);
if (!valid) {
r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
r_error_str = RTR("Iterator became invalid:") + " " + Variant::get_type_name(p_inputs[0]->get_type());
return 0;
}
if (!can_iter) {
return 1; //nothing to iterate
}
*p_outputs[0] = p_working_mem[0].iter_get(p_working_mem[1], valid);
if (!valid) {
r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
r_error_str = RTR("Iterator became invalid");
return 0;
}
}
return 0 | STEP_FLAG_PUSH_STACK_BIT; //go around
}
};
VisualScriptNodeInstance *VisualScriptIterator::instantiate(VisualScriptInstance *p_instance) {
VisualScriptNodeInstanceIterator *instance = memnew(VisualScriptNodeInstanceIterator);
instance->node = this;
instance->instance = p_instance;
return instance;
}
VisualScriptIterator::VisualScriptIterator() {
}
//////////////////////////////////////////
////////////////SEQUENCE/////////////////
//////////////////////////////////////////
int VisualScriptSequence::get_output_sequence_port_count() const {
return steps;
}
bool VisualScriptSequence::has_input_sequence_port() const {
return true;
}
int VisualScriptSequence::get_input_value_port_count() const {
return 0;
}
int VisualScriptSequence::get_output_value_port_count() const {
return 1;
}
String VisualScriptSequence::get_output_sequence_port_text(int p_port) const {
return itos(p_port + 1);
}
PropertyInfo VisualScriptSequence::get_input_value_port_info(int p_idx) const {
return PropertyInfo();
}
PropertyInfo VisualScriptSequence::get_output_value_port_info(int p_idx) const {
return PropertyInfo(Variant::INT, "current");
}
String VisualScriptSequence::get_caption() const {
return RTR("Sequence");
}
String VisualScriptSequence::get_text() const {
return RTR("in order:");
}
void VisualScriptSequence::set_steps(int p_steps) {
ERR_FAIL_COND(p_steps < 1);
if (steps == p_steps) {
return;
}
steps = p_steps;
ports_changed_notify();
}
int VisualScriptSequence::get_steps() const {
return steps;
}
void VisualScriptSequence::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_steps", "steps"), &VisualScriptSequence::set_steps);
ClassDB::bind_method(D_METHOD("get_steps"), &VisualScriptSequence::get_steps);
ADD_PROPERTY(PropertyInfo(Variant::INT, "steps", PROPERTY_HINT_RANGE, "1,64,1"), "set_steps", "get_steps");
}
class VisualScriptNodeInstanceSequence : public VisualScriptNodeInstance {
public:
VisualScriptSequence *node = nullptr;
VisualScriptInstance *instance = nullptr;
int steps = 0;
virtual int get_working_memory_size() const override { return 1; }
//virtual bool is_output_port_unsequenced(int p_idx) const { return false; }
//virtual bool get_output_port_unsequenced(int p_idx,Variant* r_value,Variant* p_working_mem,String &r_error) const { return true; }
virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) override {
if (p_start_mode == START_MODE_BEGIN_SEQUENCE) {
p_working_mem[0] = 0;
}
int step = p_working_mem[0];
*p_outputs[0] = step;
if (step + 1 == steps) {
return step;
} else {
p_working_mem[0] = step + 1;
return step | STEP_FLAG_PUSH_STACK_BIT;
}
}
};
VisualScriptNodeInstance *VisualScriptSequence::instantiate(VisualScriptInstance *p_instance) {
VisualScriptNodeInstanceSequence *instance = memnew(VisualScriptNodeInstanceSequence);
instance->node = this;
instance->instance = p_instance;
instance->steps = steps;
return instance;
}
VisualScriptSequence::VisualScriptSequence() {
steps = 1;
}
//////////////////////////////////////////
////////////////EVENT TYPE FILTER///////////
//////////////////////////////////////////
int VisualScriptSwitch::get_output_sequence_port_count() const {
return case_values.size() + 1;
}
bool VisualScriptSwitch::has_input_sequence_port() const {
return true;
}
int VisualScriptSwitch::get_input_value_port_count() const {
return case_values.size() + 1;
}
int VisualScriptSwitch::get_output_value_port_count() const {
return 0;
}
String VisualScriptSwitch::get_output_sequence_port_text(int p_port) const {
if (p_port == case_values.size()) {
return "done";
}
return String();
}
PropertyInfo VisualScriptSwitch::get_input_value_port_info(int p_idx) const {
if (p_idx < case_values.size()) {
return PropertyInfo(case_values[p_idx].type, " =");
} else {
return PropertyInfo(Variant::NIL, "input");
}
}
PropertyInfo VisualScriptSwitch::get_output_value_port_info(int p_idx) const {
return PropertyInfo();
}
String VisualScriptSwitch::get_caption() const {
return RTR("Switch");
}
String VisualScriptSwitch::get_text() const {
return RTR("'input' is:");
}
class VisualScriptNodeInstanceSwitch : public VisualScriptNodeInstance {
public:
VisualScriptInstance *instance = nullptr;
int case_count = 0;
//virtual int get_working_memory_size() const override { return 0; }
//virtual bool is_output_port_unsequenced(int p_idx) const { return false; }
//virtual bool get_output_port_unsequenced(int p_idx,Variant* r_value,Variant* p_working_mem,String &r_error) const { return false; }
virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) override {
if (p_start_mode == START_MODE_CONTINUE_SEQUENCE) {
return case_count; //exit
}
for (int i = 0; i < case_count; i++) {
if (*p_inputs[i] == *p_inputs[case_count]) {
return i | STEP_FLAG_PUSH_STACK_BIT;
}
}
return case_count;
}
};
VisualScriptNodeInstance *VisualScriptSwitch::instantiate(VisualScriptInstance *p_instance) {
VisualScriptNodeInstanceSwitch *instance = memnew(VisualScriptNodeInstanceSwitch);
instance->instance = p_instance;
instance->case_count = case_values.size();
return instance;
}
bool VisualScriptSwitch::_set(const StringName &p_name, const Variant &p_value) {
if (String(p_name) == "case_count") {
case_values.resize(p_value);
notify_property_list_changed();
ports_changed_notify();
return true;
}
if (String(p_name).begins_with("case/")) {
int idx = String(p_name).get_slice("/", 1).to_int();
ERR_FAIL_INDEX_V(idx, case_values.size(), false);
case_values.write[idx].type = Variant::Type(int(p_value));
notify_property_list_changed();
ports_changed_notify();
return true;
}
return false;
}
bool VisualScriptSwitch::_get(const StringName &p_name, Variant &r_ret) const {
if (String(p_name) == "case_count") {
r_ret = case_values.size();
return true;
}
if (String(p_name).begins_with("case/")) {
int idx = String(p_name).get_slice("/", 1).to_int();
ERR_FAIL_INDEX_V(idx, case_values.size(), false);
r_ret = case_values[idx].type;
return true;
}
return false;
}
void VisualScriptSwitch::_get_property_list(List<PropertyInfo> *p_list) const {
p_list->push_back(PropertyInfo(Variant::INT, "case_count", PROPERTY_HINT_RANGE, "0,128"));
String argt = "Any";
for (int i = 1; i < Variant::VARIANT_MAX; i++) {
argt += "," + Variant::get_type_name(Variant::Type(i));
}
for (int i = 0; i < case_values.size(); i++) {
p_list->push_back(PropertyInfo(Variant::INT, "case/" + itos(i), PROPERTY_HINT_ENUM, argt));
}
}
void VisualScriptSwitch::reset_state() {
case_values.clear();
}
void VisualScriptSwitch::_bind_methods() {
}
VisualScriptSwitch::VisualScriptSwitch() {
}
//////////////////////////////////////////
////////////////TYPE CAST///////////
//////////////////////////////////////////
int VisualScriptTypeCast::get_output_sequence_port_count() const {
return 2;
}
bool VisualScriptTypeCast::has_input_sequence_port() const {
return true;
}
int VisualScriptTypeCast::get_input_value_port_count() const {
return 1;
}
int VisualScriptTypeCast::get_output_value_port_count() const {
return 1;
}
String VisualScriptTypeCast::get_output_sequence_port_text(int p_port) const {
return p_port == 0 ? "yes" : "no";
}
PropertyInfo VisualScriptTypeCast::get_input_value_port_info(int p_idx) const {
return PropertyInfo(Variant::OBJECT, "instance");
}
PropertyInfo VisualScriptTypeCast::get_output_value_port_info(int p_idx) const {
return PropertyInfo(Variant::OBJECT, "", PROPERTY_HINT_TYPE_STRING, get_base_type());
}
String VisualScriptTypeCast::get_caption() const {
return RTR("Type Cast");
}
String VisualScriptTypeCast::get_text() const {
if (!script.is_empty()) {
return vformat(RTR("Is %s?"), script.get_file());
} else {
return vformat(RTR("Is %s?"), base_type);
}
}
void VisualScriptTypeCast::set_base_type(const StringName &p_type) {
if (base_type == p_type) {
return;
}
base_type = p_type;
notify_property_list_changed();
ports_changed_notify();
}
StringName VisualScriptTypeCast::get_base_type() const {
return base_type;
}
void VisualScriptTypeCast::set_base_script(const String &p_path) {
if (script == p_path) {
return;
}
script = p_path;
notify_property_list_changed();
ports_changed_notify();
}
String VisualScriptTypeCast::get_base_script() const {
return script;
}
VisualScriptTypeCast::TypeGuess VisualScriptTypeCast::guess_output_type(TypeGuess *p_inputs, int p_output) const {
TypeGuess tg;
tg.type = Variant::OBJECT;
if (!script.is_empty()) {
tg.script = ResourceLoader::load(script);
}
//if (!tg.script.is_valid()) {
// tg.gdclass = base_type;
//}
return tg;
}
class VisualScriptNodeInstanceTypeCast : public VisualScriptNodeInstance {
public:
VisualScriptInstance *instance = nullptr;
StringName base_type;
String script;
//virtual int get_working_memory_size() const override { return 0; }
//virtual bool is_output_port_unsequenced(int p_idx) const { return false; }
//virtual bool get_output_port_unsequenced(int p_idx,Variant* r_value,Variant* p_working_mem,String &r_error) const { return false; }
virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) override {
Object *obj = *p_inputs[0];
*p_outputs[0] = Variant();
if (!obj) {
r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
r_error_str = "Instance is null";
return 0;
}
if (!script.is_empty()) {
Ref<Script> obj_script = obj->get_script();
if (!obj_script.is_valid()) {
return 1; //well, definitely not the script because object we got has no script.
}
if (!ResourceCache::has(script)) {
//if the script is not in use by anyone, we can safely assume whatever we got is not casting to it.
return 1;
}
Ref<Script> cast_script = ResourceCache::get_ref(script);
if (!cast_script.is_valid()) {
r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
r_error_str = "Script path is not a script: " + script;
return 1;
}
while (obj_script.is_valid()) {
if (cast_script == obj_script) {
*p_outputs[0] = *p_inputs[0]; //copy
return 0; // it is the script, yey
}
obj_script = obj_script->get_base_script();
}
return 1; //not found sorry
}
if (ClassDB::is_parent_class(obj->get_class_name(), base_type)) {
*p_outputs[0] = *p_inputs[0]; //copy
return 0;
} else {
return 1;
}
}
};
VisualScriptNodeInstance *VisualScriptTypeCast::instantiate(VisualScriptInstance *p_instance) {
VisualScriptNodeInstanceTypeCast *instance = memnew(VisualScriptNodeInstanceTypeCast);
instance->instance = p_instance;
instance->base_type = base_type;
instance->script = script;
return instance;
}
void VisualScriptTypeCast::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_base_type", "type"), &VisualScriptTypeCast::set_base_type);
ClassDB::bind_method(D_METHOD("get_base_type"), &VisualScriptTypeCast::get_base_type);
ClassDB::bind_method(D_METHOD("set_base_script", "path"), &VisualScriptTypeCast::set_base_script);
ClassDB::bind_method(D_METHOD("get_base_script"), &VisualScriptTypeCast::get_base_script);
List<String> script_extensions;
for (int i = 0; i > ScriptServer::get_language_count(); i++) {
ScriptServer::get_language(i)->get_recognized_extensions(&script_extensions);
}
String script_ext_hint;
for (const String &E : script_extensions) {
if (!script_ext_hint.is_empty()) {
script_ext_hint += ",";
}
script_ext_hint += "*." + E;
}
ADD_PROPERTY(PropertyInfo(Variant::STRING, "base_type", PROPERTY_HINT_TYPE_STRING, "Object"), "set_base_type", "get_base_type");
ADD_PROPERTY(PropertyInfo(Variant::STRING, "base_script", PROPERTY_HINT_FILE, script_ext_hint), "set_base_script", "get_base_script");
}
VisualScriptTypeCast::VisualScriptTypeCast() {
base_type = "Object";
}
void register_visual_script_flow_control_nodes() {
VisualScriptLanguage::singleton->add_register_func("flow_control/return", create_return_node<false>);
VisualScriptLanguage::singleton->add_register_func("flow_control/return_with_value", create_return_node<true>);
VisualScriptLanguage::singleton->add_register_func("flow_control/condition", create_node_generic<VisualScriptCondition>);
VisualScriptLanguage::singleton->add_register_func("flow_control/while", create_node_generic<VisualScriptWhile>);
VisualScriptLanguage::singleton->add_register_func("flow_control/iterator", create_node_generic<VisualScriptIterator>);
VisualScriptLanguage::singleton->add_register_func("flow_control/sequence", create_node_generic<VisualScriptSequence>);
VisualScriptLanguage::singleton->add_register_func("flow_control/switch", create_node_generic<VisualScriptSwitch>);
//VisualScriptLanguage::singleton->add_register_func("flow_control/input", create_node_generic<VisualScriptInputFilter>);
VisualScriptLanguage::singleton->add_register_func("flow_control/type_cast", create_node_generic<VisualScriptTypeCast>);
}

View File

@ -1,268 +0,0 @@
/*************************************************************************/
/* visual_script_flow_control.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef VISUAL_SCRIPT_FLOW_CONTROL_H
#define VISUAL_SCRIPT_FLOW_CONTROL_H
#include "visual_script.h"
class VisualScriptReturn : public VisualScriptNode {
GDCLASS(VisualScriptReturn, VisualScriptNode);
Variant::Type type;
bool with_value;
protected:
static void _bind_methods();
public:
virtual int get_output_sequence_port_count() const override;
virtual bool has_input_sequence_port() const override;
virtual String get_output_sequence_port_text(int p_port) const override;
virtual int get_input_value_port_count() const override;
virtual int get_output_value_port_count() const override;
virtual PropertyInfo get_input_value_port_info(int p_idx) const override;
virtual PropertyInfo get_output_value_port_info(int p_idx) const override;
virtual String get_caption() const override;
virtual String get_text() const override;
virtual String get_category() const override { return "flow_control"; }
void set_return_type(Variant::Type);
Variant::Type get_return_type() const;
void set_enable_return_value(bool p_enable);
bool is_return_value_enabled() const;
virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
VisualScriptReturn();
};
class VisualScriptCondition : public VisualScriptNode {
GDCLASS(VisualScriptCondition, VisualScriptNode);
protected:
static void _bind_methods();
public:
virtual int get_output_sequence_port_count() const override;
virtual bool has_input_sequence_port() const override;
virtual String get_output_sequence_port_text(int p_port) const override;
virtual int get_input_value_port_count() const override;
virtual int get_output_value_port_count() const override;
virtual PropertyInfo get_input_value_port_info(int p_idx) const override;
virtual PropertyInfo get_output_value_port_info(int p_idx) const override;
virtual String get_caption() const override;
virtual String get_text() const override;
virtual String get_category() const override { return "flow_control"; }
virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
VisualScriptCondition();
};
class VisualScriptWhile : public VisualScriptNode {
GDCLASS(VisualScriptWhile, VisualScriptNode);
protected:
static void _bind_methods();
public:
virtual int get_output_sequence_port_count() const override;
virtual bool has_input_sequence_port() const override;
virtual String get_output_sequence_port_text(int p_port) const override;
virtual int get_input_value_port_count() const override;
virtual int get_output_value_port_count() const override;
virtual PropertyInfo get_input_value_port_info(int p_idx) const override;
virtual PropertyInfo get_output_value_port_info(int p_idx) const override;
virtual String get_caption() const override;
virtual String get_text() const override;
virtual String get_category() const override { return "flow_control"; }
virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
VisualScriptWhile();
};
class VisualScriptIterator : public VisualScriptNode {
GDCLASS(VisualScriptIterator, VisualScriptNode);
protected:
static void _bind_methods();
public:
virtual int get_output_sequence_port_count() const override;
virtual bool has_input_sequence_port() const override;
virtual String get_output_sequence_port_text(int p_port) const override;
virtual int get_input_value_port_count() const override;
virtual int get_output_value_port_count() const override;
virtual PropertyInfo get_input_value_port_info(int p_idx) const override;
virtual PropertyInfo get_output_value_port_info(int p_idx) const override;
virtual String get_caption() const override;
virtual String get_text() const override;
virtual String get_category() const override { return "flow_control"; }
virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
VisualScriptIterator();
};
class VisualScriptSequence : public VisualScriptNode {
GDCLASS(VisualScriptSequence, VisualScriptNode);
int steps;
protected:
static void _bind_methods();
public:
virtual int get_output_sequence_port_count() const override;
virtual bool has_input_sequence_port() const override;
virtual String get_output_sequence_port_text(int p_port) const override;
virtual int get_input_value_port_count() const override;
virtual int get_output_value_port_count() const override;
virtual PropertyInfo get_input_value_port_info(int p_idx) const override;
virtual PropertyInfo get_output_value_port_info(int p_idx) const override;
virtual String get_caption() const override;
virtual String get_text() const override;
virtual String get_category() const override { return "flow_control"; }
void set_steps(int p_steps);
int get_steps() const;
virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
VisualScriptSequence();
};
class VisualScriptSwitch : public VisualScriptNode {
GDCLASS(VisualScriptSwitch, VisualScriptNode);
struct Case {
Variant::Type type;
Case() { type = Variant::NIL; }
};
Vector<Case> case_values;
friend class VisualScriptNodeInstanceSwitch;
protected:
bool _set(const StringName &p_name, const Variant &p_value);
bool _get(const StringName &p_name, Variant &r_ret) const;
void _get_property_list(List<PropertyInfo> *p_list) const;
static void _bind_methods();
public:
virtual void reset_state() override;
virtual int get_output_sequence_port_count() const override;
virtual bool has_input_sequence_port() const override;
virtual String get_output_sequence_port_text(int p_port) const override;
virtual bool has_mixed_input_and_sequence_ports() const override { return true; }
virtual int get_input_value_port_count() const override;
virtual int get_output_value_port_count() const override;
virtual PropertyInfo get_input_value_port_info(int p_idx) const override;
virtual PropertyInfo get_output_value_port_info(int p_idx) const override;
virtual String get_caption() const override;
virtual String get_text() const override;
virtual String get_category() const override { return "flow_control"; }
virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
VisualScriptSwitch();
};
class VisualScriptTypeCast : public VisualScriptNode {
GDCLASS(VisualScriptTypeCast, VisualScriptNode);
StringName base_type;
String script;
protected:
static void _bind_methods();
public:
virtual int get_output_sequence_port_count() const override;
virtual bool has_input_sequence_port() const override;
virtual String get_output_sequence_port_text(int p_port) const override;
virtual int get_input_value_port_count() const override;
virtual int get_output_value_port_count() const override;
virtual PropertyInfo get_input_value_port_info(int p_idx) const override;
virtual PropertyInfo get_output_value_port_info(int p_idx) const override;
virtual String get_caption() const override;
virtual String get_text() const override;
virtual String get_category() const override { return "flow_control"; }
void set_base_type(const StringName &p_type);
StringName get_base_type() const;
void set_base_script(const String &p_path);
String get_base_script() const;
virtual TypeGuess guess_output_type(TypeGuess *p_inputs, int p_output) const override;
virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
VisualScriptTypeCast();
};
void register_visual_script_flow_control_nodes();
#endif // VISUAL_SCRIPT_FLOW_CONTROL_H

File diff suppressed because it is too large Load Diff

View File

@ -1,363 +0,0 @@
/*************************************************************************/
/* visual_script_func_nodes.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef VISUAL_SCRIPT_FUNC_NODES_H
#define VISUAL_SCRIPT_FUNC_NODES_H
#include "visual_script.h"
class VisualScriptFunctionCall : public VisualScriptNode {
GDCLASS(VisualScriptFunctionCall, VisualScriptNode);
public:
enum CallMode {
CALL_MODE_SELF,
CALL_MODE_NODE_PATH,
CALL_MODE_INSTANCE,
CALL_MODE_BASIC_TYPE,
CALL_MODE_SINGLETON,
};
enum RPCCallMode {
RPC_DISABLED,
RPC_RELIABLE,
RPC_UNRELIABLE,
RPC_RELIABLE_TO_ID,
RPC_UNRELIABLE_TO_ID
};
private:
CallMode call_mode;
StringName base_type;
String base_script;
Variant::Type basic_type;
NodePath base_path;
StringName function;
int use_default_args;
RPCCallMode rpc_call_mode;
StringName singleton;
bool validate;
Node *_get_base_node() const;
StringName _get_base_type() const;
MethodInfo method_cache;
void _update_method_cache();
void _set_argument_cache(const Dictionary &p_cache);
Dictionary _get_argument_cache() const;
protected:
void _validate_property(PropertyInfo &p_property) const;
static void _bind_methods();
public:
virtual int get_output_sequence_port_count() const override;
virtual bool has_input_sequence_port() const override;
virtual String get_output_sequence_port_text(int p_port) const override;
virtual int get_input_value_port_count() const override;
virtual int get_output_value_port_count() const override;
virtual PropertyInfo get_input_value_port_info(int p_idx) const override;
virtual PropertyInfo get_output_value_port_info(int p_idx) const override;
virtual String get_caption() const override;
virtual String get_text() const override;
virtual String get_category() const override { return "functions"; }
void set_basic_type(Variant::Type p_type);
Variant::Type get_basic_type() const;
void set_base_type(const StringName &p_type);
StringName get_base_type() const;
void set_base_script(const String &p_path);
String get_base_script() const;
void set_singleton(const StringName &p_type);
StringName get_singleton() const;
void set_function(const StringName &p_type);
StringName get_function() const;
void set_base_path(const NodePath &p_type);
NodePath get_base_path() const;
void set_call_mode(CallMode p_mode);
CallMode get_call_mode() const;
void set_use_default_args(int p_amount);
int get_use_default_args() const;
void set_validate(bool p_amount);
bool get_validate() const;
void set_rpc_call_mode(RPCCallMode p_mode);
RPCCallMode get_rpc_call_mode() const;
virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
virtual TypeGuess guess_output_type(TypeGuess *p_inputs, int p_output) const override;
VisualScriptFunctionCall();
};
VARIANT_ENUM_CAST(VisualScriptFunctionCall::CallMode);
VARIANT_ENUM_CAST(VisualScriptFunctionCall::RPCCallMode);
class VisualScriptPropertySet : public VisualScriptNode {
GDCLASS(VisualScriptPropertySet, VisualScriptNode);
public:
enum CallMode {
CALL_MODE_SELF,
CALL_MODE_NODE_PATH,
CALL_MODE_INSTANCE,
CALL_MODE_BASIC_TYPE,
};
enum AssignOp {
ASSIGN_OP_NONE,
ASSIGN_OP_ADD,
ASSIGN_OP_SUB,
ASSIGN_OP_MUL,
ASSIGN_OP_DIV,
ASSIGN_OP_MOD,
ASSIGN_OP_SHIFT_LEFT,
ASSIGN_OP_SHIFT_RIGHT,
ASSIGN_OP_BIT_AND,
ASSIGN_OP_BIT_OR,
ASSIGN_OP_BIT_XOR,
ASSIGN_OP_MAX
};
private:
PropertyInfo type_cache;
CallMode call_mode;
Variant::Type basic_type;
StringName base_type;
String base_script;
NodePath base_path;
StringName property;
StringName index;
AssignOp assign_op;
Node *_get_base_node() const;
StringName _get_base_type() const;
void _update_base_type();
void _update_cache();
void _set_type_cache(const Dictionary &p_type);
Dictionary _get_type_cache() const;
void _adjust_input_index(PropertyInfo &pinfo) const;
protected:
void _validate_property(PropertyInfo &p_property) const;
static void _bind_methods();
public:
virtual int get_output_sequence_port_count() const override;
virtual bool has_input_sequence_port() const override;
virtual String get_output_sequence_port_text(int p_port) const override;
virtual int get_input_value_port_count() const override;
virtual int get_output_value_port_count() const override;
virtual PropertyInfo get_input_value_port_info(int p_idx) const override;
virtual PropertyInfo get_output_value_port_info(int p_idx) const override;
virtual String get_caption() const override;
virtual String get_text() const override;
virtual String get_category() const override { return "functions"; }
void set_base_type(const StringName &p_type);
StringName get_base_type() const;
void set_base_script(const String &p_path);
String get_base_script() const;
void set_basic_type(Variant::Type p_type);
Variant::Type get_basic_type() const;
void set_property(const StringName &p_type);
StringName get_property() const;
void set_base_path(const NodePath &p_type);
NodePath get_base_path() const;
void set_call_mode(CallMode p_mode);
CallMode get_call_mode() const;
void set_index(const StringName &p_type);
StringName get_index() const;
void set_assign_op(AssignOp p_op);
AssignOp get_assign_op() const;
virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
virtual TypeGuess guess_output_type(TypeGuess *p_inputs, int p_output) const override;
VisualScriptPropertySet();
};
VARIANT_ENUM_CAST(VisualScriptPropertySet::CallMode);
VARIANT_ENUM_CAST(VisualScriptPropertySet::AssignOp);
class VisualScriptPropertyGet : public VisualScriptNode {
GDCLASS(VisualScriptPropertyGet, VisualScriptNode);
public:
enum CallMode {
CALL_MODE_SELF,
CALL_MODE_NODE_PATH,
CALL_MODE_INSTANCE,
CALL_MODE_BASIC_TYPE,
};
private:
Variant::Type type_cache;
CallMode call_mode;
Variant::Type basic_type;
StringName base_type;
String base_script;
NodePath base_path;
StringName property;
StringName index;
void _update_base_type();
Node *_get_base_node() const;
StringName _get_base_type() const;
void _update_cache();
void _set_type_cache(Variant::Type p_type);
Variant::Type _get_type_cache() const;
void _adjust_input_index(PropertyInfo &pinfo) const;
protected:
void _validate_property(PropertyInfo &p_property) const;
static void _bind_methods();
public:
virtual int get_output_sequence_port_count() const override;
virtual bool has_input_sequence_port() const override;
virtual String get_output_sequence_port_text(int p_port) const override;
virtual int get_input_value_port_count() const override;
virtual int get_output_value_port_count() const override;
virtual PropertyInfo get_input_value_port_info(int p_idx) const override;
virtual PropertyInfo get_output_value_port_info(int p_idx) const override;
virtual String get_caption() const override;
virtual String get_text() const override;
virtual String get_category() const override { return "functions"; }
void set_base_type(const StringName &p_type);
StringName get_base_type() const;
void set_base_script(const String &p_path);
String get_base_script() const;
void set_basic_type(Variant::Type p_type);
Variant::Type get_basic_type() const;
void set_property(const StringName &p_type);
StringName get_property() const;
void set_base_path(const NodePath &p_type);
NodePath get_base_path() const;
void set_call_mode(CallMode p_mode);
CallMode get_call_mode() const;
void set_index(const StringName &p_type);
StringName get_index() const;
virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
VisualScriptPropertyGet();
};
VARIANT_ENUM_CAST(VisualScriptPropertyGet::CallMode);
class VisualScriptEmitSignal : public VisualScriptNode {
GDCLASS(VisualScriptEmitSignal, VisualScriptNode);
private:
StringName name;
protected:
void _validate_property(PropertyInfo &p_property) const;
static void _bind_methods();
public:
virtual int get_output_sequence_port_count() const override;
virtual bool has_input_sequence_port() const override;
virtual String get_output_sequence_port_text(int p_port) const override;
virtual int get_input_value_port_count() const override;
virtual int get_output_value_port_count() const override;
virtual PropertyInfo get_input_value_port_info(int p_idx) const override;
virtual PropertyInfo get_output_value_port_info(int p_idx) const override;
virtual String get_caption() const override;
//virtual String get_text() const;
virtual String get_category() const override { return "functions"; }
void set_signal(const StringName &p_type);
StringName get_signal() const;
virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
VisualScriptEmitSignal();
};
void register_visual_script_func_nodes();
#endif // VISUAL_SCRIPT_FUNC_NODES_H

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,598 +0,0 @@
/*************************************************************************/
/* visual_script_yield_nodes.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "visual_script_yield_nodes.h"
#include "core/os/os.h"
#include "scene/main/node.h"
#include "scene/main/scene_tree.h"
#include "visual_script_nodes.h"
//////////////////////////////////////////
////////////////YIELD///////////
//////////////////////////////////////////
int VisualScriptYield::get_output_sequence_port_count() const {
return 1;
}
bool VisualScriptYield::has_input_sequence_port() const {
return true;
}
int VisualScriptYield::get_input_value_port_count() const {
return 0;
}
int VisualScriptYield::get_output_value_port_count() const {
return 0;
}
String VisualScriptYield::get_output_sequence_port_text(int p_port) const {
return String();
}
PropertyInfo VisualScriptYield::get_input_value_port_info(int p_idx) const {
return PropertyInfo();
}
PropertyInfo VisualScriptYield::get_output_value_port_info(int p_idx) const {
return PropertyInfo();
}
String VisualScriptYield::get_caption() const {
return yield_mode == YIELD_RETURN ? RTR("Yield") : RTR("Wait");
}
String VisualScriptYield::get_text() const {
switch (yield_mode) {
case YIELD_RETURN:
return "";
break;
case YIELD_FRAME:
return RTR("Next Frame");
break;
case YIELD_PHYSICS_FRAME:
return RTR("Next Physics Frame");
break;
case YIELD_WAIT:
return vformat(RTR("%s sec(s)"), rtos(wait_time));
break;
}
return String();
}
class VisualScriptNodeInstanceYield : public VisualScriptNodeInstance {
public:
VisualScriptYield::YieldMode mode;
double wait_time = 0.0;
virtual int get_working_memory_size() const override { return 1; } //yield needs at least 1
//virtual bool is_output_port_unsequenced(int p_idx) const { return false; }
//virtual bool get_output_port_unsequenced(int p_idx,Variant* r_value,Variant* p_working_mem,String &r_error) const { return false; }
virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) override {
if (p_start_mode == START_MODE_RESUME_YIELD) {
return 0; //resuming yield
} else {
//yield
SceneTree *tree = Object::cast_to<SceneTree>(OS::get_singleton()->get_main_loop());
if (!tree) {
r_error_str = "Main Loop is not SceneTree";
r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
return 0;
}
Ref<VisualScriptFunctionState> state;
state.instantiate();
int ret = STEP_YIELD_BIT;
switch (mode) {
case VisualScriptYield::YIELD_RETURN:
ret = STEP_EXIT_FUNCTION_BIT;
break; //return the yield
case VisualScriptYield::YIELD_FRAME:
state->connect_to_signal(tree, "process_frame", Array());
break;
case VisualScriptYield::YIELD_PHYSICS_FRAME:
state->connect_to_signal(tree, "physics_frame", Array());
break;
case VisualScriptYield::YIELD_WAIT:
state->connect_to_signal(tree->create_timer(wait_time).ptr(), "timeout", Array());
break;
}
*p_working_mem = state;
return ret;
}
}
};
VisualScriptNodeInstance *VisualScriptYield::instantiate(VisualScriptInstance *p_instance) {
VisualScriptNodeInstanceYield *instance = memnew(VisualScriptNodeInstanceYield);
//instance->instance=p_instance;
instance->mode = yield_mode;
instance->wait_time = wait_time;
return instance;
}
void VisualScriptYield::set_yield_mode(YieldMode p_mode) {
if (yield_mode == p_mode) {
return;
}
yield_mode = p_mode;
ports_changed_notify();
notify_property_list_changed();
}
VisualScriptYield::YieldMode VisualScriptYield::get_yield_mode() {
return yield_mode;
}
void VisualScriptYield::set_wait_time(double p_time) {
if (wait_time == p_time) {
return;
}
wait_time = p_time;
ports_changed_notify();
}
double VisualScriptYield::get_wait_time() {
return wait_time;
}
void VisualScriptYield::_validate_property(PropertyInfo &p_property) const {
if (p_property.name == "wait_time") {
if (yield_mode != YIELD_WAIT) {
p_property.usage = PROPERTY_USAGE_NONE;
}
}
}
void VisualScriptYield::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_yield_mode", "mode"), &VisualScriptYield::set_yield_mode);
ClassDB::bind_method(D_METHOD("get_yield_mode"), &VisualScriptYield::get_yield_mode);
ClassDB::bind_method(D_METHOD("set_wait_time", "sec"), &VisualScriptYield::set_wait_time);
ClassDB::bind_method(D_METHOD("get_wait_time"), &VisualScriptYield::get_wait_time);
ADD_PROPERTY(PropertyInfo(Variant::INT, "mode", PROPERTY_HINT_ENUM, "Frame,Physics Frame,Time", PROPERTY_USAGE_NO_EDITOR), "set_yield_mode", "get_yield_mode");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "wait_time"), "set_wait_time", "get_wait_time");
BIND_ENUM_CONSTANT(YIELD_FRAME);
BIND_ENUM_CONSTANT(YIELD_PHYSICS_FRAME);
BIND_ENUM_CONSTANT(YIELD_WAIT);
}
VisualScriptYield::VisualScriptYield() {
yield_mode = YIELD_FRAME;
wait_time = 1;
}
template <VisualScriptYield::YieldMode MODE>
static Ref<VisualScriptNode> create_yield_node(const String &p_name) {
Ref<VisualScriptYield> node;
node.instantiate();
node->set_yield_mode(MODE);
return node;
}
///////////////////////////////////////////////////
////////////////YIELD SIGNAL//////////////////////
//////////////////////////////////////////////////
int VisualScriptYieldSignal::get_output_sequence_port_count() const {
return 1;
}
bool VisualScriptYieldSignal::has_input_sequence_port() const {
return true;
}
#ifdef TOOLS_ENABLED
static Node *_find_script_node(Node *p_edited_scene, Node *p_current_node, const Ref<Script> &script) {
if (p_edited_scene != p_current_node && p_current_node->get_owner() != p_edited_scene) {
return nullptr;
}
Ref<Script> scr = p_current_node->get_script();
if (scr.is_valid() && scr == script) {
return p_current_node;
}
for (int i = 0; i < p_current_node->get_child_count(); i++) {
Node *n = _find_script_node(p_edited_scene, p_current_node->get_child(i), script);
if (n) {
return n;
}
}
return nullptr;
}
#endif
Node *VisualScriptYieldSignal::_get_base_node() const {
#ifdef TOOLS_ENABLED
Ref<Script> script = get_visual_script();
if (!script.is_valid()) {
return nullptr;
}
MainLoop *main_loop = OS::get_singleton()->get_main_loop();
SceneTree *scene_tree = Object::cast_to<SceneTree>(main_loop);
if (!scene_tree) {
return nullptr;
}
Node *edited_scene = scene_tree->get_edited_scene_root();
if (!edited_scene) {
return nullptr;
}
Node *script_node = _find_script_node(edited_scene, edited_scene, script);
if (!script_node) {
return nullptr;
}
if (!script_node->has_node(base_path)) {
return nullptr;
}
Node *path_to = script_node->get_node(base_path);
return path_to;
#else
return nullptr;
#endif
}
StringName VisualScriptYieldSignal::_get_base_type() const {
if (call_mode == CALL_MODE_SELF && get_visual_script().is_valid()) {
return get_visual_script()->get_instance_base_type();
} else if (call_mode == CALL_MODE_NODE_PATH && get_visual_script().is_valid()) {
Node *path = _get_base_node();
if (path) {
return path->get_class();
}
}
return base_type;
}
int VisualScriptYieldSignal::get_input_value_port_count() const {
if (call_mode == CALL_MODE_INSTANCE) {
return 1;
} else {
return 0;
}
}
int VisualScriptYieldSignal::get_output_value_port_count() const {
MethodInfo sr;
if (!ClassDB::get_signal(_get_base_type(), signal, &sr)) {
return 0;
}
return sr.arguments.size();
}
String VisualScriptYieldSignal::get_output_sequence_port_text(int p_port) const {
return String();
}
PropertyInfo VisualScriptYieldSignal::get_input_value_port_info(int p_idx) const {
if (call_mode == CALL_MODE_INSTANCE) {
return PropertyInfo(Variant::OBJECT, "instance");
} else {
return PropertyInfo();
}
}
PropertyInfo VisualScriptYieldSignal::get_output_value_port_info(int p_idx) const {
MethodInfo sr;
if (!ClassDB::get_signal(_get_base_type(), signal, &sr)) {
return PropertyInfo(); //no signal
}
ERR_FAIL_INDEX_V(p_idx, sr.arguments.size(), PropertyInfo());
return sr.arguments[p_idx];
}
String VisualScriptYieldSignal::get_caption() const {
switch (call_mode) {
case CALL_MODE_SELF: {
return RTR("WaitSignal");
} break;
case CALL_MODE_NODE_PATH: {
return RTR("WaitNodeSignal");
} break;
case CALL_MODE_INSTANCE: {
return RTR("WaitInstanceSignal");
} break;
}
return String();
}
String VisualScriptYieldSignal::get_text() const {
if (call_mode == CALL_MODE_SELF) {
return " " + String(signal) + "()";
} else {
return " " + _get_base_type() + "." + String(signal) + "()";
}
}
void VisualScriptYieldSignal::set_base_type(const StringName &p_type) {
if (base_type == p_type) {
return;
}
base_type = p_type;
notify_property_list_changed();
ports_changed_notify();
}
StringName VisualScriptYieldSignal::get_base_type() const {
return base_type;
}
void VisualScriptYieldSignal::set_signal(const StringName &p_type) {
if (signal == p_type) {
return;
}
signal = p_type;
notify_property_list_changed();
ports_changed_notify();
}
StringName VisualScriptYieldSignal::get_signal() const {
return signal;
}
void VisualScriptYieldSignal::set_base_path(const NodePath &p_type) {
if (base_path == p_type) {
return;
}
base_path = p_type;
notify_property_list_changed();
ports_changed_notify();
}
NodePath VisualScriptYieldSignal::get_base_path() const {
return base_path;
}
void VisualScriptYieldSignal::set_call_mode(CallMode p_mode) {
if (call_mode == p_mode) {
return;
}
call_mode = p_mode;
notify_property_list_changed();
ports_changed_notify();
}
VisualScriptYieldSignal::CallMode VisualScriptYieldSignal::get_call_mode() const {
return call_mode;
}
void VisualScriptYieldSignal::_validate_property(PropertyInfo &p_property) const {
if (p_property.name == "base_type") {
if (call_mode != CALL_MODE_INSTANCE) {
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
}
}
if (p_property.name == "node_path") {
if (call_mode != CALL_MODE_NODE_PATH) {
p_property.usage = PROPERTY_USAGE_NONE;
} else {
Node *bnode = _get_base_node();
if (bnode) {
p_property.hint_string = bnode->get_path(); //convert to long string
}
}
}
if (p_property.name == "signal") {
p_property.hint = PROPERTY_HINT_ENUM;
List<MethodInfo> methods;
ClassDB::get_signal_list(_get_base_type(), &methods);
List<String> mstring;
for (const MethodInfo &E : methods) {
if (E.name.begins_with("_")) {
continue;
}
mstring.push_back(E.name.get_slice(":", 0));
}
mstring.sort();
String ml;
for (const String &E : mstring) {
if (!ml.is_empty()) {
ml += ",";
}
ml += E;
}
p_property.hint_string = ml;
}
}
void VisualScriptYieldSignal::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_base_type", "base_type"), &VisualScriptYieldSignal::set_base_type);
ClassDB::bind_method(D_METHOD("get_base_type"), &VisualScriptYieldSignal::get_base_type);
ClassDB::bind_method(D_METHOD("set_signal", "signal"), &VisualScriptYieldSignal::set_signal);
ClassDB::bind_method(D_METHOD("get_signal"), &VisualScriptYieldSignal::get_signal);
ClassDB::bind_method(D_METHOD("set_call_mode", "mode"), &VisualScriptYieldSignal::set_call_mode);
ClassDB::bind_method(D_METHOD("get_call_mode"), &VisualScriptYieldSignal::get_call_mode);
ClassDB::bind_method(D_METHOD("set_base_path", "base_path"), &VisualScriptYieldSignal::set_base_path);
ClassDB::bind_method(D_METHOD("get_base_path"), &VisualScriptYieldSignal::get_base_path);
String bt;
for (int i = 0; i < Variant::VARIANT_MAX; i++) {
if (i > 0) {
bt += ",";
}
bt += Variant::get_type_name(Variant::Type(i));
}
ADD_PROPERTY(PropertyInfo(Variant::INT, "call_mode", PROPERTY_HINT_ENUM, "Self,Node Path,Instance"), "set_call_mode", "get_call_mode");
ADD_PROPERTY(PropertyInfo(Variant::STRING, "base_type", PROPERTY_HINT_TYPE_STRING, "Object"), "set_base_type", "get_base_type");
ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "node_path", PROPERTY_HINT_NODE_PATH_TO_EDITED_NODE), "set_base_path", "get_base_path");
ADD_PROPERTY(PropertyInfo(Variant::STRING, "signal"), "set_signal", "get_signal");
BIND_ENUM_CONSTANT(CALL_MODE_SELF);
BIND_ENUM_CONSTANT(CALL_MODE_NODE_PATH);
BIND_ENUM_CONSTANT(CALL_MODE_INSTANCE);
}
class VisualScriptNodeInstanceYieldSignal : public VisualScriptNodeInstance {
public:
VisualScriptYieldSignal::CallMode call_mode;
NodePath node_path;
int output_args = 0;
StringName signal;
VisualScriptYieldSignal *node = nullptr;
VisualScriptInstance *instance = nullptr;
virtual int get_working_memory_size() const override { return 1; }
//virtual bool is_output_port_unsequenced(int p_idx) const { return false; }
//virtual bool get_output_port_unsequenced(int p_idx,Variant* r_value,Variant* p_working_mem,String &r_error) const { return true; }
virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Callable::CallError &r_error, String &r_error_str) override {
if (p_start_mode == START_MODE_RESUME_YIELD) {
return 0; //resuming yield
} else {
//yield
Object *object = nullptr;
switch (call_mode) {
case VisualScriptYieldSignal::CALL_MODE_SELF: {
object = instance->get_owner_ptr();
} break;
case VisualScriptYieldSignal::CALL_MODE_NODE_PATH: {
Node *node = Object::cast_to<Node>(instance->get_owner_ptr());
if (!node) {
r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
r_error_str = "Base object is not a Node!";
return 0;
}
Node *another = node->get_node(node_path);
if (!another) {
r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
r_error_str = "Path does not lead Node!";
return 0;
}
object = another;
} break;
case VisualScriptYieldSignal::CALL_MODE_INSTANCE: {
object = *p_inputs[0];
if (!object) {
r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
r_error_str = "Supplied instance input is null.";
return 0;
}
} break;
}
Ref<VisualScriptFunctionState> state;
state.instantiate();
state->connect_to_signal(object, signal, Array());
*p_working_mem = state;
return STEP_YIELD_BIT;
}
}
};
VisualScriptNodeInstance *VisualScriptYieldSignal::instantiate(VisualScriptInstance *p_instance) {
VisualScriptNodeInstanceYieldSignal *instance = memnew(VisualScriptNodeInstanceYieldSignal);
instance->node = this;
instance->instance = p_instance;
instance->signal = signal;
instance->call_mode = call_mode;
instance->node_path = base_path;
instance->output_args = get_output_value_port_count();
return instance;
}
VisualScriptYieldSignal::VisualScriptYieldSignal() {
call_mode = CALL_MODE_SELF;
base_type = "Object";
}
template <VisualScriptYieldSignal::CallMode cmode>
static Ref<VisualScriptNode> create_yield_signal_node(const String &p_name) {
Ref<VisualScriptYieldSignal> node;
node.instantiate();
node->set_call_mode(cmode);
return node;
}
void register_visual_script_yield_nodes() {
VisualScriptLanguage::singleton->add_register_func("functions/wait/wait_frame", create_yield_node<VisualScriptYield::YIELD_FRAME>);
VisualScriptLanguage::singleton->add_register_func("functions/wait/wait_physics_frame", create_yield_node<VisualScriptYield::YIELD_PHYSICS_FRAME>);
VisualScriptLanguage::singleton->add_register_func("functions/wait/wait_time", create_yield_node<VisualScriptYield::YIELD_WAIT>);
VisualScriptLanguage::singleton->add_register_func("functions/yield", create_yield_node<VisualScriptYield::YIELD_RETURN>);
VisualScriptLanguage::singleton->add_register_func("functions/yield_signal", create_node_generic<VisualScriptYieldSignal>);
}

View File

@ -1,147 +0,0 @@
/*************************************************************************/
/* visual_script_yield_nodes.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef VISUAL_SCRIPT_YIELD_NODES_H
#define VISUAL_SCRIPT_YIELD_NODES_H
#include "visual_script.h"
class VisualScriptYield : public VisualScriptNode {
GDCLASS(VisualScriptYield, VisualScriptNode);
public:
enum YieldMode {
YIELD_RETURN,
YIELD_FRAME,
YIELD_PHYSICS_FRAME,
YIELD_WAIT
};
private:
YieldMode yield_mode;
double wait_time;
protected:
void _validate_property(PropertyInfo &p_property) const;
static void _bind_methods();
public:
virtual int get_output_sequence_port_count() const override;
virtual bool has_input_sequence_port() const override;
virtual String get_output_sequence_port_text(int p_port) const override;
virtual int get_input_value_port_count() const override;
virtual int get_output_value_port_count() const override;
virtual PropertyInfo get_input_value_port_info(int p_idx) const override;
virtual PropertyInfo get_output_value_port_info(int p_idx) const override;
virtual String get_caption() const override;
virtual String get_text() const override;
virtual String get_category() const override { return "functions"; }
void set_yield_mode(YieldMode p_mode);
YieldMode get_yield_mode();
void set_wait_time(double p_time);
double get_wait_time();
virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
VisualScriptYield();
};
VARIANT_ENUM_CAST(VisualScriptYield::YieldMode)
class VisualScriptYieldSignal : public VisualScriptNode {
GDCLASS(VisualScriptYieldSignal, VisualScriptNode);
public:
enum CallMode {
CALL_MODE_SELF,
CALL_MODE_NODE_PATH,
CALL_MODE_INSTANCE,
};
private:
CallMode call_mode;
StringName base_type;
NodePath base_path;
StringName signal;
Node *_get_base_node() const;
StringName _get_base_type() const;
protected:
void _validate_property(PropertyInfo &p_property) const;
static void _bind_methods();
public:
virtual int get_output_sequence_port_count() const override;
virtual bool has_input_sequence_port() const override;
virtual String get_output_sequence_port_text(int p_port) const override;
virtual int get_input_value_port_count() const override;
virtual int get_output_value_port_count() const override;
virtual PropertyInfo get_input_value_port_info(int p_idx) const override;
virtual PropertyInfo get_output_value_port_info(int p_idx) const override;
virtual String get_caption() const override;
virtual String get_text() const override;
virtual String get_category() const override { return "functions"; }
void set_base_type(const StringName &p_type);
StringName get_base_type() const;
void set_signal(const StringName &p_type);
StringName get_signal() const;
void set_base_path(const NodePath &p_type);
NodePath get_base_path() const;
void set_call_mode(CallMode p_mode);
CallMode get_call_mode() const;
virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
VisualScriptYieldSignal();
};
VARIANT_ENUM_CAST(VisualScriptYieldSignal::CallMode);
void register_visual_script_yield_nodes();
#endif // VISUAL_SCRIPT_YIELD_NODES_H