{"instruction": "Vervollständige den GDScript-Code:", "input": "## Factory class providing convenient static methods to create various fuzzer instances.[br]\n##\n## Fuzzers is a utility class that simplifies the creation of different fuzzer types\n## for testing purposes. It provides static factory methods that create pre-configured\n## fuzzers with sensible defaults, making it easier to set up fuzz testing in your\n## test suites without manually instantiating each fuzzer type.[br]\n##\n## This class acts as a central access point for all fuzzer types, improving code\n## readability and reducing boilerplate in test cases.[br]\n##\n## @tutorial(Fuzzing Testing): https://en.wikipedia.org/wiki/Fuzzing\nclass_name Fuzzers\nextends Resource\n\n\n## Generates random strings with length between [param min_length] and\n## [param max_length] (inclusive), using characters from [param charset].\n## See [StringFuzzer] for detailed documentation and examples.\nstatic func rand_str(min_length: int, max_length: int, charset := StringFuzzer.DEFAULT_CHARSET) -> StringFuzzer:\n\treturn StringFuzzer.new(min_length, max_length, charset)\n\n\n## Creates a [BoolFuzzer] for generating random boolean values.[br]\n##\n## See [BoolFuzzer] for detailed documentation and examples.\nstatic func boolean() -> BoolFuzzer:\n\treturn BoolFuzzer.new()", "output": "\n## Creates an [IntFuzzer] for generating random integers within a range.[br]\n##\n## Generates random integers between [param from] and [param to] (inclusive)\n## using [constant IntFuzzer.NORMAL] mode.\n## See [IntFuzzer] for detailed documentation and examples.\nstatic func rangei(from: int, to: int) -> IntFuzzer:\n\treturn IntFuzzer.new(from, to)\n\n## Creates a [FloatFuzzer] for generating random floats within a range.[br]\n##\n## Generates random float values between [param from] and [param to] (inclusive).\n## See [FloatFuzzer] for detailed documentation and examples.\nstatic func rangef(from: float, to: float) -> FloatFuzzer:\n\treturn FloatFuzzer.new(from, to)\n\n## Creates a [Vector2Fuzzer] for generating random 2D vectors within a range.[br]\n##\n## Generates random Vector2 values where each component is bounded by\n## [param from] and [param to] (inclusive).\n## See [Vector2Fuzzer] for detailed documentation and examples.\nstatic func rangev2(from: Vector2, to: Vector2) -> Vector2Fuzzer:\n\treturn Vector2Fuzzer.new(from, to)\n\n## Creates a [Vector3Fuzzer] for generating random 3D vectors within a range.[br]\n##\n## Generates random Vector3 values where each component is bounded by\n## [param from] and [param to] (inclusive).\n## See [Vector3Fuzzer] for detailed documentation and examples.\nstatic func rangev3(from: Vector3, to: Vector3) -> Vector3Fuzzer:\n\treturn Vector3Fuzzer.new(from, to)\n\n## Creates an [IntFuzzer] that generates only even integers.[br]\n##\n## Generates random even integers between [param from] and [param to] (inclusive)\n## using [constant IntFuzzer.EVEN] mode.\n## See [IntFuzzer] for detailed documentation about even number generation.\nstatic func eveni(from: int, to: int) -> IntFuzzer:\n\treturn IntFuzzer.new(from, to, IntFuzzer.EVEN)\n\n## Creates an [IntFuzzer] that generates only odd integers.[br]\n##\n## Generates random odd integers between [param from] and [param to] (inclusive)\n## using [constant IntFuzzer.ODD] mode."} {"instruction": "Erstelle eine GDScript-Funktion namens 'has_cell':", "input": "", "output": "func has_cell(coord: Vector2i) -> bool:\n\treturn has_point(Gameboard.cell_to_index(coord))\n\n## Returns true if the coordinate is found in the Pathfinder and the cell is unoccupied.\nfunc can_move_to(coord: Vector2i) -> bool:\n\tvar uid: = Gameboard.cell_to_index(coord)\n\treturn has_point(uid) and not is_point_disabled(uid)\n\n## Find a path between two cells. Returns an empty array if no path is available.\n## If allow_blocked_source or allow_blocked_target are false, the pathinder wlil fail if a gamepiece\n## occupies the source or target cells, respectively.\nfunc get_path_to_cell(source_coord: Vector2i, target_coord: Vector2i,\n\t\toccupancy_flags: int = 1) -> Array[Vector2i]:\n\t# Store the return value in a variable.\n\tvar move_path: Array[Vector2i] = []\n\n\t# Find the source/target IDs and keep track of whether or not the cells are occupied.\n\tvar source_id: = Gameboard.cell_to_index(source_coord)\n\tvar target_id: = Gameboard.cell_to_index(target_coord)\n\n\t# The pathfinder has several flags to ignore cell occupancy. We'll need to track which occupants\n\t# are temporarily ignored and then re-disable their pathfinder points once a path is found.\n\t# Key is point id, value is whether or not the point is disabled.\n\tvar ignored_points: Dictionary[int, bool] = {}", "source": "extracted_function"} {"instruction": "Vervollständige den GDScript-Code:", "input": "## Specialized camera that is constrained to the [Gameboard]'s boundaries.\n##\n## The camera's limits are set dynamically according to the viewport's dimensions. Normally, the\n## camera is limited to the [member Gameboard.boundaries].\n## [br][br]In some cases the gameboard is smaller than the viewport, in which case it will be\n## snapped to the gameboard centre along the constrained axis/axes.\nclass_name FieldCamera\nextends Camera2D\n\n@export var gameboard_properties: GameboardProperties:\n\tset(value):\n\t\t_on_viewport_resized()\n\n\n@export var gamepiece: Gamepiece:\n\tset(value):\n\t\tif gamepiece:\n\t\t\tgamepiece.animation_transform.remote_path = \"\"\n\t\t\n\t\tgamepiece = value\n\t\tif gamepiece:\n\t\t\tgamepiece.animation_transform.remote_path \\\n\t\t\t\t= gamepiece.animation_transform.get_path_to(self)\n\n\nfunc _ready() -> void:\n\tget_viewport().size_changed.connect(_on_viewport_resized)\n\t_on_viewport_resized()", "output": "\nfunc reset_position() -> void:\n\tif gamepiece:\n\t\tposition = gamepiece.position * scale\n\n\treset_smoothing()\n\nfunc _on_viewport_resized() -> void:\n\tif not gameboard_properties:\n\t\treturn\n\n\t# Calculate tentative camera boundaries based on the gameboard.\n\tvar boundary_left: = gameboard_properties.extents.position.x * gameboard_properties.cell_size.x\n\tvar boundary_top: = gameboard_properties.extents.position.y * gameboard_properties.cell_size.y\n\tvar boundary_right: = gameboard_properties.extents.end.x * gameboard_properties.cell_size.x\n\tvar boundary_bottom: = gameboard_properties.extents.end.y * gameboard_properties.cell_size.y\n\n\t# We'll also want the current viewport boundary sizes.\n\tvar vp_size: = get_viewport_rect().size / global_scale\n\tvar boundary_width: = boundary_right - boundary_left\n\tvar boundary_height: = boundary_bottom - boundary_top\n\n\t# If the boundary size is less than the viewport size, the camera limits will be smaller than\n\t# the camera dimensions (which does all kinds of crazy things in-game).\n\t# Therefore, if this is the case we'll want to centre the camera on the gameboard and set the\n\t# limits to be that of the viewport, locking the camera to one or both axes.\n\t# Start by checking the x-axis.\n\t# Note that the camera limits must be in global coordinates to function correctly, so account\n\t# using the global scale.\n\tif boundary_width < vp_size.x:\n\t\t# Set the camera position to the centre of the gameboard.\n\t\tposition.x = (gameboard_properties.extents.position.x \\\n\t\t\t+ gameboard_properties.extents.size.x/2.0) * gameboard_properties.cell_size.x\n\n\t\t# And add/subtract half the viewport dimension to come up with the limits. This will fix the\n\t\t# camera with the gameboard centred.\n\t\tlimit_left = (position.x - vp_size.x/2.0)*global_scale.x as int\n\t\tlimit_right = (position.x + vp_size.x/2.0)*global_scale.x as int\n\n\t# If, however, the viewport is smaller than the gameplay area, the camera can be free to move\n\t# as needed.\n\telse:\n\t\tlimit_left = boundary_left*global_scale.x as int\n\t\tlimit_right = boundary_right*global_scale.x as int\n\n\t# Perform the same checks as above for the y-axis.\n\tif boundary_height < vp_size.y:\n\t\tposition.y = (gameboard_properties.extents.position.y +\\"} {"instruction": "Erstelle eine Godot-Klasse 'ValueProvider' die von RefCounted erbt mit folgenden Funktionen: get_value, dispose", "input": "", "output": "# base interface for assert value provider\nclass_name ValueProvider\nextends RefCounted\n\nfunc get_value() -> Variant:\n\treturn null\n\nfunc dispose() -> void:\n\tpass\n"} {"instruction": "Erstelle eine GDScript-Funktion namens 'get_stat':", "input": "", "output": "func get_stat(stat_name := \"\") -> float:\n\tassert(stat_name in _stats_list)\n\treturn _cache[stat_name]\n\n# Adds a modifier to the stat corresponding to `stat_name` and returns the new modifier's id.\nfunc add_modifier(stat_name: String, modifier: float) -> int:\n\tassert(stat_name in _stats_list)\n\t_modifiers[stat_name].append(modifier)\n\t_update(stat_name)\n\treturn len(_modifiers)\n\n# Removes a modifier from the stat corresponding to `stat_name`.\nfunc remove_modifier(stat_name: String, id: int) -> void:\n\tassert(stat_name in _stats_list)\n\t_modifiers[stat_name].erase(id)\n\t_update(stat_name)\n\n# Removes the last modifier applied the stat corresponding to `stat_name`.\nfunc pop_modifier(stat_name: String) -> void:\n\tassert(stat_name in _stats_list)\n\t_modifiers[stat_name].pop_back()\n\t_update(stat_name)\n\n# Remove all modifiers and recalculate stats.\nfunc reset() -> void:\n\t_modifiers = {}", "source": "extracted_function"} {"instruction": "Vervollständige den GDScript-Code:", "input": "#*\n#* back_away.gd\n#* =============================================================================\n#* Copyright (c) 2023-present Serhii Snitsaruk and the LimboAI contributors.\n#*\n#* Use of this source code is governed by an MIT-style\n#* license that can be found in the LICENSE file or at\n#* https://opensource.org/licenses/MIT.\n#* =============================================================================\n#*\n@tool\nextends BTAction\n## Moves the agent in the opposite direction of its current facing. [br]", "output": "## Returns [code]RUNNING[/code] always.\n\n## Blackboard variable that stores desired speed.\n@export var speed_var: StringName = &\"speed\"\n\n## How much can we deviate from the \"away\" direction (in radians).\n@export var max_angle_deviation: float = 0.7\n\nvar _dir: Vector2\nvar _desired_velocity: Vector2\n\n# Called each time this task is entered.\nfunc _enter() -> void:\n\t# Determine \"away\" direction and desired velocity\n\t_dir = Vector2.LEFT * agent.get_facing()\n\tvar speed: float = blackboard.get_var(speed_var, 200.0)\n\tvar rand_angle = randf_range(-max_angle_deviation, max_angle_deviation)\n\t_desired_velocity = _dir.rotated(rand_angle) * speed\n\n# Called each time this task is ticked (aka executed).\nfunc _tick(_delta: float) -> Status:\n\tagent.move(_desired_velocity)\n\tagent.face_dir(-signf(_dir.x))\n\treturn RUNNING\n"} {"instruction": "Erstelle eine GDScript-Funktion namens 'keys':", "input": "", "output": "func keys() -> Array[String]:\n\tvar keys: Array[String]\n\tkeys.assign(_data.keys().duplicate())\n\treturn keys\n\nfunc set_value(key: Variant, value: Variant, blackboard_name: String = DEFAULT) -> void:\n\tif not _data.has(blackboard_name):\n\t\t_data[blackboard_name] = {}", "source": "extracted_function"} {"instruction": "Vervollständige den GDScript-Code:", "input": "extends Node2D\n\n## The cutscene that will play on starting a new game.\n@export var opening_cutscene: Cutscene\n\n## A PlayerController that will be dynamically assigned to whichever Gamepiece the player currently\n## controls.\n@export var player_controller: PackedScene\n\n## The first gamepiece that the player will control. This may be null and assigned via an\n## introductory cutscene instead.\n@export var player_default_gamepiece: Gamepiece\n\n\nfunc _ready() -> void:\n\trandomize()\n\t", "output": "\t# Assign proper controllers to player gamepieces whenever they change.\n\tPlayer.gamepiece_changed.connect(\n\t\tfunc _on_player_gp_changed() -> void:\n\t\t\tvar new_gp: = Player.gamepiece\n\t\t\tCamera.gamepiece = new_gp\n\n\t\t\t# Free up any lingering controller(s).\n\t\t\tfor controller in get_tree().get_nodes_in_group(PlayerController.GROUP):\n\t\t\t\tcontroller.queue_free()\n\n\t\t\tif new_gp:\n\t\t\t\tvar new_controller = player_controller.instantiate()\n\t\t\t\tassert(new_controller is PlayerController, \"The Field game state requires a valid\n\t\t\t\t\t PlayerController set in the editor!\")\n\n\t\t\t\tnew_gp.add_child(new_controller)\n\t\t\t\tnew_controller.is_active = true\n\t)\n\n\tPlayer.gamepiece = player_default_gamepiece\n\n\t# The field state must pause/unpause with combat accordingly.\n\t# Note that pausing/unpausing input is already wrapped up in triggers, which are what will\n\t# initiate combat.\n\tCombatEvents.combat_initiated.connect(func(): hide())\n\tCombatEvents.combat_finished.connect(func(_is_victory): show())\n\n\tCamera.scale = scale\n\tCamera.make_current()\n\tCamera.reset_position()\n\n\tif opening_cutscene:\n\t\topening_cutscene.run.call_deferred()\n"} {"instruction": "Erstelle eine Godot-Klasse 'GdUnitArrayAssert' die von GdUnitAssert erbt mit folgenden Funktionen: is_null, is_not_null, is_equal, is_equal_ignoring_case, is_not_equal", "input": "", "output": "## An Assertion Tool to verify array values\n@abstract class_name GdUnitArrayAssert\nextends GdUnitAssert\n\n## Verifies that the current value is null.\n@abstract func is_null() -> GdUnitArrayAssert\n\n## Verifies that the current value is not null.\n@abstract func is_not_null() -> GdUnitArrayAssert\n\n## Verifies that the current Array is equal to the given one.\n@abstract func is_equal(...expected: Array) -> GdUnitArrayAssert\n\n## Verifies that the current Array is equal to the given one, ignoring case considerations.\n@abstract func is_equal_ignoring_case(...expected: Array) -> GdUnitArrayAssert\n\n## Verifies that the current Array is not equal to the given one.\n@abstract func is_not_equal(...expected: Array) -> GdUnitArrayAssert\n\n## Verifies that the current Array is not equal to the given one, ignoring case considerations.\n@abstract func is_not_equal_ignoring_case(...expected: Array) -> GdUnitArrayAssert\n\n## Overrides the default failure message by given custom message.\n@abstract func override_failure_message(message: String) -> GdUnitArrayAssert\n\n## Appends a custom message to the failure message.\n@abstract func append_failure_message(message: String) -> GdUnitArrayAssert\n\n## Verifies that the current Array is empty, it has a size of 0.\n@abstract func is_empty() -> GdUnitArrayAssert\n\n## Verifies that the current Array is not empty, it has a size of minimum 1.\n@abstract func is_not_empty() -> GdUnitArrayAssert\n\n## Verifies that the current Array is the same. [br]\n## Compares the current by object reference equals\n@abstract func is_same(expected: Variant) -> GdUnitArrayAssert\n\n## Verifies that the current Array is NOT the same. [br]\n## Compares the current by object reference equals\n@abstract func is_not_same(expected: Variant) -> GdUnitArrayAssert\n\n## Verifies that the current Array has a size of given value.\n@abstract func has_size(expectd: int) -> GdUnitArrayAssert\n\n## Verifies that the current Array contains the given values, in any order.[br]\n## The values"} {"instruction": "Vervollständige den GDScript-Code:", "input": "## An Assertion Tool to verify for emitted signals until a waiting time\n@abstract class_name GdUnitSignalAssert\nextends GdUnitAssert\n\n\n## Verifies that the current value is null.\n@abstract func is_null() -> GdUnitSignalAssert\n\n\n## Verifies that the current value is not null.\n@abstract func is_not_null() -> GdUnitSignalAssert\n\n\n## Verifies that the current value is equal to the given one.\n@abstract func is_equal(expected: Variant) -> GdUnitSignalAssert\n\n\n## Verifies that the current value is not equal to expected one.\n@abstract func is_not_equal(expected: Variant) -> GdUnitSignalAssert\n\n\n## Overrides the default failure message by given custom message.\n@abstract func override_failure_message(message: String) -> GdUnitSignalAssert\n\n\n## Appends a custom message to the failure message.\n@abstract func append_failure_message(message: String) -> GdUnitSignalAssert\n\n\n## Verifies that the specified signal is emitted with the expected arguments.[br]\n##\n## This assertion waits for a signal to be emitted from the object under test and\n## validates that it was emitted with the correct arguments. The function supports\n## both typed signals (Signal type) and string-based signal names for flexibility\n## in different testing scenarios.[br]\n## [br]\n## [b]Parameters:[/b][br]\n## [param signal_name]: The signal to monitor. Can be either:[br]\n## • A [Signal] reference (recommended for type safety)[br]\n## • A [String] with the signal name\n## [param signal_args]: Optional expected signal arguments.[br]\n## When provided, verifies the signal was emitted with exactly these values.[br]\n## [br]\n## [b]Returns:[/b][br]\n## [GdUnitSignalAssert] - Returns self for method chaining.[br]\n## [br]\n## [b]Examples:[/b]\n## [codeblock]\n## signal signal_a(value: int)\n## signal signal_b(name: String, count: int)\n##\n## # Wait for signal emission without checking arguments\n## # Using Signal reference (type-safe)", "output": "## await assert_signal(instance).is_emitted(signal_a)\n## # Using string name (dynamic)\n## await assert_signal(instance).is_emitted(\"signal_a\")\n##\n## # Wait for signal emission with specific argument\n## await assert_signal(instance).is_emitted(signal_a, 10)\n##\n## # Wait for signal with multiple arguments\n## await assert_signal(instance).is_emitted(signal_b, \"test\", 42)\n##\n## # Wait max 500ms for signal with argument 10\n## await assert_signal(instance).wait_until(500).is_emitted(signal_a, 10)\n## [/codeblock]\n## [br]\n## [b]Note:[/b] This is an async operation - use [code]await[/code] when calling.[br]\n## The assertion fails if the signal is not emitted within the timeout period.\n@abstract func is_emitted(signal_name: Variant, ...signal_args: Array) -> GdUnitSignalAssert\n\n## Verifies that the specified signal is NOT emitted with the expected arguments.[br]\n##\n## This assertion waits for a specified time period and validates that a signal\n## was not emitted with the given arguments. Useful for ensuring certain conditions\n## don't trigger unwanted signals or for verifying signal filtering logic.[br]\n## [br]\n## [b]Parameters:[/b][br]\n## [param signal_name]: The signal to monitor. Can be either:[br]\n## • A [Signal] reference (recommended for type safety)[br]\n## • A [String] with the signal name\n## [param signal_args]: Optional expected signal arguments.[br]\n## When provided, verifies the signal was not emitted with these specific values.[br]\n## If omitted, verifies the signal was not emitted at all.[br]\n## [br]\n## [b]Returns:[/b][br]\n## [GdUnitSignalAssert] - Returns self for method chaining.[br]\n## [br]\n## [b]Examples:[/b]\n## [codeblock]\n## signal signal_a(value: int)\n## signal signal_b(name: String, count: int)\n##\n## # Verify signal is not emitted at all (without checking arguments)\n## await assert_signal(instance).wait_until(500).is_not_emitted(signal_a)\n## await assert_signal(instance).wait_until(500).is_not_emitted(\"signal_a\")\n##\n## # Verify signal is not emitted with specific argument\n## await assert_signal(instance).wait_until(500).is_not_emitted(signal_a, 10)\n##\n## # Verify signal is not emitted with multiple arguments\n## await assert_signal(instance).wait_until(500).is_not_emitted(signal_b, \"test\", 42)"} {"instruction": "Vervollständige den GDScript-Code:", "input": "@tool\nclass_name FadeMessage3D\nextends Node3D\n\n## Text to show, after assigning text it will disappear after a time.\n@export var text : String = \"\":\n\tset(value):\n\t\t# Note, even if we don't change the value, we re-initiate our fade\n\t\ttext = value\n\t\tif is_inside_tree():\n\t\t\t_update_text()\n\n## Text color.\n@export var text_color : Color = Color(1.0, 1.0, 1.0):\n\tset(value):\n\t\ttext_color = value\n\t\tif is_inside_tree():\n\t\t\t_update_color()\n\n## Duration the text stays on screen before it fades out.\n@export_range(0.1, 10.0, 0.1, \"suffix:s\") var fade_duration : float = 0.5\n\n## Duration of our fade out.\n@export_range(0.1, 10.0, 0.1, \"suffix:s\") var fade_delay : float = 1.0\n\n\nvar _label : Label3D\nvar _delay : float = 1.0\nvar _modulate : float = 1.0\n", "output": "# Update our label text\nfunc _update_text():\n\tif Engine.is_editor_hint():\n\t\t# In editor we don't apply the fade\n\t\tif text.is_empty():\n\t\t\t# and show a placeholder text\n\t\t\t_label.text = \"FadeMessage3D\"\n\t\t\t_update_color()\n\t\telse:\n\t\t\t_label.text = text\n\t\t\t_update_color()\n\telif text.is_empty():\n\t\t_modulate = 0.0\n\t\t_label.visible = false\n\t\tset_process(false)\n\telse:\n\t\t_delay = fade_delay\n\t\t_modulate = 1.0\n\t\t_label.text = text\n\t\t_label.visible = true\n\t\t_update_color()\n\t\tset_process(true)\n\n# Update our text color and modulation\nfunc _update_color():\n\t_label.modulate = Color(text_color.r, text_color.g, text_color.b, _modulate)\n\t_label.outline_modulate = Color(0.0, 0.0, 0.0, _modulate)\n\n# Called when the node enters the scene tree for the first time.\nfunc _ready():\n\t_label = Label3D.new()\n\t_label.pixel_size = 0.002\n\tadd_child(_label, false, Node.INTERNAL_MODE_BACK)\n\n\t_update_text()\n\t_update_color()\n\n# Called every frame. 'delta' is the elapsed time since the previous frame.\nfunc _process(delta):\n\t# Don't run this in editor.\n\tif Engine.is_editor_hint():\n\t\tset_process(false)\n\t\treturn\n\n\t# Once modulate reaches zero, hide and cleanup\n\tif _modulate == 0.00:\n\t\t_label.visible = false"} {"instruction": "Vervollständige den GDScript-Code:", "input": "extends GdUnitGodotErrorAssert\n\nvar _current_failure_message := \"\"\nvar _custom_failure_message := \"\"\nvar _additional_failure_message := \"\"\nvar _callable: Callable\nvar _logger := GodotGdErrorMonitor.GdUnitLogger.new(true, true)\n\n\nfunc _init(callable: Callable) -> void:\n\t# save the actual assert instance on the current thread context\n\tGdUnitThreadManager.get_current_context().set_assert(self)\n\tGdAssertReports.reset_last_error_line_number()\n\t_callable = callable\n\n\nfunc _execute() -> Array[ErrorLogEntry]:\n\tawait _callable.call()\n\treturn _logger.entries()\n\n\nfunc failure_message() -> String:\n\treturn _current_failure_message\n\n\nfunc _report_success() -> GdUnitAssert:\n\tGdAssertReports.report_success()\n\treturn self\n\n\nfunc _report_error(error_message: String, failure_line_number: int = -1) -> GdUnitAssert:\n\tvar line_number := failure_line_number if failure_line_number != -1 else GdUnitAssertions.get_line_number()\n\t_current_failure_message = GdAssertMessages.build_failure_message(error_message, _additional_failure_message, _custom_failure_message)\n\tGdAssertReports.report_error(_current_failure_message, line_number)\n\treturn self\n\n\nfunc _has_log_entry(log_entries: Array[ErrorLogEntry], type: ErrorLogEntry.TYPE, error: Variant) -> bool:\n\tfor entry in log_entries:\n\t\tif entry._type == type and GdObjects.equals(entry._message, error):\n\t\t\tGdUnitThreadManager.get_current_context().get_execution_context().error_monitor.erase_log_entry(entry)\n\t\t\treturn true\n\treturn false\n\n\nfunc _to_list(log_entries: Array[ErrorLogEntry]) -> String:\n\tif log_entries.is_empty():\n\t\treturn \"no errors\"\n\n\tvar values := []", "output": "\tfor entry in log_entries:\n\t\tvalues.append(entry)\n\treturn \"\\n\".join(values)\n\nfunc is_null() -> GdUnitGodotErrorAssert:\n\treturn _report_error(\"Not implemented\")\n\nfunc is_not_null() -> GdUnitGodotErrorAssert:\n\treturn _report_error(\"Not implemented\")\n\nfunc is_equal(_expected: Variant) -> GdUnitGodotErrorAssert:\n\treturn _report_error(\"Not implemented\")\n\nfunc is_not_equal(_expected: Variant) -> GdUnitGodotErrorAssert:\n\treturn _report_error(\"Not implemented\")\n\nfunc override_failure_message(message: String) -> GdUnitGodotErrorAssert:\n\t_custom_failure_message = message\n\treturn self\n\nfunc append_failure_message(message: String) -> GdUnitGodotErrorAssert:\n\t_additional_failure_message = message\n\treturn self\n\nfunc is_success() -> GdUnitGodotErrorAssert:\n\tif not _validate_callable():\n\t\treturn self\n\n\tvar log_entries := await _execute()\n\tif log_entries.is_empty():\n\t\treturn _report_success()\n\treturn _report_error(\"\"\"\n\t\tExpecting: no error's are ocured.\n\t\t\tbut found: '%s'\n\t\t\"\"\".dedent().trim_prefix(\"\\n\") % _to_list(log_entries))\n\nfunc is_runtime_error(expected_error: Variant) -> GdUnitGodotErrorAssert:\n\tif not _validate_callable():\n\t\treturn self\n\n\tvar result := GdUnitArgumentMatchers.is_variant_string_matching(expected_error)\n\tif result.is_error():"} {"instruction": "Erstelle eine Godot-Klasse 'InteractionPopup' die von UIPopup erbt mit folgenden Funktionen: _ready, _on_area_entered, _on_area_exited, _on_input_paused", "input": "", "output": "@tool\n## A [UIPopup] used specifically to mark [Interaction]s and other points of interest for the player.\n##\n## InteractionPopups may be added as children to a variety of objects. They respond to the player's\n## physics layer and show up as an emote bubble when the player is nearby.\nclass_name InteractionPopup extends UIPopup\n\n## The different emote types that may be selected.\nenum EmoteTypes { COMBAT, EMPTY, EXCLAMATION, QUESTION}\n\n## The emote textures that may appear over a point of interest.\nconst EMOTES: = {\n\tEmoteTypes.COMBAT: preload(\"res://assets/gui/emotes/emote_combat.png\"),\n\tEmoteTypes.EMPTY: preload(\"res://assets/gui/emotes/emote__.png\"),\n\tEmoteTypes.EXCLAMATION: preload(\"res://assets/gui/emotes/emote_exclamations.png\"),\n\tEmoteTypes.QUESTION: preload(\"res://assets/gui/emotes/emote_question.png\"),\n}\n\n## The emote bubble that will be displayed when the character is nearby.\n@export var emote: = EmoteTypes.EMPTY:\n\tset(value):\n\t\temote = value\n\n\t\tif not is_inside_tree():\n\t\t\tawait ready\n\n\t\t_sprite.texture = EMOTES.get(emote, EMOTES[EmoteTypes.EMPTY])\n\n## How close the player must be to the emote before it will display.\n@export var radius: = 32:\n\tset(value):\n\t\tradius = value\n\n\t\tif not is_inside_tree():\n\t\t\tawait ready\n\n\t\t_collision_shape.shape.radius = radius\n\n## Is true if the InteractionPopup should respond to the player's presence. Otherwise, the popup\n## will not be triggered.\n@export var is_active: = true:\n\tset(value):\n\t\tis_active = value\n\n\t\tif not Engine.is_editor_hint():\n\t\t\tif not is_inside_tree():\n\t\t\t\tawait ready\n\n\t\t\t_area.monitoring = is_active\n\t\t\t_collision_shape.disabled = !is_active\n\n@onready var _area: = $Area2D as Area2D\n@onready var _collision_shape: = $Area2D/CollisionShape2D as CollisionShape2D\n\nfunc _ready() -> void:\n\tsuper._ready()\n\n\tif not Engine.is_editor_hint():\n\t\tFieldEvents.input_paused.connect(_on_input_paused)\n\nfunc _on_area_entered(_entered_area: Area2D) -> void:\n\t_is_shown = true\n\nfunc _on_area_exited(_exited_area: Ar"} {"instruction": "Vervollständige den GDScript-Code:", "input": "extends CharacterBody3D\n\n# Settings to control the character.\n@export var rotation_speed := 1.0\n@export var movement_speed := 5.0\n@export var movement_acceleration := 5.0\n\n# Get the gravity from the project settings to be synced with RigidBody nodes.\nvar gravity := float(ProjectSettings.get_setting(\"physics/3d/default_gravity\"))\n\n# Helper variables to keep our code readable.\n@onready var origin_node: XROrigin3D = $XROrigin3D\n@onready var camera_node: XRCamera3D = $XROrigin3D/XRCamera3D\n@onready var neck_position_node: Node3D = $XROrigin3D/XRCamera3D/Neck\n@onready var black_out: Node3D = $XROrigin3D/XRCamera3D/BlackOut\n\n## Called when the user has requested their view to be recentered.\nfunc recenter() -> void:\n\tvar xr_interface: OpenXRInterface = XRServer.find_interface(\"OpenXR\")\n\tif not xr_interface:\n\t\tpush_error(\"Couldn't access OpenXR interface!\")\n\t\treturn\n\n\tvar play_area_mode: XRInterface.PlayAreaMode = xr_interface.get_play_area_mode()\n\tif play_area_mode == XRInterface.XR_PLAY_AREA_SITTING:\n\t\tpush_warning(\"Sitting play space is not suitable for this setup.\")\n\telif play_area_mode == XRInterface.XR_PLAY_AREA_ROOMSCALE:\n\t\t# This is already handled by the headset.\n\t\tpass\n\telse:\n\t\t# Use Godot's own logic.\n\t\tXRServer.center_on_hmd(XRServer.RESET_BUT_KEEP_TILT, true)\n\n\t# XRCamera3D node won't be updated yet, so go straight to the source!\n\tvar head_tracker: XRPositionalTracker = XRServer.get_tracker(&\"head\")\n\tif not head_tracker:\n\t\tpush_error(\"Couldn't locate head tracker!\")\n\t\treturn\n\n\tvar pose: XRPose = head_tracker.get_pose(&\"default\")\n\tvar head_transform: Transform3D = pose.get_adjusted_transform()\n\n\t# Get neck transform in XROrigin3D space\n\tvar neck_transform: Transform3D = neck_position_node.transform * head_transform\n\n\t# Reset our XROrigin transform and apply the inverse of the neck position.\n\tvar new_origin_transform: Transform3D = Transform3D()\n\tnew_origin_transform.origin.x = -neck_transform.origin.x\n\tnew_origin_transform.origin.y = 0.0\n\tnew_origin_transform.origin.z = -neck_transform.origin.z\n\torigin_node.transform = new_origin_transform", "output": "\n\t# Finally reset character orientation\n\ttransform.basis = Basis()\n\n# Returns our move input by querying the move action on each controller.\nfunc _get_movement_input() -> Vector2:\n\tvar movement := Vector2()\n\n\t# If move is not bound to one of our controllers,\n\t# that controller will return `Vector2.ZERO`.\n\tmovement += $XROrigin3D/LeftHand.get_vector2(&\"move\")\n\tmovement += $XROrigin3D/RightHand.get_vector2(&\"move\")\n\n\treturn movement\n\n# `_process_on_physical_movement()` handles the physical movement of the player\n# adjusting our character body position to \"catch up to\" the player.\n# If the character body encounters an obstruction our view will black out\n# and we will stop further character movement until the player physically\n# moves back.\nfunc _process_on_physical_movement(delta: float) -> bool:\n\t# Remember our current velocity, as we'll apply that later.\n\tvar current_velocity := velocity\n\n\t# Start by rotating the player to face the same way our real player is.\n\tvar camera_basis: Basis = origin_node.transform.basis * camera_node.transform.basis\n\tvar forward: Vector2 = Vector2(camera_basis.z.x, camera_basis.z.z)\n\tvar angle: float = forward.angle_to(Vector2(0.0, 1.0))\n\n\t# Rotate our character body.\n\ttransform.basis = transform.basis.rotated(Vector3.UP, angle)\n\n\t# Reverse this rotation our origin node.\n\torigin_node.transform = Transform3D().rotated(Vector3.UP, -angle) * origin_node.transform\n\n\t# Now apply movement, first move our player body to the right location.\n\tvar org_player_body: Vector3 = global_transform.origin\n\tvar player_body_location: Vector3 = origin_node.transform * camera_node.transform * neck_position_node.transform.origin\n\tplayer_body_location.y = 0.0\n\tplayer_body_location = global_transform * player_body_location\n\n\tvelocity = (player_body_location - org_player_body) / delta\n\tmove_and_slide()\n\n\t# Now move our XROrigin back.\n\tvar delta_movement := global_transform.origin - org_player_body\n\torigin_node.global_transform.origin -= delta_movement\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "# A specialized steering agent that updates itself every frame so the user does\n# not have to using a CharacterBody3D\n# @category - Specialized agents\nclass_name GSAICharacterBody3DAgent\nextends GSAISpecializedAgent\n\n# SLIDE uses `move_and_slide`\n# COLLIDE uses `move_and_collide`\n# POSITION changes the global_position directly\nenum MovementType { SLIDE, COLLIDE, POSITION }\n\n# The CharacterBody3D to keep track of\nvar body: CharacterBody3D: set = _set_body\n\n# The type of movement the body executes\nvar movement_type: int\n\nvar _last_position: Vector3\nvar _body_ref: WeakRef\n\n\nfunc _init(_body: CharacterBody3D, _movement_type: int = MovementType.SLIDE) -> void:\n\tif not _body.is_inside_tree():\n\t\tawait(_body).ready\n\n\tself.body = _body\n\tself.movement_type = _movement_type\n\n\t# warning-ignore:return_value_discarded\n\t_body.get_tree().physics_frame.connect(_on_SceneTree_physics_frame)\n\n\n# Moves the agent's `body` by target `acceleration`.\n# @tags - virtual\nfunc _apply_steering(acceleration: GSAITargetAcceleration, delta: float) -> void:\n\t_applied_steering = true\n\tmatch movement_type:\n\t\tMovementType.COLLIDE:\n\t\t\t_apply_collide_steering(acceleration.linear, delta)\n\t\tMovementType.SLIDE:\n\t\t\t_apply_sliding_steering(acceleration.linear, delta)\n\t\t_:\n\t\t\t_apply_position_steering(acceleration.linear, delta)\n\n\t_apply_orientation_steering(acceleration.angular, delta)\n\n\nfunc _apply_sliding_steering(accel: Vector3, delta: float) -> void:\n\tvar _body: CharacterBody3D = _body_ref.get_ref()\n\tif not _body:\n\t\treturn\n\n\t_body.velocity = GSAIUtils.clampedv3(\n\t\tlinear_velocity + accel * delta, linear_speed_max", "output": "\t)\n\tif apply_linear_drag:\n\t\t_body.velocity = _body.velocity.lerp(Vector3.ZERO, linear_drag_percentage)\n\n\t_body.move_and_slide()\n\n\tif calculate_velocities:\n\t\tlinear_velocity = _body.velocity\n\nfunc _apply_collide_steering(accel: Vector3, delta: float) -> void:\n\tvar _body: CharacterBody3D = _body_ref.get_ref()\n\tif not _body:\n\t\treturn\n\n\t_body.velocity = GSAIUtils.clampedv3(\n\t\tlinear_velocity + accel * delta, linear_speed_max\n\t)\n\tif apply_linear_drag:\n\t\t_body.velocity = _body.velocity.lerp(Vector3.ZERO, linear_drag_percentage)\n\n\t# warning-ignore:return_value_discarded\n\t_body.move_and_collide(_body.velocity * delta)\n\n\tif calculate_velocities:\n\t\tlinear_velocity = _body.velocity\n\nfunc _apply_position_steering(accel: Vector3, delta: float) -> void:\n\tvar _body: CharacterBody3D = _body_ref.get_ref()\n\tif not _body:\n\t\treturn\n\n\tvar velocity := GSAIUtils.clampedv3(\n\t\tlinear_velocity + accel * delta, linear_speed_max\n\t)\n\tif apply_linear_drag:\n\t\tvelocity = velocity.lerp(Vector3.ZERO, linear_drag_percentage)\n\n\t_body.global_transform.origin += velocity * delta\n\tif calculate_velocities:\n\t\tlinear_velocity = velocity\n\nfunc _apply_orientation_steering(angular_acceleration: float, delta: float) -> void:\n\tvar _body: CharacterBody3D = _body_ref.get_ref()\n\tif not _body:\n\t\treturn\n\n\tvar velocity = clamp("} {"instruction": "Erstelle eine GDScript-Funktion namens '_init':", "input": "", "output": "func _init() -> void:\n\t# Disable/re-enable occupied cells whenever a gamepiece moves.\n\tGamepieceRegistry.gamepiece_moved.connect(\n\t\tfunc _on_gamepiece_moved(_gp: Gamepiece, new_cell: Vector2i, old_cell: Vector2i) -> void:\n\t\t\tvar new_cell_id: = Gameboard.cell_to_index(new_cell)\n\t\t\tif has_point(new_cell_id):\n\t\t\t\tset_point_disabled(new_cell_id, true)\n\n\t\t\tvar old_cell_id: = Gameboard.cell_to_index(old_cell)\n\t\t\tif has_point(old_cell_id):\n\t\t\t\tset_point_disabled(old_cell_id, false)\n\t)\n\n\tGamepieceRegistry.gamepiece_freed.connect(\n\t\tfunc _on_gamepiece_free(_gp: Gamepiece, coord: Vector2i) -> void:\n\t\t\tvar cell_id: = Gameboard.cell_to_index(coord)\n\t\t\tif has_point(cell_id):\n\t\t\t\tset_point_disabled(cell_id, false)\n\t)\n\n## Returns true if the coordinate is found in the Pathfinder.\nfunc has_cell(coord: Vector2i) -> bool:\n\treturn has_point(Gameboard.cell_to_index(coord))\n\n## Returns true if the coordinate is found in the Pathfinder and the cell is unoccupied.\nfunc can_move_to(coord: Vector2i) -> bool:\n\tvar uid: = Gameboard.cell_to_index(coord)\n\treturn has_point(uid) and not is_point_disabled(uid)\n\n## Find a path between two cells. Returns an empty array if no path is available.\n## If allow_blocked_source or allow_blocked_target are false, the pathinder wlil fail if a gamepiece\n## occupies the source or target cells, respectively.\nfunc get_path_to_cell(source_coord: Vector2i, target_coord: Vector2i,\n\t\toccupancy_flags: int = 1) -> Array[Vector2i]:\n\t# Store the return value in a variable.\n\tvar move_path: Array[Vector2i] = []\n\n\t# Find the source/target IDs and keep track of whether or not the cells are occupied.\n\tvar source_id: = Gameboard.cell_to_index(source_coord)\n\tvar target_id: = Gameboard.cell_to_index(target_coord)\n\n\t# The pathfinder has several flags to ignore cell occupancy. We'll need to track which occupants\n\t# are temporarily ignored and then re-disable their pathfinder points once a path is found.\n\t# Key is point id, value is whether or not the point is disabled.\n\tvar ignored_points: Dictionary[int, bool] = {}", "source": "extracted_function"} {"instruction": "Erstelle eine GDScript-Funktion namens '_ready':", "input": "", "output": "func _ready() -> void:\n\tawait owner.ready\n\t_parent = get_parent() as State\n\nfunc unhandled_input(_event: InputEvent) -> void:\n\tpass\n\nfunc physics_process(_delta: float) -> void:\n\tpass\n\nfunc enter(_msg: Dictionary = {}"} {"instruction": "Vervollständige den GDScript-Code:", "input": "#*\n#* fireball.gd\n#* =============================================================================\n#* Copyright (c) 2023-present Serhii Snitsaruk and the LimboAI contributors.\n#*\n#* Use of this source code is governed by an MIT-style\n#* license that can be found in the LICENSE file or at\n#* https://opensource.org/licenses/MIT.\n#* =============================================================================\n#*\nextends Node2D\n## Fireball\n\nconst SPEED := 800.0\nconst DEAD_SPEED := 400.0\n\n@export var dir: float = 1.0\n\nvar _is_dead: bool = false", "output": "\n@onready var fireball_sprite: Sprite2D = $Root/Fireball\n@onready var death: GPUParticles2D = $FX/Death\n@onready var collision_shape_2d: CollisionShape2D = $Hitbox/CollisionShape2D\n@onready var root: Node2D = $Root\n@onready var trail: GPUParticles2D = $FX/Trail\n\nfunc _ready() -> void:\n\tvar tween := create_tween().set_loops()\n\ttween.tween_property(fireball_sprite, ^\"rotation\", PI * signf(dir), 1.0).as_relative()\n\n\tvar tween2 := create_tween().set_trans(Tween.TRANS_QUAD).set_ease(Tween.EASE_IN)\n\ttween2.tween_property(fireball_sprite, \"position:y\", -10.0, 0.5).as_relative().set_ease(Tween.EASE_OUT)\n\ttween2.tween_property(fireball_sprite, \"position:y\", 0.0, 1.0)\n\ttween2.tween_callback(_die)\n\nfunc _physics_process(delta: float) -> void:\n\tvar speed: float = SPEED if not _is_dead else DEAD_SPEED\n\tposition += Vector2.RIGHT * speed * dir * delta\n\nfunc _die() -> void:\n\tif _is_dead:\n\t\treturn\n\t_is_dead = true\n\ttrail.emitting = false\n\troot.hide()\n\tcollision_shape_2d.set_deferred(&\"disabled\", true)\n\tdeath.emitting = true\n\tawait death.finished\n\tqueue_free()\n\nfunc _on_hitbox_area_entered(_area: Area2D) -> void:\n\t_die()\n"} {"instruction": "Erstelle eine GDScript-Funktion namens 'set_value':", "input": "", "output": "func set_value(key: Variant, value: Variant, blackboard_name: String = DEFAULT) -> void:\n\tif not _data.has(blackboard_name):\n\t\t_data[blackboard_name] = {}", "source": "extracted_function"} {"instruction": "Erstelle eine Godot-Klasse 'Conductor' die von Node erbt mit folgenden Funktionen: _ready, _process, _physics_process, play, stop", "input": "", "output": "## Accurately tracks the current beat of a song.\nclass_name Conductor\nextends Node\n\n## If [code]true[/code], the song is paused. Setting [member is_paused] to\n## [code]false[/code] resumes the song.\n@export var is_paused: bool = false:\n\tget:\n\t\tif player:\n\t\t\treturn player.stream_paused\n\t\treturn false\n\tset(value):\n\t\tif player:\n\t\t\tplayer.stream_paused = value\n\n@export_group(\"Nodes\")\n## The song player.\n@export var player: AudioStreamPlayer\n\n@export_group(\"Song Parameters\")\n## Beats per minute of the song.\n@export var bpm: float = 100\n## Offset (in milliseconds) of when the 1st beat of the song is in the audio\n## file. [code]5000[/code] means the 1st beat happens 5 seconds into the track.\n@export var first_beat_offset_ms: int = 0\n\n@export_group(\"Filter Parameters\")\n## [code]cutoff[/code] for the 1€ filter. Decrease to reduce jitter.\n@export var allowed_jitter: float = 0.1\n## [code]beta[/code] for the 1€ filter. Increase to reduce lag.\n@export var lag_reduction: float = 5\n\n# Calling this is expensive, so cache the value. This should not change.\nvar _cached_output_latency: float = AudioServer.get_output_latency()\n\n# General conductor state\nvar _is_playing: bool = false\n\n# Audio thread state\nvar _song_time_audio: float = -100\n\n# System time state\nvar _song_time_begin: float = 0\nvar _song_time_system: float = -100\n\n# Filtered time state\nvar _filter: OneEuroFilter\nvar _filtered_audio_system_delta: float = 0\n\nfunc _ready() -> void:\n\t# Ensure that playback state is always updating, otherwise the smoothing\n\t# filter causes issues.\n\tprocess_mode = Node.PROCESS_MODE_ALWAYS\n\nfunc _process(_delta: float) -> void:\n\tif not _is_playing:\n\t\treturn\n\n\t# Handle a web bug where AudioServer.get_time_since_last_mix() occasionally\n\t# returns unsigned 64-bit integer max value. This is likely due to minor\n\t# timing issues between the main/audio threads, thus causing an underflow\n\t# in the engine code.\n\tvar last_mix := AudioServer.get_time_since_last_mix()\n\tif last_mix > 1000:\n\t\tlast_mix = 0\n"} {"instruction": "Erstelle eine GDScript-Funktion namens '_init':", "input": "", "output": "func _init() -> void:\n\tset_report_directory(GdUnitFileAccess.current_dir() + \"reports\")\n\tset_current_report_path()\n\nfunc _process(_delta: float) -> bool:\n\t# check if reports exists\n\tif not reports_available():\n\t\tprints(\"no reports found\")\n\t\treturn true\n\n\t# only process if godot logging is enabled\n\tif not GdUnitSettings.is_log_enabled():\n\t\twrite_report(NO_LOG_MESSAGE, \"\")\n\t\treturn true\n\n\t# parse possible custom report path,\n\tvar cmd_parser := CmdArgumentParser.new(_cmd_options, \"GdUnitCmdTool.gd\")\n\t# ignore erros and exit quitly\n\tif cmd_parser.parse(get_cmdline_args(), true).is_error():\n\t\treturn true\n\tCmdCommandHandler.new(_cmd_options).register_cb(\"-rd\", set_report_directory)\n\n\tvar godot_log_file := scan_latest_godot_log()\n\tvar result := read_log_file_content(godot_log_file)\n\tif result.is_error():\n\t\twrite_report(result.error_message(), godot_log_file)\n\t\treturn true\n\twrite_report(result.value_as_string(), godot_log_file)\n\treturn true\n\nfunc set_current_report_path() -> void:\n\t# scan for latest report directory\n\tvar iteration := GdUnitFileAccess.find_last_path_index(\n\t\t_report_root_path, GdUnitConstants.REPORT_DIR_PREFIX\n\t)\n\t_current_report_path = \"%s/%s%d\" % [_report_root_path, GdUnitConstants.REPORT_DIR_PREFIX, iteration]\n\nfunc set_report_directory(path: String) -> void:\n\t_report_root_path = path\n\nfunc get_log_report_html() -> String:\n\treturn _current_report_path + \"/godot_report_log.html\"\n\nfunc reports_available() -> bool:\n\treturn DirAccess.dir_exists_absolute(_report_root_path)\n\nfunc scan_latest_godot_log() -> String:\n\tvar path := GdUnitSettings.get_log_path().get_base_dir()\n\tvar files_sorted := Array()\n\tfor file in GdUnitFileAccess.scan_dir(path):\n\t\tvar file_name := \"%s/%s\" % [path, file]\n\t\tfiles_sorted.append(file_name)\n\t# sort by name, the name contains the timestamp so we sort at the end by timestamp\n\tfiles_sorted.sort()\n\treturn files_sorted.back()\n\nfunc read_log_file_content(log_file: String) -> GdUnitResult:\n\tvar file := FileAccess.open(log_file, FileAccess.READ)\n\tif file == null:\n\t\treturn GdUnitResult.error(\n\t\t\t\"Can't find log file '%s'. Error: %s\"\n\t\t\t% [log_file, error_string(FileAccess.get_open_error())]\n\t\t)\n\tvar content := \"
\" + file.get_as_text()\n\t# patch out console format codes\n\tfor color_index in range(0, 256):\n\t\tvar to_replace := \"\u001b[38;5;%dm\" % color_index\n\t\tcontent = content.replace(to_replace, \"\")\n\tcontent += \"\"\n\tcontent = content\\\n\t\t.replace(\"\u001b[0m\", \"\")\\\n\t\t.replace(GdUnitCSIMessageWriter.CSI_BOLD, \"\")\\\n\t\t.replace(GdUnitCSIMessageWriter.CSI_ITALIC, \"\")\\\n\t\t.replace(GdUnitCSIMessageWriter.CSI_UNDERLINE, \"\")\n\treturn GdUnitResult.success(content)\n\nfunc write_report(content: String, godot_log_file: String) -> GdUnitResult:\n\tvar file := FileAccess.open(get_log_report_html(), FileAccess.WRITE)\n\tif file == null:\n\t\treturn GdUnitResult.error(\n\t\t\t\"Can't open to write '%s'. Error: %s\"\n\t\t\t% [get_log_report_html(), error_string(FileAccess.get_open_error())]\n\t\t)\n\tvar report_html := LOG_FRAME_TEMPLATE.replace(\"${content}", "source": "extracted_function"} {"instruction": "Vervollständige den GDScript-Code:", "input": "## Defines the playable area of the game and where everything on it lies.\n##\n## The gameboard is defined, essentially, as a grid of [Vector2i] cells. Anything may be\n## placed on one of these cells, so the gameboard determines where each cell is located. In this\n## case, we are using a simple orthographic (square) projection.\n## [br][br]The grid is contained within the playable [member boundaries] and its constituent cells.\nextends Node\n\n## Emitted whenever [member properties] is set. This is used in case a [Gamepiece] is added to the\n## board before the board properties are ready.\nsignal properties_set\n\n## Emitted whenever the [member pathfinder] state changes.\n## This signal is emitted automatically in response to changed [GameboardLayer]s.\n##\n## Note: This signal is only emitted when the actual movement state of the Gameboard\n## changes. [GameboardLayer]s may change their cells without actually changing the pathfinder's\n## state (i.e. a visual update only), in which case this signal is not emitted.\nsignal pathfinder_changed(added_cells: Array[Vector2i], removed_cells: Array[Vector2i])\n\n## An invalid cell is not part of the gameboard. Note that this requires positive\n## [member boundaries].\nconst INVALID_CELL: = Vector2i(-1, -1)\n\nconst INVALID_INDEX: = -1\n\n## Determines the [member GameboardProperties.extents] of the Gameboard, among other details.\nvar properties: GameboardProperties = null:\n\tset(value):\n\t\tif value != properties:\n\t\t\tproperties = value\n\t\t\tproperties_set.emit()\n\n## A reference to the Pathfinder for the current playable area.\n@onready var pathfinder: Pathfinder = Pathfinder.new()\n\n\n## Convert cell coordinates to pixel coordinates.\nfunc cell_to_pixel(cell_coordinates: Vector2i) -> Vector2:\n\treturn Vector2(cell_coordinates * properties.cell_size) + properties.half_cell_size\n\n\n## Convert pixel coordinates to cell coordinates.\nfunc pixel_to_cell(pixel_coordinates: Vector2) -> Vector2i:\n\t@warning_ignore(\"integer_division\")\n\treturn Vector2i(\n\t\tfloori(pixel_coordinates.x / properties.cell_size.x),\n\t\tfloori(pixel_coordinates.y / properties.cell_size.y)\n\t)\n\n\nfunc get_cell_under_node(node: Node2D) -> Vector2i:\n\treturn pixel_to_cell(node.global_position/node.global_scale)\n\n\n## Convert cell coordinates to an index unique to those coordinates.\n## [br][br][b]Note:[/b] cell coordinates outside the [member extents] will return\n## [constant INVALID_INDEX].\nfunc cell_to_index(cell_coordinates: Vector2i) -> int:\n\tif properties.extents.has_point(cell_coordinates):\n\t\t# Negative coordinates can throw off index generation, so offset the boundary so that it's\n\t\t# top left corner is always considered Vector2i.ZERO and index 0.\n\t\treturn (cell_coordinates.x-properties.extents.position.x) \\\n\t\t\t+ (cell_coordinates.y-properties.extents.position.y)*properties.extents.size.x\n\treturn INVALID_INDEX", "output": "\n## Convert a unique index to cell coordinates.\n## [br][br][b]Note:[/b] indices outside the gameboard [member GameboardProperties.extents] will\n## return [constant INVALID_CELL].\nfunc index_to_cell(index: int) -> Vector2i:\n\t@warning_ignore(\"integer_division\")\n\tvar cell: = Vector2i(\n\t\tindex % properties.extents.size.x + properties.extents.position.x,\n\t\tindex / properties.extents.size.x + properties.extents.position.y\n\t)\n\n\tif properties.extents.has_point(cell):\n\t\treturn cell\n\treturn INVALID_CELL\n\n## Find a neighbouring cell, if it exists. Otherwise, returns [constant INVALID_CELL].\nfunc get_adjacent_cell(cell: Vector2i, direction: int) -> Vector2i:\n\tvar neighbour: Vector2i = cell + Directions.MAPPINGS.get(direction, Vector2i.ZERO)\n\tif properties.extents.has_point(neighbour):\n\t\treturn neighbour\n\treturn INVALID_CELL\n\n## Find all cells adjacent to a given cell. Only existing cells will be included.\nfunc get_adjacent_cells(cell: Vector2i) -> Array[Vector2i]:\n\tvar neighbours: Array[Vector2i] = []\n\tfor direction in Directions.Points.values():\n\t\tvar neighbour = get_adjacent_cell(cell, direction)\n\t\tif not neighbour == INVALID_CELL and not neighbour == cell:\n\t\t\tneighbours.append(neighbour)\n\n\treturn neighbours\n\n## The Gameboard's state (where [Gamepiece]'s may or may not move) is composed from a number of\n## [GameboardLayer]s. These layers determine which cells are blocked or clear.\n## The layers register themselves to the Gameboard in _ready.\nfunc register_gameboard_layer(board_map: GameboardLayer) -> void:\n\t# We want to know whenever the board_map changes the gameboard state. This occurs when the map\n\t# is added or removed from the scene tree, or when its list of moveable cells changes.\n\t# Compare the changed cells with those already in the pathfinder. Any changes will cause the\n\t# Pathfinder to be updated.\n\tboard_map.cells_changed.connect(\n\t\tfunc _on_gameboard_layer_cells_changed(cleared_cells: Array[Vector2i],\n\t\t\t\tblocked_cells: Array[Vector2i]):\n\t\tif board_map.name == \"DoorGameboardLayer\":\n\t\t\tprint(\"Door layer \", cleared_cells, \" \", blocked_cells)\n\t\tvar added_cells: = _add_cells_to_pathfinder(cleared_cells)"} {"instruction": "Vervollständige den GDScript-Code:", "input": "extends Node2D\n\nvar main_viewport: Viewport\nvar vr_render_size: Vector2 = Vector2()\nvar window_size: Vector2 = Vector2()\nvar hmd_view_material: ShaderMaterial\n\n@onready var hmd_view: ColorRect = $HMDView\n@onready var ui_spectator_view: OptionButton = $UI/SpectatorView\n@onready var ui_track_camera: CheckBox = $UI/TrackCamera\n@onready var ui_zoom_slider: HSlider = $UI/ZoomSlider\n@onready var spectator_camera: Camera3D = $SpectatorCamera\n@onready var stabilized_camera: Camera3D = $StabilizedCamera\n@onready var vr_viewport: SubViewport = $VRSubViewport\n@onready var main_scene: Node3D = $VRSubViewport/Main\n@onready var start_vr = $VRSubViewport/Main/StartVR\n\n\n# Update the size and position of our HMDView showing our HMD output.\nfunc _reposition_texture_rect():\n\tif window_size != Vector2() and vr_render_size != Vector2():\n\t\tvar size = vr_render_size * ui_zoom_slider.value\n\t\thmd_view.size = size\n\t\thmd_view.position = (window_size - size) * 0.5\n\n\n# Called when our window size changed.\nfunc _on_size_changed():\n\t# Get the new size of our window.\n\twindow_size = get_tree().get_root().size\n\t_reposition_texture_rect()\n\n\n# Called when the node enters the scene tree for the first time.\nfunc _ready():\n\t# Get our main viewport.\n\tmain_viewport = get_viewport()\n\n\t# Disable options not available outside of compatibility.\n\tif RenderingServer.get_current_rendering_method() != \"gl_compatibility\":", "output": "\t\tui_spectator_view.set(\"popup/item_2/disabled\", true)\n\t\tui_spectator_view.set(\"popup/item_3/disabled\", true)\n\n\t# Get our hmd view material.\n\thmd_view_material = hmd_view.material\n\n\t# Get a signal when our window size changes\n\tget_tree().get_root().size_changed.connect(_on_size_changed)\n\n\t# Call at least once to initialize.\n\t_on_size_changed()\n\n\t# Select our default view mode.\n\t_on_spectator_view_item_selected(ui_spectator_view.selected)\n\n\t# Set up our tracked camera.\n\t_on_track_camera_toggled(ui_track_camera.button_pressed)\n\n# Called when our OpenXR session has begun.\nfunc _on_main_session_begun():\n\tvr_render_size = start_vr.get_vr_render_size()\n\t_reposition_texture_rect()\n\n# User selected a new option from our view dropdown.\nfunc _on_spectator_view_item_selected(index):\n\tmatch index:\n\t\t0: # Spectator camera\n\t\t\tmain_viewport.disable_3d = false\n\t\t\tspectator_camera.visible = true\n\t\t\tspectator_camera.current = true\n\t\t\thmd_view.visible = false\n\t\t\tui_track_camera.visible = true\n\t\t\tui_zoom_slider.visible = false\n\t\t1: # Stabilized\n\t\t\tmain_viewport.disable_3d = false\n\t\t\tspectator_camera.visible = false\n\t\t\tstabilized_camera.current = true\n\t\t\thmd_view.visible = false\n\t\t\tui_track_camera.visible = false\n\t\t\tui_zoom_slider.visible = false\n\t\t2: # Left eye\n\t\t\tmain_viewport.disable_3d = true\n\t\t\tspectator_camera.visible = false\n\t\t\thmd_view.visible = true\n\t\t\tui_track_camera.visible = false\n\t\t\tui_zoom_slider.visible = true\n\t\t\tif hmd_view_material:\n\t\t\t\tvar vp_texture = vr_viewport.get_texture()"} {"instruction": "Vervollständige den GDScript-Code:", "input": "class_name XRPointer\nextends RayCast3D\n\n\nvar pointing_at: Node3D\nvar colliding_at: Vector3 = Vector3()\n\n\n# Called every frame. 'delta' is the elapsed time since the previous frame.\nfunc _process(_delta):\n\t$Laser.visible = enabled\n\n\tvar col_with: Node3D\n\tvar col_at: Vector3 = Vector3()", "output": "\n\tif enabled:\n\t\tif is_colliding():\n\t\t\tcol_with = get_collider()\n\t\t\tcol_at = get_collision_point()\n\t\t\t$Target.global_position = col_at\n\t\t\t$Target.visible = true\n\t\telse:\n\t\t\t$Target.visible = false\n\telse:\n\t\t$Target.visible = false\n\n\tif pointing_at and pointing_at != col_with:\n\t\tif pointing_at.has_method(&\"_exit_pointer\"):\n\t\t\tpointing_at._exit_pointer(self, colliding_at)\n\t\tpointing_at = null\n\n\tif col_with and not pointing_at:\n\t\tpointing_at = col_with\n\t\tcolliding_at = col_at\n\t\tif pointing_at.has_method(&\"_enter_pointer\"):\n\t\t\tpointing_at._enter_pointer(self, colliding_at)\n\n\tif pointing_at and colliding_at != col_at:\n\t\tif pointing_at.has_method(&\"_moved_pointer\"):\n\t\t\tpointing_at._moved_pointer(self, colliding_at, col_at)\n\t\tcolliding_at = col_at\n"} {"instruction": "Erstelle eine Godot-Klasse 'PickupAbleBody3D' die von RigidBody3D erbt mit folgenden Funktionen: add_is_closest, remove_is_closest, is_picked_up, pick_up, let_go", "input": "", "output": "class_name PickupAbleBody3D\nextends RigidBody3D\n\nvar highlight_material : Material = preload(\"res://shaders/highlight_material.tres\")\nvar picked_up_by : Area3D\nvar closest_areas : Array\n\nvar original_parent : Node3D\nvar tween : Tween\n\n# Called when this object becomes the closest body in an area\nfunc add_is_closest(area : Area3D) -> void:\n\tif not closest_areas.has(area):\n\t\tclosest_areas.push_back(area)\n\n\t_update_highlight()\n\n# Called when this object becomes the closest body in an area\nfunc remove_is_closest(area : Area3D) -> void:\n\tif closest_areas.has(area):\n\t\tclosest_areas.erase(area)\n\n\t_update_highlight()\n\n# Returns whether we have been picked up.\nfunc is_picked_up() -> bool:\n\t# If we have a valid picked up by object,\n\t# we've been picked up\n\tif picked_up_by:\n\t\treturn true\n\n\treturn false\n\n# Pick this object up.\nfunc pick_up(pick_up_by) -> void:\n\t# Already picked up? Can't pick up twice.\n\tif picked_up_by:\n\t\tif picked_up_by == pick_up_by:\n\t\t\treturn\n\n\t\tlet_go()\n\n\t# Remember some state we want to reapply on release.\n\toriginal_parent = get_parent()\n\tvar current_transform = global_transform\n\n\t# Remove us from our old parent.\n\toriginal_parent.remove_child(self)\n\n\t# Process our pickup.\n\tpicked_up_by = pick_up_by\n\tpicked_up_by.add_child(self)\n\tglobal_transform = current_transform\n\tfreeze = true\n\n\t# Kill any existing tween and create a new one.\n\tif tween:\n\t\ttween.kill()\n\ttween = create_tween()\n\n\t# Snap the object to this transform.\n\tvar snap_to : Transform3D\n\n\t# Add code here to determine snap position and orientation.\n\n\t# Now tween\n\ttween.tween_property(self, ^\"transform\", snap_to, 0.1)\n\n# Let this object go.\nfunc let_go() -> void:\n\t# Ignore if we haven't been picked up.\n\tif not picked_up_by:\n\t\treturn\n\n\t# Cancel any ongoing tween\n\tif tween:\n\t\ttween.kill()\n\t\ttween = null\n\n\t# Remember our current transform.\n\tvar current_transform = global_transform\n\n\t# Remove us from what picked us up.\n\tpicked_up_by.remove_child(self)\n\tpicked_up_by = null\n\n\t# Reset some state.\n\torigin"} {"instruction": "Erstelle eine Godot-Klasse 'GSAISeparation' die von GSAIGroupBehavior erbt mit folgenden Funktionen: _init, _calculate_steering, _report_neighbor", "input": "", "output": "# Calculates an acceleration that repels the agent from its neighbors in the\n# given `GSAIProximity`.\n#\n# The acceleration is an average based on all neighbors, multiplied by a\n# strength decreasing by the inverse square law in relation to distance, and it\n# accumulates.\n# @category - Group behaviors\nclass_name GSAISeparation\nextends GSAIGroupBehavior\n\n# The coefficient to calculate how fast the separation strength decays with distance.\nvar decay_coefficient := 1.0\n\nvar _acceleration: GSAITargetAcceleration\n\nfunc _init(agent: GSAISteeringAgent, proximity: GSAIProximity) -> void:\n\tsuper._init(agent, proximity)\n\tpass\n\nfunc _calculate_steering(acceleration: GSAITargetAcceleration) -> void:\n\tacceleration.set_zero()\n\tself._acceleration = acceleration\n\t# warning-ignore:return_value_discarded\n\tproximity._find_neighbors(_callback)\n\n# Callback for the proximity to call when finding neighbors. Determines the amount of\n# acceleration that `neighbor` imposes based on its distance from the owner agent.\n# @tags - virtual\nfunc _report_neighbor(neighbor: GSAISteeringAgent) -> bool:\n\tvar to_agent := agent.position - neighbor.position\n\n\tvar distance_squared := to_agent.length_squared()\n\tvar acceleration_max := agent.linear_acceleration_max\n\n\tvar strength := decay_coefficient / distance_squared\n\tif strength > acceleration_max:\n\t\tstrength = acceleration_max\n\n\t_acceleration.linear += to_agent * (strength / sqrt(distance_squared))\n\n\treturn true\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "## The GamepieceRegistry keeps track of each [Gamepiece] that is currently placed on the board.\n##\n## Since player movement is locked to gameboard cells (rather than physics-based movement), this\n## allows UI elements, cutscenes, and other systems to quickly lookup gamepieces by name or\n## location. Additionally, it allows pathfinders to see which cells are occupied or unoccupied.\n##\n## Note that only ONE gamepiece may occupy a cell and will block the movement of other\n## gamepieces.\nextends Node\n\nsignal gamepiece_moved(gp: Gamepiece, new_cell: Vector2i, old_cell: Vector2i)\nsignal gamepiece_freed(gp: Gamepiece, cell: Vector2i)\n\n# Store all registered gamepeices by the cell they occupy.\nvar _gamepieces: Dictionary[Vector2i, Gamepiece] = {}\n\n\nfunc register(gamepiece: Gamepiece, cell: Vector2i) -> bool:\n\t# Don't register a gamepiece if it's cell is already occupied...\n\tif _gamepieces.has(cell):\n\t\tprinterr(\"Failed to register Gamepiece '%s' at cell '%s'. \" % [gamepiece.name, str(cell)],\n\t\t\t\"A gamepiece already exists at that cell!\")\n\t\treturn false\n\n\t#...or if it has already been registered, for some reason.\n\tif gamepiece in _gamepieces.values():\n\t\tprinterr(\"Refused to register Gamepiece '%s' at cell '%s'. \" % [gamepiece.name, str(cell)],\n\t\t\t\"The gamepiece has already been registered!\")\n\t\treturn true\n\n\t# We want to know when the gamepiece leaves the scene tree, as it is no longer on the gameboard.\n\t# This probably means that the gamepiece has been freed.\n\tgamepiece.tree_exiting.connect(_on_gamepiece_tree_exiting.bind(gamepiece))\n\n\t_gamepieces[cell] = gamepiece\n\tgamepiece_moved.emit(gamepiece, cell, Gameboard.INVALID_CELL)", "output": "\n\treturn true\n\n## Update a gamepiece's position within the registry.\n## Note that animation/position will need to be updated in response to the\n## [signal Events.gamepiece_moved] signal.\nfunc move_gamepiece(gp: Gamepiece, new_cell: Vector2i) -> bool:\n\t# Don't move a gamepiece to an occupied cell.\n\tif _gamepieces.has(new_cell):\n\t\tprint(\"Cell %s is already occupied, cannot move gamepiece '%s'!\" % [str(new_cell), gp.name])\n\t\treturn false\n\n\tvar old_cell: = get_cell(gp)\n\tif old_cell == new_cell:\n\t\treturn false\n\n\t_gamepieces.erase(old_cell)\n\t_gamepieces[new_cell] = gp\n\n\tgamepiece_moved.emit(gp, new_cell, old_cell)\n\treturn true\n\n## Return the gamepiece, if any,that is found at a given cell.\nfunc get_gamepiece(cell: Vector2i) -> Gamepiece:\n\treturn _gamepieces.get(cell) as Gamepiece\n\n## Return the gamepiece, if any, that has a given name.\nfunc get_gamepiece_by_name(gp_name: String) -> Gamepiece:\n\tfor gp: Gamepiece in _gamepieces.values():\n\t\tif gp.name == gp_name:\n\t\t\treturn gp\n\treturn null\n\n## Return the cell occupied by a given gamepiece.\nfunc get_cell(gp: Gamepiece) -> Vector2i:\n\t# Don't look up null gamepieces (i.e. blocked cells).\n\tif gp:\n\t\tvar cell: = _gamepieces.find_key(gp) as Vector2i\n\t\tif _gamepieces.has(cell):\n\t\t\treturn cell\n\treturn Gameboard.INVALID_CELL\n\nfunc get_occupied_cells() -> Array[Vector2i]:\n\treturn _gamepieces.keys()\n"} {"instruction": "Erstelle eine GDScript-Funktion namens '_init':", "input": "", "output": "func _init() -> void:\n\t# Disable/re-enable occupied cells whenever a gamepiece moves.\n\tGamepieceRegistry.gamepiece_moved.connect(\n\t\tfunc _on_gamepiece_moved(_gp: Gamepiece, new_cell: Vector2i, old_cell: Vector2i) -> void:\n\t\t\tvar new_cell_id: = Gameboard.cell_to_index(new_cell)\n\t\t\tif has_point(new_cell_id):\n\t\t\t\tset_point_disabled(new_cell_id, true)\n\n\t\t\tvar old_cell_id: = Gameboard.cell_to_index(old_cell)\n\t\t\tif has_point(old_cell_id):\n\t\t\t\tset_point_disabled(old_cell_id, false)\n\t)\n\n\tGamepieceRegistry.gamepiece_freed.connect(\n\t\tfunc _on_gamepiece_free(_gp: Gamepiece, coord: Vector2i) -> void:\n\t\t\tvar cell_id: = Gameboard.cell_to_index(coord)\n\t\t\tif has_point(cell_id):\n\t\t\t\tset_point_disabled(cell_id, false)\n\t)\n\n## Returns true if the coordinate is found in the Pathfinder.\nfunc has_cell(coord: Vector2i) -> bool:\n\treturn has_point(Gameboard.cell_to_index(coord))\n\n## Returns true if the coordinate is found in the Pathfinder and the cell is unoccupied.\nfunc can_move_to(coord: Vector2i) -> bool:\n\tvar uid: = Gameboard.cell_to_index(coord)\n\treturn has_point(uid) and not is_point_disabled(uid)\n\n## Find a path between two cells. Returns an empty array if no path is available.\n## If allow_blocked_source or allow_blocked_target are false, the pathinder wlil fail if a gamepiece\n## occupies the source or target cells, respectively.\nfunc get_path_to_cell(source_coord: Vector2i, target_coord: Vector2i,\n\t\toccupancy_flags: int = 1) -> Array[Vector2i]:\n\t# Store the return value in a variable.\n\tvar move_path: Array[Vector2i] = []\n\n\t# Find the source/target IDs and keep track of whether or not the cells are occupied.\n\tvar source_id: = Gameboard.cell_to_index(source_coord)\n\tvar target_id: = Gameboard.cell_to_index(target_coord)\n\n\t# The pathfinder has several flags to ignore cell occupancy. We'll need to track which occupants\n\t# are temporarily ignored and then re-disable their pathfinder points once a path is found.\n\t# Key is point id, value is whether or not the point is disabled.\n\tvar ignored_points: Dictionary[int, bool] = {}"} {"instruction": "Vervollständige den GDScript-Code:", "input": "extends ColorRect\n\n@onready var parent: PianoKey = get_parent()", "output": "\n# Yes, this script exists just for this one method.\nfunc _gui_input(input_event: InputEvent) -> void:\n\tif input_event is InputEventMouseButton and input_event.pressed:\n\t\tparent.activate()\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "class_name CollisionHands3D\nextends AnimatableBody3D\n\nfunc _ready():\n\t# Make sure these are set correctly.\n\ttop_level = true", "output": "\tsync_to_physics = false\n\tprocess_physics_priority = -90\n\nfunc _physics_process(_delta):\n\t# Follow our parent node around.\n\tvar dest_transform = get_parent().global_transform\n\n\t# We just apply rotation for this example.\n\tglobal_basis = dest_transform.basis\n\n\t# Attempt to move to where our tracked hand is.\n\tmove_and_collide(dest_transform.origin - global_position)\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "extends Node3D\n\nsignal session_started\nsignal focus_lost\nsignal focus_gained\nsignal pose_recentered\n\n## Set the highest refresh rate we wish to enable.\n## We'll find the closest matching one.\n@export var maximum_refresh_rate: int = 90\n\nvar xr_interface: OpenXRInterface\nvar xr_is_focused: bool = false\n\n\n## Get our OpenXR Interface.\nfunc get_xr_interface() -> OpenXRInterface:\n\treturn xr_interface\n\n\n# Called when the node enters the scene tree for the first time.\nfunc _ready() -> void:\n\txr_interface = XRServer.find_interface(\"OpenXR\")\n\tif xr_interface and xr_interface.is_initialized():\n\t\tprint(\"OpenXR instantiated successfully.\")\n\t\tvar vp: Viewport = get_viewport()\n\n\t\t# Enable XR on our viewport.\n\t\tvp.use_xr = true\n\n\t\t# Make sure V-Sync is off, as V-Sync is handled by OpenXR.\n\t\tDisplayServer.window_set_vsync_mode(DisplayServer.VSYNC_DISABLED)\n\n\t\t# Enable variable rate shading.\n\t\tif RenderingServer.get_rendering_device():\n\t\t\tvp.vrs_mode = Viewport.VRS_XR\n\t\telif int(ProjectSettings.get_setting(\"xr/openxr/foveation_level\")) == 0:\n\t\t\tpush_warning(\"OpenXR: Recommend setting Foveation level to High in Project Settings\")\n\n\t\t# Connect the OpenXR events.\n\t\txr_interface.session_begun.connect(_on_openxr_session_begun)", "output": "\t\txr_interface.session_visible.connect(_on_openxr_visible_state)\n\t\txr_interface.session_focussed.connect(_on_openxr_focused_state)\n\t\txr_interface.session_stopping.connect(_on_openxr_stopping)\n\t\txr_interface.pose_recentered.connect(_on_openxr_pose_recentered)\n\telse:\n\t\t# We couldn't start OpenXR.\n\t\tprint(\"OpenXR not instantiated!\")\n\t\tget_tree().quit()\n\n# Handle OpenXR session ready.\nfunc _on_openxr_session_begun() -> void:\n\t# Get the reported refresh rate.\n\tvar current_refresh_rate := xr_interface.get_display_refresh_rate()\n\tif current_refresh_rate > 0:\n\t\tprint(\"OpenXR: Refresh rate reported as \", str(current_refresh_rate))\n\telse:\n\t\tprint(\"OpenXR: No refresh rate given by XR runtime\")\n\n\t# See if we have a better refresh rate available.\n\tvar new_rate := current_refresh_rate\n\tvar available_rates: Array = xr_interface.get_available_display_refresh_rates()\n\tif available_rates.is_empty():\n\t\tprint(\"OpenXR: Target does not support refresh rate extension\")\n\telif available_rates.size() == 1:\n\t\t# Only one available, so use it.\n\t\tnew_rate = available_rates[0]\n\telse:\n\t\tfor rate in available_rates:\n\t\t\tif rate > new_rate and rate <= maximum_refresh_rate:\n\t\t\t\tnew_rate = rate\n\n\t# Did we find a better rate?\n\tif current_refresh_rate != new_rate:\n\t\tprint(\"OpenXR: Setting refresh rate to \", str(new_rate))\n\t\txr_interface.set_display_refresh_rate(new_rate)\n\t\tcurrent_refresh_rate = new_rate\n\n\t# Now match our physics rate. This is currently needed to avoid jittering,\n\t# due to physics interpolation not being used.\n\tEngine.physics_ticks_per_second = roundi(current_refresh_rate)\n\n\tsession_started.emit()\n\n# Handle OpenXR visible state.\nfunc _on_openxr_visible_state() -> void:\n\t# We always pass this state at startup,\n\t# but the second time we get this, it means our player took off their headset.\n\tif xr_is_focused:"} {"instruction": "Erstelle eine GDScript-Funktion namens 'unhandled_input':", "input": "", "output": "func unhandled_input(_event: InputEvent) -> void:\n\tpass\n\nfunc physics_process(_delta: float) -> void:\n\tpass\n\nfunc enter(_msg: Dictionary = {}"} {"instruction": "Vervollständige den GDScript-Code:", "input": "extends Node3D\n\nsignal session_started\nsignal focus_lost\nsignal focus_gained\nsignal pose_recentered\n\n## Set the highest refresh rate we wish to enable.\n## We'll find the closest matching one.\n@export var maximum_refresh_rate: int = 90\n\nvar xr_interface: OpenXRInterface\nvar xr_is_focused: bool = false\n\n\n## Get our OpenXR Interface.\nfunc get_xr_interface() -> OpenXRInterface:\n\treturn xr_interface\n\n\n# Called when the node enters the scene tree for the first time.\nfunc _ready() -> void:\n\txr_interface = XRServer.find_interface(\"OpenXR\")\n\tif xr_interface and xr_interface.is_initialized():\n\t\tprint(\"OpenXR instantiated successfully.\")\n\t\tvar vp: Viewport = get_viewport()\n\n\t\t# Enable XR on our viewport.\n\t\tvp.use_xr = true\n\n\t\t# Make sure V-Sync is off, as V-Sync is handled by OpenXR.\n\t\tDisplayServer.window_set_vsync_mode(DisplayServer.VSYNC_DISABLED)\n\n\t\t# Enable variable rate shading.\n\t\tif RenderingServer.get_rendering_device():\n\t\t\tvp.vrs_mode = Viewport.VRS_XR\n\t\telif int(ProjectSettings.get_setting(\"xr/openxr/foveation_level\")) == 0:\n\t\t\tpush_warning(\"OpenXR: Recommend setting Foveation level to High in Project Settings\")\n\n\t\t# Connect the OpenXR events.\n\t\txr_interface.session_begun.connect(_on_openxr_session_begun)", "output": "\t\txr_interface.session_visible.connect(_on_openxr_visible_state)\n\t\txr_interface.session_focussed.connect(_on_openxr_focused_state)\n\t\txr_interface.session_stopping.connect(_on_openxr_stopping)\n\t\txr_interface.pose_recentered.connect(_on_openxr_pose_recentered)\n\telse:\n\t\t# We couldn't start OpenXR.\n\t\tprint(\"OpenXR not instantiated!\")\n\t\tget_tree().quit()\n\n# Handle OpenXR session ready.\nfunc _on_openxr_session_begun() -> void:\n\t# Get the reported refresh rate.\n\tvar current_refresh_rate := xr_interface.get_display_refresh_rate()\n\tif current_refresh_rate > 0:\n\t\tprint(\"OpenXR: Refresh rate reported as \", str(current_refresh_rate))\n\telse:\n\t\tprint(\"OpenXR: No refresh rate given by XR runtime\")\n\n\t# See if we have a better refresh rate available.\n\tvar new_rate := current_refresh_rate\n\tvar available_rates: Array = xr_interface.get_available_display_refresh_rates()\n\tif available_rates.is_empty():\n\t\tprint(\"OpenXR: Target does not support refresh rate extension\")\n\telif available_rates.size() == 1:\n\t\t# Only one available, so use it.\n\t\tnew_rate = available_rates[0]\n\telse:\n\t\tfor rate in available_rates:\n\t\t\tif rate > new_rate and rate <= maximum_refresh_rate:\n\t\t\t\tnew_rate = rate\n\n\t# Did we find a better rate?\n\tif current_refresh_rate != new_rate:\n\t\tprint(\"OpenXR: Setting refresh rate to \", str(new_rate))\n\t\txr_interface.set_display_refresh_rate(new_rate)\n\t\tcurrent_refresh_rate = new_rate\n\n\t# Now match our physics rate. This is currently needed to avoid jittering,\n\t# due to physics interpolation not being used.\n\tEngine.physics_ticks_per_second = roundi(current_refresh_rate)\n\n\tsession_started.emit()\n\n# Handle OpenXR visible state.\nfunc _on_openxr_visible_state() -> void:\n\t# We always pass this state at startup,\n\t# but the second time we get this, it means our player took off their headset.\n\tif xr_is_focused:"} {"instruction": "Vervollständige den GDScript-Code:", "input": "extends Node\n\n# Keep the number of samples per second to mix low, as GDScript is not super fast.\nvar sample_hz := 22050.0\nvar pulse_hz := 440.0\nvar phase := 0.0\n\n# Actual playback stream, assigned in _ready().\nvar playback: AudioStreamPlayback\n\nfunc _fill_buffer() -> void:\n\tvar increment := pulse_hz / sample_hz\n\n\tvar to_fill: int = playback.get_frames_available()", "output": "\twhile to_fill > 0:\n\t\tplayback.push_frame(Vector2.ONE * sin(phase * TAU)) # Audio frames are stereo.\n\t\tphase = fmod(phase + increment, 1.0)\n\t\tto_fill -= 1\n\nfunc _process(_delta: float) -> void:\n\t_fill_buffer()\n\nfunc _ready() -> void:\n\t# Setting mix rate is only possible before play().\n\t$Player.stream.mix_rate = sample_hz\n\t$Player.play()\n\tplayback = $Player.get_stream_playback()\n\t# `_fill_buffer` must be called *after* setting `playback`,\n\t# as `fill_buffer` uses the `playback` member variable.\n\t_fill_buffer()\n\nfunc _on_frequency_h_slider_value_changed(value: float) -> void:\n\t%FrequencyLabel.text = \"%d Hz\" % value\n\tpulse_hz = value\n\nfunc _on_volume_h_slider_value_changed(value: float) -> void:\n\t# Use `linear_to_db()` to get a volume slider that matches perceptual human hearing.\n\t%VolumeLabel.text = \"%.2f dB\" % linear_to_db(value)\n\t$Player.volume_db = linear_to_db(value)\n"} {"instruction": "Erstelle eine Godot-Klasse 'FadeMessage3D' die von Node3D erbt mit folgenden Funktionen: _update_text, _update_color, _ready, _process", "input": "", "output": "@tool\nclass_name FadeMessage3D\nextends Node3D\n\n## Text to show, after assigning text it will disappear after a time.\n@export var text : String = \"\":\n\tset(value):\n\t\t# Note, even if we don't change the value, we re-initiate our fade\n\t\ttext = value\n\t\tif is_inside_tree():\n\t\t\t_update_text()\n\n## Text color.\n@export var text_color : Color = Color(1.0, 1.0, 1.0):\n\tset(value):\n\t\ttext_color = value\n\t\tif is_inside_tree():\n\t\t\t_update_color()\n\n## Duration the text stays on screen before it fades out.\n@export_range(0.1, 10.0, 0.1, \"suffix:s\") var fade_duration : float = 0.5\n\n## Duration of our fade out.\n@export_range(0.1, 10.0, 0.1, \"suffix:s\") var fade_delay : float = 1.0\n\nvar _label : Label3D\nvar _delay : float = 1.0\nvar _modulate : float = 1.0\n\n# Update our label text\nfunc _update_text():\n\tif Engine.is_editor_hint():\n\t\t# In editor we don't apply the fade\n\t\tif text.is_empty():\n\t\t\t# and show a placeholder text\n\t\t\t_label.text = \"FadeMessage3D\"\n\t\t\t_update_color()\n\t\telse:\n\t\t\t_label.text = text\n\t\t\t_update_color()\n\telif text.is_empty():\n\t\t_modulate = 0.0\n\t\t_label.visible = false\n\t\tset_process(false)\n\telse:\n\t\t_delay = fade_delay\n\t\t_modulate = 1.0\n\t\t_label.text = text\n\t\t_label.visible = true\n\t\t_update_color()\n\t\tset_process(true)\n\n# Update our text color and modulation\nfunc _update_color():\n\t_label.modulate = Color(text_color.r, text_color.g, text_color.b, _modulate)\n\t_label.outline_modulate = Color(0.0, 0.0, 0.0, _modulate)\n\n# Called when the node enters the scene tree for the first time.\nfunc _ready():\n\t_label = Label3D.new()\n\t_label.pixel_size = 0.002\n\tadd_child(_label, false, Node.INTERNAL_MODE_BACK)\n\n\t_update_text()\n\t_update_color()\n\n# Called every frame. 'delta' is the elapsed time since the previous frame.\nfunc _process(delta):\n\t# Don't run this in editor.\n\tif Engine.is_editor_hint():\n\t\tset_process(false)\n\t\treturn\n\n\t# Once modulate reaches zero, hide and cleanup\n\tif _modulate == 0.00:\n\t\t_label.visible = false\n\t\tset_process(false)\n\t\treturn\n\n\t# Apply our delay.\n\tif _delay > 0.0"} {"instruction": "Vervollständige den GDScript-Code:", "input": "#*\n#* in_range.gd\n#* =============================================================================\n#* Copyright (c) 2023-present Serhii Snitsaruk and the LimboAI contributors.\n#*\n#* Use of this source code is governed by an MIT-style\n#* license that can be found in the LICENSE file or at\n#* https://opensource.org/licenses/MIT.\n#* =============================================================================\n#*\n@tool\nextends BTCondition\n## InRange condition checks if the agent is within a range of target,\n## defined by [member distance_min] and [member distance_max]. [br]\n## Returns [code]SUCCESS[/code] if the agent is within the given range;\n## otherwise, returns [code]FAILURE[/code].\n\n## Minimum distance to target.", "output": "@export var distance_min: float\n\n## Maximum distance to target.\n@export var distance_max: float\n\n## Blackboard variable that holds the target (expecting Node2D).\n@export var target_var: StringName = &\"target\"\n\nvar _min_distance_squared: float\nvar _max_distance_squared: float\n\n# Called to generate a display name for the task.\nfunc _generate_name() -> String:\n\treturn \"InRange (%d, %d) of %s\" % [distance_min, distance_max,\n\t\tLimboUtility.decorate_var(target_var)]\n\n# Called to initialize the task.\nfunc _setup() -> void:\n\t## Small performance optimization\n\t_min_distance_squared = distance_min * distance_min\n\t_max_distance_squared = distance_max * distance_max\n\n# Called when the task is executed.\nfunc _tick(_delta: float) -> Status:\n\tvar target: Node2D = blackboard.get_var(target_var, null)\n\tif not is_instance_valid(target):\n\t\treturn FAILURE\n\n\tvar dist_sq: float = agent.global_position.distance_squared_to(target.global_position)\n\tif dist_sq >= _min_distance_squared and dist_sq <= _max_distance_squared:\n\t\treturn SUCCESS\n\telse:\n\t\treturn FAILURE\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "#*\n#* dodge_state.gd\n#* =============================================================================\n#* Copyright (c) 2023-present Serhii Snitsaruk and the LimboAI contributors.\n#*\n#* Use of this source code is governed by an MIT-style\n#* license that can be found in the LICENSE file or at\n#* https://opensource.org/licenses/MIT.\n#* =============================================================================\n#*\nextends LimboState\n## Dodge state.\n\n\n@export var animation_player: AnimationPlayer\n@export var animation: StringName", "output": "@export var duration: float = 0.4\n@export var dodge_speed: float = 1000.0\n@export var hurtbox_collision: CollisionShape2D\n\nvar move_dir: Vector2\nvar elapsed_time: float\n\nfunc _enter() -> void:\n\telapsed_time = 0.0\n\thurtbox_collision.disabled = true\n\n\tvar horizontal_move: float = Input.get_axis(&\"move_left\", &\"move_right\")\n\tif is_zero_approx(horizontal_move):\n\t\tmove_dir = Vector2.RIGHT * agent.get_facing()\n\telse:\n\t\tmove_dir = Vector2.RIGHT * signf(horizontal_move)\n\tagent.face_dir(move_dir.x)\n\n\tanimation_player.play(animation, 0.1)\n\nfunc _exit() -> void:\n\thurtbox_collision.set_deferred(&\"disabled\", false)\n\nfunc _update(p_delta: float) -> void:\n\telapsed_time += p_delta\n\tvar desired_velocity: Vector2 = move_dir * dodge_speed\n\tagent.move(desired_velocity)\n\tif elapsed_time > duration:\n\t\tget_root().dispatch(EVENT_FINISHED)\n"} {"instruction": "Erstelle eine Godot-Klasse 'HasPositivePosition' die von ConditionLeaf erbt mit folgenden Funktionen: tick", "input": "", "output": "@tool\nclass_name HasPositivePosition extends ConditionLeaf\n\nfunc tick(actor: Node, _blackboard: Blackboard) -> int:\n\tif actor.position.x > 0.0 and actor.position.y > 0.0:\n\t\treturn SUCCESS\n\telse:\n\t\treturn FAILURE\n"} {"instruction": "Erstelle eine Godot-Klasse 'PlayStats' die von Resource erbt mit folgenden Funktionen:", "input": "", "output": "class_name PlayStats\nextends Resource\n\n@export var mean_hit_error: float = 0.0:\n\tset(value):\n\t\tif mean_hit_error != value:\n\t\t\tmean_hit_error = value\n\t\t\temit_changed()\n\n@export var perfect_count: int = 0:\n\tset(value):\n\t\tif perfect_count != value:\n\t\t\tperfect_count = value\n\t\t\temit_changed()\n\n@export var good_count: int = 0:\n\tset(value):\n\t\tif good_count != value:\n\t\t\tgood_count = value\n\t\t\temit_changed()\n\n@export var miss_count: int = 0:\n\tset(value):\n\t\tif miss_count != value:\n\t\t\tmiss_count = value\n\t\t\temit_changed()\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "## The Scene Runner is a tool used for simulating interactions on a scene.\n## With this tool, you can simulate input events such as keyboard or mouse input and/or simulate scene processing over a certain number of frames.\n## This tool is typically used for integration testing a scene.\n@abstract class_name GdUnitSceneRunner\nextends RefCounted\n\n\n## Simulates that an action has been pressed.[br]\n## [member action] : the action e.g. [code]\"ui_up\"[/code][br]\n## [member event_index] : [url=https://docs.godotengine.org/en/4.4/classes/class_inputeventaction.html#class-inputeventaction-property-event-index]default=-1[/url][br]\n@abstract func simulate_action_pressed(action: String, event_index := -1) -> GdUnitSceneRunner\n\n\n## Simulates that an action is pressed.[br]\n## [member action] : the action e.g. [code]\"ui_up\"[/code][br]\n## [member event_index] : [url=https://docs.godotengine.org/en/4.4/classes/class_inputeventaction.html#class-inputeventaction-property-event-index]default=-1[/url][br]\n@abstract func simulate_action_press(action: String, event_index := -1) -> GdUnitSceneRunner\n\n\n## Simulates that an action has been released.[br]\n## [member action] : the action e.g. [code]\"ui_up\"[/code][br]\n## [member event_index] : [url=https://docs.godotengine.org/en/4.4/classes/class_inputeventaction.html#class-inputeventaction-property-event-index]default=-1[/url][br]\n@abstract func simulate_action_release(action: String, event_index := -1) -> GdUnitSceneRunner\n\n\n## Simulates that a key has been pressed.[br]\n## @deprecated: the modifier [b]shift_pressed[/b] and [b]ctrl_pressed[/b] will be removed in v7.0\n## [member key_code] : the key code e.g. [constant KEY_ENTER][br]\n## [codeblock]\n## func test_key_presssed():\n## var runner = scene_runner(\"res://scenes/simple_scene.tscn\")\n## await runner.simulate_key_pressed(KEY_SPACE)\n## [/codeblock]\n@abstract func simulate_key_pressed(key_code: int, shift_pressed := false, ctrl_pressed := false) -> GdUnitSceneRunner\n\n\n## Simulates that a key is pressing.[br]\n## @deprecated: the modifier [b]shift_pressed[/b] and [b]ctrl_pressed[/b] will be removed in v7.0[br]See `test_key_shift_and_A_presssing` for example using key combinations\n## [member key_code] : the key code e.g. [constant KEY_ENTER][br]\n## [codeblock]\n## # Do simulate key pressing A\n## func test_key_A_presssing():\n## var runner = scene_runner(\"res://scenes/simple_scene.tscn\")\n## await runner.simulate_key_press(KEY_A)\n##\n##\n## # Do simulate keycombination pressing shift+A\n## func test_key_shift_and_A_presssing():\n## var runner = scene_runner(\"res://scenes/simple_scene.tscn\")\n## runner.simulate_key_press(KEY_SHIFT)\n## runner.simulate_key_press(KEY_A)\n## await _runner.await_input_processed()\n## [/codeblock]\n@abstract func simulate_key_press(key_code: int, shift_pressed := false, ctrl_pressed := false) -> GdUnitSceneRunner\n\n\n## Simulates that a key has been released.[br]\n## [member key_code] : the key code e.g. [constant KEY_ENTER][br]\n## [codeblock]\n## # Do simulate releasing key A\n## func test_key_A_releasing():\n## var runner = scene_runner(\"res://scenes/simple_scene.tscn\")\n## await runner.simulate_key_release(KEY_A)\n##\n##\n## # Do simulate keycombination pressing shift+A\n## func test_key_shift_and_A_releasing(():\n## var runner = scene_runner(\"res://scenes/simple_scene.tscn\")\n## runner.simulate_key_release(KEY_SHIFT)\n## runner.simulate_key_release(KEY_A)\n## await _runner.await_input_processed()\n## [/codeblock]\n## @deprecated: the modifier [b]shift_pressed[/b] and [b]ctrl_pressed[/b] will be removed in v7.0[br]See `test_key_shift_and_A_releasing` for example using key combinations\n@abstract func simulate_key_release(key_code: int, shift_pressed := false, ctrl_pressed := false) -> GdUnitSceneRunner\n\n\n## Sets the mouse position to the specified vector, provided in pixels and relative to an origin at the upper left corner of the currently focused Window Manager game window.[br]\n## [member position] : The absolute position in pixels as Vector2\n@abstract func set_mouse_position(position: Vector2) -> GdUnitSceneRunner\n\n\n## Returns the mouse's position in this Viewport using the coordinate system of this Viewport.\n@abstract func get_mouse_position() -> Vector2\n\n\n## Gets the current global mouse position of the current window\n@abstract func get_global_mouse_position() -> Vector2\n\n\n## Simulates a mouse moved to final position.[br]\n## [member position] : The final mouse position\n@abstract func simulate_mouse_move(position: Vector2) -> GdUnitSceneRunner\n\n\n## Simulates a mouse move to the relative coordinates (offset).[br]\n## [color=yellow]You must use [b]await[/b] to wait until the simulated mouse movement is complete.[/color][br]\n## [br]\n## [member relative] : The relative position, indicating the mouse position offset.[br]\n## [member time] : The time to move the mouse by the relative position in seconds (default is 1 second).[br]\n## [member trans_type] : Sets the type of transition used (default is TRANS_LINEAR).[br]\n## [codeblock]\n## func test_move_mouse():\n## var runner = scene_runner(\"res://scenes/simple_scene.tscn\")\n## await runner.simulate_mouse_move_relative(Vector2(100,100))\n## [/codeblock]\n@abstract func simulate_mouse_move_relative(relative: Vector2, time: float = 1.0, trans_type: Tween.TransitionType = Tween.TRANS_LINEAR) -> GdUnitSceneRunner\n\n\n## Simulates a mouse move to the absolute coordinates.[br]\n## [color=yellow]You must use [b]await[/b] to wait until the simulated mouse movement is complete.[/color][br]\n## [br]\n## [member position] : The final position of the mouse.[br]\n## [member time] : The time to move the mouse to the final position in seconds (default is 1 second).[br]\n## [member trans_type] : Sets the type of transition used (default is TRANS_LINEAR).[br]\n## [codeblock]\n## func test_move_mouse():\n## var runner = scene_runner(\"res://scenes/simple_scene.tscn\")", "output": "## await runner.simulate_mouse_move_absolute(Vector2(100,100))\n## [/codeblock]\n@abstract func simulate_mouse_move_absolute(position: Vector2, time: float = 1.0, trans_type: Tween.TransitionType = Tween.TRANS_LINEAR) -> GdUnitSceneRunner\n\n## Simulates a mouse button pressed.[br]\n## [member button_index] : The mouse button identifier, one of the [enum MouseButton] or button wheel constants.\n## [member double_click] : Set to true to simulate a double-click\n@abstract func simulate_mouse_button_pressed(button_index: MouseButton, double_click := false) -> GdUnitSceneRunner\n\n## Simulates a mouse button press (holding)[br]\n## [member button_index] : The mouse button identifier, one of the [enum MouseButton] or button wheel constants.\n## [member double_click] : Set to true to simulate a double-click\n@abstract func simulate_mouse_button_press(button_index: MouseButton, double_click := false) -> GdUnitSceneRunner\n\n## Simulates a mouse button released.[br]\n## [member button_index] : The mouse button identifier, one of the [enum MouseButton] or button wheel constants.\n@abstract func simulate_mouse_button_release(button_index: MouseButton) -> GdUnitSceneRunner\n\n## Simulates a screen touch is pressed.[br]\n## [member index] : The touch index in the case of a multi-touch event.[br]\n## [member position] : The position to touch the screen.[br]\n## [member double_tap] : If true, the touch's state is a double tab.\n@abstract func simulate_screen_touch_pressed(index: int, position: Vector2, double_tap := false) -> GdUnitSceneRunner\n\n## Simulates a screen touch press without releasing it immediately, effectively simulating a \"hold\" action.[br]\n## [member index] : The touch index in the case of a multi-touch event.[br]\n## [member position] : The position to touch the screen.[br]\n## [member double_tap] : If true, the touch's state is a double tab.\n@abstract func simulate_screen_touch_press(index: int, position: Vector2, double_tap := false) -> GdUnitSceneRunner\n\n## Simulates a screen touch is released.[br]\n## [member index] : The touch index in the case of a multi-touch event.[br]\n## [member double_tap] : If true, the touch's state is a double tab.\n@abstract func simulate_screen_touch_release(index: int, double_tap := false) -> GdUnitSceneRunner\n\n## Simulates a touch drag and drop event to a relative position.[br]\n## [color=yellow]You must use [b]await[/b] to wait until the simulated drag&drop is complete.[/color][br]\n## [br]\n## [member index] : The touch index in the case of a multi-touch event.[br]\n## [member relative] : The relative position, indicating the drag&drop position offset.[br]\n## [member time] : The time to move to the relative position in seconds (default is 1 second).[br]\n## [member trans_type] : Sets the type of transition used (default is TRANS_LINEAR).[br]\n## [codeblock]"} {"instruction": "Vervollständige den GDScript-Code:", "input": "## The Combat class manages combat logic from beginning to end.\n##\n## The battle is composed from several components which should all be wrapped up in a [CombatArena].\n## The Combat class instantiates the arena as a child before instantiating the player battlers and\n## assigning them as descendants of the arena's [BattlerRoster].[br][br]\n##\n## The combat logic follows the pattern set by early JRPGs, where each combat round includes two\n## phases:\n## [br]\t1) Action selection: each Battler selects an action, AI battlers followed by the player.\n## [br]\t2) Action execution: the Battlers carry out their selected actions.[br][br]\n## If the player and enemy sides are both still alive, combat procedes to the next round. Combat\n## logic may be illustrated as follows:[br][br]\n## [method setup] combat with a [CombatArena] (usually triggered by\n## [signal FieldEvents.combat_triggered]).\n## [br]\t- Begin new combat round\n## [br]\t\t- AI Battlers select their actions.\n## [br]\t\t- Until all player Battlers have a [member Battler.cached_action]:\n## [br]\t\t\t- The next player Battler selects their action via the [UICombat].\n## [br]\t\t\t- If all player Battlers have a [member Battler.cached_action], move to action\n## execution.\n## [br][br]\t\t- For each Battler with a cached action (sorted by speed):\n## [br]\t\t\t- [method Battler.act]\n## [br]\t\t- If player and enemy Battlers are still alive, go to the next round.[br]\n## [method shutdown] combat, cleaning up combat objects\n## [br]\t- Emit the [signal CombatEvents.combat_finished] signal.\nclass_name Combat extends CanvasLayer\n\n## Tracks which combat round is currently being played. Every round, all active [Battler]s will get\n## a turn to act.\nvar round_count: int = 0\n\n# Keep track of what music track was playing previously, and return to it once combat has finished.\nvar _previous_music_track: AudioStream = null\n\n# A reference to \n@onready var _battler_roster: BattlerRoster\n@onready var _combat_container: = $CenterContainer as CenterContainer\n@onready var _transition_delay_timer: = $UI/TransitionDelay as Timer\n@onready var _ui: = $UI as UICombat\n\n\nfunc _ready() -> void:\n\thide()\n\tFieldEvents.combat_triggered.connect(setup)\n\n\n## Begin a combat. Takes a PackedScene as its only parameter, expecting it to be a CombatState \n## object once instantiated.\n## This is normally a response to [signal FieldEvents.combat_triggered].\nfunc setup(arena: PackedScene) -> void:\n\tawait Transition.cover(0.2)\n\tshow()\n\n\tvar new_arena := arena.instantiate()\n\tassert(\n\t\tnew_arena != null,\n\t\t\"Failed to initiate combat. Provided 'arena' arugment is not a CombatArena.\"\n\t)\n\n\tvar combat_arena: CombatArena = new_arena\n\t_combat_container.add_child(combat_arena)\n\t_battler_roster = combat_arena.get_battler_roster()\n\t\n\t# Wait a frame for the arena and its children (VFX, Battlers, etc.) to be ready.\n\tawait get_tree().process_frame\n\t\n\t_ui.setup(_battler_roster)\n\n\t_previous_music_track = Music.get_playing_track()\n\tMusic.play(combat_arena.music)\n\n\tCombatEvents.combat_initiated.emit()\n\n\t# Before starting combat itself, reveal the screen again.\n\t# The Transition.clear() call is deferred since it follows on the heels of cover(), and needs a\n\t# frame to allow everything else to respond to Transition.finished.\n\tTransition.clear.call_deferred(0.2)\n\tawait Transition.finished\n\t\n\t# Fade in the combat UI elements.\n\t_ui.animation.play(\"fade_in\")\n\tawait _ui.animation.animation_finished", "output": "\n\t# Begin the combat logic. The turn queue takes over from here.\n\tround_count = 0\n\tnext_round.call_deferred()\n\n# Moves combat to the next round. At the beginning of the round, all Battlers will choose an action.\nfunc next_round() -> void:\n\tround_count += 1\n\n\t# First of all, let enemy (necessarily AI) battlers pick their actions.\n\tfor battler in _battler_roster.find_live_battlers(_battler_roster.get_enemy_battlers()):\n\t\tif battler.ai != null:\n\t\t\tbattler.ai.select_action(battler)\n\n\t# Secondly, allow player Battlers to pick their action.\n\t# This will be iterative as the player selects and cancels their choices. The turn queue will\n\t# move to the action phase once all player Battlers have an action selected.\n\t_select_next_player_action()\n\n# Player Battlers select their actions by repeatedly calling _select_next_player_action. The method\n# looks for player Battlers who have no cached action and prioritizes those further up in the scene\n# tree. This allows the player to go \"backwards\" and \"forwards\" between Battlers, choosing actions\n# and cancelling them as needed.\n# At this point, all AI Battlers should have a cached actoin.\n# Once all Battlers have an action cached (see Battler.cached_action), _select_next_player_action\n# calls _next_turn to move into the second phase.\nfunc _select_next_player_action() -> void:\n\t# Find any remaining player Battlers that need an action selected.\n\tvar player_battlers: = _battler_roster.get_player_battlers()\n\tvar remaining_battlers: = _battler_roster.find_battlers_needing_actions(player_battlers)\n\n\t# If there are no player Battlers needing actions, move on to the second phase of a round:\n\t# taking action!\n\tif remaining_battlers.is_empty():\n\t\t# De-select the last Battler that was receiving orders.\n\t\tCombatEvents.player_battler_selected.emit(null)\n\t\t_play_next_action.call_deferred()\n\t\treturn\n\n\t# If there are player Battlers needing cached actions, pick the first one and allow it to search\n\t# for an action using either its AI controller (if present) or player input.\n\tvar next_player_battler: Battler = remaining_battlers.front()\n\n\t# When the player selects an action (or presses 'back'), the current Battler needs to move back\n\t# to its rest position before moving on to the next battler, hence the await call below.\n\tnext_player_battler.action_cached.connect(\n\t\t(func _on_selected_battler_action_cached(battler: Battler) -> void:\n\t\t\t# Check to see if the player cancelled action selection (pressed \"back\" from the"} {"instruction": "Erstelle eine GDScript-Funktion namens '_on_gamepiece_moved':", "input": "", "output": "func _on_gamepiece_moved(_gp: Gamepiece, new_cell: Vector2i, old_cell: Vector2i) -> void:\n\t\t\tvar new_cell_id: = Gameboard.cell_to_index(new_cell)\n\t\t\tif has_point(new_cell_id):\n\t\t\t\tset_point_disabled(new_cell_id, true)\n\n\t\t\tvar old_cell_id: = Gameboard.cell_to_index(old_cell)\n\t\t\tif has_point(old_cell_id):\n\t\t\t\tset_point_disabled(old_cell_id, false)\n\t)\n\n\tGamepieceRegistry.gamepiece_freed.connect(\n\t\tfunc _on_gamepiece_free(_gp: Gamepiece, coord: Vector2i) -> void:\n\t\t\tvar cell_id: = Gameboard.cell_to_index(coord)\n\t\t\tif has_point(cell_id):\n\t\t\t\tset_point_disabled(cell_id, false)\n\t)\n\n## Returns true if the coordinate is found in the Pathfinder.\nfunc has_cell(coord: Vector2i) -> bool:\n\treturn has_point(Gameboard.cell_to_index(coord))\n\n## Returns true if the coordinate is found in the Pathfinder and the cell is unoccupied.\nfunc can_move_to(coord: Vector2i) -> bool:\n\tvar uid: = Gameboard.cell_to_index(coord)\n\treturn has_point(uid) and not is_point_disabled(uid)\n\n## Find a path between two cells. Returns an empty array if no path is available.\n## If allow_blocked_source or allow_blocked_target are false, the pathinder wlil fail if a gamepiece\n## occupies the source or target cells, respectively.\nfunc get_path_to_cell(source_coord: Vector2i, target_coord: Vector2i,\n\t\toccupancy_flags: int = 1) -> Array[Vector2i]:\n\t# Store the return value in a variable.\n\tvar move_path: Array[Vector2i] = []\n\n\t# Find the source/target IDs and keep track of whether or not the cells are occupied.\n\tvar source_id: = Gameboard.cell_to_index(source_coord)\n\tvar target_id: = Gameboard.cell_to_index(target_coord)\n\n\t# The pathfinder has several flags to ignore cell occupancy. We'll need to track which occupants\n\t# are temporarily ignored and then re-disable their pathfinder points once a path is found.\n\t# Key is point id, value is whether or not the point is disabled.\n\tvar ignored_points: Dictionary[int, bool] = {}", "source": "extracted_function"} {"instruction": "Vervollständige den GDScript-Code:", "input": "@tool\n## Applied to any gamepiece to allow player control.\n##\n## The controller responds to player input to handle movement and interaction.\nclass_name PlayerController extends GamepieceController\n\nconst GROUP: = \"_PLAYER_CONTROLLER_GROUP\"\n\n# Keep track of a targeted interaction. Used to face & interact with the object at a path's end.\n# It is reset on cancelling the move path or continuing movement via arrows/gamepad directions.\nvar _target_interaction: Interaction = null\n\n# Keep track of any Triggers that the player has stepped on.\nvar _active_trigger: Trigger = null\n\n# Also keep track of the most recently pressed move key (e.g. WASD keys). This makes keyboard input\n# feel more intuitive, since the gamepiece will move towards the most recently pressed key rather\n# than prefering an arbitrary axis.\nvar _last_input_direction: = Vector2.ZERO\n\n# The \"interaction searcher\" area basically activates any Interactions, which means that they'll\n# respond to key/button input.\n@onready var _interaction_searcher: = $InteractionSearcher as Area2D\n@onready var _interaction_shape: = $InteractionSearcher/CollisionShape2D as CollisionShape2D\n\n# The player collision area activates Triggers whenever the player moves onto their collision\n# shape.\n@onready var _player_collision: = $PlayerCollision as Area2D\n\n\nfunc _ready() -> void:\n\tsuper._ready()\n\t\n\tif not Engine.is_editor_hint():\n\t\tadd_to_group(GROUP)\n\t\t\n\t\t# Refer the various player collision shapes to their gamepiece (parent of the controller).\n\t\t# This will allow other objects/systems to quickly find which gamepiece they are working on\n\t\t# via the collision \"owners\".\n\t\t_interaction_searcher.owner = _gamepiece\n\t\t_player_collision.owner = _gamepiece\n\t\t\n\t\t# Update the position of the player's collision shape to match the cell that it is currently\n\t\t# moving towards.\n\t\twaypoint_changed.connect(\n\t\t\tfunc _on_waypoint_changed(new_waypoint: Vector2i):\n\t\t\t\tif new_waypoint == Gameboard.INVALID_CELL:\n\t\t\t\t\t_player_collision.position = Vector2.ZERO\n\t\t\t\telse:\n\t\t\t\t\t_player_collision.position = Gameboard.cell_to_pixel(new_waypoint) \\\n\t\t\t\t\t\t- _gamepiece.position\n\t\t)\n\t\t\n\t\t# The player collision picks up any triggers that it moves over. Keep track of them until\n\t\t# player movement to the current cells has completed.\n\t\t_player_collision.area_entered.connect(\n\t\t\tfunc _on_collision_triggered(area: Area2D):\n\t\t\t\tif area.owner is Trigger:\n\t\t\t\t\t_active_trigger = area.owner\n\t\t)\n\t\t\n\t\t_gamepiece.direction_changed.connect(\n\t\t\tfunc _on_gamepiece_direction_changed(new_direction: Directions.Points):\n\t\t\t\tvar offset: Vector2 = Directions.MAPPINGS[new_direction] * 16\n\t\t\t\t_interaction_searcher.position = offset\n\t\t)\n\t\t\n\t\tFieldEvents.cell_selected.connect(_on_cell_selected)\n\t\tFieldEvents.interaction_selected.connect(_on_interaction_selected)\n\n\nfunc _unhandled_input(event: InputEvent) -> void:\n\tif event is InputEventKey:\n\t\tif event.is_action_pressed(\"ui_up\"):", "output": "\t\t\t_last_input_direction = Vector2.UP\n\t\t\tif _gamepiece.is_moving():\tstop_moving()\n\t\t\telse:\tmove_to_pressed_key(Vector2.UP)\n\n\t\telif event.is_action_pressed(\"ui_down\"):\n\t\t\t_last_input_direction = Vector2.DOWN\n\t\t\tif _gamepiece.is_moving():\tstop_moving()\n\t\t\telse:\tmove_to_pressed_key(Vector2.DOWN)\n\n\t\telif event.is_action_pressed(\"ui_left\"):\n\t\t\t_last_input_direction = Vector2.LEFT\n\t\t\tif _gamepiece.is_moving():\tstop_moving()\n\t\t\telse:\tmove_to_pressed_key(Vector2.LEFT)\n\n\t\telif event.is_action_pressed(\"ui_right\"):\n\t\t\t_last_input_direction = Vector2.RIGHT\n\t\t\tif _gamepiece.is_moving():\tstop_moving()\n\t\t\telse:\tmove_to_pressed_key(Vector2.RIGHT)\n\nfunc move_along_path(value: Array[Vector2i]) -> void:\n\tsuper.move_along_path(value.duplicate())\n\n\t_interaction_shape.disabled = true\n\tPlayer.player_path_set.emit(_gamepiece, value.back())\n\nfunc move_to_pressed_key(input_direction: Vector2) -> void:\n\tif is_active:\n\t\tvar source_cell: = GamepieceRegistry.get_cell(_gamepiece)\n\t\tvar target_cell: = Vector2i.ZERO\n\n\t\t# Unless using 8-direction movement, one movement axis must be preferred.\n\t\t#\tDefault to the x-axis.\n\t\ttarget_cell = source_cell + Vector2i(input_direction)\n\n\t\t# Try to get a path to destination (will fail if cell is occupied)\n\t\tvar new_move_path: = Gameboard.pathfinder.get_path_to_cell(source_cell, target_cell)\n\n\t\t# Path is invalid. Bump animation?\n\t\tif new_move_path.size() < 1:\n\t\t\t_gamepiece.direction = Directions.angle_to_direction(input_direction.angle())\n\n\t\telse:\n\t\t\tmove_path = new_move_path.duplicate()\n\nfunc stop_moving() -> void:\n\tmove_path.clear()\n\t_target_interaction = null"} {"instruction": "Vervollständige den GDScript-Code:", "input": "@tool\n## Draws the boundaries set by a [Gameboard] object.\n##\n## Used within the editor to illustrate which cells will be included in the pathfinder calculations.\nclass_name DebugGameboardBoundaries extends Node2D\n\n@export var gameboard_properties: GameboardProperties:\n\tset(value):\n\t\tgameboard_properties = value\n\t\t_update_boundaries()\n\n@export var boundary_color: Color = Color.DARK_RED:\n\tset(value):\n\t\tboundary_color = value\n\t\tqueue_redraw()\n", "output": "@export_range(0.5, 5.0, 0.1, \"or_greater\") var line_width: = 2.0:\n\tset(value):\n\t\tline_width = value\n\t\tqueue_redraw()\n\nvar _boundaries: Rect2i\n\nfunc _ready() -> void:\n\tif gameboard_properties != null:\n\t\tgameboard_properties.extents_changed.connect(_update_boundaries)\n\t\tgameboard_properties.cell_size_changed.connect(_update_boundaries)\n\n\tif not Engine.is_editor_hint():\n\t\thide()\n\nfunc _draw() -> void:\n\tif not gameboard_properties:\n\t\treturn\n\n\tdraw_rect(_boundaries, boundary_color, false, line_width)\n\nfunc _update_boundaries() -> void:\n\tif gameboard_properties != null:\n\t\t_boundaries = Rect2i(\n\t\t\tgameboard_properties.extents.position * gameboard_properties.cell_size,\n\t\t\tgameboard_properties.extents.size * gameboard_properties.cell_size\n\t\t)\n\n\t\tqueue_redraw()\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "## An Assertion Tool to verify Results\n@abstract class_name GdUnitResultAssert\nextends GdUnitAssert\n\n\n## Verifies that the current value is null.\n@abstract func is_null() -> GdUnitResultAssert\n\n\n## Verifies that the current value is not null.\n@abstract func is_not_null() -> GdUnitResultAssert\n\n\n## Verifies that the current value is equal to the given one.\n@abstract func is_equal(expected: Variant) -> GdUnitResultAssert\n\n", "output": "## Verifies that the current value is not equal to expected one.\n@abstract func is_not_equal(expected: Variant) -> GdUnitResultAssert\n\n## Overrides the default failure message by given custom message.\n@abstract func override_failure_message(message: String) -> GdUnitResultAssert\n\n## Appends a custom message to the failure message.\n@abstract func append_failure_message(message: String) -> GdUnitResultAssert\n\n## Verifies that the result is ends up with empty\n@abstract func is_empty() -> GdUnitResultAssert\n\n## Verifies that the result is ends up with success\n@abstract func is_success() -> GdUnitResultAssert\n\n## Verifies that the result is ends up with warning\n@abstract func is_warning() -> GdUnitResultAssert\n\n## Verifies that the result is ends up with error\n@abstract func is_error() -> GdUnitResultAssert\n\n## Verifies that the result contains the given message\n@abstract func contains_message(expected: String) -> GdUnitResultAssert\n\n## Verifies that the result contains the given value\n@abstract func is_value(expected: Variant) -> GdUnitResultAssert\n"} {"instruction": "Erstelle eine Godot-Klasse 'XRPointer' die von RayCast3D erbt mit folgenden Funktionen: _process", "input": "", "output": "class_name XRPointer\nextends RayCast3D\n\nvar pointing_at: Node3D\nvar colliding_at: Vector3 = Vector3()\n\n# Called every frame. 'delta' is the elapsed time since the previous frame.\nfunc _process(_delta):\n\t$Laser.visible = enabled\n\n\tvar col_with: Node3D\n\tvar col_at: Vector3 = Vector3()\n\n\tif enabled:\n\t\tif is_colliding():\n\t\t\tcol_with = get_collider()\n\t\t\tcol_at = get_collision_point()\n\t\t\t$Target.global_position = col_at\n\t\t\t$Target.visible = true\n\t\telse:\n\t\t\t$Target.visible = false\n\telse:\n\t\t$Target.visible = false\n\n\tif pointing_at and pointing_at != col_with:\n\t\tif pointing_at.has_method(&\"_exit_pointer\"):\n\t\t\tpointing_at._exit_pointer(self, colliding_at)\n\t\tpointing_at = null\n\n\tif col_with and not pointing_at:\n\t\tpointing_at = col_with\n\t\tcolliding_at = col_at\n\t\tif pointing_at.has_method(&\"_enter_pointer\"):\n\t\t\tpointing_at._enter_pointer(self, colliding_at)\n\n\tif pointing_at and colliding_at != col_at:\n\t\tif pointing_at.has_method(&\"_moved_pointer\"):\n\t\t\tpointing_at._moved_pointer(self, colliding_at, col_at)\n\t\tcolliding_at = col_at\n"} {"instruction": "Erstelle eine GDScript-Funktion namens '_ready':", "input": "", "output": "func _ready() -> void:\n\t# Ensure that playback state is always updating, otherwise the smoothing\n\t# filter causes issues.\n\tprocess_mode = Node.PROCESS_MODE_ALWAYS\n\nfunc _process(_delta: float) -> void:\n\tif not _is_playing:\n\t\treturn\n\n\t# Handle a web bug where AudioServer.get_time_since_last_mix() occasionally\n\t# returns unsigned 64-bit integer max value. This is likely due to minor\n\t# timing issues between the main/audio threads, thus causing an underflow\n\t# in the engine code.\n\tvar last_mix := AudioServer.get_time_since_last_mix()\n\tif last_mix > 1000:\n\t\tlast_mix = 0\n\n\t# First, calculate the song time using data from the audio thread. This\n\t# value is very jittery, but will always match what the player is hearing.\n\t_song_time_audio = (\n\t\t\tplayer.get_playback_position()\n\t\t\t# The 1st beat may not start at second 0 of the audio track. Compensate\n\t\t\t# with an offset setting.\n\t\t\t- first_beat_offset_ms / 1000.0\n\t\t\t# For most platforms, the playback position value updates in chunks,\n\t\t\t# with each chunk being one \"mix\". Smooth this out by adding in the time\n\t\t\t# since the last chunk was processed.\n\t\t\t+ last_mix\n\t\t\t# Current processed audio is heard later.\n\t\t\t- _cached_output_latency\n\t\t)\n\n\t# Next, calculate the song time using the system clock at render rate. This\n\t# value is very stable, but can drift from the playing audio due to pausing,\n\t# stuttering, etc.\n\t_song_time_system = (Time.get_ticks_usec() / 1000000.0) - _song_time_begin\n\t_song_time_system *= player.pitch_scale\n\n\t# We don't do anything else here. Check _physics_process next.\n\nfunc _physics_process(delta: float) -> void:\n\tif not _is_playing:\n\t\treturn\n\n\t# To have the best of both the audio-based time and system-based time, we\n\t# apply a smoothing filter (1€ filter) on the delta between the two values,\n\t# then add it to the system-based time. This allows us to have a stable\n\t# value that is also always accurate to what the player hears.\n\t#\n\t# Notes:\n\t# - The 1€ filter jitter reduction is more effective on values that don't\n\t# change drastically between samples, so we filter on the delta (generally\n\t# less variable between frames) rather than the time itself.\n\t# - We run the filter step in _physics_process to reduce the variability of\n\t# different systems' update rates. The filter params are specifically\n\t# tuned for 60 UPS.\n\tvar audio_system_delta := _song_time_audio - _song_time_system\n\t_filtered_audio_system_delta = _filter.filter(audio_system_delta, delta)\n\n\t# Uncomment this to show the difference between raw and filtered time.\n\t#var song_time := _song_time_system + _filtered_audio_system_delta\n\t#print(\"Error: %+.1f ms\" % [abs(song_time - _song_time_audio) * 1000.0])\n\nfunc play() -> void:\n\tvar filter_args := {\n\t\t\"cutoff\": allowed_jitter,\n\t\t\"beta\": lag_reduction,\n\t}"} {"instruction": "Erstelle eine Godot-Klasse 'NoteManager' die von Node2D erbt mit folgenden Funktionen: _ready, _process, _miss_old_notes, _handle_keypress, _finish_song", "input": "", "output": "class_name NoteManager\nextends Node2D\n\nsignal play_stats_updated(play_stats: PlayStats)\nsignal note_hit(beat: float, hit_type: Enums.HitType, hit_error: float)\nsignal song_finished(play_stats: PlayStats)\n\nconst NOTE_SCENE = preload(\"res://objects/note/note.tscn\")\nconst HIT_MARGIN_PERFECT = 0.050\nconst HIT_MARGIN_GOOD = 0.150\nconst HIT_MARGIN_MISS = 0.300\n\n@export var conductor: Conductor\n@export var time_type: Enums.TimeType = Enums.TimeType.FILTERED\n@export var chart: ChartData.Chart = ChartData.Chart.THE_COMEBACK\n\nvar _notes: Array[Note] = []\n\nvar _play_stats: PlayStats\nvar _hit_error_acc: float = 0.0\nvar _hit_count: int = 0\n\nfunc _ready() -> void:\n\t_play_stats = PlayStats.new()\n\t_play_stats.changed.connect(\n\t\t\tfunc() -> void:\n\t\t\t\tplay_stats_updated.emit(_play_stats)\n\t\t\t\t)\n\n\tvar chart_data := ChartData.get_chart_data(chart)\n\n\tvar note_beats: Array[float] = []\n\tfor measure_i in range(chart_data.size()):\n\t\tvar measure: Array = chart_data[measure_i]\n\t\tvar subdivision := 1.0 / measure.size() * 4\n\t\tfor note_i: int in range(measure.size()):\n\t\t\tvar beat := measure_i * 4 + note_i * subdivision\n\t\t\tif measure[note_i] == 1:\n\t\t\t\tnote_beats.append(beat)\n\n\tfor beat in note_beats:\n\t\tvar note := NOTE_SCENE.instantiate() as Note\n\t\tnote.beat = beat\n\t\tnote.conductor = conductor\n\t\tnote.update_beat(-100)\n\t\tadd_child(note)\n\t\t_notes.append(note)\n\nfunc _process(_delta: float) -> void:\n\tif _notes.is_empty():\n\t\treturn\n\n\tvar curr_beat := _get_curr_beat()\n\tfor i in range(_notes.size()):\n\t\t_notes[i].update_beat(curr_beat)\n\n\t_miss_old_notes()\n\n\tif Input.is_action_just_pressed(&\"main_key\"):\n\t\t_handle_keypress()\n\n\tif _notes.is_empty():\n\t\t_finish_song()\n\nfunc _miss_old_notes() -> void:\n\twhile not _notes.is_empty():\n\t\tvar note := _notes[0] as Note\n\t\tvar note_delta := _get_note_delta(note)\n\n\t\tif note_delta > HIT_MARGIN_GOOD:\n\t\t\t# Time is past the note's hit window, miss.\n\t\t\tnote.miss(false)\n\t\t\t_notes.remove_at(0)\n\t\t\t_play_stats.miss_count += 1\n\t\t\tnote_hit.emit(note.beat, Enums.HitType.MISS_LATE,"}