{"instruction": "Erstelle eine Godot-Klasse 'GSAISteeringAgent' die von GSAIAgentLocation erbt mit folgenden Funktionen:", "input": "", "output": "# Adds velocity, speed, and size data to `GSAIAgentLocation`.\n#\n# It is the character's responsibility to keep this information up to date for\n# the steering toolkit to work correctly.\n# @category - Base types\nclass_name GSAISteeringAgent\nextends GSAIAgentLocation\n\n# The amount of velocity to be considered effectively not moving.\nvar zero_linear_speed_threshold := 0.01\n# The maximum speed at which the agent can move.\nvar linear_speed_max := 0.0\n# The maximum amount of acceleration that any behavior can apply to the agent.\nvar linear_acceleration_max := 0.0\n# The maximum amount of angular speed at which the agent can rotate.\nvar angular_speed_max := 0.0\n# The maximum amount of angular acceleration that any behavior can apply to an\n# agent.\nvar angular_acceleration_max := 0.0\n# Current velocity of the agent.\nvar linear_velocity := Vector3.ZERO\n# Current angular velocity of the agent.\nvar angular_velocity := 0.0\n# The radius of the sphere that approximates the agent's size in space.\nvar bounding_radius := 0.0\n# Used internally by group behaviors and proximities to mark the agent as already\n# considered.\nvar is_tagged := false\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "# Autoloaded singleton that holds signals that would be troublesome to wire in a\n# local parent or a scene owner.\n# \n# This keeps objects passed through setup functions or unsafe accessors at a\n# lower count, and can be replaced with simpler `Events.connect` calls.\nextends Node\n\nsignal player_died\nsignal quit_requested\n\nsignal node_spawned(node)\nsignal station_spawned(station, player)\nsignal pirate_spawned(pirate)", "output": "signal asteroid_spawned(object)\n\nsignal map_toggled(is_visible, animation_length)\n\nsignal upgrade_unlocked\nsignal upgrade_chosen(choice)\n\nsignal damaged(target, damage, shooter)\n\nsignal begin_patrol(squad_leader)\nsignal end_patrol(squad_leader)\nsignal reached_cluster(squad_leader)\nsignal squad_leader_changed(old_leader, new_leader, current_patrol_point)\nsignal target_aggroed(squad_leader, target)\nsignal call_off_pursuit(squad_leader)\n\nsignal force_undock\nsignal docked(docking_point)\nsignal undocked\nsignal mine_started(mine_position)\nsignal mine_finished\n\nsignal explosion_occurred\n\nenum UpgradeChoices { HEALTH, SPEED, CARGO, MINING, WEAPON }\n\nenum UITypes { UPGRADE, QUIT }\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "extends Control\n\n\nfunc _on_toggle_music_toggled(button_pressed: bool) -> void:\n\tif button_pressed:\n\t\t$SoundEffects/Music.play()\n\telse:\n\t\t$SoundEffects/Music.stop()\n\n\nfunc _on_ding_button_pressed() -> void:\n\t$SoundEffects/Ding.play()\n\n\nfunc _on_glass_button_pressed() -> void:\n\t$SoundEffects/Glass.play()\n\n\nfunc _on_meow_button_pressed() -> void:\n\t$SoundEffects/Meow.play()\n\n\nfunc _on_beeps_button_pressed() -> void:\n\t$SoundEffects/Beeps.play()\n\n\nfunc _on_trombone_button_pressed() -> void:\n\t$SoundEffects/Trombone.play()\n\n\nfunc _on_static_button_pressed() -> void:\n\t$SoundEffects/Static.play()\n\n\nfunc _on_whistle_button_pressed() -> void:\n\t$SoundEffects/Whistle.play()", "output": "\nfunc _on_toggle_amplify_toggled(button_pressed: bool) -> void:\n\t\tAudioServer.set_bus_effect_enabled(0, 0, button_pressed)\n\nfunc _on_toggle_band_limiter_toggled(button_pressed: bool) -> void:\n\t\tAudioServer.set_bus_effect_enabled(0, 1, button_pressed)\n\nfunc _on_toggle_band_pass_filter_toggled(button_pressed: bool) -> void:\n\t\tAudioServer.set_bus_effect_enabled(0, 2, button_pressed)\n\nfunc _on_toggle_chorus_toggled(button_pressed: bool) -> void:\n\t\tAudioServer.set_bus_effect_enabled(0, 3, button_pressed)\n\nfunc _on_toggle_compressor_toggled(button_pressed: bool) -> void:\n\t\tAudioServer.set_bus_effect_enabled(0, 4, button_pressed)\n\nfunc _on_toggle_delay_toggled(button_pressed: bool) -> void:\n\t\tAudioServer.set_bus_effect_enabled(0, 5, button_pressed)\n\nfunc _on_toggle_distortion_toggled(button_pressed: bool) -> void:\n\t\tAudioServer.set_bus_effect_enabled(0, 6, button_pressed)\n\nfunc _on_toggle_eq_6_toggled(button_pressed: bool) -> void:\n\t\tAudioServer.set_bus_effect_enabled(0, 7, button_pressed)\n\nfunc _on_toggle_eq_10_toggled(button_pressed: bool) -> void:\n\t\tAudioServer.set_bus_effect_enabled(0, 8, button_pressed)\n\nfunc _on_toggle_eq_21_toggled(button_pressed: bool) -> void:\n\t\tAudioServer.set_bus_effect_enabled(0, 9, button_pressed)\n\nfunc _on_toggle_high_pass_filter_toggled(button_pressed: bool) -> void:\n\t\tAudioServer.set_bus_effect_enabled(0, 10, button_pressed)\n\nfunc _on_toggle_low_shelf_filter_toggled(button_pressed: bool) -> void:\n\t\tAudioServer.set_bus_effect_enabled(0, 11, button_pressed)\n"} {"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,"} {"instruction": "Vervollständige den GDScript-Code:", "input": "extends Control\n\nvar effect: AudioEffect\nvar recording: AudioStreamWAV\n\nvar stereo: bool = true\nvar mix_rate := 44100 # This is the default mix rate on recordings.\nvar format := AudioStreamWAV.FORMAT_16_BITS # This is the default format on recordings.\n\n\nfunc _ready() -> void:\n\tvar idx := AudioServer.get_bus_index(&\"Record\")\n\teffect = AudioServer.get_bus_effect(idx, 0)\n\n\nfunc _on_record_button_pressed() -> void:\n\tif effect.is_recording_active():\n\t\trecording = effect.get_recording()\n\t\t$PlayButton.disabled = false\n\t\t$SaveButton.disabled = false\n\t\teffect.set_recording_active(false)\n\t\trecording.set_mix_rate(mix_rate)\n\t\trecording.set_format(format)\n\t\trecording.set_stereo(stereo)\n\t\t$RecordButton.text = \"Record\"\n\t\t$Status.text = \"\"\n\telse:\n\t\t$PlayButton.disabled = true\n\t\t$SaveButton.disabled = true\n\t\teffect.set_recording_active(true)\n\t\t$RecordButton.text = \"Stop\"\n\t\t$Status.text = \"Status: Recording...\"\n", "output": "\nfunc _on_play_button_pressed() -> void:\n\tprint_rich(\"\\n[b]Playing recording:[/b] %s\" % recording)\n\tprint_rich(\"[b]Format:[/b] %s\" % (\"8-bit uncompressed\" if recording.format == 0 else \"16-bit uncompressed\" if recording.format == 1 else \"IMA ADPCM compressed\"))\n\tprint_rich(\"[b]Mix rate:[/b] %s Hz\" % recording.mix_rate)\n\tprint_rich(\"[b]Stereo:[/b] %s\" % (\"Yes\" if recording.stereo else \"No\"))\n\tvar data := recording.get_data()\n\tprint_rich(\"[b]Size:[/b] %s bytes\" % data.size())\n\t$AudioStreamPlayer.stream = recording\n\t$AudioStreamPlayer.play()\n\nfunc _on_play_music_pressed() -> void:\n\tif $AudioStreamPlayer2.playing:\n\t\t$AudioStreamPlayer2.stop()\n\t\t$PlayMusic.text = \"Play Music\"\n\telse:\n\t\t$AudioStreamPlayer2.play()\n\t\t$PlayMusic.text = \"Stop Music\"\n\nfunc _on_save_button_pressed() -> void:\n\tvar save_path: String = $SaveButton/Filename.text\n\trecording.save_to_wav(save_path)\n\t$Status.text = \"Status: Saved WAV file to: %s\\n(%s)\" % [save_path, ProjectSettings.globalize_path(save_path)]\n\nfunc _on_mix_rate_option_button_item_selected(index: int) -> void:\n\tmatch index:\n\t\t0:\n\t\t\tmix_rate = 11025\n\t\t1:\n\t\t\tmix_rate = 16000\n\t\t2:\n\t\t\tmix_rate = 22050\n\t\t3:\n\t\t\tmix_rate = 32000\n\t\t4:\n\t\t\tmix_rate = 44100\n\t\t5:\n\t\t\tmix_rate = 48000\n\tif recording != null:\n\t\trecording.set_mix_rate(mix_rate)\n\nfunc _on_format_option_button_item_selected(index: int) -> void:\n\tmatch index:\n\t\t0:\n\t\t\tformat = AudioStreamWAV.FORMAT_8_BITS\n\t\t1:"} {"instruction": "Vervollständige den GDScript-Code:", "input": "## This is the base interface for value extraction\nclass_name GdUnitValueExtractor\nextends RefCounted", "output": "\n## Extracts a value by given implementation\nfunc extract_value(value :Variant) -> Variant:\n\tpush_error(\"Uninplemented func 'extract_value'\")\n\treturn value\n"} {"instruction": "Erstelle eine Godot-Klasse 'GameWorld' die von Node2D erbt mit folgenden Funktionen: _ready, setup, _find_largest_inoccupied_asteroid_cluster, _on_Events_upgrade_chosen, _on_AsteroidSpawner_cluster_depleted", "input": "", "output": "# Spawns the station, asteroids, and pirates when entering the game.\n# Keeps track of resources available in the world and which asteroid clusters holds it,\n# and spawns more when running low.\n# It also signals the pirate spawner when an upgrade has been made.\nclass_name GameWorld\nextends Node2D\n\n# Radius of the world in pixels.\n@export var radius := 8000.0\n\n# Minimum amount of iron that must be added when the world spawns new asteroids.\n# Used in `_spawn_asteroids`.\n@export var iron_amount_balance_level := 100.0\n# If the amouns of iron in the world goes below this threshold, spawns new asteroids.\n@export var refresh_threshold_range := 25.0\n\nvar _spawned_positions := []\nvar _world_objects := []\nvar _iron_clusters := {}\n\n@onready var rng := RandomNumberGenerator.new()\n\n@onready var station_spawner: StationSpawner = $StationSpawner\n@onready var asteroid_spawner: AsteroidSpawner = $AsteroidSpawner\n@onready var pirate_spawner: PirateSpawner = $PirateSpawner\n\nfunc _ready() -> void:\n\tawait owner.ready\n\tsetup()\n\nfunc setup() -> void:\n\trng.randomize()\n\n\tEvents.upgrade_chosen.connect(_on_Events_upgrade_chosen)\n\tasteroid_spawner.cluster_depleted.connect(_on_AsteroidSpawner_cluster_depleted)\n\n\tstation_spawner.spawn_station(rng)\n\tasteroid_spawner.spawn_asteroid_clusters(rng, iron_amount_balance_level, radius)\n\tpirate_spawner.spawn_pirate_group(\n\t\trng, 0, radius, _find_largest_inoccupied_asteroid_cluster().global_position\n\t)\n\n# Returns the AsteroidCluster with the most iron that isn't occupied.\n# If all clusters are occupied, returns `null`.\nfunc _find_largest_inoccupied_asteroid_cluster() -> AsteroidCluster:\n\tvar target_cluster: AsteroidCluster\n\n\tvar target_cluster_iron_amount := -INF\n\tfor cluster in asteroid_spawner.get_children():\n\t\tassert(cluster is AsteroidCluster)\n\t\tif cluster.is_occupied:\n\t\t\tcontinue\n\t\tif cluster.iron_amount > target_cluster_iron_amount:\n\t\t\ttarget_cluster = cluster\n\t\t\ttarget_cluster_iron_amount = cluster.iron_amount\n\tif target_cluster:\n\t\ttarget_cluster"} {"instruction": "Erstelle eine Godot-Klasse 'Cutscene' die von Node2D erbt mit folgenden Funktionen: is_cutscene_in_progress, run, _execute", "input": "", "output": "## A cutscene stops field gameplay to run a scripted event.\n##\n## A cutscene may be thought of as the videogame equivalent of a short scene in a film. For example,\n## dialogue may be displayed, the scene may switch to show key NPCs performing an event, or the\n## inventory may be altered. Gameplay on the field is [b]stopped[/b] until the cutscene concludes,\n## though this may span a combat scenario (e.g. epic bossfight).\n##\n##[br][br]\n## Cutscenes may or may not have duration, and only one cutscene may be active at a time. Field\n## gameplay is stopped for the entire duration of the active cutscene.\n## Gameplay is stopped by emitting the global [signal FieldEvents.input_paused] signal.\n## AI and player objects respond to this signal. For examples or responses to this signal, see\n## [member GamepieceController.is_paused] or [method FieldCursor._on_input_paused].\n##\n##[br][br]\n## Cutscenes are inherently custom and must be derived to do anything useful. They may be run via\n## the [method run] method and derived cutscenes will override the [method _execute] method to\n## provide custom functionality.\n##\n##[br][br]\n## Cutscenes are easily extensible, taking advantage of Godot's scene architecture. A variety of\n## cutscene templates are included out-of-the-box. See [Trigger] for a type of cutscene that is\n## triggered by contact with a gamepeiece. See [Interaction] for cutscene's that are triggered by\n## the player interaction with them via a keypress or touch. Several derived temlpates (for example,\n## open-able doors) are included in res://field/cutscenes/templates.\n@icon(\"res://assets/editor/icons/Cutscene.svg\")\nclass_name Cutscene extends Node2D\n\n# Indicates if a cutscene is currently running. [b]This member should not be set externally[/b].\nstatic var _is_cutscene_in_progress: = false:\n\tset(value):\n\t\tif _is_cutscene_in_progress != value:\n\t\t\t_is_cutscene_in_progress = value\n\n\t\t\tFieldEvents.input_paused.emit(value)\n\n## Returns true if a cutscene is currently running."} {"instruction": "Vervollständige den GDScript-Code:", "input": "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", "output": "@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": "# Calculates an acceleration to take an agent to a target agent's position\n# directly.\n# @category - Individual behaviors\nclass_name GSAISeek\nextends GSAISteeringBehavior\n\n# The target that the behavior aims to move the agent to.", "output": "var target: GSAIAgentLocation\n\nfunc _init(agent: GSAISteeringAgent, _target: GSAIAgentLocation) -> void:\n\tsuper._init(agent)\n\tself.target = _target\n\nfunc _calculate_steering(acceleration: GSAITargetAcceleration) -> void:\n\tacceleration.linear = (\n\t\t(target.position - agent.position).normalized()\n\t\t* agent.linear_acceleration_max\n\t)\n\tacceleration.angular = 0\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "## A transition (usually between gameplay scenes) in which the screen is hidden behind an opaque\n## color and then shown again.\n##\n## Screen transitions are often used in [Cutscenes] to cover up changes in the scenery or sudden\n## changes to the loaded area. Many games begin with the screen covered and play some kind of\n## animation before transitioning (see [method reveal]) to gameplay.\n##\n## [br][br]ScreenTransitions cover or reveal the screen uniformly as a fade animation.\nclass_name ScreenTransition extends CanvasLayer\n\n## Emitted when the screen has finished the current animation, whether that is to [method cover] the\n## screen or [method reveal] the screen.\nsignal finished\n\n## The modulate color of the scene when it is to be invisible. Note that it is just\n## [constant Color.WHITE] with a zero alpha channel.\nconst CLEAR: = Color(1, 1, 1, 0)\n\n## The target modulate value of the scene when the transition covers the screen. Note that it is\n## just [constant Color.WHITE].\n## Consequently, the color of the screen transition may be set through the [member color] property.\nconst COVERED: = Color.WHITE\n\nvar _tween: Tween\n\n@onready var _color_rect: = $ColorRect as ColorRect\n\n\nfunc _ready() -> void:", "output": "\t# The screen transitions need to run over the gameplay, which is instantiated below all\n\t# autoloads (including this class). Therefore, we want to move the ScreenTransition object to\n\t# the very bottom of the SceneTree's child list.\n\t# We cannot do so during ready, in which this node's parents are not yet ready. Therefore the\n\t# call to move_child must be deferred a frame.\n\tget_parent().move_child.call_deferred(self, get_parent().get_child_count()-1)\n\n\t# Allow the mouse through the transition GUI elements.\n\t_color_rect.mouse_filter = Control.MOUSE_FILTER_IGNORE\n\n\t# By default, do NOT have the ColorRect covering the screen.\n\tshow()\n\tclear()\n\n## Hide the ColorRect instantly, unless the duration argument is non-zero.\n## This method is a coroutine that will finish once the screen has been cleared.\nfunc clear(duration: = 0.0) -> void:\n\tif _tween:\n\t\t_tween.kill()\n\t\t_tween = null\n\t\tfinished.emit()\n\n\tif is_equal_approx(duration, 0.0) or _color_rect.modulate.is_equal_approx(CLEAR):\n\t\t_color_rect.modulate = CLEAR\n\t\tcall_deferred(\"emit_signal\", \"finished\")\n\n\telse:\n\t\t_tween_transition(duration, CLEAR)\n\n\tawait finished\n\n## Cover the screen instantly, unless the duration argument is non-zero.\n## This method is a coroutine that will finish once the screen has been covered.\nfunc cover(duration: = 0.0) -> void:\n\tif _tween:\n\t\tif _tween.is_running():\n\t\t\tfinished.emit()\n\t\t_tween.kill()\n\t\t_tween = null\n\n\tif is_equal_approx(duration, 0.0) or _color_rect.modulate.is_equal_approx(COVERED):\n\t\t_color_rect.modulate = COVERED\n\t\tcall_deferred(\"emit_signal\", \"finished\")\n\n\telse:\n\t\t_tween_transition(duration, COVERED)\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "## An arena is the editor-configured environment for a battle. It is a Control node that contains \n## the combat participants and details (such as background, foreground, music, etc.).\nclass_name CombatArena extends Control\n", "output": "## The music that will be automatically played during this combat instance.\n@export var music: AudioStream\n\n## Retrieve the list of the combat participants, in [BattlerRoster] form.\nfunc get_battler_roster() -> BattlerRoster:\n\treturn $Battlers as BattlerRoster\n"} {"instruction": "Erstelle eine Godot-Klasse 'GdUnitSceneRunner' die von RefCounted erbt mit folgenden Funktionen: simulate_action_pressed, simulate_action_press, simulate_action_release, test_key_presssed, simulate_key_pressed", "input": "", "output": "## 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## 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## 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## 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## 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## Simulates"} {"instruction": "Vervollständige den GDScript-Code:", "input": "extends Trigger\n\n@export var _anim: AnimationPlayer\n", "output": "\nfunc _ready() -> void:\n\tsuper._ready()\n\tassert(_anim, \"%s error: animation player reference is not set!\" % name)\n\nfunc _on_area_entered(area: Area2D) -> void:\n\tsuper._on_area_entered(area)\n\t_anim.play(\"open\")\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "class_name XRHandFallbackModifier3D\nextends SkeletonModifier3D\n\n## This node implements a fallback if the hand tracking API is not available\n## or if one of the data sources is not supported by the XR runtime.\n## It uses trigger and grip inputs from the normal controller tracker to\n## animate the index finger and bottom 3 fingers respectively.\n\n## Action to use for animating index finger.\n@export var trigger_action : String = \"trigger\"\n\n## Action to use for animating bottom 3 fingers.\n@export var grip_action : String = \"grip\"\n\n# Called by our skeleton logic when this modifier needs to apply its modifications.\nfunc _process_modification() -> void:\n\t# Get our skeleton.\n\tvar skeleton: Skeleton3D = get_skeleton()\n\tif !skeleton:\n\t\treturn\n\n\t# Find our parent controller\n\tvar parent = get_parent()\n\twhile parent and not parent is XRNode3D:\n\t\tparent = parent.get_parent()\n\tif !parent:\n\t\treturn", "output": "\n\t# Check if we have an active hand tracker,\n\t# if so, we don't need our fallback!\n\tvar xr_parent : XRNode3D = parent\n\tif not xr_parent.tracker in [ \"left_hand\", \"right_hand\" ]:\n\t\treturn\n\n\tvar trigger : float = 0.0\n\tvar grip : float = 0.0\n\n\t# Check our tracker for trigger and grip values\n\tvar tracker : XRControllerTracker = XRServer.get_tracker(xr_parent.tracker)\n\tif tracker:\n\t\tvar trigger_value : Variant = tracker.get_input(trigger_action)\n\t\tif trigger_value:\n\t\t\ttrigger = trigger_value\n\n\t\tvar grip_value : Variant = tracker.get_input(grip_action)\n\t\tif grip_value:\n\t\t\tgrip = grip_value\n\n\t# Now position bones\n\tvar bone_count = skeleton.get_bone_count()\n\tfor i in bone_count:\n\t\tvar t : Transform3D = skeleton.get_bone_rest(i)\n\n\t\t# We animate based on bone_name.\n\t\t# For now just hardcoded values.\n\t\t# Note that we position all bones in case we need to reset some.\n\t\tvar bone_name = skeleton.get_bone_name(i)\n\t\tif bone_name == \"LeftHand\":\n\t\t\t# Offset to center our palm, this requires the use of the palm pose!\n\t\t\tt.origin += Vector3(-0.015, 0.0, 0.04)\n\t\telif bone_name == \"RightHand\":\n\t\t\t# Offset to center our palm, this requires the use of the palm pose!\n\t\t\tt.origin += Vector3(0.015, 0.0, 0.04)\n\t\telif bone_name == \"LeftIndexDistal\" or bone_name == \"LeftIndexIntermediate\" \\\n\t\t\tor bone_name == \"RightIndexDistal\" or bone_name == \"RightIndexIntermediate\":\n\t\t\tvar r : Transform3D\n\t\t\tt = t * r.rotated(Vector3(1.0, 0.0, 0.0), deg_to_rad(45.0) * trigger)\n\t\telif bone_name == \"LeftIndexProximal\" or bone_name == \"RightIndexProximal\":\n\t\t\tvar r : Transform3D\n\t\t\tt = t * r.rotated(Vector3(1.0, 0.0, 0.0), deg_to_rad(20.0) * trigger)\n\t\telif bone_name == \"LeftMiddleDistal\" or bone_name == \"LeftMiddleIntermediate\" or bone_name == \"LeftMiddleProximal\" \\\n\t\t\t\tor bone_name == \"RightMiddleDistal\" or bone_name == \"RightMiddleIntermediate\" or bone_name == \"RightMiddleProximal\" \\\n\t\t\t\tor bone_name == \"LeftRingDistal\" or bone_name == \"LeftRingIntermediate\" or bone_name == \"LeftRingProximal\" \\\n\t\t\t\tor bone_name == \"RightRingDistal\" or bone_name == \"RightRingIntermediate\" or bone_name == \"RightRingProximal\" \\\n\t\t\t\tor bone_name == \"LeftLittleDistal\" or bone_name == \"LeftLittleIntermediate\" or bone_name == \"LeftLittleProximal\" \\\n\t\t\t\tor bone_name == \"RightLittleDistal\" or bone_name == \"RightLittleIntermediate\" or bone_name == \"RightLittleProximal\":\n\t\t\tvar r : Transform3D"} {"instruction": "Erstelle eine Godot-Klasse 'Trigger' die von Cutscene erbt mit folgenden Funktionen: _ready, _get_configuration_warnings, _on_input_paused, _on_area_entered, _on_area_exited", "input": "", "output": "@tool\n\n## A [Cutscene] that triggers on collision with a [Gamepiece]'s collision shapes.\n##\n## A Gamepiece with collision shapes on a layer monitored by the Trigger may activate the Trigger.\n## Triggers typically wait for [signal Gamepiece.arriving] before being run, but that behaviour may\n## be overridden in derived Triggers by modifying [method _on_area_entered].\n@icon(\"res://assets/editor/icons/Contact.svg\")\nclass_name Trigger extends Cutscene\n\n## Emitted when a [Gamepiece] begins moving to the cell occupied by the [code]Trigger[/code].\nsignal gamepiece_entered(gamepiece: Gamepiece)\n\n## Emitted when a [Gamepiece] begins moving away from the cell occupied by the [code]Trigger[/code].\nsignal gamepiece_exited(gamepiece: Gamepiece)\n\n## Emitted when a [Gamepiece] is finishing moving to the cell occupied by the [code]Trigger[/code].\nsignal triggered(gamepiece: Gamepiece)\n\n## An active [code]Trigger[/code] may be run, whereas one that is inactive may only be run\n## directly through code via the [method Cutscene.run] method.\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# We use \"Visible Collision Shapes\" to debug positions on the gameboard, so we'll want\n\t\t\t# to change the state of child collision shapes.These could be either CollisionShape2Ds\n\t\t\t# or CollisionPolygon2Ds.\n\t\t\t# Note that we only want to disable the collision shapes of objects that are actually\n\t\t\t# connected to this Interaction.\n\t\t\tfor data in get_incoming_connections():\n\t\t\t\tvar callable: = data[\"callable\"] as Callable\n\t\t\t\tif callable == _on_area_entered :\n\t\t\t\t\tvar connected_area: = data[\"signal\"].get_object() as Area2D\n\t\t\t\t\tif connected_area:\n\t\t\t\t\t\tfor node in connected_area.find_children(\"*\", \"CollisionShape2D\"):\n\t\t\t\t\t\t\t(node as CollisionShape2D).disabled = !is_active\n\t\t\t\t\t\tfor node in connected_area.find_children(\"*\", \"CollisionPolygon2D\"):\n\t\t\t\t\t\t\t(node as CollisionPolygon2D).disabled = !is_activ"} {"instruction": "Erstelle eine Godot-Klasse 'GSAIPath' die von RefCounted erbt mit folgenden Funktionen: _init, create_path, calculate_distance, calculate_target_position, get_start_point", "input": "", "output": "# Represents a path made up of Vector3 waypoints, split into segments path\n# follow behaviors can use.\n# @category - Base types\nclass_name GSAIPath\nextends RefCounted\n\n# If `false`, the path loops.\nvar is_open: bool\n# Total length of the path.\nvar length: float\n\nvar _segments: Array\n\nvar _nearest_point_on_segment: Vector3\nvar _nearest_point_on_path: Vector3\n\nfunc _init(waypoints: Array, _is_open := false) -> void:\n\tself.is_open = _is_open\n\tcreate_path(waypoints)\n\t_nearest_point_on_segment = waypoints[0]\n\t_nearest_point_on_path = waypoints[0]\n\n# Creates a path from a list of waypoints.\nfunc create_path(waypoints: Array) -> void:\n\tif not waypoints or waypoints.size() < 2:\n\t\tprinterr(\"Waypoints cannot be null and must contain at least two (2) waypoints.\")\n\t\treturn\n\n\t_segments = []\n\tlength = 0\n\tvar current: Vector3 = waypoints.front()\n\tvar previous: Vector3\n\n\tfor i in range(1, waypoints.size(), 1):\n\t\tprevious = current\n\t\tif i < waypoints.size():\n\t\t\tcurrent = waypoints[i]\n\t\telif is_open:\n\t\t\tbreak\n\t\telse:\n\t\t\tcurrent = waypoints[0]\n\t\tvar segment := GSAISegment.new(previous, current)\n\t\tlength += segment.length\n\t\tsegment.cumulative_length = length\n\t\t_segments.append(segment)\n\n# Returns the distance from `agent_current_position` to the next waypoint.\nfunc calculate_distance(agent_current_position: Vector3) -> float:\n\tif _segments.size() == 0:\n\t\treturn 0.0\n\tvar smallest_distance_squared: float = INF\n\tvar nearest_segment: GSAISegment\n\tfor i in range(_segments.size()):\n\t\tvar segment: GSAISegment = _segments[i]\n\t\tvar distance_squared := _calculate_point_segment_distance_squared(\n\t\t\tsegment.begin, segment.end, agent_current_position\n\t\t)\n\n\t\tif distance_squared < smallest_distance_squared:\n\t\t\t_nearest_point_on_path = _nearest_point_on_segment\n\t\t\tsmallest_distance_squared = distance_squared\n\t\t\tnearest_segment = segment\n\n\tvar length_on_path := (\n\t\tnearest_segment.cumulative_length\n\t\t- _nearest_point_on_path.distance_to(nearest_segment.end)\n\t)\n\n\treturn length_on_path\n\n# Calculates"} {"instruction": "Vervollständige den GDScript-Code:", "input": "extends ProgressBar\n\n@export var Ore: PackedScene = preload(\"res://world/ores/iron_ore.tscn\")\n\n@onready var arc_bottom := $ArcBottom\n@onready var arc_top := $ArcTop\n@onready var fill := $Fill\n@onready var tween : Tween\n@onready var anim_player := $AnimationPlayer\n@onready var audio_unload: AudioStreamPlayer = $AudioUnload\n\nvar docked_position := Vector2.ZERO\n\nvar _player_is_mining := false\n\n\nfunc _ready() -> void:\n\tEvents.docked.connect(_on_Events_docked)\n\tEvents.mine_started.connect(_on_Events_mine_started)\n\tEvents.mine_finished.connect(_on_Events_mine_finished)\n\tself.value_changed.connect(_on_value_changed)\n\tshare(arc_bottom)\n\tshare(arc_top)\n", "output": "\nfunc initialize(player: PlayerShip) -> void:\n\tplayer.cargo.stats.stat_changed.connect(_on_Stats_stat_changed)\n\tmax_value = player.cargo.stats.get_max_cargo()\n\tvalue = player.cargo.stats.get_stat(\"cargo\")\n\nfunc spawn_ore() -> void:\n\tvar ore := Ore.instantiate()\n\tadd_child(ore)\n\tif _player_is_mining:\n\t\tore.global_position = docked_position\n\t\tore.animate_to(global_position + pivot_offset)\n\telse:\n\t\tore.global_position = global_position + pivot_offset\n\t\tore.animate_to(docked_position)\n\t\taudio_unload.play()\n\nfunc _on_Events_docked(docking_point: DockingPoint) -> void:\n\tdocked_position = docking_point.get_global_transform_with_canvas().origin\n\nfunc _on_Events_mine_started(_mining_position: Vector2) -> void:\n\t_player_is_mining = true\n\nfunc _on_Events_mine_finished() -> void:\n\t_player_is_mining = false\n\nfunc _on_Stats_stat_changed(stat: String, _value_start: float, current_value: float) -> void:\n\tif not stat == \"cargo\":\n\t\treturn\n\tvalue = current_value\n\nfunc _on_value_changed(_value: float) -> void:\n\tif tween and tween.is_running():\n\t\treturn\n\ttween = create_tween()\n\ttween.tween_property(\n\t\tfill,\n\t\t\"scale\",\n\t\tVector2(ratio, ratio),\n\t\t0.25\n\t).from_current().set_ease(Tween.EASE_OUT).set_trans(Tween.TRANS_ELASTIC)\n\ttween.play()\n\tspawn_ore()\n"} {"instruction": "Erstelle eine GDScript-Funktion namens '_process':", "input": "", "output": "func _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}", "source": "extracted_function"} {"instruction": "Erstelle eine Godot-Klasse 'XRHandFallbackModifier3D' die von SkeletonModifier3D erbt mit folgenden Funktionen: _process_modification", "input": "", "output": "class_name XRHandFallbackModifier3D\nextends SkeletonModifier3D\n\n## This node implements a fallback if the hand tracking API is not available\n## or if one of the data sources is not supported by the XR runtime.\n## It uses trigger and grip inputs from the normal controller tracker to\n## animate the index finger and bottom 3 fingers respectively.\n\n## Action to use for animating index finger.\n@export var trigger_action : String = \"trigger\"\n\n## Action to use for animating bottom 3 fingers.\n@export var grip_action : String = \"grip\"\n\n# Called by our skeleton logic when this modifier needs to apply its modifications.\nfunc _process_modification() -> void:\n\t# Get our skeleton.\n\tvar skeleton: Skeleton3D = get_skeleton()\n\tif !skeleton:\n\t\treturn\n\n\t# Find our parent controller\n\tvar parent = get_parent()\n\twhile parent and not parent is XRNode3D:\n\t\tparent = parent.get_parent()\n\tif !parent:\n\t\treturn\n\n\t# Check if we have an active hand tracker,\n\t# if so, we don't need our fallback!\n\tvar xr_parent : XRNode3D = parent\n\tif not xr_parent.tracker in [ \"left_hand\", \"right_hand\" ]:\n\t\treturn\n\n\tvar trigger : float = 0.0\n\tvar grip : float = 0.0\n\n\t# Check our tracker for trigger and grip values\n\tvar tracker : XRControllerTracker = XRServer.get_tracker(xr_parent.tracker)\n\tif tracker:\n\t\tvar trigger_value : Variant = tracker.get_input(trigger_action)\n\t\tif trigger_value:\n\t\t\ttrigger = trigger_value\n\n\t\tvar grip_value : Variant = tracker.get_input(grip_action)\n\t\tif grip_value:\n\t\t\tgrip = grip_value\n\n\t# Now position bones\n\tvar bone_count = skeleton.get_bone_count()\n\tfor i in bone_count:\n\t\tvar t : Transform3D = skeleton.get_bone_rest(i)\n\n\t\t# We animate based on bone_name.\n\t\t# For now just hardcoded values.\n\t\t# Note that we position all bones in case we need to reset some.\n\t\tvar bone_name = skeleton.get_bone_name(i)\n\t\tif bone_name == \"LeftHand\":\n\t\t\t# Offset to center our palm, this requires the use of the palm pose!\n\t\t\tt.origin += Vector3(-0.015, 0.0, 0.04)\n\t\telif bone_name == \"RightHand\":\n\t\t\t# Offset to"} {"instruction": "Vervollständige den GDScript-Code:", "input": "# Calculates an acceleration to make an agent intercept another based on the\n# target agent's movement.\n# @category - Individual behaviors\nclass_name GSAIPursue\nextends GSAISteeringBehavior\n\n# The target agent that the behavior is trying to intercept.\nvar target: GSAISteeringAgent\n# The maximum amount of time in the future the behavior predicts the target's\n# location.\nvar predict_time_max: float\n\n", "output": "func _init(agent: GSAISteeringAgent, _target: GSAISteeringAgent, _predict_time_max := 1.0) -> void:\n\tsuper._init(agent)\n\tself.target = _target\n\tself.predict_time_max = _predict_time_max\n\nfunc _calculate_steering(acceleration: GSAITargetAcceleration) -> void:\n\tvar target_position := target.position\n\tvar distance_squared := (target_position - agent.position).length_squared()\n\n\tvar speed_squared := agent.linear_velocity.length_squared()\n\tvar predict_time := predict_time_max\n\n\tif speed_squared > 0:\n\t\tvar predict_time_squared := distance_squared / speed_squared\n\t\tif predict_time_squared < predict_time_max * predict_time_max:\n\t\t\tpredict_time = sqrt(predict_time_squared)\n\n\tacceleration.linear = ((target_position + (target.linear_velocity * predict_time)) - agent.position).normalized()\n\tacceleration.linear *= _get_modified_acceleration()\n\n\tacceleration.angular = 0\n\nfunc _get_modified_acceleration() -> float:\n\treturn agent.linear_acceleration_max\n"} {"instruction": "Erstelle eine Godot-Klasse 'GdUnitSignalAssert' die von GdUnitAssert erbt mit folgenden Funktionen: is_null, is_not_null, is_equal, is_not_equal, override_failure_message", "input": "", "output": "## An Assertion Tool to verify for emitted signals until a waiting time\n@abstract class_name GdUnitSignalAssert\nextends GdUnitAssert\n\n## Verifies that the current value is null.\n@abstract func is_null() -> GdUnitSignalAssert\n\n## Verifies that the current value is not null.\n@abstract func is_not_null() -> GdUnitSignalAssert\n\n## Verifies that the current value is equal to the given one.\n@abstract func is_equal(expected: Variant) -> GdUnitSignalAssert\n\n## Verifies that the current value is not equal to expected one.\n@abstract func is_not_equal(expected: Variant) -> GdUnitSignalAssert\n\n## Overrides the default failure message by given custom message.\n@abstract func override_failure_message(message: String) -> GdUnitSignalAssert\n\n## Appends a custom message to the failure message.\n@abstract func append_failure_message(message: String) -> GdUnitSignalAssert\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)\n## await assert_signal(instance).is_emitted(signal_a)\n## # Using string name (dynamic)\n## await"} {"instruction": "Vervollständige den GDScript-Code:", "input": "## An assertion tool to verify GDUnit asserts.\n## This assert is for internal use only, to verify that failed asserts work as expected.\n@abstract class_name GdUnitFailureAssert\nextends GdUnitAssert\n\n\n## Verifies that the current value is null.\n@abstract func is_null() -> GdUnitFailureAssert\n\n\n## Verifies that the current value is not null.\n@abstract func is_not_null() -> GdUnitFailureAssert\n\n\n## Verifies that the current value is equal to the given one.\n@abstract func is_equal(expected: Variant) -> GdUnitFailureAssert\n", "output": "\n## Verifies that the current value is not equal to expected one.\n@abstract func is_not_equal(expected: Variant) -> GdUnitFailureAssert\n\n## Overrides the default failure message by given custom message.\n@abstract func override_failure_message(message: String) -> GdUnitFailureAssert\n\n## Appends a custom message to the failure message.\n@abstract func append_failure_message(message: String) -> GdUnitFailureAssert\n\n## Verifies if the executed assert was successful\n@abstract func is_success() -> GdUnitFailureAssert\n\n## Verifies if the executed assert has failed\n@abstract func is_failed() -> GdUnitFailureAssert\n\n## Verifies the failure line is equal to expected one.\n@abstract func has_line(expected: int) -> GdUnitFailureAssert\n\n## Verifies the failure message is equal to expected one.\n@abstract func has_message(expected: String) -> GdUnitFailureAssert\n\n## Verifies that the failure message starts with the expected message.\n@abstract func starts_with_message(expected: String) -> GdUnitFailureAssert\n\n## Verifies that the failure message contains the expected message.\n@abstract func contains_message(expected: String) -> GdUnitFailureAssert\n"} {"instruction": "Erstelle eine Godot-Klasse 'DebugGameboardBoundaries' die von Node2D erbt mit folgenden Funktionen: _ready, _draw, _update_boundaries", "input": "", "output": "@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\n@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": "Erstelle eine GDScript-Funktion namens '_init':", "input": "", "output": "func _init(agent: GSAISteeringAgent) -> void:\n\tsuper._init(agent)\n\n# Appends a behavior to the internal array along with its `weight`.\nfunc add(behavior: GSAISteeringBehavior, weight: float) -> void:\n\tbehavior.agent = agent\n\t_behaviors.append({behavior = behavior, weight = weight}", "source": "extracted_function"} {"instruction": "Erstelle eine Godot-Klasse 'DefaultValueProvider' die von ValueProvider erbt mit folgenden Funktionen: _init, get_value", "input": "", "output": "# default value provider, simple returns the initial value\nclass_name DefaultValueProvider\nextends ValueProvider\n\nvar _value: Variant\n\nfunc _init(value: Variant) -> void:\n\t_value = value\n\nfunc get_value() -> Variant:\n\treturn _value\n"} {"instruction": "Erstelle eine Godot-Klasse 'GdUnitIntAssert' die von GdUnitAssert erbt mit folgenden Funktionen: is_null, is_not_null, is_equal, is_not_equal, override_failure_message", "input": "", "output": "## An Assertion Tool to verify integer values\n@abstract class_name GdUnitIntAssert\nextends GdUnitAssert\n\n## Verifies that the current value is null.\n@abstract func is_null() -> GdUnitIntAssert\n\n## Verifies that the current value is not null.\n@abstract func is_not_null() -> GdUnitIntAssert\n\n## Verifies that the current value is equal to the given one.\n@abstract func is_equal(expected: Variant) -> GdUnitIntAssert\n\n## Verifies that the current value is not equal to expected one.\n@abstract func is_not_equal(expected: Variant) -> GdUnitIntAssert\n\n## Overrides the default failure message by given custom message.\n@abstract func override_failure_message(message: String) -> GdUnitIntAssert\n\n## Appends a custom message to the failure message.\n@abstract func append_failure_message(message: String) -> GdUnitIntAssert\n\n## Verifies that the current value is less than the given one.\n@abstract func is_less(expected: int) -> GdUnitIntAssert\n\n## Verifies that the current value is less than or equal the given one.\n@abstract func is_less_equal(expected: int) -> GdUnitIntAssert\n\n## Verifies that the current value is greater than the given one.\n@abstract func is_greater(expected: int) -> GdUnitIntAssert\n\n## Verifies that the current value is greater than or equal the given one.\n@abstract func is_greater_equal(expected: int) -> GdUnitIntAssert\n\n## Verifies that the current value is even.\n@abstract func is_even() -> GdUnitIntAssert\n\n## Verifies that the current value is odd.\n@abstract func is_odd() -> GdUnitIntAssert\n\n## Verifies that the current value is negative.\n@abstract func is_negative() -> GdUnitIntAssert\n\n## Verifies that the current value is not negative.\n@abstract func is_not_negative() -> GdUnitIntAssert\n\n## Verifies that the current value is equal to zero.\n@abstract func is_zero() -> GdUnitIntAssert\n\n## Verifies that the current value is not equal to zero.\n@abstract func is_not_zero() -> GdUnitIntAssert\n\n## Verifies that the current value is in the given set of"} {"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] = {}"} {"instruction": "Vervollständige den GDScript-Code:", "input": "@tool\nextends TextureRect\n", "output": "\nfunc _ready() -> void:\n\tvar vp_text = get_node(\"../../DistortMaskView/SubViewport\").get_texture()\n\tvar s_mat = material as ShaderMaterial\n\ts_mat.set_shader_parameter(\"displacement_mask\", vp_text)\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "@tool\n\n## A [Cutscene] that triggers on collision with a [Gamepiece]'s collision shapes.\n##\n## A Gamepiece with collision shapes on a layer monitored by the Trigger may activate the Trigger.\n## Triggers typically wait for [signal Gamepiece.arriving] before being run, but that behaviour may\n## be overridden in derived Triggers by modifying [method _on_area_entered].\n@icon(\"res://assets/editor/icons/Contact.svg\")\nclass_name Trigger extends Cutscene\n\n## Emitted when a [Gamepiece] begins moving to the cell occupied by the [code]Trigger[/code].\nsignal gamepiece_entered(gamepiece: Gamepiece)\n\n## Emitted when a [Gamepiece] begins moving away from the cell occupied by the [code]Trigger[/code].\nsignal gamepiece_exited(gamepiece: Gamepiece)\n\n## Emitted when a [Gamepiece] is finishing moving to the cell occupied by the [code]Trigger[/code].\nsignal triggered(gamepiece: Gamepiece)\n\n## An active [code]Trigger[/code] may be run, whereas one that is inactive may only be run\n## directly through code via the [method Cutscene.run] method.\n@export var is_active: = true:\n\tset(value):\n\t\tis_active = value\n\t\t\n\t\tif not Engine.is_editor_hint():\n\t\t\tif not is_inside_tree():\n\t\t\t\tawait ready\n\t\t\t\n\t\t\t# We use \"Visible Collision Shapes\" to debug positions on the gameboard, so we'll want \n\t\t\t# to change the state of child collision shapes.These could be either CollisionShape2Ds\n\t\t\t# or CollisionPolygon2Ds.\n\t\t\t# Note that we only want to disable the collision shapes of objects that are actually\n\t\t\t# connected to this Interaction.\n\t\t\tfor data in get_incoming_connections():\n\t\t\t\tvar callable: = data[\"callable\"] as Callable", "output": "\t\t\t\tif callable == _on_area_entered :\n\t\t\t\t\tvar connected_area: = data[\"signal\"].get_object() as Area2D\n\t\t\t\t\tif connected_area:\n\t\t\t\t\t\tfor node in connected_area.find_children(\"*\", \"CollisionShape2D\"):\n\t\t\t\t\t\t\t(node as CollisionShape2D).disabled = !is_active\n\t\t\t\t\t\tfor node in connected_area.find_children(\"*\", \"CollisionPolygon2D\"):\n\t\t\t\t\t\t\t(node as CollisionPolygon2D).disabled = !is_active\n\nfunc _ready() -> void:\n\tif not Engine.is_editor_hint():\n\t\tFieldEvents.input_paused.connect(_on_input_paused)\n\n# Ensure that something is connected to _on_area_entered, which the Trigger requires.\n# If nothing is connected, issue a configuration warning.\nfunc _get_configuration_warnings() -> PackedStringArray:\n\tvar warnings: PackedStringArray = []\n\tvar has_area_entered_bindings: = false\n\n\tfor data in get_incoming_connections():\n\t\tif data[\"callable\"] == _on_area_entered:\n\t\t\thas_area_entered_bindings = true\n\n\tif not has_area_entered_bindings:\n\t\twarnings.append(\"This object does not have a CollisionObject2D's signals connected to \" +\n\t\t\t\"this Trigger's _on_area_entered method. The Trigger will never be triggered!\")\n\treturn warnings\n\n# Pause any collision objects that would normally send signals regarding interactions.\n# This will automatically accept or ignore currently overlapping areas.\nfunc _on_input_paused(is_paused: bool) -> void:\n\tfor data in get_incoming_connections():\n\t\t# Note that we only want to check _on_area_entered, since _on_area_exited will clean up any\n\t\t# lingering references once the Area2Ds are 'shut off' (i.e. not monitoring/monitorable).\n\t\tif data[\"callable\"] == _on_area_entered:\n\t\t\tvar connected_area: = data[\"signal\"].get_object() as Area2D\n\t\t\tif connected_area:\n\t\t\t\tconnected_area.monitoring = !is_paused\n\t\t\t\tconnected_area.monitorable = !is_paused\n\n# Register the colliding gamepiece and wait for it to finish moving before running the trigger.\nfunc _on_area_entered(area: Area2D) -> void:\n\tvar gamepiece: = area.owner as Gamepiece\n\n\t# Check to make sure that the gamepiece is moving before connecting to its 'arriving'\n\t# signal. This catches edge cases where the Trigger is unpaused while a colliding object\n\t# is standing on top of it (which would mean that _on_gamepiece_arrived would trigger once"} {"instruction": "Erstelle eine Godot-Klasse 'UIInventory' die von HBoxContainer erbt mit folgenden Funktionen: _ready, get_ui_item, _update_item, _on_inventory_item_changed", "input": "", "output": "## An exceptionally simple item inventory that tracks which items the player has picked up.\n## Normally, inventory design would be more complex. In particular, you would want to separate the\n## inventory data structures from the UI implementation, as should be done in a future update to\n## the OpenRPG project.\n## In this case, we just want to show the player which items have been picked up so that we can demo\n## a variety of RPG events.\nclass_name UIInventory extends HBoxContainer\n\n# Keep track of the inventory item packed scene to easily instantiate new items.\nvar _ITEM_SCENE: = preload(\"res://src/field/ui/inventory/ui_inventory_item.tscn\")\n\nfunc _ready() -> void:\n\tvar inventory: = Inventory.restore()\n\n\tfor item_name in Inventory.ItemTypes:\n\t\t_update_item(Inventory.ItemTypes[item_name], inventory)\n\tinventory.item_changed.connect(_on_inventory_item_changed.bind(inventory))\n\nfunc get_ui_item(item_id: Inventory.ItemTypes) -> UIInventoryItem:\n\tfor child in get_children():\n\t\tvar item: = child as UIInventoryItem\n\t\tif item and item.ID == item_id:\n\t\t\treturn item\n\treturn null\n\nfunc _update_item(item_id: Inventory.ItemTypes, inventory: Inventory) -> void:\n\tvar amount: = inventory.get_item_count(item_id)\n\tvar item: = get_ui_item(item_id)\n\n\tif amount > 0:\n\t\tif not item:\n\t\t\titem = _ITEM_SCENE.instantiate() as UIInventoryItem\n\t\t\titem.ID = item_id\n\t\t\titem.texture = Inventory.get_item_icon(item_id)\n\t\t\tadd_child(item)\n\n\t\titem.count = amount\n\n\telse:\n\t\tif item:\n\t\t\titem.queue_free()\n\nfunc _on_inventory_item_changed(item_type: Inventory.ItemTypes, inventory: Inventory) -> void:\n\t_update_item(item_type, inventory)\n"} {"instruction": "Erstelle eine Godot-Klasse 'GSAISeek' die von GSAISteeringBehavior erbt mit folgenden Funktionen: _init, _calculate_steering", "input": "", "output": "# Calculates an acceleration to take an agent to a target agent's position\n# directly.\n# @category - Individual behaviors\nclass_name GSAISeek\nextends GSAISteeringBehavior\n\n# The target that the behavior aims to move the agent to.\nvar target: GSAIAgentLocation\n\nfunc _init(agent: GSAISteeringAgent, _target: GSAIAgentLocation) -> void:\n\tsuper._init(agent)\n\tself.target = _target\n\nfunc _calculate_steering(acceleration: GSAITargetAcceleration) -> void:\n\tacceleration.linear = (\n\t\t(target.position - agent.position).normalized()\n\t\t* agent.linear_acceleration_max\n\t)\n\tacceleration.angular = 0\n"} {"instruction": "Erstelle eine GDScript-Funktion namens '_init':", "input": "", "output": "func _init() -> void:\n\tfor stat in _stats_list:\n\t\t_modifiers[stat] = []\n\t\t_cache[stat] = 0.0\n\n# Call this function from your node's ready function, before accessing the stats. This ensures\n# they're all loaded.\nfunc initialize() -> void:\n\t_update_all()\n\n# Get the final value of a stat, with all modifiers applied to it.\nfunc 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 = {}"} {"instruction": "Vervollständige den GDScript-Code:", "input": "## The base class responsible for AI-controlled Battlers.\n##\n## For now, this simply selects a random [BattlerAction] and picks a random target, if one is\n## available.\nclass_name CombatAI extends Node\n\n## Defines the max number of loops that the controller will search for a valid action. If no valid\n## action has been found after this number of iterations, the AI Battler will pass its turn.\nconst ITERATION_MAX: = 60\n\n\n## This controller randomly chooses an action from the Battler's [member Battler.actions] and then\n## randomly chooses a target.\nfunc select_action(source: Battler) -> void:\n\t# Keep track of how many times the controller has tried to find a valid action. In the event", "output": "\t# that the controller fails ITERATION_MAX times, it will cease searching for an action.\n\t# We do this because it is possible that the designer may create a scenario where there are\n\t# no valid actions to choose, in which case the AI would loop forever finding a valid action.\n\tvar iteration_counter = 0\n\n\tif not source.actions.is_empty():\n\t\twhile iteration_counter < ITERATION_MAX:\n\t\t\t# Randomly choose an action.\n\t\t\tvar action_index: = randi() % source.actions.size()\n\n\t\t\tvar selected_action: = source.actions[action_index]\n\t\t\tvar action: BattlerAction = selected_action.duplicate()\n\t\t\taction.battler_roster = selected_action.battler_roster\n\t\t\taction.source = selected_action.source\n\n\t\t\t# Randomly choose a target.\n\t\t\tvar possible_targets: = action.get_possible_targets()\n\t\t\tvar targets: Array[Battler] = []\n\t\t\tif action.targets_all():\n\t\t\t\ttargets = possible_targets\n\t\t\telse:\n\t\t\t\tvar target_index: = randi() % possible_targets.size()\n\t\t\t\ttargets.append(possible_targets[target_index])\n\n\t\t\t# If there are valid targets, register the action and exit the search loop.\n\t\t\tif not targets.is_empty():\n\t\t\t\taction.cached_targets = targets\n\t\t\t\tsource.cached_action = action\n\t\t\t\treturn\n\n\t\t\titeration_counter += 1\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "## An Assertion Tool to verify dictionary\n@abstract class_name GdUnitDictionaryAssert\nextends GdUnitAssert\n\n\n## Verifies that the current value is null.\n@abstract func is_null() -> GdUnitDictionaryAssert\n\n\n## Verifies that the current value is not null.\n@abstract func is_not_null() -> GdUnitDictionaryAssert\n\n\n## Verifies that the current dictionary is equal to the given one, ignoring order.\n@abstract func is_equal(expected: Variant) -> GdUnitDictionaryAssert\n\n\n## Verifies that the current dictionary is not equal to the given one, ignoring order.\n@abstract func is_not_equal(expected: Variant) -> GdUnitDictionaryAssert\n\n\n## Overrides the default failure message by given custom message.\n@abstract func override_failure_message(message: String) -> GdUnitDictionaryAssert\n\n\n## Appends a custom message to the failure message.", "output": "@abstract func append_failure_message(message: String) -> GdUnitDictionaryAssert\n\n## Verifies that the current dictionary is empty, it has a size of 0.\n@abstract func is_empty() -> GdUnitDictionaryAssert\n\n## Verifies that the current dictionary is not empty, it has a size of minimum 1.\n@abstract func is_not_empty() -> GdUnitDictionaryAssert\n\n## Verifies that the current dictionary is the same. [br]\n## Compares the current by object reference equals\n@abstract func is_same(expected: Variant) -> GdUnitDictionaryAssert\n\n## Verifies that the current dictionary is NOT the same. [br]\n## Compares the current by object reference equals\n@abstract func is_not_same(expected: Variant) -> GdUnitDictionaryAssert\n\n## Verifies that the current dictionary has a size of given value.\n@abstract func has_size(expected: int) -> GdUnitDictionaryAssert\n\n## Verifies that the current dictionary contains the given key(s).[br]\n## The keys are compared by deep parameter comparision, for object reference compare you have to use [method contains_same_keys]\n@abstract func contains_keys(...expected: Array) -> GdUnitDictionaryAssert\n\n## Verifies that the current dictionary contains the given key and value.[br]\n## The key and value are compared by deep parameter comparision, for object reference compare you have to use [method contains_same_key_value]\n@abstract func contains_key_value(key: Variant, value: Variant) -> GdUnitDictionaryAssert\n\n## Verifies that the current dictionary not contains the given key(s).[br]\n## The keys are compared by deep parameter comparision, for object reference compare you have to use [method not_contains_same_keys]\n@abstract func not_contains_keys(...expected: Array) -> GdUnitDictionaryAssert\n\n## Verifies that the current dictionary contains the given key(s).[br]\n## The keys are compared by object reference, for deep parameter comparision use [method contains_keys]\n@abstract func contains_same_keys(expected: Array) -> GdUnitDictionaryAssert\n\n## Verifies that the current dictionary contains the given key and value.[br]\n## The key and value are compared by object reference, for deep parameter comparision use [method contains_key_value]\n@abstract func contains_same_key_value(key: Variant, value: Variant) -> GdUnitDictionaryAssert\n"} {"instruction": "Erstelle eine GDScript-Funktion namens 'set_current_report_path':", "input": "", "output": "func 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": "extends Node3D\n\nsignal focus_lost\nsignal focus_gained\nsignal pose_recentered\n\n@export var maximum_refresh_rate: int = 90\n\nvar xr_interface: OpenXRInterface\nvar xr_is_focused: bool = false\n\n\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)\n\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:", "output": "\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: float = 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: float = 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# 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:\n\t\tprint(\"OpenXR lost focus\")\n\n\t\txr_is_focused = false\n\n\t\t# Pause our game.\n\t\tprocess_mode = Node.PROCESS_MODE_DISABLED\n"} {"instruction": "Erstelle eine Godot-Klasse 'MusicPlayer' die von Node erbt mit folgenden Funktionen: play, stop, is_playing, get_playing_track", "input": "", "output": "class_name MusicPlayer extends Node\n\n@onready var _anim: = $AnimationPlayer as AnimationPlayer\n@onready var _track: = $AudioStreamPlayer as AudioStreamPlayer\n\nfunc play(new_stream: AudioStream, time_in: = 0.0, time_out: = 0.0) -> void:\n\tif new_stream == _track.stream:\n\t\treturn\n\n\tif is_playing():\n\t\tif is_equal_approx(time_out, 0.0):\n\t\t\ttime_out = 0.005\n\n\t\t_anim.speed_scale = 1.0/time_out\n\t\t_anim.play(\"fade_out\")\n\t\tawait _anim.animation_finished\n\n\t\t_track.stop()\n\n\t_track.stream = new_stream\n\tif is_equal_approx(time_in, 0.0):\n\t\ttime_in = 0.005\n\n\t_track.volume_db = -50.0\n\t_track.play()\n\t_anim.speed_scale = 1.0/time_in\n\t_anim.play(\"fade_in\")\n\tawait _anim.animation_finished\n\n\t_anim.speed_scale = 1.0\n\nfunc stop(time_out: = 0.0) -> void:\n\tif is_equal_approx(time_out, 0.0):\n\t\ttime_out = 0.005\n\n\t_anim.speed_scale = 1.0/time_out\n\t_anim.play(\"fade_out\")\n\tawait _anim.animation_finished\n\n\t_track.stop()\n\t_track.stream = null\n\nfunc is_playing() -> bool:\n\treturn _track.playing\n\nfunc get_playing_track() -> AudioStream:\n\treturn _track.stream\n"} {"instruction": "Erstelle eine GDScript-Funktion namens 'format_dict':", "input": "", "output": "func format_dict(value :Variant) -> String:\n\tif not value is Dictionary:\n\t\treturn str(value)\n\n\tvar dict_value: Dictionary = value\n\tif dict_value.is_empty():\n\t\treturn \"{ }", "source": "extracted_function"} {"instruction": "Vervollständige den GDScript-Code:", "input": "extends Camera3D\n\n## If true, we are in control of positioning.\n@export var enable_positioning: bool = true:\n\tset(value):\n\t\tif enable_positioning == value:\n\t\t\treturn\n\n\t\tenable_positioning = value\n\t\tif is_inside_tree():\n\t\t\t$Area3D/CollisionShape3D.disabled = not enable_positioning\n\t\t\tif enable_positioning:\n\t\t\t\t# We just turned this on? Reset this.", "output": "\t\t\t\tglobal_transform = last_transform\n\n## Our camera should be pointed at this node.\n@export var lookat_node: Node3D\n\n@onready var last_transform: Transform3D = global_transform\n@onready var display: MeshInstance3D = $CameraBody/DisplayContainer/Display\n\n# Called when the node enters the scene tree for the first time.\nfunc _ready():\n\tvar material: ShaderMaterial = display.material_override\n\tif material:\n\t\tmaterial.set_shader_parameter(&\"albedo_texture\", get_viewport().get_texture())\n\n# Called every frame. 'delta' is the elapsed time since the previous frame.\nfunc _process(_delta):\n\tif not enable_positioning:\n\t\treturn\n\n\t# Make sure we look in the right direction.\n\tif lookat_node:\n\t\tlook_at(lookat_node.global_position, Vector3.UP, false)\n\n\t# Remember this.\n\tlast_transform = global_transform\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "## A playable combatant that carries out [BattlerActions] as its [member readiness] charges.\n##\n## Battlers are the playable characters or enemies that show up in battle. They have [BattlerStats],\n## a list of [BattlerAction]s to choose from, and respond to a variety of stimuli such as status\n## effects and [BattlerHit]s, which typically deal damage or heal the Battler.\n##\n## [br][br]Battlers have [BattlerAnim]ation children which play out the Battler's actions.\n@tool\nclass_name Battler extends Node2D\n\n## Emitted whenever the Battler caches a valid action.\nsignal action_cached\n## Emitted whenever the Battler's turn is finished. Thos should emit only after all actions and \n## animations are complete.\nsignal turn_finished\n## Forwarded from the receiving of [signal BettlerStats.health_depleted].\nsignal health_depleted\n## Emitted when taking damage or being healed from a [BattlerHit].\n## [br][br]Note the difference between this and [signal BattlerStats.health_changed]:\n## 'hit_received' is always the direct result of an action, requiring graphical feedback.\nsignal hit_received(value: int)\n## Emitted whenever a hit targeting this battler misses.\nsignal hit_missed\n## Emitted when modifying `is_selected`. The user interface will react to this for\n## player-controlled battlers.\nsignal selection_toggled(value: bool)\n\n## The name of the node group that will contain all combat Battlers.\nconst GROUP: = \"_COMBAT_BATTLER_GROUP\"\n\n## A Battler must have [BattlerStats] to act and receive actions.\n@export var stats: BattlerStats = null\n## Each action's data stored in this array represents an action the battler can perform.\n## These can be anything: attacks, healing spells, etc.\n\n@export var actions: Array[BattlerAction]\n\n## Each Battler is shown on the screen by a [BattlerAnim] object. The object is created dynamically\n## from a PackedScene, which must yield a [BattlerAnim] object when instantiated.\n@export var battler_anim_scene: PackedScene:\n\tset(value):\n\t\tbattler_anim_scene = value\n\n\t\tif not is_inside_tree():\n\t\t\tawait ready\n\n\t\t# Free an already existing BattlerAnim.\n\t\tif anim:\n\t\t\tanim.queue_free()\n\t\t\tanim = null\n\n\t\t# Add the new BattlerAnim class as a child and link it to this Battler instance.\n\t\tif battler_anim_scene:\n\t\t\t# Normally we could wrap a check for battler_anim_scene's type (should be BattlerAnim)\n\t\t\t# in a call to assert, but we want the following code to run in the editor and clean up\n\t\t\t# dynamically if the user drops an incorrect PackedScene (i.e. not a BattlerAnim) into\n\t\t\t# the battler_anim_scene slot.\n\t\t\tvar new_scene: = battler_anim_scene.instantiate()\n\t\t\tanim = new_scene as BattlerAnim\n\t\t\tif not anim:\n\t\t\t\tpush_warning(\"Battler '%s' cannot accept '%s' as \" % [name, new_scene.name],\n\t\t\t\t\t\"battler_anim_scene. '%s' is not a BattlerAnim!\" % new_scene.name)\n\t\t\t\tnew_scene.free()\n\t\t\t\tbattler_anim_scene = null\n\t\t\t\treturn\n\n\t\t\tadd_child(anim)\n\t\t\tvar facing: = BattlerAnim.Direction.LEFT if is_player else BattlerAnim.Direction.RIGHT\n\t\t\tanim.setup(self, facing)\n\n## A CombatAI object that will determine the Battler's combat behaviour.\n## If the battler has an `ai_scene`, we will instantiate it and let the AI make decisions.", "output": "## If not, the player controls this battler. The system should allow for ally AIs.\n@export var ai_scene: PackedScene:\n\tset(value):\n\t\tai_scene = value\n\n\t\tif ai_scene != null:\n\t\t\t# In the editor, check to make sure that the value set to ai_scene is actually a\n\t\t\t# CombatAI bject.\n\t\t\tvar new_instance: = ai_scene.instantiate()\n\t\t\tif Engine.is_editor_hint():\n\t\t\t\tif new_instance is not CombatAI:\n\t\t\t\t\tprinterr(\"Cannot assign '%s' to Battler '%s'\" % [new_instance.name, self.name] +\n\t\t\t\t\t\t\" as ai_scene property. Assigned PackedScene is not a CombatAI type!\")\n\t\t\t\t\tai_scene = null\n\t\t\t\tnew_instance.free()\n\n\t\t\telse:\n\t\t\t\tai = new_instance\n\t\t\t\tadd_child(ai)\n\n## If this is [b]true[/b], this actor is controlled by the player. Use this to\n## differentiate between player-controlled actors and AI-controlled ones.\n## [/n][/n] Note that player Battlers may be controlled by an AI controller, but enemy Battlers may\n## not be controlled by the player.\n@export var is_player: = false:\n\tset(value):\n\t\tis_player = value\n\t\tif anim:\n\t\t\tvar facing: = BattlerAnim.Direction.LEFT if is_player else BattlerAnim.Direction.RIGHT\n\t\t\tanim.direction = facing\n\n## Reference to this Battler's child [CombatAI] node, if applicable.\nvar ai: CombatAI = null\n\n## Reference to this Battler's child [BattlerAnim] node.\nvar anim: BattlerAnim = null\n\n## If this is [b]true[/b], this Battler can take turns.\nvar is_active: bool = true:\n\tset(value):\n\t\tis_active = value\n\n\t\tset_process(is_active)\n\n## If `true`, the battler is selected, which makes it move forward.\nvar is_selected: bool = false:\n\tset(value):\n\t\tif value:\n\t\t\tassert(is_selectable)\n"} {"instruction": "Erstelle eine Godot-Klasse 'GdUnitValueExtractor' die von RefCounted erbt mit folgenden Funktionen: extract_value", "input": "", "output": "## This is the base interface for value extraction\nclass_name GdUnitValueExtractor\nextends RefCounted\n\n## Extracts a value by given implementation\nfunc extract_value(value :Variant) -> Variant:\n\tpush_error(\"Uninplemented func 'extract_value'\")\n\treturn value\n"} {"instruction": "Erstelle eine GDScript-Funktion namens '_init':", "input": "", "output": "func _init() -> void:\n\tadd_to_group(\"state_machine\")\n\nfunc _ready() -> void:\n\tawait owner.ready\n\tstate.enter()\n\nfunc _unhandled_input(event: InputEvent) -> void:\n\tstate.unhandled_input(event)\n\nfunc _physics_process(delta: float) -> void:\n\tstate.physics_process(delta)\n\nfunc transition_to(target_state_path: String, msg: Dictionary = {}", "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 = {}", "source": "extracted_function"} {"instruction": "Vervollständige den GDScript-Code:", "input": "extends Node3D\n\n## The position of this node will be updated if a camera tracker is available.\n@export var tracked_camera : Node3D:\n\tset(value):\n\t\ttracked_camera = value\n\t\tif tracked_camera:\n\t\t\t%CameraRemoteTransform3D.remote_path = tracked_camera.get_path()\n\t\telse:\n\t\t\t%CameraRemoteTransform3D.remote_path = NodePath()\n\n# Enable the left or right pointer?\nvar left_or_right: int = 1", "output": "\n# Enable the pointer on the last controller we pressed a button on.\nfunc _enable_pointer():\n\t$XROrigin3D/LeftHandAim/XRPointer.enabled = left_or_right == 0\n\t$XROrigin3D/RightHandAim/XRPointer.enabled = left_or_right == 1\n\n# Called when the node enters the scene tree for the first time.\nfunc _ready():\n\t_enable_pointer()\n\n# We pressed a button on our left hand.\nfunc _on_left_hand_aim_button_pressed(_name):\n\t# Toggle to left hand.\n\tif left_or_right != 0:\n\t\tleft_or_right = 0\n\t\t_enable_pointer()\n\n# We pressed a button on our right hand.\nfunc _on_right_hand_aim_button_pressed(_name):\n\t# Toggle to right hand.\n\tif left_or_right != 1:\n\t\tleft_or_right = 1\n\t\t_enable_pointer()\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "## An Assertion Tool to verify Object values\n@abstract class_name GdUnitObjectAssert\nextends GdUnitAssert\n\n\n## Verifies that the current value is null.\n@abstract func is_null() -> GdUnitObjectAssert\n\n\n## Verifies that the current value is not null.\n@abstract func is_not_null() -> GdUnitObjectAssert\n\n\n## Verifies that the current value is equal to the given one.\n@abstract func is_equal(expected: Variant) -> GdUnitObjectAssert\n\n", "output": "## Verifies that the current value is not equal to expected one.\n@abstract func is_not_equal(expected: Variant) -> GdUnitObjectAssert\n\n## Overrides the default failure message by given custom message.\n@abstract func override_failure_message(message: String) -> GdUnitObjectAssert\n\n## Appends a custom message to the failure message.\n@abstract func append_failure_message(message: String) -> GdUnitObjectAssert\n\n## Verifies that the current object is the same as the given one.\n@abstract func is_same(expected: Variant) -> GdUnitObjectAssert\n\n## Verifies that the current object is not the same as the given one.\n@abstract func is_not_same(expected: Variant) -> GdUnitObjectAssert\n\n## Verifies that the current object is an instance of the given type.\n@abstract func is_instanceof(type: Variant) -> GdUnitObjectAssert\n\n## Verifies that the current object is not an instance of the given type.\n@abstract func is_not_instanceof(type: Variant) -> GdUnitObjectAssert\n\n## Checks whether the current object inherits from the specified type.\n@abstract func is_inheriting(type: Variant) -> GdUnitObjectAssert\n\n## Checks whether the current object does NOT inherit from the specified type.\n@abstract func is_not_inheriting(type: Variant) -> GdUnitObjectAssert\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "## A variation of [TileMapLayer] that is used to create the [Gameboard].\n##\n## Comes setup with a few tools used by designers to setup maps, specifying which cells may be\n## moved to or from. Multiple GameboardLayers may exist simultaneously to allow developers to\n## affect the gameboard with more than one layer.\n##\n## These collision layers may also dynamically change, with the changes being reflected\n## by the gameboard and pathfinder.\nclass_name GameboardLayer extends TileMapLayer\n\n## Emitted whenever the collision state of the tile map changes.\n##\n## The GameboardLayer's tile map may change without changing which cells are blocked or\n## are open for movement. In this case, the signal is not emitted. However, it is emitted whenever\n## the map is added or removed from the game, in addition to when there is a change in blocked/clear\n## cells.\nsignal cells_changed(cleared_cells: Array[Vector2i], blocked_cells: Array[Vector2i])\n\n## The group name of all [GameboardLayer] that will be checked for blocked/walkable cells.\nconst GROUP: = \"GameboardTileMapLayers\"\n\n## The name of the \"custom data layer\" that determines whether or not a cell is blocked/walkable.\n## The returned value will be a boolean reflecting if a cell is blocked or not. Fetches the value\n## via [method TileData.get_custom_data].\n##\n## If the data layer is not present in the [Tileset], then all cells in this [TileMapLayer] will,\n## by default, block movement.\nconst BLOCKED_CELL_DATA_LAYER: = \"IsCellBlocked\"\n\n# A false value will cause is_cell_clear to always return true. This is used to flag when the", "output": "# TileMapLayers is being cleaned up an should no longer affect the pathfinder.\nvar _affects_collision: = true\n\nfunc _ready() -> void:\n\tadd_to_group(GROUP)\n\tGameboard.register_gameboard_layer(self)\n\n\ttree_exiting.connect(\n\t\tfunc _on_tree_exiting() -> void:\n\t\t\t_affects_collision = false\n\n\t\t\tvar blocked_cells: Array[Vector2i] = []\n\t\t\tcells_changed.emit(get_used_cells(), blocked_cells)\n\t)\n\n## Returns true if the tile at coord exists and does not have a custom blocking data layer with a\n## value set to true.\n## Otherwise, returns false.\nfunc is_cell_clear(coord: Vector2i) -> bool:\n\tif not _affects_collision:\n\t\treturn true\n\n\tvar tile_data: = get_cell_tile_data(coord)\n\tif tile_data:\n\t\tvar is_cell_blocked: = tile_data.get_custom_data(BLOCKED_CELL_DATA_LAYER) as bool\n\t\treturn not is_cell_blocked\n\n\t# If the above conditions have not been met, the cell is blocked.\n\treturn false\n\n# See [method TileMapLayer._update_cells]; called whenever the cells change. This allows designers\n# to change maps on the fly and the collision state of the pathfinder should update. The coords\n# parameter lets us know which cells have changed. Also, the method is called as the TileMapLayer\n# is added to the scene.\n# Note that if forced_cleanup is true, the TileMapLayer is in a state where its tiles should not\n# affect collision. The conditions causing forced_cleanup are handled seperately through signals\n# found in _ready().\nfunc _update_cells(coords: Array[Vector2i], forced_cleanup: bool) -> void:\n\t# First of all, check to make sure the the tilemap has a tileset and the specific custom data\n\t# layer that we need to specify whether or not a tile blocks movement.\n\tif not tile_set or not tile_set.has_custom_data_layer_by_name(BLOCKED_CELL_DATA_LAYER):\n\t\treturn\n\n\t# Go through the specified coords, checking to see if any moveable cells (those that are NOT\n\t# blocked) have been added or removed.\n\tvar cleared_cells: Array[Vector2i] = []\n\tvar blocked_cells: Array[Vector2i] = []"} {"instruction": "Vervollständige den GDScript-Code:", "input": "extends Area3D\n\n@export var interaction_action: String = \"interact\"\n\nvar _parent_camera: Camera3D\nvar _current_pointer: XRPointer\nvar _controller: XRController3D\nvar _was_pos: Vector3\n\n# Find the XRController3D ancester of the given node.\nfunc _get_controller(node: Node3D) -> XRController3D:\n\tvar parent = node.get_parent()\n\twhile parent:\n\t\tif parent is XRController3D:\n\t\t\treturn parent\n\t\tparent = parent.get_parent()\n\treturn null\n\n\n# Called when the node enters the scene tree for the first time.\nfunc _ready():\n\t_parent_camera = get_parent()\n\n", "output": "# Called every frame. 'delta' is the elapsed time since the previous frame.\nfunc _process(_delta):\n\tif not _parent_camera:\n\t\treturn\n\n\t# If we don't have a controller, let's see if we can find one!\n\tif not _controller:\n\t\t# If nothing is pointing at us, we have nothing to do!\n\t\tif not _current_pointer:\n\t\t\treturn\n\n\t\t# Find our related controller.\n\t\tvar controller = _get_controller(_current_pointer)\n\t\tif controller:\n\t\t\tif not controller.is_button_pressed(interaction_action):\n\t\t\t\treturn\n\n\t\t\t# We \"capture\" this controller, even if the pointer leaves\n\t\t\t# we keep using this controller until the user releases the button.\n\t\t\t_controller = controller\n\n\t\t\tvar plane: Plane = Plane(global_basis.z, global_position)\n\t\t\t_was_pos = plane.intersects_ray(_controller.global_position, -_controller.global_basis.z)\n\telse:\n\t\tif not _controller.is_button_pressed(interaction_action):\n\t\t\t_controller = null\n\t\t\treturn\n\n\t\tvar plane: Plane = Plane(global_basis.z, global_position)\n\t\tvar new_pos = plane.intersects_ray(_controller.global_position, -_controller.global_basis.z)\n\n\t\tvar movement = new_pos - _was_pos\n\t\t_was_pos = new_pos\n\n\t\tmovement = global_basis.inverse() * movement\n\t\tmovement *= Vector3(1.0, 1.0, 0.0)\n\t\t_parent_camera.global_position += global_basis * movement\n\n# A pointer is touching our area.\nfunc _enter_pointer(pointer: XRPointer, _at: Vector3) -> void:\n\t_current_pointer = pointer\n\n# A pointer is no longer touching our area.\nfunc _exit_pointer(pointer: XRPointer, _at: Vector3) -> void:\n\tif _current_pointer == pointer:\n\t\t_current_pointer = null\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "class_name GdUnitAssertImpl\nextends GdUnitAssert\n\n\nvar _current :Variant\nvar _current_failure_message :String = \"\"\nvar _custom_failure_message :String = \"\"\nvar _additional_failure_message: String = \"\"\n\n\nfunc _init(current :Variant) -> void:\n\t_current = current\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\n\n\nfunc failure_message() -> String:\n\treturn _current_failure_message\n\n\nfunc current_value() -> Variant:\n\treturn _current\n\n\nfunc report_success() -> GdUnitAssert:", "output": "\tGdAssertReports.report_success()\n\treturn self\n\nfunc report_error(failure :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\tGdAssertReports.set_last_error_line_number(line_number)\n\t_current_failure_message = GdAssertMessages.build_failure_message(failure, _additional_failure_message, _custom_failure_message)\n\tGdAssertReports.report_error(_current_failure_message, line_number)\n\tEngine.set_meta(\"GD_TEST_FAILURE\", true)\n\treturn self\n\nfunc do_fail() -> GdUnitAssert:\n\treturn report_error(GdAssertMessages.error_not_implemented())\n\nfunc override_failure_message(message: String) -> GdUnitAssert:\n\t_custom_failure_message = message\n\treturn self\n\nfunc append_failure_message(message: String) -> GdUnitAssert:\n\t_additional_failure_message = message\n\treturn self\n\nfunc is_null() -> GdUnitAssert:\n\tvar current :Variant = current_value()\n\tif current != null:\n\t\treturn report_error(GdAssertMessages.error_is_null(current))\n\treturn report_success()\n\nfunc is_not_null() -> GdUnitAssert:\n\tvar current :Variant = current_value()\n\tif current == null:\n\t\treturn report_error(GdAssertMessages.error_is_not_null())\n\treturn report_success()\n\nfunc is_equal(expected: Variant) -> GdUnitAssert:\n\tvar current: Variant = current_value()\n\tif not GdObjects.equals(current, expected):\n\t\treturn report_error(GdAssertMessages.error_equal(current, expected))\n\treturn report_success()\n\nfunc is_not_equal(expected: Variant) -> GdUnitAssert:\n\tvar current: Variant = current_value()"} {"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#* agent_base.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 CharacterBody2D\n## Base agent script that is shared by all agents.\n\nsignal death\n\n# Resource file to use in summon_minion() method.\nconst MINION_RESOURCE := \"res://demo/agents/03_agent_imp.tscn\"\n\n# Projectile resource.\nconst NinjaStar := preload(\"res://demo/agents/ninja_star/ninja_star.tscn\")\nconst Fireball := preload(\"res://demo/agents/fireball/fireball.tscn\")\n\nvar summon_count: int = 0\n\nvar _frames_since_facing_update: int = 0\nvar _is_dead: bool = false\nvar _moved_this_frame: bool = false\n\n@onready var animation_player: AnimationPlayer = $AnimationPlayer\n@onready var health: Health = $Health\n@onready var root: Node2D = $Root\n@onready var collision_shape_2d: CollisionShape2D = $CollisionShape2D\n@onready var summoning_effect: GPUParticles2D = $FX/Summoned\n\n\nfunc _ready() -> void:\n\thealth.damaged.connect(_damaged)\n\thealth.death.connect(die)\n\n\nfunc _physics_process(_delta: float) -> void:\n\t_post_physics_process.call_deferred()\n\n\nfunc _post_physics_process() -> void:\n\tif not _moved_this_frame:\n\t\tvelocity = lerp(velocity, Vector2.ZERO, 0.5)\n\t_moved_this_frame = false\n\n\nfunc move(p_velocity: Vector2) -> void:\n\tvelocity = lerp(velocity, p_velocity, 0.2)\n\tmove_and_slide()\n\t_moved_this_frame = true", "output": "\n## Update agent's facing in the velocity direction.\nfunc update_facing() -> void:\n\t_frames_since_facing_update += 1\n\tif _frames_since_facing_update > 3:\n\t\tface_dir(velocity.x)\n\n## Face specified direction.\nfunc face_dir(dir: float) -> void:\n\tif dir > 0.0 and root.scale.x < 0.0:\n\t\troot.scale.x = 1.0;\n\t\t_frames_since_facing_update = 0\n\tif dir < 0.0 and root.scale.x > 0.0:\n\t\troot.scale.x = -1.0;\n\t\t_frames_since_facing_update = 0\n\n## Returns 1.0 when agent is facing right.\n## Returns -1.0 when agent is facing left.\nfunc get_facing() -> float:\n\treturn signf(root.scale.x)\n\nfunc throw_ninja_star() -> void:\n\tvar ninja_star := NinjaStar.instantiate()\n\tninja_star.dir = get_facing()\n\tget_parent().add_child(ninja_star)\n\tninja_star.global_position = global_position + Vector2.RIGHT * 100.0 * get_facing()\n\nfunc spit_fire() -> void:\n\tvar fireball := Fireball.instantiate()\n\tfireball.dir = get_facing()\n\tget_parent().add_child(fireball)\n\tfireball.global_position = global_position + Vector2.RIGHT * 100.0 * get_facing()\n\nfunc summon_minion(p_position: Vector2) -> void:\n\tvar minion: CharacterBody2D = load(MINION_RESOURCE).instantiate()\n\tget_parent().add_child(minion)\n\tminion.position = p_position\n\tminion.play_summoning_effect()\n\tsummon_count += 1\n\tminion.death.connect(func(): summon_count -= 1)\n\n## Method is used when this agent is summoned from the dungeons of the castle AaaAaaAAAAAaaAAaaaaaa\nfunc play_summoning_effect() -> void:\n\tsummoning_effect.emitting = true\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 GDScript-Funktion namens 'get_cell_under_node':", "input": "", "output": "func get_cell_under_node(node: Node2D) -> Vector2i:\n\treturn pixel_to_cell(node.global_position/node.global_scale)\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\n\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)\n\t\tvar removed_cells: = _remove_cells_from_pathfinder(blocked_cells)\n\n\t\t_connect_new_pathfinder_cells(added_cells)\n\t\tif not added_cells.is_empty() or not removed_cells.is_empty():\n\t\t\tpathfinder_changed.emit(added_cells.values(), removed_cells)\n\t)\n\n# Add cells to the pathfinder, checking that there are no blocking tiles on any GameboardLayers.\n# Returns a dictionary representing the cells that are actually added to the pathfinder (may differ\n# from cleared_cells). Key = cell id (int, see cell_to_index), value = coordinate (Vector2i)\nfunc _add_cells_to_pathfinder(cleared_cells: Array[Vector2i]) -> Dictionary[int, Vector2i]:\n\tvar added_cells: Dictionary[int, Vector2i] = {}"} {"instruction": "Vervollständige den GDScript-Code:", "input": "extends XROrigin3D\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 character_body : CharacterBody3D = $CharacterBody3D\n@onready var camera_node : XRCamera3D = $XRCamera3D\n@onready var neck_position_node : Node3D = $XRCamera3D/Neck\n@onready var black_out : Node3D = $XRCamera3D/BlackOut\n\n## Called when the user has requested their view to be recentered.\nfunc recenter() -> void:\n\t# The code here assumes the player has walked into an area they shouldn't be\n\t# and we return the player back to the character body.\n\t# But other strategies can be applied here as well such as returning the player\n\t# to a starting position or a checkpoint.\n\n\t# Calculate where our camera should be, we start with our global transform.\n\tvar new_camera_transform: Transform3D = character_body.global_transform\n\n\t# Set to the height of our neck joint.\n\tnew_camera_transform.origin.y = neck_position_node.global_position.y\n\n\t# Apply transform our our next position to get our desired camera transform.\n\tnew_camera_transform = new_camera_transform * neck_position_node.transform.inverse()\n\n\t# Remove tilt from camera transform.\n\tvar camera_transform: Transform3D = camera_node.transform\n\tvar forward_dir: Vector3 = camera_transform.basis.z\n\tforward_dir.y = 0.0\n\tcamera_transform = camera_transform.looking_at(camera_transform.origin + forward_dir.normalized(), Vector3.UP, true)\n\n\t# Update our XR location.\n\tglobal_transform = new_camera_transform * camera_transform.inverse()\n\n\t# Recenter character body.\n\tcharacter_body.transform = Transform3D()\n\n\n# `_get_movement_input()` returns our move input by querying the move action on each controller.\nfunc _get_movement_input() -> Vector2:\n\tvar movement : Vector2 = Vector2()\n\n\t# If move is not bound to one of our controllers,\n\t# that controller will return `Vector2.ZERO`.\n\tmovement += $LeftHand.get_vector2(&\"move\")\n\tmovement += $RightHand.get_vector2(&\"move\")\n", "output": "\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 := character_body.velocity\n\n\t# Remember where our player body currently is.\n\tvar org_player_body: Vector3 = character_body.global_transform.origin\n\n\t# Determine where our player body should be.\n\tvar player_body_location: Vector3 = 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\t# Attempt to move our character.\n\tcharacter_body.velocity = (player_body_location - org_player_body) / delta\n\tcharacter_body.move_and_slide()\n\n\t# Set back to our current value.\n\tcharacter_body.velocity = current_velocity\n\n\t# Check if we managed to move all the way, ignoring height change.\n\tvar movement_left := player_body_location - character_body.global_transform.origin\n\tmovement_left.y = 0.0\n\n\t# Check if we managed to move where we wanted to.\n\tvar location_offset := movement_left.length()\n\tif location_offset > 0.1:\n\t\t# We couldn't go where we wanted to, black out our screen.\n\t\tblack_out.fade = clamp((location_offset - 0.1) / 0.1, 0.0, 1.0)\n\n\t\treturn true\n\telse:\n\t\tblack_out.fade = 0.0\n\t\treturn false\n\nfunc _copy_player_rotation_to_character_body() -> void:\n\t# We only copy our forward direction to our character body, we ignore tilt.\n\tvar camera_forward := -camera_node.global_transform.basis.z\n\tvar body_forward := Vector3(camera_forward.x, 0.0, camera_forward.z)\n\n\tcharacter_body.global_transform.basis = Basis.looking_at(body_forward, Vector3.UP)\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "extends Node3D\n\nsignal focus_lost\nsignal focus_gained\nsignal pose_recentered\n\n@export var maximum_refresh_rate: int = 90\n\nvar xr_interface: OpenXRInterface\nvar xr_is_focused: bool = false\n\n\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)\n\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:", "output": "\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: float = 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: float = 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# 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:\n\t\tprint(\"OpenXR lost focus\")\n\n\t\txr_is_focused = false\n\n\t\t# Pause our game.\n\t\tprocess_mode = Node.PROCESS_MODE_DISABLED\n"} {"instruction": "Erstelle eine Godot-Klasse 'GSAIEvade' die von GSAIPursue erbt mit folgenden Funktionen: _init, _get_modified_acceleration", "input": "", "output": "# Calculates acceleration to take an agent away from where a target agent is\n# moving.\n# @category - Individual behaviors\nclass_name GSAIEvade\nextends GSAIPursue\n\nfunc _init(agent: GSAISteeringAgent, target: GSAISteeringAgent, predict_time_max := 1.0):\n\tsuper._init(agent, target, predict_time_max)\n\nfunc _get_modified_acceleration() -> float:\n\treturn -agent.linear_acceleration_max\n"} {"instruction": "Erstelle eine GDScript-Funktion namens '_process':", "input": "", "output": "func _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 GDScript-Funktion namens 'physics_process':", "input": "", "output": "func physics_process(_delta: float) -> void:\n\tpass\n\nfunc enter(_msg: Dictionary = {}"} {"instruction": "Vervollständige den GDScript-Code:", "input": "extends Control\n\n# A standard piano with 88 keys has keys from 21 to 108.\n# To get a different set of keys, modify these numbers.\n# A maximally extended 108-key piano goes from 12 to 119.\n# A 76-key piano goes from 23 to 98, 61-key from 36 to 96,\n# 49-key from 36 to 84, 37-key from 41 to 77, and 25-key\n# from 48 to 72. Middle C is pitch number 60, A440 is 69.\nconst START_KEY = 21\nconst END_KEY = 108\n\nconst WhiteKeyScene := preload(\"res://piano_keys/white_piano_key.tscn\")\nconst BlackKeyScene := preload(\"res://piano_keys/black_piano_key.tscn\")\n\nvar piano_key_dict := Dictionary()\n\n@onready var white_keys: HBoxContainer = $WhiteKeys\n@onready var black_keys: HBoxContainer = $BlackKeys\n\nfunc _ready() -> void:\n\tassert(not _is_note_index_sharp(_pitch_index_to_note_index(START_KEY)), \"The start key can't be a sharp note (limitation of this piano-generating algorithm). Try 21.\")\n\n\tfor i in range(START_KEY, END_KEY + 1):\n\t\tpiano_key_dict[i] = _create_piano_key(i)\n\n\tif white_keys.get_child_count() != black_keys.get_child_count():\n\t\t_add_placeholder_key(black_keys)\n\n\tOS.open_midi_inputs()\n\n\tif not OS.get_connected_midi_inputs().is_empty():\n\t\tprint(OS.get_connected_midi_inputs())\n", "output": "\nfunc _input(input_event: InputEvent) -> void:\n\tif input_event is not InputEventMIDI:\n\t\treturn\n\n\tvar midi_event: InputEventMIDI = input_event\n\tif midi_event.pitch < START_KEY or midi_event.pitch > END_KEY:\n\t\t# The given pitch isn't on the on-screen keyboard, so return.\n\t\treturn\n\n\t_print_midi_info(midi_event)\n\tvar key: PianoKey = piano_key_dict[midi_event.pitch]\n\tif midi_event.message == MIDI_MESSAGE_NOTE_ON:\n\t\tkey.activate()\n\telse:\n\t\tkey.deactivate()\n\nfunc _add_placeholder_key(container: HBoxContainer) -> void:\n\tvar placeholder := Control.new()\n\tplaceholder.size_flags_horizontal = SIZE_EXPAND_FILL\n\tplaceholder.mouse_filter = Control.MOUSE_FILTER_IGNORE\n\tplaceholder.name = &\"Placeholder\"\n\tcontainer.add_child(placeholder)\n\nfunc _create_piano_key(pitch_index: int) -> PianoKey:\n\tvar note_index := _pitch_index_to_note_index(pitch_index)\n\tvar piano_key: PianoKey\n\tif _is_note_index_sharp(note_index):\n\t\tpiano_key = BlackKeyScene.instantiate()\n\t\tblack_keys.add_child(piano_key)\n\telse:\n\t\tpiano_key = WhiteKeyScene.instantiate()\n\t\twhite_keys.add_child(piano_key)\n\t\tif _is_note_index_lacking_sharp(note_index):\n\t\t\t_add_placeholder_key(black_keys)\n\tpiano_key.setup(pitch_index)\n\treturn piano_key\n\nfunc _is_note_index_lacking_sharp(note_index: int) -> bool:\n\t# B and E, because no B# or E#\n\treturn note_index in [2, 7]\n\nfunc _is_note_index_sharp(note_index: int) -> bool:\n\t# A#, C#, D#, F#, and G#\n\treturn note_index in [1, 4, 6, 9, 11]\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "#*\n#* move_forward.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## Applies velocity in the direction the agent is facing on each tick", "output": "## until the [member duration] is exceeded. [br]\n## Returns [code]SUCCESS[/code] if the elapsed time exceeds [member duration]. [br]\n## Returns [code]RUNNING[/code] if the elapsed time does not exceed [member duration]. [br]\n\n## Blackboard variable that stores desired speed.\n@export var speed_var: StringName = &\"speed\"\n\n## How long to perform this task (in seconds).\n@export var duration: float = 0.1\n\n# Display a customized name (requires @tool).\nfunc _generate_name() -> String:\n\treturn \"MoveForward speed: %s duration: %ss\" % [\n\t\tLimboUtility.decorate_var(speed_var),\n\t\tduration]\n\n# Called each time this task is ticked (aka executed).\nfunc _tick(_delta: float) -> Status:\n\tvar facing: float = agent.get_facing()\n\tvar speed: float = blackboard.get_var(speed_var, 100.0)\n\tvar desired_velocity: Vector2 = Vector2.RIGHT * facing * speed\n\tagent.move(desired_velocity)\n\tagent.update_facing()\n\tif elapsed_time > duration:\n\t\treturn SUCCESS\n\treturn RUNNING\n"} {"instruction": "Erstelle eine GDScript-Funktion namens '_init':", "input": "", "output": "func _init():\n\tname = \"BeehavePlugin\"\n\tadd_autoload_singleton(\"BeehaveGlobalMetrics\", \"metrics/beehave_global_metrics.gd\")\n\tadd_autoload_singleton(\"BeehaveGlobalDebugger\", \"debug/global_debugger.gd\")\n\n\t# Add project settings\n\tif not ProjectSettings.has_setting(\"beehave/debugger/start_detached\"):\n\t\tProjectSettings.set_setting(\"beehave/debugger/start_detached\", false)\n\t\tProjectSettings.set_initial_value(\"beehave/debugger/start_detached\", false)\n\t\tProjectSettings.add_property_info({\n\t\t\t\"name\": \"beehave/debugger/start_detached\",\n\t\t\t\"type\": TYPE_BOOL,\n\t\t\t\"hint\": PROPERTY_HINT_NONE,\n\t\t\t\"hint_string\": \"If enabled, the debugger will start in a separate window\"\n\t\t}", "source": "extracted_function"} {"instruction": "Vervollständige den GDScript-Code:", "input": "@tool\n## An [InteractionPopup] that follows a moving [Gamepiece].\n##\n## This [code]Popup[/code] must be a child of a [Gamepiece] to function.\n##\n## Note that other popup types will jump to the occupied cell of the ancestor [Gamepiece], whereas\n## MovingInteractionPopups sync their position to that of the gamepiece's graphical representation.\nextends InteractionPopup\n\n@onready var _gp: = get_parent() as Gamepiece\n\n", "output": "func _ready() -> void:\n\tsuper._ready()\n\n\t# Do not follow anything in editor or if this object's parent is not of the correct type.\n\tif Engine.is_editor_hint() or not _gp:\n\t\tset_process(false)\n\nfunc _get_configuration_warnings() -> PackedStringArray:\n\tif not _gp:\n\t\treturn [\"This popup must be a child of a Gamepiece node!\"]\n\treturn []\n\nfunc _notification(what: int) -> void:\n\tif what == NOTIFICATION_PARENTED:\n\t\t_gp = get_parent() as Gamepiece\n\t\tupdate_configuration_warnings()\n\n# Every process frame the popup sets its position to that of the graphical representation of the\n# gamepiece, appearing to follow the gamepiece around the field while still playing nicely with the\n# physics/interaction system.\nfunc _process(_delta: float) -> void:\n\tposition = _gp.follower.position\n"} {"instruction": "Erstelle eine Godot-Klasse 'BattlerAnim' die von Marker2D erbt mit folgenden Funktionen: _ready, _on_animation_player_finished, setup, _on_battler_health_depleted, _on_battler_hit_received", "input": "", "output": "## The visual representation of a [Battler].\n##\n## Battler animations respond visually to a closed set of stimiuli, such as receiving a hit or\n## moving to a position. These animations often represent a single character or a class of enemies\n## and are added as children to a given Battler.\n##\n## [br][br]Note: BattlerAnims must be children of a Battler object to function correctly!\n@tool\nclass_name BattlerAnim extends Marker2D\n\n## Dictates how far the battler moves forwards and backwards at the beginning/end of its turn.\nconst MOVE_OFFSET: = 140.0\n\n## Determines which direction the battler faces on the screen.\nenum Direction { LEFT, RIGHT }\n\n## Emitted whenever an action-based animation wants to apply an effect. May be triggered multiple\n## times per animation.\n@warning_ignore(\"unused_signal\")\nsignal action_triggered\n\n## Forward AnimationPlayer's same signal.\nsignal animation_finished(name)\n\n## An icon that shows up on the turn bar.\n@export var battler_icon: Texture\n\n## Determines which direction the [BattlerAnim] faces. This is generally set by whichever \"side\"\n## the battler is on, player or enemy.\n@export var direction: = Direction.RIGHT:\n\tset(value):\n\t\tdirection = value\n\n\t\tscale.x = 1\n\t\tif direction == Direction.LEFT:\n\t\t\tscale.x = -1\n\n## Determines the time it takes for the [BattlerAnim] to slide forward or backward when its turn\n## comes up.\n@export var select_move_time: = 0.3\n\nvar _move_tween: Tween = null\nvar _rest_position: = Vector2.ZERO\n\n@onready var front: = $FrontAnchor as Marker2D\n@onready var top: = $TopAnchor as Marker2D\n\n@onready var _anim: = $Pivot/AnimationPlayer as AnimationPlayer\n\nfunc _ready() -> void:\n\t_anim.animation_finished.connect(\n\t\tfunc _on_animation_player_finished(anim_name: String) -> void:\n\t\t\tanimation_finished.emit(anim_name)\n\t)\n\n\t_rest_position = position\n\n## Setup the BattlerAnim object to respond to gameplay signals from a [Battler] class.\nfunc setup(battler: Battler, facing: Direction) -> void:\n\t# BattlerAnim objects are ass"} {"instruction": "Erstelle eine Godot-Klasse 'Battler' die von Node2D erbt mit folgenden Funktionen: sort, _ready, on_stats_health_depleted, act, take_hit", "input": "", "output": "## A playable combatant that carries out [BattlerActions] as its [member readiness] charges.\n##\n## Battlers are the playable characters or enemies that show up in battle. They have [BattlerStats],\n## a list of [BattlerAction]s to choose from, and respond to a variety of stimuli such as status\n## effects and [BattlerHit]s, which typically deal damage or heal the Battler.\n##\n## [br][br]Battlers have [BattlerAnim]ation children which play out the Battler's actions.\n@tool\nclass_name Battler extends Node2D\n\n## Emitted whenever the Battler caches a valid action.\nsignal action_cached\n## Emitted whenever the Battler's turn is finished. Thos should emit only after all actions and\n## animations are complete.\nsignal turn_finished\n## Forwarded from the receiving of [signal BettlerStats.health_depleted].\nsignal health_depleted\n## Emitted when taking damage or being healed from a [BattlerHit].\n## [br][br]Note the difference between this and [signal BattlerStats.health_changed]:\n## 'hit_received' is always the direct result of an action, requiring graphical feedback.\nsignal hit_received(value: int)\n## Emitted whenever a hit targeting this battler misses.\nsignal hit_missed\n## Emitted when modifying `is_selected`. The user interface will react to this for\n## player-controlled battlers.\nsignal selection_toggled(value: bool)\n\n## The name of the node group that will contain all combat Battlers.\nconst GROUP: = \"_COMBAT_BATTLER_GROUP\"\n\n## A Battler must have [BattlerStats] to act and receive actions.\n@export var stats: BattlerStats = null\n## Each action's data stored in this array represents an action the battler can perform.\n## These can be anything: attacks, healing spells, etc.\n\n@export var actions: Array[BattlerAction]\n\n## Each Battler is shown on the screen by a [BattlerAnim] object. The object is created dynamically\n## from a PackedScene, which must yield a [BattlerAnim] object when instantiated.\n@export var battler_anim_scene: PackedScene:\n\tset(value):\n\t\tbattler_anim_scene = valu"} {"instruction": "Erstelle eine Godot-Klasse 'GdUnitResultAssert' die von GdUnitAssert erbt mit folgenden Funktionen: is_null, is_not_null, is_equal, is_not_equal, override_failure_message", "input": "", "output": "## An Assertion Tool to verify Results\n@abstract class_name GdUnitResultAssert\nextends GdUnitAssert\n\n## Verifies that the current value is null.\n@abstract func is_null() -> GdUnitResultAssert\n\n## Verifies that the current value is not null.\n@abstract func is_not_null() -> GdUnitResultAssert\n\n## Verifies that the current value is equal to the given one.\n@abstract func is_equal(expected: Variant) -> GdUnitResultAssert\n\n## 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 'PickupHandler3D' die von Area3D erbt mit folgenden Funktionen: _update_detect_range, _update_closest_body, _get_parent_controller, _ready, _physics_process", "input": "", "output": "@tool\nclass_name PickupHandler3D\nextends Area3D\n\n# This area3D class detects all physics bodies based on\n# PickupAbleBody3D within range and handles the logic\n# for selecting the closest one and allowing pickup\n# of that object.\n\n# Detect range specifies within what radius we detect\n# objects we can pick up.\n@export var detect_range : float = 0.3:\n\tset(value):\n\t\tdetect_range = value\n\t\tif is_inside_tree():\n\t\t\t_update_detect_range()\n\t\t\t_update_closest_body()\n\n# Pickup Action specifies the action in the OpenXR\n# action map that triggers our pickup function.\n@export var pickup_action : String = \"pickup\"\n\nvar closest_body : PickupAbleBody3D\nvar picked_up_body: PickupAbleBody3D\nvar was_pickup_pressed : bool = false\n\n# Update our detection range.\nfunc _update_detect_range() -> void:\n\tvar shape : SphereShape3D = $CollisionShape3D.shape\n\tif shape:\n\t\tshape.radius = detect_range\n\n# Update our closest body.\nfunc _update_closest_body() -> void:\n\t# Do not do this when we're in the editor.\n\tif Engine.is_editor_hint():\n\t\treturn\n\n\t# Do not check this if we've picked something up.\n\tif picked_up_body:\n\t\tif closest_body:\n\t\t\tclosest_body.remove_is_closest(self)\n\t\t\tclosest_body = null\n\n\t\treturn\n\n\t# Find the body that is currently the closest.\n\tvar new_closest_body : PickupAbleBody3D\n\tvar closest_distance : float = 1000000.0\n\n\tfor body in get_overlapping_bodies():\n\t\tif body is PickupAbleBody3D and not body.is_picked_up():\n\t\t\tvar distance_squared = (body.global_position - global_position).length_squared()\n\t\t\tif distance_squared < closest_distance:\n\t\t\t\tnew_closest_body = body\n\t\t\t\tclosest_distance = distance_squared\n\n\t# Unchanged? Just exit\n\tif closest_body == new_closest_body:\n\t\treturn\n\n\t# We had a closest body\n\tif closest_body:\n\t\tclosest_body.remove_is_closest(self)\n\n\tclosest_body = new_closest_body\n\tif closest_body:\n\t\tclosest_body.add_is_closest(self)\n\n# Get our controller that we are a child of\nfunc _get_parent_controller() -> XRController3D:\n\tvar parent : Node = get_parent()\n\twhile p"} {"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 = {}", "source": "extracted_function"} {"instruction": "Vervollständige den GDScript-Code:", "input": "extends Area3D\n\n@export var interaction_action: String = \"interact\"\n\nvar _parent_camera: Camera3D\nvar _current_pointer: XRPointer\nvar _controller: XRController3D\nvar _was_pos: Vector3\n\n# Find the XRController3D ancester of the given node.\nfunc _get_controller(node: Node3D) -> XRController3D:\n\tvar parent = node.get_parent()\n\twhile parent:\n\t\tif parent is XRController3D:\n\t\t\treturn parent\n\t\tparent = parent.get_parent()\n\treturn null\n\n\n# Called when the node enters the scene tree for the first time.\nfunc _ready():\n\t_parent_camera = get_parent()\n\n", "output": "# Called every frame. 'delta' is the elapsed time since the previous frame.\nfunc _process(_delta):\n\tif not _parent_camera:\n\t\treturn\n\n\t# If we don't have a controller, let's see if we can find one!\n\tif not _controller:\n\t\t# If nothing is pointing at us, we have nothing to do!\n\t\tif not _current_pointer:\n\t\t\treturn\n\n\t\t# Find our related controller.\n\t\tvar controller = _get_controller(_current_pointer)\n\t\tif controller:\n\t\t\tif not controller.is_button_pressed(interaction_action):\n\t\t\t\treturn\n\n\t\t\t# We \"capture\" this controller, even if the pointer leaves\n\t\t\t# we keep using this controller until the user releases the button.\n\t\t\t_controller = controller\n\n\t\t\tvar plane: Plane = Plane(global_basis.z, global_position)\n\t\t\t_was_pos = plane.intersects_ray(_controller.global_position, -_controller.global_basis.z)\n\telse:\n\t\tif not _controller.is_button_pressed(interaction_action):\n\t\t\t_controller = null\n\t\t\treturn\n\n\t\tvar plane: Plane = Plane(global_basis.z, global_position)\n\t\tvar new_pos = plane.intersects_ray(_controller.global_position, -_controller.global_basis.z)\n\n\t\tvar movement = new_pos - _was_pos\n\t\t_was_pos = new_pos\n\n\t\tmovement = global_basis.inverse() * movement\n\t\tmovement *= Vector3(1.0, 1.0, 0.0)\n\t\t_parent_camera.global_position += global_basis * movement\n\n# A pointer is touching our area.\nfunc _enter_pointer(pointer: XRPointer, _at: Vector3) -> void:\n\t_current_pointer = pointer\n\n# A pointer is no longer touching our area.\nfunc _exit_pointer(pointer: XRPointer, _at: Vector3) -> void:\n\tif _current_pointer == pointer:\n\t\t_current_pointer = null\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "class_name PianoKey\nextends Control\n\nvar pitch_scale: float\n\n@onready var key: ColorRect = $Key\n@onready var start_color: Color = key.color\n@onready var color_timer: Timer = $ColorTimer\n\nfunc setup(pitch_index: int) -> void:", "output": "\tname = \"PianoKey\" + str(pitch_index)\n\tvar exponent := (pitch_index - 69.0) / 12.0\n\tpitch_scale = pow(2, exponent)\n\nfunc activate() -> void:\n\tkey.color = (Color.YELLOW + start_color) / 2\n\tvar audio := AudioStreamPlayer.new()\n\tadd_child(audio)\n\taudio.stream = preload(\"res://piano_keys/A440.wav\")\n\taudio.pitch_scale = pitch_scale\n\taudio.play()\n\tcolor_timer.start()\n\tawait get_tree().create_timer(8.0).timeout\n\taudio.queue_free()\n\nfunc deactivate() -> void:\n\tkey.color = start_color\n"} {"instruction": "Erstelle eine Godot-Klasse 'LoopingAudioStreamPlayer2D' die von AudioStreamPlayer2D erbt mit folgenden Funktionen: _ready, start, end, _on_finished", "input": "", "output": "class_name LoopingAudioStreamPlayer2D\nextends AudioStreamPlayer2D\n\n@export var sound_start: AudioStream\n@export var sound_loop: AudioStream\n@export var sound_tail: AudioStream\n\nvar ending := false\n\nfunc _ready() -> void:\n\tfinished.connect(_on_finished)\n\nfunc start() -> void:\n\tstream = sound_start\n\tending = false\n\tplay()\n\nfunc end() -> void:\n\tstream = sound_tail\n\tending = true\n\nfunc _on_finished() -> void:\n\tif stream == sound_start:\n\t\tstream = sound_loop\n\t\tplay()\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "extends Node3D\n\nsignal session_begun\nsignal focus_lost\nsignal focus_gained\nsignal pose_recentered\n\n@export var maximum_refresh_rate: int = 90\n\nvar xr_interface: OpenXRInterface\nvar xr_is_focused := false\n\n\nfunc get_vr_render_size():\n\tif xr_interface and xr_interface.is_initialized():\n\t\treturn xr_interface.get_render_target_size()\n\telse:\n\t\treturn Vector2(0.0, 0.0)\n\n\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 the Project Settings.\")\n\n\t\t# Connect the OpenXR events.\n\t\txr_interface.session_begun.connect(_on_openxr_session_begun)\n\t\txr_interface.session_visible.connect(_on_openxr_visible_state)", "output": "\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 the 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_begun.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:\n\t\tprint(\"OpenXR lost focus\")"} {"instruction": "Vervollständige den GDScript-Code:", "input": "extends Node3D\n\nvar xr_interface : MobileVRInterface\n\n# Called when the node enters the scene tree for the first time.\nfunc _ready():\n\txr_interface = XRServer.find_interface(\"Native mobile\")\n\tif xr_interface and xr_interface.initialize():\n\t\t# Disable lens distortion.\n\t\t#xr_interface.k1 = 0.0\n\t\t#xr_interface.k2 = 0.0", "output": "\n\t\t# Set up viewport.\n\t\tvar vp = get_viewport()\n\t\tvp.use_xr = true\n\t\tvp.vrs_mode = Viewport.VRS_XR\n\telse:\n\t\t# How did we get here?\n\t\tget_tree().quit()\n\nfunc _process(delta):\n\tvar dir : Vector2 = Vector2()\n\n\tif Input.is_action_pressed(&\"ui_left\"):\n\t\tdir.x = -1.0\n\telif Input.is_action_pressed(&\"ui_right\"):\n\t\tdir.x = 1.0\n\tif Input.is_action_pressed(&\"ui_up\"):\n\t\tdir.y = -1.0\n\telif Input.is_action_pressed(&\"ui_down\"):\n\t\tdir.y = 1.0\n\n\t$XROrigin3D.global_position += $XROrigin3D.global_transform.basis.x * dir.x * delta\n\t$XROrigin3D.global_position += $XROrigin3D.global_transform.basis.z * dir.y * delta\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "#*\n#* pursue.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## Move towards the target until the agent is flanking it. [br]\n## Returns [code]RUNNING[/code] while moving towards the target but not yet at the desired position. [br]\n## Returns [code]SUCCESS[/code] when at the desired position relative to the target (flanking it). [br]\n## Returns [code]FAILURE[/code] if the target is not a valid [Node2D] instance. [br]\n\n## How close should the agent be to the desired position to return SUCCESS.\nconst TOLERANCE := 30.0\n\n## Blackboard variable that stores our target (expecting Node2D).\n@export var target_var: StringName = &\"target\"\n\n## Blackboard variable that stores desired speed.\n@export var speed_var: StringName = &\"speed\"\n", "output": "## Desired distance from target.\n@export var approach_distance: float = 100.0\n\nvar _waypoint: Vector2\n\n# Display a customized name (requires @tool).\nfunc _generate_name() -> String:\n\treturn \"Pursue %s\" % [LimboUtility.decorate_var(target_var)]\n\n# Called each time this task is entered.\nfunc _enter() -> void:\n\tvar target: Node2D = blackboard.get_var(target_var, null)\n\tif is_instance_valid(target):\n\t\t# Movement is performed in smaller steps.\n\t\t# For each step, we select a new waypoint.\n\t\t_select_new_waypoint(_get_desired_position(target))\n\n# Called each time this task is ticked (aka 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 desired_pos: Vector2 = _get_desired_position(target)\n\tif agent.global_position.distance_to(desired_pos) < TOLERANCE:\n\t\treturn SUCCESS\n\n\tif agent.global_position.distance_to(_waypoint) < TOLERANCE:\n\t\t_select_new_waypoint(desired_pos)\n\n\tvar speed: float = blackboard.get_var(speed_var, 200.0)\n\tvar desired_velocity: Vector2 = agent.global_position.direction_to(_waypoint) * speed\n\tagent.move(desired_velocity)\n\tagent.update_facing()\n\treturn RUNNING\n\n## Get the closest flanking position to target.\nfunc _get_desired_position(target: Node2D) -> Vector2:\n\tvar side: float = signf(agent.global_position.x - target.global_position.x)\n\tvar desired_pos: Vector2 = target.global_position\n\tdesired_pos.x += approach_distance * side\n\treturn desired_pos\n\n## Select an intermidiate waypoint towards the desired position.\nfunc _select_new_waypoint(desired_position: Vector2) -> void:"} {"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 RigidBody3D\n# @category - Specialized agents\nclass_name GSAIRigidBody3DAgent\nextends GSAISpecializedAgent\n\n# The RigidBody3D to keep track of\nvar body: RigidBody3D: set = _set_body\n\nvar _last_position: Vector3\nvar _body_ref: WeakRef\n\nfunc _init(_body: RigidBody3D) -> void:\n\tif not _body.is_inside_tree():\n\t\tawait(_body).ready\n\tself.body = _body\n\n\t# warning-ignore:return_value_discarded\n\t_body.get_tree().physics_frame.connect(_on_SceneTree_frame)\n\n\n# Moves the agent's `body` by target `acceleration`.", "output": "# @tags - virtual\nfunc _apply_steering(acceleration: GSAITargetAcceleration, _delta: float) -> void:\n\tvar _body: RigidBody3D = _body_ref.get_ref()\n\tif not _body:\n\t\treturn\n\n\t_applied_steering = true\n\t_body.apply_central_impulse(acceleration.linear)\n\t_body.apply_torque_impulse(Vector3.UP * acceleration.angular)\n\tif calculate_velocities:\n\t\tlinear_velocity = _body.linear_velocity\n\t\tangular_velocity = _body.angular_velocity.y\n\nfunc _set_body(value: RigidBody3D) -> void:\n\tbody = value\n\t_body_ref = weakref(value)\n\n\t_last_position = value.transform.origin\n\t_last_orientation = value.rotation.y\n\n\tposition = _last_position\n\torientation = _last_orientation\n\nfunc _on_SceneTree_frame() -> void:\n\tvar _body: RigidBody3D = _body_ref.get_ref()\n\tif not _body:\n\t\treturn\n\n\tif not _body.is_inside_tree():\n\t\treturn\n\n\tvar current_position := _body.transform.origin\n\tvar current_orientation := _body.rotation.y\n\n\tposition = current_position\n\torientation = current_orientation\n\n\tif calculate_velocities:\n\t\tif _applied_steering:\n\t\t\t_applied_steering = false\n\t\telse:\n\t\t\tlinear_velocity = _body.linear_velocity\n\t\t\tangular_velocity = _body.angular_velocity.y\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "## A wrapper for [AStar2D] that allows working with [Vector2i] coordinates.\n##\n## Additionally provides utility methods for easily dealing with cell availability and passability.\nclass_name Pathfinder\nextends AStar2D\n\n## When finding a path, we may want to ignore certain cells that are occupied by Gamepeices.\n## These flags specify which disabled cells will still allow the path through.\n##\n## Ignore the occupant of the source cell when searching for a path via [method path_to_cell].\n## This is especially useful when wanting to find a path for a gamepiece from their current cell.\nconst FLAG_ALLOW_SOURCE_OCCUPANT = 1 << 0\n## Ignore the occupant of the target cell when searching for a path via [method path_to_cell].\nconst FLAG_ALLOW_TARGET_OCCUPANT = 1 << 1\n## Ignore all gamepieces on the pathfinder cells when searching for a path via\n## [method path_to_cell].\nconst FLAG_ALLOW_ALL_OCCUPANTS = 1 << 2\n\n\nfunc _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", "output": "## 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] = {}\n\tif (occupancy_flags & FLAG_ALLOW_ALL_OCCUPANTS) != 0:\n\t\tfor id in get_point_ids():\n\t\t\tif is_point_disabled(id):\n\t\t\t\tignored_points[id] = true\n\t\t\t\tset_point_disabled(id, false)\n\n\tif has_point(source_id) and has_point(target_id):\n\t\t# Check to see if we want to un-disable the source/target cells.\n\t\tif (occupancy_flags & FLAG_ALLOW_SOURCE_OCCUPANT) != 0:\n\t\t\tignored_points[source_id] = is_point_disabled(source_id)\n\t\t\tset_point_disabled(source_id, false)\n\t\tif (occupancy_flags & FLAG_ALLOW_TARGET_OCCUPANT) != 0:\n\t\t\tignored_points[target_id] = is_point_disabled(target_id)\n\t\t\tset_point_disabled(target_id, false)\n\n\t\tfor path_coord: Vector2i in get_point_path(source_id, target_id):\n\t\t\tif path_coord != source_coord: # Don't include the source as the first path element.\n\t\t\t\tmove_path.append(path_coord)\n\n\t\t# Change any enabled cells back to their previous state.\n\t\tfor id in ignored_points:\n\t\t\tset_point_disabled(id, ignored_points[id])\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "# Calculates angular acceleration to rotate a target to face its target's\n# position. The behavior attemps to arrive with zero remaining angular velocity.\n# @category - Individual behaviors\nclass_name GSAIFace\nextends GSAIMatchOrientation\n\n\nfunc _init(agent: GSAISteeringAgent, target: GSAIAgentLocation, use_z := false) -> void:\n\tsuper._init(agent, target, use_z)", "output": "\nfunc _face(acceleration: GSAITargetAcceleration, target_position: Vector3) -> void:\n\tvar to_target := target_position - agent.position\n\tvar distance_squared := to_target.length_squared()\n\n\tif distance_squared < agent.zero_linear_speed_threshold:\n\t\tacceleration.set_zero()\n\telse:\n\t\tvar orientation = (\n\t\t\tGSAIUtils.vector3_to_angle(to_target)\n\t\t\tif use_z\n\t\t\telse GSAIUtils.vector2_to_angle(GSAIUtils.to_vector2(to_target))\n\t\t)\n\t\t_match_orientation(acceleration, orientation)\n\nfunc _calculate_steering(acceleration: GSAITargetAcceleration) -> void:\n\t_face(acceleration, target.position)\n"} {"instruction": "Erstelle eine Godot-Klasse 'Gamepiece' die von Path2D erbt mit folgenden Funktionen: _ready, _process, move_to, stop, is_moving", "input": "", "output": "@tool\n\n## A Gamepiece is a scene that moves about and is snapped to the gameboard.\n##\n## Gamepieces, like other scenes in Godot, are expected to be composed from other nodes (i.e. an AI\n## [GamepieceController], a collision shape, or a [Sprite2D], for example). Gamepieces themselves\n## are 'dumb' objects that do nothing but occupy and move about the gameboard.\n##\n## [br][br][b]Note:[/b] The [code]gameboard[/code] is considered to be the playable area on which a\n## Gamepiece may be placed. The gameboard is made up of cells, each of which may be occupied by one\n## or more gamepieces.\n@icon(\"res://assets/editor/icons/Gamepiece.svg\")\nclass_name Gamepiece extends Path2D\n\n## Emitted when a gamepiece is about to finish travlling to its destination cell. The remaining\n## distance that the gamepiece could travel is based on how far the gamepiece has travelled this\n## frame. [br][br]\n## The signal is emitted prior to wrapping up the path and traveller, allowing other objects to\n## extend the move path, if necessary.\nsignal arriving(remaining_distance: float)\n\n## Emitted when the gamepiece has finished travelling to its destination cell.\nsignal arrived\n\n## Emitted when the gamepiece's [member direction] changes, usually as it travels about the board.\nsignal direction_changed(new_direction: Directions.Points)\n\n## A [GamepieceAnimation] packed scene that will be automatically added to the gamepiece. Other\n## scene types will not be accepted.\n@export var animation_scene: PackedScene:\n\tset(value):\n\t\tanimation_scene = value\n\n\t\tif not is_inside_tree():\n\t\t\tawait ready\n\n\t\tif animation:\n\t\t\tanimation.queue_free()\n\t\t\tanimation = null\n\n\t\tif animation_scene:\n\t\t\t# Check to make sure that the supplied scene instantiates as a GamepieceAnimation.\n\t\t\tvar new_scene: = animation_scene.instantiate()\n\t\t\tanimation = new_scene as GamepieceAnimation\n\t\t\tif not animation:\n\t\t\t\tprinterr(\"Gamepiece '%s' cannot accept '%s' as \" % [name, new_scene.name],\n\t\t\t\t\t\"gamepiece_gfx_scene. '%s' is not a GamepieceGFX"} {"instruction": "Vervollständige den GDScript-Code:", "input": "extends GdUnitStringAssert\n\nvar _base: GdUnitAssertImpl\n\n\nfunc _init(current :Variant) -> void:\n\t_base = GdUnitAssertImpl.new(current)\n\t# save the actual assert instance on the current thread context\n\tGdUnitThreadManager.get_current_context().set_assert(self)\n\tif current != null and typeof(current) != TYPE_STRING and typeof(current) != TYPE_STRING_NAME:\n\t\t@warning_ignore(\"return_value_discarded\")\n\t\treport_error(\"GdUnitStringAssert inital error, unexpected type <%s>\" % GdObjects.typeof_as_string(current))\n\n\nfunc _notification(event :int) -> void:\n\tif event == NOTIFICATION_PREDELETE:\n\t\tif _base != null:\n\t\t\t_base.notification(event)\n\t\t\t_base = null\n\n\nfunc failure_message() -> String:\n\treturn _base.failure_message()\n\n\nfunc current_value() -> Variant:\n\treturn _base.current_value()\n\n\nfunc report_success() -> GdUnitStringAssert:\n\t@warning_ignore(\"return_value_discarded\")\n\t_base.report_success()\n\treturn self\n\n\nfunc report_error(error :String) -> GdUnitStringAssert:\n\t@warning_ignore(\"return_value_discarded\")\n\t_base.report_error(error)\n\treturn self\n\n\nfunc override_failure_message(message: String) -> GdUnitStringAssert:\n\t@warning_ignore(\"return_value_discarded\")\n\t_base.override_failure_message(message)\n\treturn self\n\n\nfunc append_failure_message(message: String) -> GdUnitStringAssert:\n\t@warning_ignore(\"return_value_discarded\")\n\t_base.append_failure_message(message)\n\treturn self\n\n\nfunc is_null() -> GdUnitStringAssert:\n\t@warning_ignore(\"return_value_discarded\")\n\t_base.is_null()\n\treturn self\n\n\nfunc is_not_null() -> GdUnitStringAssert:\n\t@warning_ignore(\"return_value_discarded\")\n\t_base.is_not_null()\n\treturn self\n\n\nfunc is_equal(expected: Variant) -> GdUnitStringAssert:\n\treturn _is_equal(expected, false, GdAssertMessages.error_equal)\n\n", "output": "func is_equal_ignoring_case(expected: Variant) -> GdUnitStringAssert:\n\treturn _is_equal(expected, true, GdAssertMessages.error_equal_ignoring_case)\n\n@warning_ignore_start(\"unsafe_call_argument\")\nfunc _is_equal(expected: Variant, ignore_case: bool, message_cb: Callable) -> GdUnitStringAssert:\n\tvar current: Variant = current_value()\n\tif current == null:\n\t\treturn report_error(message_cb.call(current, expected))\n\tvar cur_value := str(current)\n\tif not GdObjects.equals(cur_value, expected, ignore_case):\n\t\tvar exp_value := str(expected)\n\t\tif contains_bbcode(cur_value):\n\t\t\t# mask user bbcode\n\t\t\t# https://docs.godotengine.org/en/4.5/tutorials/ui/bbcode_in_richtextlabel.html#handling-user-input-safely\n\t\t\treturn report_error(message_cb.call(cur_value.replace(\"[\", \"[lb]\"), exp_value.replace(\"[\", \"[lb]\")))\n\t\tvar diffs := GdDiffTool.string_diff(cur_value, exp_value)\n\t\tvar formatted_current := GdAssertMessages.colored_array_div(diffs[1])\n\t\treturn report_error(message_cb.call(formatted_current, exp_value))\n\treturn report_success()\n@warning_ignore_restore(\"unsafe_call_argument\")\n\nfunc is_not_equal(expected: Variant) -> GdUnitStringAssert:\n\tvar current: Variant = current_value()\n\tif GdObjects.equals(current, expected):\n\t\treturn report_error(GdAssertMessages.error_not_equal(current, expected))\n\treturn report_success()\n\nfunc is_not_equal_ignoring_case(expected :Variant) -> GdUnitStringAssert:\n\tvar current :Variant = current_value()\n\tif GdObjects.equals(current, expected, true):\n\t\treturn report_error(GdAssertMessages.error_not_equal(current, expected))\n\treturn report_success()\n\nfunc is_empty() -> GdUnitStringAssert:\n\tvar current :Variant = current_value()\n\t@warning_ignore(\"unsafe_cast\")\n\tif current == null or not (current as String).is_empty():\n\t\treturn report_error(GdAssertMessages.error_is_empty(current))\n\treturn report_success()\n\nfunc is_not_empty() -> GdUnitStringAssert:\n\tvar current :Variant = current_value()\n\t@warning_ignore(\"unsafe_cast\")\n\tif current == null or (current as String).is_empty():\n\t\treturn report_error(GdAssertMessages.error_is_not_empty())"} {"instruction": "Vervollständige den GDScript-Code:", "input": "extends Node3D\n\nvar tween : Tween\nvar active_hand : XRController3D\n\n\n# Called when the node enters the scene tree for the first time.\nfunc _ready():\n\t$XROrigin3D/LeftHand/Pointer.visible = false\n\t$XROrigin3D/RightHand/Pointer.visible = true\n\tactive_hand = $XROrigin3D/RightHand\n\n\n# Callback for our tween to set the energy level on our active pointer.\nfunc _update_energy(new_value : float):\n\tvar pointer = active_hand.get_node(^\"Pointer\")\n\tvar material : ShaderMaterial = pointer.material_override\n\tif material:\n\t\tmaterial.set_shader_parameter(&\"energy\", new_value)\n\n", "output": "# Start our tween to show a pulse on our click.\nfunc _do_tween_energy():\n\tif tween:\n\t\ttween.kill()\n\n\ttween = create_tween()\n\ttween.tween_method(_update_energy, 5.0, 1.0, 0.5)\n\n# Called if left hand trigger is pressed.\nfunc _on_left_hand_button_pressed(action_name):\n\tif action_name == \"select\":\n\t\t# Make the left hand the active pointer.\n\t\t$XROrigin3D/LeftHand/Pointer.visible = true\n\t\t$XROrigin3D/RightHand/Pointer.visible = false\n\n\t\tactive_hand = $XROrigin3D/LeftHand\n\t\t$XROrigin3D/OpenXRCompositionLayerEquirect.controller = active_hand\n\n\t\t# Make a visual pulse.\n\t\t_do_tween_energy()\n\n\t\t# And make us feel it.\n\t\t# NOTE: `frequence == 0.0` => XR runtime chooses optimal frequency for a given controller.\n\t\tactive_hand.trigger_haptic_pulse(\"haptic\", 0.0, 1.0, 0.5, 0.0)\n\n# Called if right hand trigger is pressed.\nfunc _on_right_hand_button_pressed(action_name):\n\tif action_name == \"select\":\n\t\t# Make the right hand the active pointer.\n\t\t$XROrigin3D/LeftHand/Pointer.visible = false\n\t\t$XROrigin3D/RightHand/Pointer.visible = true\n\n\t\tactive_hand = $XROrigin3D/RightHand\n\t\t$XROrigin3D/OpenXRCompositionLayerEquirect.controller = active_hand\n\n\t\t# Make a visual pulse.\n\t\t_do_tween_energy()\n\n\t\t# And make us feel it.\n\t\t# NOTE: `frequence == 0.0` => XR runtime chooses optimal frequency for a given controller.\n\t\tactive_hand.trigger_haptic_pulse(\"haptic\", 0.0, 1.0, 0.5, 0.0)\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "@tool\nextends Node2D\n\n## The map defines the properties of the playable grid, which will be applied on _ready to the\n## [Gameboard]. These properties usually correspond to one or multiple tilesets.\n@export var gameboard_properties: GameboardProperties:\n\tset(value):\n\t\tgameboard_properties = value\n\t\t\n\t\tif not is_inside_tree():", "output": "\t\t\tawait ready\n\n\t\t_debug_boundaries.gameboard_properties = gameboard_properties\n\n@onready var _debug_boundaries: DebugGameboardBoundaries = $Overlay/DebugBoundaries\n\nfunc _ready() -> void:\n\tif not Engine.is_editor_hint():\n\t\tCamera.gameboard_properties = gameboard_properties\n\t\tGameboard.properties = gameboard_properties\n\n\t\t# Gamepieces need to be registered according to which cells they currently occupy.\n\t\t# Gamepieces may not overlap, and only the first gamepiece registered to a given cell will\n\t\t# be kept.\n\t\t#for gamepiece: Gamepiece in find_children(\"*\", \"Gamepiece\"):\n\t\t\t#var cell: = Gameboard.get_cell_under_node(gamepiece)\n\t\t\t#gamepiece.position = Gameboard.cell_to_pixel(cell)\n\t\t\t#\n\t\t\t#if GamepieceRegistry.register(gamepiece, cell) == false:\n\t\t\t\t#gamepiece.queue_free()\n"} {"instruction": "Erstelle eine Godot-Klasse 'GdUnitAssertImpl' die von GdUnitAssert erbt mit folgenden Funktionen: _init, failure_message, current_value, report_success, report_error", "input": "", "output": "class_name GdUnitAssertImpl\nextends GdUnitAssert\n\nvar _current :Variant\nvar _current_failure_message :String = \"\"\nvar _custom_failure_message :String = \"\"\nvar _additional_failure_message: String = \"\"\n\nfunc _init(current :Variant) -> void:\n\t_current = current\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\nfunc failure_message() -> String:\n\treturn _current_failure_message\n\nfunc current_value() -> Variant:\n\treturn _current\n\nfunc report_success() -> GdUnitAssert:\n\tGdAssertReports.report_success()\n\treturn self\n\nfunc report_error(failure :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\tGdAssertReports.set_last_error_line_number(line_number)\n\t_current_failure_message = GdAssertMessages.build_failure_message(failure, _additional_failure_message, _custom_failure_message)\n\tGdAssertReports.report_error(_current_failure_message, line_number)\n\tEngine.set_meta(\"GD_TEST_FAILURE\", true)\n\treturn self\n\nfunc do_fail() -> GdUnitAssert:\n\treturn report_error(GdAssertMessages.error_not_implemented())\n\nfunc override_failure_message(message: String) -> GdUnitAssert:\n\t_custom_failure_message = message\n\treturn self\n\nfunc append_failure_message(message: String) -> GdUnitAssert:\n\t_additional_failure_message = message\n\treturn self\n\nfunc is_null() -> GdUnitAssert:\n\tvar current :Variant = current_value()\n\tif current != null:\n\t\treturn report_error(GdAssertMessages.error_is_null(current))\n\treturn report_success()\n\nfunc is_not_null() -> GdUnitAssert:\n\tvar current :Variant = current_value()\n\tif current == null:\n\t\treturn report_error(GdAssertMessages.error_is_not_null())\n\treturn report_success()\n\nfunc is_equal(expected: Variant) -> GdUnitAssert:\n\tvar current: Variant = current_value()\n\tif not GdObjects.equals(current, expected):\n\t\treturn report_erro"} {"instruction": "Vervollständige den GDScript-Code:", "input": "@tool\nclass_name PickupHandler3D\nextends Area3D\n\n# This area3D class detects all physics bodies based on\n# PickupAbleBody3D within range and handles the logic\n# for selecting the closest one and allowing pickup\n# of that object.\n\n# Detect range specifies within what radius we detect\n# objects we can pick up.\n@export var detect_range : float = 0.3:\n\tset(value):\n\t\tdetect_range = value\n\t\tif is_inside_tree():\n\t\t\t_update_detect_range()\n\t\t\t_update_closest_body()\n\n# Pickup Action specifies the action in the OpenXR\n# action map that triggers our pickup function.\n@export var pickup_action : String = \"pickup\"\n\nvar closest_body : PickupAbleBody3D\nvar picked_up_body: PickupAbleBody3D\nvar was_pickup_pressed : bool = false\n\n\n# Update our detection range.\nfunc _update_detect_range() -> void:\n\tvar shape : SphereShape3D = $CollisionShape3D.shape\n\tif shape:\n\t\tshape.radius = detect_range\n\n\n# Update our closest body.\nfunc _update_closest_body() -> void:\n\t# Do not do this when we're in the editor.\n\tif Engine.is_editor_hint():\n\t\treturn\n", "output": "\t# Do not check this if we've picked something up.\n\tif picked_up_body:\n\t\tif closest_body:\n\t\t\tclosest_body.remove_is_closest(self)\n\t\t\tclosest_body = null\n\n\t\treturn\n\n\t# Find the body that is currently the closest.\n\tvar new_closest_body : PickupAbleBody3D\n\tvar closest_distance : float = 1000000.0\n\n\tfor body in get_overlapping_bodies():\n\t\tif body is PickupAbleBody3D and not body.is_picked_up():\n\t\t\tvar distance_squared = (body.global_position - global_position).length_squared()\n\t\t\tif distance_squared < closest_distance:\n\t\t\t\tnew_closest_body = body\n\t\t\t\tclosest_distance = distance_squared\n\n\t# Unchanged? Just exit\n\tif closest_body == new_closest_body:\n\t\treturn\n\n\t# We had a closest body\n\tif closest_body:\n\t\tclosest_body.remove_is_closest(self)\n\n\tclosest_body = new_closest_body\n\tif closest_body:\n\t\tclosest_body.add_is_closest(self)\n\n# Get our controller that we are a child of\nfunc _get_parent_controller() -> XRController3D:\n\tvar parent : Node = get_parent()\n\twhile parent:\n\t\tif parent is XRController3D:\n\t\t\treturn parent\n\n\t\tparent = parent.get_parent()\n\n\treturn null\n\n# Called when the node enters the scene tree for the first time.\nfunc _ready() -> void:\n\t_update_detect_range()\n\t_update_closest_body()\n"} {"instruction": "Erstelle eine Godot-Klasse 'GSAIFace' die von GSAIMatchOrientation erbt mit folgenden Funktionen: _init, _face, _calculate_steering", "input": "", "output": "# Calculates angular acceleration to rotate a target to face its target's\n# position. The behavior attemps to arrive with zero remaining angular velocity.\n# @category - Individual behaviors\nclass_name GSAIFace\nextends GSAIMatchOrientation\n\nfunc _init(agent: GSAISteeringAgent, target: GSAIAgentLocation, use_z := false) -> void:\n\tsuper._init(agent, target, use_z)\n\nfunc _face(acceleration: GSAITargetAcceleration, target_position: Vector3) -> void:\n\tvar to_target := target_position - agent.position\n\tvar distance_squared := to_target.length_squared()\n\n\tif distance_squared < agent.zero_linear_speed_threshold:\n\t\tacceleration.set_zero()\n\telse:\n\t\tvar orientation = (\n\t\t\tGSAIUtils.vector3_to_angle(to_target)\n\t\t\tif use_z\n\t\t\telse GSAIUtils.vector2_to_angle(GSAIUtils.to_vector2(to_target))\n\t\t)\n\t\t_match_orientation(acceleration, orientation)\n\nfunc _calculate_steering(acceleration: GSAITargetAcceleration) -> void:\n\t_face(acceleration, target.position)\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "extends GdUnitFileAssert\n\nconst GdUnitTools := preload(\"res://addons/gdUnit4/src/core/GdUnitTools.gd\")\n\nvar _base: GdUnitAssertImpl\n\n\nfunc _init(current :Variant) -> void:\n\t_base = GdUnitAssertImpl.new(current)\n\t# save the actual assert instance on the current thread context\n\tGdUnitThreadManager.get_current_context().set_assert(self)\n\tif not GdUnitAssertions.validate_value_type(current, TYPE_STRING):\n\t\t@warning_ignore(\"return_value_discarded\")\n\t\treport_error(\"GdUnitFileAssert inital error, unexpected type <%s>\" % GdObjects.typeof_as_string(current))\n\n\nfunc _notification(event :int) -> void:\n\tif event == NOTIFICATION_PREDELETE:\n\t\tif _base != null:\n\t\t\t_base.notification(event)\n\t\t\t_base = null\n\n\nfunc current_value() -> String:\n\treturn _base.current_value()\n\n\nfunc report_success() -> GdUnitFileAssert:\n\t@warning_ignore(\"return_value_discarded\")\n\t_base.report_success()\n\treturn self\n\n\nfunc report_error(error :String) -> GdUnitFileAssert:\n\t@warning_ignore(\"return_value_discarded\")\n\t_base.report_error(error)\n\treturn self\n\n", "output": "func failure_message() -> String:\n\treturn _base.failure_message()\n\nfunc override_failure_message(message: String) -> GdUnitFileAssert:\n\t@warning_ignore(\"return_value_discarded\")\n\t_base.override_failure_message(message)\n\treturn self\n\nfunc append_failure_message(message: String) -> GdUnitFileAssert:\n\t@warning_ignore(\"return_value_discarded\")\n\t_base.append_failure_message(message)\n\treturn self\n\nfunc is_null() -> GdUnitFileAssert:\n\t@warning_ignore(\"return_value_discarded\")\n\t_base.is_null()\n\treturn self\n\nfunc is_not_null() -> GdUnitFileAssert:\n\t@warning_ignore(\"return_value_discarded\")\n\t_base.is_not_null()\n\treturn self\n\nfunc is_equal(expected: Variant) -> GdUnitFileAssert:\n\t@warning_ignore(\"return_value_discarded\")\n\t_base.is_equal(expected)\n\treturn self\n\nfunc is_not_equal(expected: Variant) -> GdUnitFileAssert:\n\t@warning_ignore(\"return_value_discarded\")\n\t_base.is_not_equal(expected)\n\treturn self\n\nfunc is_file() -> GdUnitFileAssert:\n\tvar current := current_value()\n\tif FileAccess.open(current, FileAccess.READ) == null:\n\t\treturn report_error(\"Is not a file '%s', error code %s\" % [current, FileAccess.get_open_error()])\n\treturn report_success()\n\nfunc exists() -> GdUnitFileAssert:\n\tvar current := current_value()\n\tif not FileAccess.file_exists(current):"} {"instruction": "Vervollständige den GDScript-Code:", "input": "@tool\n## A simple inventory implementation that includes all item types and data within the class.\nclass_name Inventory extends Resource\n\n## All item types available to add or remove from the inventory.\nenum ItemTypes { KEY, COIN, BOMB, RED_WAND, BLUE_WAND, GREEN_WAND }\n\n#TODO: I expect we'll want to have a proper inventory definition somewhere. Some folks advocate for\n# spreadsheets, but whatever it is should probably integrate with the editor so that level designers\n# can easily pick from items from a dropdown list, or something similar.\n## Icons associated with the [member ItemTypes].\nconst ICONS: = {\n\tItemTypes.KEY: preload(\"res://assets/items/key.atlastex\"),\n\tItemTypes.COIN: preload(\"res://assets/items/coin.atlastex\"),\n\tItemTypes.BOMB: preload(\"res://assets/items/bomb.atlastex\"),\n\tItemTypes.RED_WAND: preload(\"res://assets/items/wand_red.atlastex\"),\n\tItemTypes.BLUE_WAND: preload(\"res://assets/items/wand_blue.atlastex\"),\n\tItemTypes.GREEN_WAND: preload(\"res://assets/items/wand_green.atlastex\"),\n}\n\nconst INVENTORY_PATH: = \"user://inventory.tres\"\n\n## Emitted when the count of a given item type changes.\nsignal item_changed(type: ItemTypes)\n\n# Keep track of what is in the inventory. Dictionary keys are an ItemType, values are the amount.\n@export var _items: = {}", "output": "\nfunc _init() -> void:\n\tfor item_name in ItemTypes:\n\t\t_items[ItemTypes[item_name]] = 0\n\n## Load the [Inventory] from file or create a new resource, if it was missing. Godot caches calls,\n## so this can be used every time needed.\nstatic func restore() -> Inventory:\n\tif Engine.is_editor_hint():\n\t\treturn null\n\n\tif FileAccess.file_exists(INVENTORY_PATH):\n\t\tvar inventory = ResourceLoader.load(INVENTORY_PATH) as Inventory\n\t\tif inventory:\n\t\t\treturn inventory\n\n\t# Either there is no inventory associated with this profile or the file itself could not be\n\t# loaded. Either way, a new inventory resource must be created.\n\tvar new_inventory: = Inventory.new()\n\tnew_inventory.save()\n\treturn new_inventory\n\n## Increment the count of a given item by one, adding it to the inventory if it does not exist.\nfunc add(item_type: ItemTypes, amount: = 1) -> void:\n\t# Note that adding negative numbers is possible. Prevent having a total of negative items.\n\t# NPC: \"You cannot have negative potatoes.\"\n\tvar old_amount: = _items.get(item_type, 0) as int\n\t_items[item_type] = maxi(old_amount+amount, 0)\n\n\titem_changed.emit(item_type)\n\n## Decrement the count of a given item by one.\n## The item will be removed entirely if there are none remaining. Removing an item that is not\n## posessed will do nothing.\nfunc remove(item_type: ItemTypes, amount: = 1) -> void:\n\tadd(item_type, -amount)\n\n## Returns the number of a certain item type posessed by the player.\nfunc get_item_count(item_type: ItemTypes) -> int:\n\treturn _items.get(item_type, 0)\n\n## Returns the icon associated with a given item type.\nstatic func get_item_icon(item_type: ItemTypes) -> Texture:\n\treturn ICONS.get(item_type, null)"} {"instruction": "Erstelle eine Godot-Klasse 'GSAILookWhereYouGo' die von GSAIMatchOrientation erbt mit folgenden Funktionen: _init, _calculate_steering", "input": "", "output": "# Calculates an angular acceleration to match an agent's orientation to its\n# direction of travel.\n# @category - Individual behaviors\nclass_name GSAILookWhereYouGo\nextends GSAIMatchOrientation\n\nfunc _init(agent: GSAISteeringAgent, use_z := false) -> void:\n\tsuper._init(agent, null, use_z)\n\nfunc _calculate_steering(accel: GSAITargetAcceleration) -> void:\n\tif agent.linear_velocity.length_squared() < agent.zero_linear_speed_threshold:\n\t\taccel.set_zero()\n\telse:\n\t\tvar orientation := (\n\t\t\tGSAIUtils.vector3_to_angle(agent.linear_velocity)\n\t\t\tif use_z\n\t\t\telse GSAIUtils.vector2_to_angle(GSAIUtils.to_vector2(agent.linear_velocity))\n\t\t)\n\t\t_match_orientation(accel, orientation)\n"} {"instruction": "Erstelle eine Godot-Klasse 'State' die von Node erbt mit folgenden Funktionen: _ready, unhandled_input, physics_process, enter, exit", "input": "", "output": "# State interface to use in Hierarchical State Machines.\n# The lowest leaf tries to handle callbacks, and if it can't, it delegates the work to its parent.\n# It's up to the user to call the parent state's functions, e.g. `_parent.physics_process(delta)`\n# Use State as a child of a StateMachine node.\n# tags: abstract\nextends Node\nclass_name State\n\n@onready var _state_machine := _get_state_machine(self)\nvar _parent: State = null\n\nfunc _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 = {}) -> void:\n\tpass\n\nfunc exit() -> void:\n\tpass\n\nfunc _get_state_machine(node: Node) -> Node:\n\tif node != null and not node.is_in_group(\"state_machine\"):\n\t\treturn _get_state_machine(node.get_parent())\n\treturn node\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "@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\t\t\n\t\tif not is_inside_tree():", "output": "\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: Area2D) -> void:\n\t_is_shown = false\n\n# Be sure to hide input when the player is not able to do anything (e.g. cutscenes).\nfunc _on_input_paused(paused: bool) -> void:\n\t_area.monitoring = !paused\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "# State interface to use in Hierarchical State Machines.\n# The lowest leaf tries to handle callbacks, and if it can't, it delegates the work to its parent.\n# It's up to the user to call the parent state's functions, e.g. `_parent.physics_process(delta)`\n# Use State as a child of a StateMachine node.\n# tags: abstract\nextends Node\nclass_name State\n\n@onready var _state_machine := _get_state_machine(self)\nvar _parent: State = null\n\n", "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 = {}) -> void:\n\tpass\n\nfunc exit() -> void:\n\tpass\n\nfunc _get_state_machine(node: Node) -> Node:\n\tif node != null and not node.is_in_group(\"state_machine\"):\n\t\treturn _get_state_machine(node.get_parent())\n\treturn node\n"} {"instruction": "Erstelle eine Godot-Klasse 'GSAIBlend' die von GSAISteeringBehavior erbt mit folgenden Funktionen: _init, add, get_behavior_at, _calculate_steering", "input": "", "output": "# Blends multiple steering behaviors into one, and returns a weighted\n# acceleration from their calculations.\n#\n# Stores the behaviors internally as dictionaries of the form\n# {\n# \tbehavior : GSAISteeringBehavior,\n# \tweight : float\n# }\n# @category - Combination behaviors\nclass_name GSAIBlend\nextends GSAISteeringBehavior\n\nvar _behaviors := []\nvar _accel := GSAITargetAcceleration.new()\n\nfunc _init(agent: GSAISteeringAgent) -> void:\n\tsuper._init(agent)\n\n# Appends a behavior to the internal array along with its `weight`.\nfunc add(behavior: GSAISteeringBehavior, weight: float) -> void:\n\tbehavior.agent = agent\n\t_behaviors.append({behavior = behavior, weight = weight})\n\n# Returns the behavior at the specified `index`, or an empty `Dictionary` if\n# none was found.\nfunc get_behavior_at(index: int) -> Dictionary:\n\tif _behaviors.size() > index:\n\t\treturn _behaviors[index]\n\tprinterr(\"Tried to get index \" + str(index) + \" in array of size \" + str(_behaviors.size()))\n\treturn {}\n\nfunc _calculate_steering(blended_accel: GSAITargetAcceleration) -> void:\n\tblended_accel.set_zero()\n\n\tfor i in range(_behaviors.size()):\n\t\tvar bw: Dictionary = _behaviors[i]\n\t\tbw.behavior.calculate_steering(_accel)\n\n\t\tblended_accel.add_scaled_accel(_accel, bw.weight)\n\n\tblended_accel.linear = GSAIUtils.clampedv3(blended_accel.linear, agent.linear_acceleration_max)\n\tblended_accel.angular = clamp(\n\t\tblended_accel.angular, -agent.angular_acceleration_max, agent.angular_acceleration_max\n\t)\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "# Calculates an acceleration that attempts to move the agent towards the center\n# of mass of the agents in the area defined by the `GSAIProximity`.\n# @category - Group behaviors\nclass_name GSAICohesion\nextends GSAIGroupBehavior\n\nvar _center_of_mass: Vector3\n\n\nfunc _init(agent: GSAISteeringAgent, proximity: GSAIProximity) -> void:", "output": "\tsuper._init(agent, proximity)\n\nfunc _calculate_steering(acceleration: GSAITargetAcceleration) -> void:\n\tacceleration.set_zero()\n\t_center_of_mass = Vector3.ZERO\n\tvar neighbor_count = proximity._find_neighbors(_callback)\n\tif neighbor_count > 0:\n\t\t_center_of_mass *= 1.0 / neighbor_count\n\t\tacceleration.linear = (\n\t\t\t(_center_of_mass - agent.position).normalized()\n\t\t\t* agent.linear_acceleration_max\n\t\t)\n\n# Callback for the proximity to call when finding neighbors. Adds `neighbor`'s position\n# to the center of mass of the group.\n# @tags - virtual\nfunc _report_neighbor(neighbor: GSAISteeringAgent) -> bool:\n\t_center_of_mass += neighbor.position\n\treturn true\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "## 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\n\nfunc _ready() -> void:\n\t# Ensure that playback state is always updating, otherwise the smoothing\n\t# filter causes issues.", "output": "\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"} {"instruction": "Vervollständige den GDScript-Code:", "input": "extends StaticBody2D\n\nsignal gong_struck\n\nvar enabled: bool = true", "output": "\n@onready var animation_player: AnimationPlayer = $AnimationPlayer\n\nfunc _on_health_damaged(_amount: float, _knockback: Vector2) -> void:\n\tif not enabled:\n\t\treturn\n\tanimation_player.play(&\"struck\")\n\tgong_struck.emit()\n\tenabled = false\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "#!/usr/bin/env -S godot -s\nextends MainLoop\n\nconst GdUnitTools := preload(\"res://addons/gdUnit4/src/core/GdUnitTools.gd\")\n\n# gdlint: disable=max-line-length\nconst LOG_FRAME_TEMPLATE = \"\"\"\n\n\n\n\t\n\t\n\tGodot Logging\n\t\n\n\n\n\t
\n${content}\n\t
\n\n\n\"\"\"\n\nconst NO_LOG_MESSAGE = \"\"\"\n

No logging available!

\n
\n

In order for logging to take place, you must activate the Activate file logging option in the project settings.

\n

You can enable the logging under:\nProject Settings > Debug > File Logging > Enable File Logging in the project settings.

\n\"\"\"\n\n#warning-ignore-all:return_value_discarded\nvar _cmd_options := CmdOptions.new([\n\t\tCmdOption.new(\n\t\t\t\"-rd, --report-directory\",\n\t\t\t\"-rd \",\n\t\t\t\"Specifies the output directory in which the reports are to be written. The default is res://reports/.\",\n\t\t\tTYPE_STRING,\n\t\t\ttrue\n\t\t)\n\t])\n\n\nvar _report_root_path: String\nvar _current_report_path: String\nvar _debug_cmd_args := PackedStringArray()\n\n\nfunc _init() -> void:\n\tset_report_directory(GdUnitFileAccess.current_dir() + \"reports\")\n\tset_current_report_path()\n\n\nfunc _process(_delta: float) -> bool:\n\t# check if reports exists", "output": "\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]"} {"instruction": "Erstelle eine Godot-Klasse 'FieldCursor' die von TileMapLayer erbt mit folgenden Funktionen: _ready, _unhandled_input, set_focus, _get_cell_under_mouse, _on_input_paused", "input": "", "output": "## Handles mouse/touch events for the field gamestate.\n##\n## The field cursor's role is to determine whether or not the input event occurs over a particular\n## cell and how that cell should be highlighted.\nclass_name FieldCursor\nextends TileMapLayer\n\n## Emitted when the highlighted cell changes to a new value. An invalid cell is indicated by a value\n## of [constant Gameboard.INVALID_CELL].\nsignal focus_changed(old_focus: Vector2i, new_focus: Vector2i)\n\n## Emitted when a cell is selected via input event.\nsignal selected(selected_cell: Vector2i)\n\n## The cell currently highlighted by the cursor.\n##\n## [br][br]A focus of [constant Gameboard.INVALID_CELL] indicates that there is no highlight.\nvar focus: = Gameboard.INVALID_CELL:\n\tset = set_focus\n\nfunc _ready() -> void:\n\tFieldEvents.input_paused.connect(_on_input_paused)\n\nfunc _unhandled_input(event: InputEvent) -> void:\n\tif event is InputEventMouseMotion:\n\t\tget_viewport().set_input_as_handled()\n\t\tset_focus(_get_cell_under_mouse())\n\n\telif event.is_action_released(\"select\"):\n\t\tget_viewport().set_input_as_handled()\n\n\t\tselected.emit(_get_cell_under_mouse())\n\t\tFieldEvents.cell_selected.emit(_get_cell_under_mouse())\n\n## Change the highlighted cell to a new value. A value of [constant Gameboard.INVALID_CELL] will\n## indicate that there is no highlighted cell.\n## [br][br][b]Note:[/b] Values will be limited to [member valid_cells] if valid_cells is not empty.\n## Values outside of valid_cells will not be focused.\nfunc set_focus(value: Vector2i) -> void:\n\tif value == focus:\n\t\treturn\n\n\tvar old_focus: = focus\n\tfocus = value\n\n\tclear()\n\n\tif focus != Gameboard.INVALID_CELL:\n\t\tset_cell(focus, 0, Vector2i(1, 5), 0)\n\t\t#set_cell(0, focus, 0, Vector2(1, 5))\n\n\tfocus_changed.emit(old_focus, focus)\n\tFieldEvents.cell_highlighted.emit(focus)\n\n# Convert mouse/touch coordinates to a gameboard cell.\nfunc _get_cell_under_mouse() -> Vector2i:\n\t# The mouse coordinates need to be corrected for any scale or position changes in the scene.\n\tvar"} {"instruction": "Erstelle eine Godot-Klasse 'GdUnitFloatAssert' die von GdUnitAssert erbt mit folgenden Funktionen: is_null, is_not_null, is_equal, is_not_equal, is_equal_approx", "input": "", "output": "## An Assertion Tool to verify float values\n@abstract class_name GdUnitFloatAssert\nextends GdUnitAssert\n\n## Verifies that the current value is null.\n@abstract func is_null() -> GdUnitFloatAssert\n\n## Verifies that the current value is not null.\n@abstract func is_not_null() -> GdUnitFloatAssert\n\n## Verifies that the current value is equal to the given one.\n@abstract func is_equal(expected: Variant) -> GdUnitFloatAssert\n\n## Verifies that the current value is not equal to expected one.\n@abstract func is_not_equal(expected: Variant) -> GdUnitFloatAssert\n\n## Verifies that the current and expected value are approximately equal.\n@abstract func is_equal_approx(expected: float, approx: float) -> GdUnitFloatAssert\n\n## Overrides the default failure message by given custom message.\n@abstract func override_failure_message(message: String) -> GdUnitFloatAssert\n\n## Appends a custom message to the failure message.\n@abstract func append_failure_message(message: String) -> GdUnitFloatAssert\n\n## Verifies that the current value is less than the given one.\n@abstract func is_less(expected: float) -> GdUnitFloatAssert\n\n## Verifies that the current value is less than or equal the given one.\n@abstract func is_less_equal(expected: float) -> GdUnitFloatAssert\n\n## Verifies that the current value is greater than the given one.\n@abstract func is_greater(expected: float) -> GdUnitFloatAssert\n\n## Verifies that the current value is greater than or equal the given one.\n@abstract func is_greater_equal(expected: float) -> GdUnitFloatAssert\n\n## Verifies that the current value is negative.\n@abstract func is_negative() -> GdUnitFloatAssert\n\n## Verifies that the current value is not negative.\n@abstract func is_not_negative() -> GdUnitFloatAssert\n\n## Verifies that the current value is equal to zero.\n@abstract func is_zero() -> GdUnitFloatAssert\n\n## Verifies that the current value is not equal to zero.\n@abstract func is_not_zero() -> GdUnitFloatAssert\n\n## Verifies that the current value is in"} {"instruction": "Erstelle eine Godot-Klasse 'GdUnitConstants' die von RefCounted erbt mit folgenden Funktionen:", "input": "", "output": "class_name GdUnitConstants\nextends RefCounted\n\nconst NO_ARG :Variant = \"<--null-->\"\n\nconst EXPECT_ASSERT_REPORT_FAILURES := \"expect_assert_report_failures\"\n\n## The maximum number of report history files to store\nconst DEFAULT_REPORT_HISTORY_COUNT = 20\nconst REPORT_DIR_PREFIX = \"report_\"\n"} {"instruction": "Erstelle eine GDScript-Funktion namens '_unhandled_input':", "input": "", "output": "func _unhandled_input(event: InputEvent) -> void:\n\tstate.unhandled_input(event)\n\nfunc _physics_process(delta: float) -> void:\n\tstate.physics_process(delta)\n\nfunc transition_to(target_state_path: String, msg: Dictionary = {}", "source": "extracted_function"} {"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 = {}", "source": "extracted_function"} {"instruction": "Vervollständige den GDScript-Code:", "input": "## A signal bus to connect distant scenes to various combat-exclusive events.\nextends Node\n\n## Emitted whenever a combat has been setup and is ready to become the active 'game state'. At this\n## point, the screen is fully covered by the [ScreenTransition] autoload.\n@warning_ignore(\"unused_signal\")", "output": "signal combat_initiated(arena: PackedScene)\n\n## Emitted whenever the player has finished with the combat state regardless of whether or not the\n## combat was won by the player. At this point the screen has faded to black and any events that\n## immediately follow the combat may occur.\n@warning_ignore(\"unused_signal\")\nsignal combat_finished(is_player_victory: bool)\n\n## Emitted whenever a player battler is selected, prompting the player to choose an action.\n@warning_ignore(\"unused_signal\")\nsignal player_battler_selected(battler: Battler)\n"} {"instruction": "Erstelle eine GDScript-Funktion namens 'get_behavior_at':", "input": "", "output": "func get_behavior_at(index: int) -> Dictionary:\n\tif _behaviors.size() > index:\n\t\treturn _behaviors[index]\n\tprinterr(\"Tried to get index \" + str(index) + \" in array of size \" + str(_behaviors.size()))\n\treturn {}", "source": "extracted_function"} {"instruction": "Vervollständige den GDScript-Code:", "input": "# Adds velocity, speed, and size data to `GSAIAgentLocation`.\n#\n# It is the character's responsibility to keep this information up to date for\n# the steering toolkit to work correctly.\n# @category - Base types\nclass_name GSAISteeringAgent\nextends GSAIAgentLocation\n\n# The amount of velocity to be considered effectively not moving.", "output": "var zero_linear_speed_threshold := 0.01\n# The maximum speed at which the agent can move.\nvar linear_speed_max := 0.0\n# The maximum amount of acceleration that any behavior can apply to the agent.\nvar linear_acceleration_max := 0.0\n# The maximum amount of angular speed at which the agent can rotate.\nvar angular_speed_max := 0.0\n# The maximum amount of angular acceleration that any behavior can apply to an\n# agent.\nvar angular_acceleration_max := 0.0\n# Current velocity of the agent.\nvar linear_velocity := Vector3.ZERO\n# Current angular velocity of the agent.\nvar angular_velocity := 0.0\n# The radius of the sphere that approximates the agent's size in space.\nvar bounding_radius := 0.0\n# Used internally by group behaviors and proximities to mark the agent as already\n# considered.\nvar is_tagged := false\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "#*\n#* hurtbox.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", "output": "#* https://opensource.org/licenses/MIT.\n#* =============================================================================\n#*\nclass_name Hurtbox\nextends Area2D\n## Area that registers damage.\n\n@export var health: Health\n\nvar last_attack_vector: Vector2\n\nfunc take_damage(amount: float, knockback: Vector2, source: Hitbox) -> void:\n\tlast_attack_vector = owner.global_position - source.owner.global_position\n\thealth.take_damage(amount, knockback)\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "@tool\n\nclass_name InteractionTemplateConversation extends Interaction\n\n@export var timeline: DialogicTimeline\n\n", "output": "func _execute() -> void:\n\tif timeline:\n\t\tDialogic.start_timeline(timeline)\n\n\t\tDialogic.signal_event.connect(_on_dialogic_signal_event)\n\n\t\t# Wait for the timeline to finish before ending the event.\n\t\tawait Dialogic.timeline_ended\n\n\t\tDialogic.signal_event.disconnect(_on_dialogic_signal_event)\n\nfunc _on_dialogic_signal_event(_argument: String) -> void:\n\tpass\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 GDScript-Funktion namens 'get_behavior_at':", "input": "", "output": "func get_behavior_at(index: int) -> Dictionary:\n\tif _behaviors.size() > index:\n\t\treturn _behaviors[index]\n\tprinterr(\"Tried to get index \" + str(index) + \" in array of size \" + str(_behaviors.size()))\n\treturn {}", "source": "extracted_function"} {"instruction": "Vervollständige den GDScript-Code:", "input": "#*\n#* arrive_pos.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 to the specified position, favoring horizontal movement. [br]\n## Returns [code]SUCCESS[/code] when close to the target position (see [member tolerance]);\n## otherwise returns [code]RUNNING[/code].\n\n## Blackboard variable that stores the target position (Vector2)\n@export var target_position_var := &\"pos\"\n\n## Variable that stores desired speed (float)\n@export var speed_var := &\"speed\"\n\n## How close should the agent be to the target position to return SUCCESS.", "output": "@export var tolerance := 50.0\n\n## Specifies the node to avoid (valid Node2D is expected).\n## If not empty, agent will circle around the node while moving into position.\n@export var avoid_var: StringName\n\nfunc _generate_name() -> String:\n\treturn \"Arrive pos: %s%s\" % [\n\t\tLimboUtility.decorate_var(target_position_var),\n\t\t\"\" if avoid_var.is_empty() else \" avoid: \" + LimboUtility.decorate_var(avoid_var)\n\t]\n\nfunc _tick(_delta: float) -> Status:\n\tvar target_pos: Vector2 = blackboard.get_var(target_position_var, Vector2.ZERO)\n\tif target_pos.distance_to(agent.global_position) < tolerance:\n\t\treturn SUCCESS\n\n\tvar speed: float = blackboard.get_var(speed_var, 10.0)\n\tvar dist: float = absf(agent.global_position.x - target_pos.x)\n\tvar dir: Vector2 = agent.global_position.direction_to(target_pos)\n\n\t# Prefer horizontal movement:\n\tvar vertical_factor: float = remap(dist, 200.0, 500.0, 1.0, 0.0)\n\tvertical_factor = clampf(vertical_factor, 0.0, 1.0)\n\tdir.y *= vertical_factor\n\n\t# Avoid the node specified by `avoid_var`.\n\t# I.e., if `avoid_var` is set, agent will circle around that node while moving into position.\n\tif not avoid_var.is_empty():\n\t\tvar avoid_node: Node2D = blackboard.get_var(avoid_var)\n\t\tif is_instance_valid(avoid_node):\n\t\t\tvar distance_vector: Vector2 = avoid_node.global_position - agent.global_position\n\t\t\tif dir.dot(distance_vector) > 0.0:\n\t\t\t\tvar side := dir.rotated(PI * 0.5).normalized()\n\t\t\t\t# The closer we are to the avoid target, the stronger is the avoidance.\n\t\t\t\tvar strength: float = remap(distance_vector.length(), 200.0, 400.0, 1.0, 0.0)\n\t\t\t\tstrength = clampf(strength, 0.0, 1.0)\n\t\t\t\tvar avoidance := side * signf(-side.dot(distance_vector)) * strength\n\t\t\t\tdir += avoidance\n\n\tvar desired_velocity: Vector2 = dir.normalized() * speed\n\tagent.move(desired_velocity)\n\tagent.update_facing()\n\treturn RUNNING\n"} {"instruction": "Erstelle eine Godot-Klasse 'GdUnitDictionaryAssert' die von GdUnitAssert erbt mit folgenden Funktionen: is_null, is_not_null, is_equal, is_not_equal, override_failure_message", "input": "", "output": "## An Assertion Tool to verify dictionary\n@abstract class_name GdUnitDictionaryAssert\nextends GdUnitAssert\n\n## Verifies that the current value is null.\n@abstract func is_null() -> GdUnitDictionaryAssert\n\n## Verifies that the current value is not null.\n@abstract func is_not_null() -> GdUnitDictionaryAssert\n\n## Verifies that the current dictionary is equal to the given one, ignoring order.\n@abstract func is_equal(expected: Variant) -> GdUnitDictionaryAssert\n\n## Verifies that the current dictionary is not equal to the given one, ignoring order.\n@abstract func is_not_equal(expected: Variant) -> GdUnitDictionaryAssert\n\n## Overrides the default failure message by given custom message.\n@abstract func override_failure_message(message: String) -> GdUnitDictionaryAssert\n\n## Appends a custom message to the failure message.\n@abstract func append_failure_message(message: String) -> GdUnitDictionaryAssert\n\n## Verifies that the current dictionary is empty, it has a size of 0.\n@abstract func is_empty() -> GdUnitDictionaryAssert\n\n## Verifies that the current dictionary is not empty, it has a size of minimum 1.\n@abstract func is_not_empty() -> GdUnitDictionaryAssert\n\n## Verifies that the current dictionary is the same. [br]\n## Compares the current by object reference equals\n@abstract func is_same(expected: Variant) -> GdUnitDictionaryAssert\n\n## Verifies that the current dictionary is NOT the same. [br]\n## Compares the current by object reference equals\n@abstract func is_not_same(expected: Variant) -> GdUnitDictionaryAssert\n\n## Verifies that the current dictionary has a size of given value.\n@abstract func has_size(expected: int) -> GdUnitDictionaryAssert\n\n## Verifies that the current dictionary contains the given key(s).[br]\n## The keys are compared by deep parameter comparision, for object reference compare you have to use [method contains_same_keys]\n@abstract func contains_keys(...expected: Array) -> GdUnitDictionaryAssert\n\n## Verifies that the current dictionary contai"} {"instruction": "Vervollständige den GDScript-Code:", "input": "@tool\n@icon(\"res://assets/editor/icons/IconGamepieceController.svg\")\nclass_name GamepieceController extends Node2D\n\n## Emitted whenever the gamepiece begins moving towards a new cell in its [member move_path].\nsignal waypoint_changed(waypoint: Vector2i)\n\n## An active controller will receive inputs (player or otherwise). An inactive controller does\n## nothing. This is useful, for example, when toggling of gamepiece movement during cutscenes.\nvar is_active: = false:\n\tset = set_is_active\n\n## Keep track of a move path. The controller will check that the path is clear each time the \n## gamepiece needs to continue on to the next cell.\nvar move_path: Array[Vector2i] = []:\n\tset = move_along_path\nvar _current_waypoint: Vector2i:\n\tset(value):\n\t\tif value != _current_waypoint:\n\t\t\t_current_waypoint = value\n\t\t\twaypoint_changed.emit(_current_waypoint)\n\n# The controller operates on its direct parent, which must be a gamepiece object.\nvar _gamepiece: Gamepiece\n\n\nfunc _ready() -> void:\n\tset_process(false)\n\tset_physics_process(false)\n\t\n\tif not Engine.is_editor_hint():\n\t\tis_active = true\n\t\t\n\t\t_gamepiece.arriving.connect(_on_gamepiece_arriving)\n\t\t_gamepiece.arrived.connect(_on_gamepiece_arrived)\n\t\t", "output": "\t\tFieldEvents.input_paused.connect(\n\t\t\tfunc _on_input_paused(value: bool) -> void:\n\t\t\t\tis_active = !value\n\t\t)\n\nfunc _get_configuration_warnings() -> PackedStringArray:\n\tvar warnings: PackedStringArray = []\n\tif not _gamepiece:\n\t\twarnings.append(\"This object must be a child of a gamepiece!\")\n\n\treturn warnings\n\nfunc _notification(what: int) -> void:\n\tif what == NOTIFICATION_PARENTED:\n\t\t_gamepiece = get_parent() as Gamepiece\n\t\tupdate_configuration_warnings()\n\nfunc move_along_path(value: Array[Vector2i]) -> void:\n\tmove_path = value\n\t_move_to_next_waypoint()\n\n## Set whether or not the controller may exert control over the gamepiece.\n## There are a number of occasions (such as cutscenes or combat) where gamepieces are inactive.\nfunc set_is_active(value: bool) -> void:\n\tis_active = value\n\t_move_to_next_waypoint() # Will only affect the gamepiece if is_active == true.\n\n# Finds the [member move_path]'s waypoint using [method Array.pop_front] and begins moveing the\n# gamepiece towards it.\n# The method will do nothing if the controller is currently inactive.\n# Returns the distance (in pixels) to the next waypoint.\nfunc _move_to_next_waypoint() -> float:\n\tvar distance_to_point: = 0.0\n\n\tif is_active:\n\t\tif move_path.size() >= 1 and Gameboard.pathfinder.can_move_to(move_path[0]):\n\t\t\t_current_waypoint = move_path.pop_front()\n\t\t\tvar destination = Gameboard.cell_to_pixel(_current_waypoint)\n\n\t\t\t# Report how far away the waypoint is.\n\t\t\tdistance_to_point = _gamepiece.position.distance_to(destination)\n\t\t\t_gamepiece.move_to(Gameboard.cell_to_pixel(_current_waypoint))\n\n\t\t\tGamepieceRegistry.move_gamepiece(_gamepiece, _current_waypoint)\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "extends Node\n\nsignal scroll_speed_changed(speed: float)\n\n@export var use_filtered_playback: bool = true\n", "output": "@export var enable_metronome: bool = false\n@export var input_latency_ms: int = 20\n\n@export var scroll_speed: float = 400:\n\tset(value):\n\t\tif scroll_speed != value:\n\t\t\tscroll_speed = value\n\t\t\tscroll_speed_changed.emit(value)\n@export var show_offsets: bool = false\n\n@export var selected_chart: ChartData.Chart = ChartData.Chart.THE_COMEBACK\n"} {"instruction": "Erstelle eine GDScript-Funktion namens '_ready':", "input": "", "output": "func _ready() -> void:\n\tawait owner.ready\n\tstate.enter()\n\nfunc _unhandled_input(event: InputEvent) -> void:\n\tstate.unhandled_input(event)\n\nfunc _physics_process(delta: float) -> void:\n\tstate.physics_process(delta)\n\nfunc transition_to(target_state_path: String, msg: Dictionary = {}", "source": "extracted_function"} {"instruction": "Vervollständige den GDScript-Code:", "input": "extends KinematicBody\n\nsignal hit\n\n# How fast the player moves in meters per second.\nexport var speed = 14\n# Vertical impulse applied to the character upon jumping in meters per second.\nexport var jump_impulse = 20\n# Vertical impulse applied to the character upon bouncing over a mob in meters per second.\nexport var bounce_impulse = 16\n# The downward acceleration when in the air, in meters per second per second.\nexport var fall_acceleration = 75\n\nvar velocity = Vector3.ZERO\n\n\nfunc _physics_process(delta):\n\tvar direction = Vector3.ZERO\n\tif Input.is_action_pressed(\"move_right\"):\n\t\tdirection.x += 1\n\tif Input.is_action_pressed(\"move_left\"):\n\t\tdirection.x -= 1\n\tif Input.is_action_pressed(\"move_back\"):\n\t\tdirection.z += 1", "output": "\tif Input.is_action_pressed(\"move_forward\"):\n\t\tdirection.z -= 1\n\n\tif direction != Vector3.ZERO:\n\t\t# In the lines below, we turn the character when moving and make the animation play faster.\n\t\tdirection = direction.normalized()\n\t\t$Pivot.look_at(translation + direction, Vector3.UP)\n\t\t$AnimationPlayer.playback_speed = 4\n\telse:\n\t\t$AnimationPlayer.playback_speed = 1\n\n\tvelocity.x = direction.x * speed\n\tvelocity.z = direction.z * speed\n\n\t# Jumping.\n\tif is_on_floor() and Input.is_action_just_pressed(\"jump\"):\n\t\tvelocity.y += jump_impulse\n\n\t# We apply gravity every frame so the character always collides with the ground when moving.\n\t# This is necessary for the is_on_floor() function to work as a body can always detect\n\t# the floor, walls, etc. when a collision happens the same frame.\n\tvelocity.y -= fall_acceleration * delta\n\tvelocity = move_and_slide(velocity, Vector3.UP)\n\n\t# Here, we check if we landed on top of a mob and if so, we kill it and bounce.\n\t# With move_and_slide(), Godot makes the body move sometimes multiple times in a row to\n\t# smooth out the character's motion. So we have to loop over all collisions that may have\n\t# happened.\n\t# If there are no \"slides\" this frame, the loop below won't run.\n\tfor index in range(get_slide_count()):\n\t\tvar collision = get_slide_collision(index)\n\t\tif collision.collider.is_in_group(\"mob\"):\n\t\t\tvar mob = collision.collider\n\t\t\tif Vector3.UP.dot(collision.normal) > 0.1:\n\t\t\t\tmob.squash()\n\t\t\t\tvelocity.y = bounce_impulse\n\n\t# This makes the character follow a nice arc when jumping\n\t$Pivot.rotation.x = PI / 6 * velocity.y / jump_impulse\n\nfunc die():\n\temit_signal(\"hit\")\n\tqueue_free()\n\nfunc _on_MobDetector_body_entered(_body):\n\tdie()\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "# Blends multiple steering behaviors into one, and returns a weighted\n# acceleration from their calculations.\n#\n# Stores the behaviors internally as dictionaries of the form\n# {\n# \tbehavior : GSAISteeringBehavior,\n# \tweight : float\n# }\n# @category - Combination behaviors\nclass_name GSAIBlend\nextends GSAISteeringBehavior\n\nvar _behaviors := []\nvar _accel := GSAITargetAcceleration.new()\n\n", "output": "func _init(agent: GSAISteeringAgent) -> void:\n\tsuper._init(agent)\n\n# Appends a behavior to the internal array along with its `weight`.\nfunc add(behavior: GSAISteeringBehavior, weight: float) -> void:\n\tbehavior.agent = agent\n\t_behaviors.append({behavior = behavior, weight = weight})\n\n# Returns the behavior at the specified `index`, or an empty `Dictionary` if\n# none was found.\nfunc get_behavior_at(index: int) -> Dictionary:\n\tif _behaviors.size() > index:\n\t\treturn _behaviors[index]\n\tprinterr(\"Tried to get index \" + str(index) + \" in array of size \" + str(_behaviors.size()))\n\treturn {}\n\nfunc _calculate_steering(blended_accel: GSAITargetAcceleration) -> void:\n\tblended_accel.set_zero()\n\n\tfor i in range(_behaviors.size()):\n\t\tvar bw: Dictionary = _behaviors[i]\n\t\tbw.behavior.calculate_steering(_accel)\n\n\t\tblended_accel.add_scaled_accel(_accel, bw.weight)\n\n\tblended_accel.linear = GSAIUtils.clampedv3(blended_accel.linear, agent.linear_acceleration_max)\n\tblended_accel.angular = clamp(\n\t\tblended_accel.angular, -agent.angular_acceleration_max, agent.angular_acceleration_max\n\t)\n"} {"instruction": "Erstelle eine Godot-Klasse 'Pickup' die von Trigger erbt mit folgenden Funktionen: _execute", "input": "", "output": "@tool\nclass_name Pickup extends Trigger\n\n@export var item_type: Inventory.ItemTypes:\n\tset(value):\n\t\titem_type = value\n\n\t\tif not is_inside_tree():\n\t\t\tawait ready\n\n\t\t_sprite.texture = Inventory.get_item_icon(item_type)\n\n@export var amount: = 1\n\n@onready var _anim: AnimationPlayer = $AnimationPlayer\n@onready var _sprite: Sprite2D = $Sprite2D\n\nfunc _execute() -> void:\n\t_anim.play(\"PickupAnimations/obtain\")\n\tInventory.restore().add(item_type, amount)\n\n\tawait _anim.animation_finished\n\tqueue_free()\n"} {"instruction": "Erstelle eine Godot-Klasse 'Elements' die von RefCounted erbt mit folgenden Funktionen:", "input": "", "output": "class_name Elements extends RefCounted\n\n#enum Types { NONE, BUG, BREAK, SEEK, VOID, STATIC, CONTROL, GUARD, EXCEPTION }\nenum Types { NONE, BUG, BREAK, SEEK }\n\n## Elements may have an advantage against others (attack power, chance-to-hit, etc.). These\n## relationships are stored in the following dictionary.\n## Dictionary values are the elements against which the dictionary key is strong. The weak elements\n## are stored as a list. An empty list indicates that the element has no advantage against others.\nconst ADVANTAGES: = {\n\tTypes.NONE: [],\n\tTypes.BUG: [Types.BREAK],\n\tTypes.BREAK: [Types.NONE, Types.SEEK],\n\tTypes.SEEK: [Types.BUG],\n}\n"} {"instruction": "Erstelle eine GDScript-Funktion namens 'report_success':", "input": "", "output": "func report_success() -> GdUnitArrayAssert:\n\t@warning_ignore(\"return_value_discarded\")\n\t_base.report_success()\n\treturn self\n\nfunc report_error(error: String) -> GdUnitArrayAssert:\n\t@warning_ignore(\"return_value_discarded\")\n\t_base.report_error(error)\n\treturn self\n\nfunc failure_message() -> String:\n\treturn _base.failure_message()\n\nfunc override_failure_message(message: String) -> GdUnitArrayAssert:\n\t@warning_ignore(\"return_value_discarded\")\n\t_base.override_failure_message(message)\n\treturn self\n\nfunc append_failure_message(message: String) -> GdUnitArrayAssert:\n\t@warning_ignore(\"return_value_discarded\")\n\t_base.append_failure_message(message)\n\treturn self\n\nfunc _validate_value_type(value: Variant) -> bool:\n\treturn value == null or GdArrayTools.is_array_type(value)\n\nfunc get_current_value() -> Variant:\n\treturn _current_value_provider.get_value()\n\nfunc max_length(left: Variant, right: Variant) -> int:\n\tvar ls := str(left).length()\n\tvar rs := str(right).length()\n\treturn rs if ls < rs else ls\n\n# gdlint: disable=function-name\nfunc _toPackedStringArray(value: Variant) -> PackedStringArray:\n\tif GdArrayTools.is_array_type(value):\n\t\t@warning_ignore(\"unsafe_cast\")\n\t\treturn PackedStringArray(value as Array)\n\treturn PackedStringArray([str(value)])\n\nfunc _array_equals_div(current: Variant, expected: Variant, case_sensitive: bool = false) -> Array:\n\tvar current_value := _toPackedStringArray(current)\n\tvar expected_value := _toPackedStringArray(expected)\n\tvar index_report := Array()\n\tfor index in current_value.size():\n\t\tvar c := current_value[index]\n\t\tif index < expected_value.size():\n\t\t\tvar e := expected_value[index]\n\t\t\tif not GdObjects.equals(c, e, case_sensitive):\n\t\t\t\tvar length := max_length(c, e)\n\t\t\t\tcurrent_value[index] = GdAssertMessages.format_invalid(c.lpad(length))\n\t\t\t\texpected_value[index] = e.lpad(length)\n\t\t\t\tindex_report.push_back({\"index\": index, \"current\": c, \"expected\": e}"} {"instruction": "Vervollständige den GDScript-Code:", "input": "class_name LoopingAudioStreamPlayer2D\nextends AudioStreamPlayer2D\n\n@export var sound_start: AudioStream\n@export var sound_loop: AudioStream\n@export var sound_tail: AudioStream\n\nvar ending := false\n\n", "output": "func _ready() -> void:\n\tfinished.connect(_on_finished)\n\nfunc start() -> void:\n\tstream = sound_start\n\tending = false\n\tplay()\n\nfunc end() -> void:\n\tstream = sound_tail\n\tending = true\n\nfunc _on_finished() -> void:\n\tif stream == sound_start:\n\t\tstream = sound_loop\n\t\tplay()\n"} {"instruction": "Erstelle eine Godot-Klasse 'GdUnitAwaiter' die von RefCounted erbt mit folgenden Funktionen: await_signal_on, await_signal_idle_frames, await_millis, await_idle_frame", "input": "", "output": "class_name GdUnitAwaiter\nextends RefCounted\n\n# Waits for a specified signal in an interval of 50ms sent from the , and terminates with an error after the specified timeout has elapsed.\n# source: the object from which the signal is emitted\n# signal_name: signal name\n# args: the expected signal arguments as an array\n# timeout: the timeout in ms, default is set to 2000ms\nfunc await_signal_on(source :Object, signal_name :String, args :Array = [], timeout_millis :int = 2000) -> Variant:\n\t# fail fast if the given source instance invalid\n\tvar assert_that := GdUnitAssertImpl.new(signal_name)\n\tvar line_number := GdUnitAssertions.get_line_number()\n\tif not is_instance_valid(source):\n\t\t@warning_ignore(\"return_value_discarded\")\n\t\tassert_that.report_error(GdAssertMessages.error_await_signal_on_invalid_instance(source, signal_name, args), line_number)\n\t\treturn await (Engine.get_main_loop() as SceneTree).process_frame\n\t# fail fast if the given source instance invalid\n\tif not is_instance_valid(source):\n\t\t@warning_ignore(\"return_value_discarded\")\n\t\tassert_that.report_error(GdAssertMessages.error_await_signal_on_invalid_instance(source, signal_name, args), line_number)\n\t\treturn await await_idle_frame()\n\tvar awaiter := GdUnitSignalAwaiter.new(timeout_millis)\n\tvar value :Variant = await awaiter.on_signal(source, signal_name, args)\n\tif awaiter.is_interrupted():\n\t\tvar failure := \"await_signal_on(%s, %s) timed out after %sms\" % [signal_name, args, timeout_millis]\n\t\t@warning_ignore(\"return_value_discarded\")\n\t\tassert_that.report_error(failure, line_number)\n\treturn value\n\n# Waits for a specified signal sent from the between idle frames and aborts with an error after the specified timeout has elapsed\n# source: the object from which the signal is emitted\n# signal_name: signal name\n# args: the expected signal arguments as an array\n# timeout: the timeout in ms, default is set to 2000ms\nfunc await_signal_idle_frames(source :Object, signal_name :String, args :Array = [], timeout_"} {"instruction": "Erstelle eine Godot-Klasse 'ColorChangingSprite' die von Sprite2D erbt mit folgenden Funktionen:", "input": "", "output": "class_name ColorChangingSprite extends Sprite2D\n\nsignal color_changed\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "extends GdUnitFailureAssert\n\nconst GdUnitTools := preload(\"res://addons/gdUnit4/src/core/GdUnitTools.gd\")\n\nvar _is_failed := false\nvar _failure_message: String\nvar _current_failure_message := \"\"\nvar _custom_failure_message := \"\"\nvar _additional_failure_message := \"\"\n\n\nfunc _set_do_expect_fail(enabled :bool = true) -> void:\n\tEngine.set_meta(GdUnitConstants.EXPECT_ASSERT_REPORT_FAILURES, enabled)\n\n\nfunc execute_and_await(assertion :Callable, do_await := true) -> GdUnitFailureAssert:\n\t# do not report any failure from the original assertion we want to test\n\t_set_do_expect_fail(true)\n\tvar thread_context := GdUnitThreadManager.get_current_context()\n\tthread_context.set_assert(null)\n\t@warning_ignore(\"return_value_discarded\")\n\tGdUnitSignals.instance().gdunit_set_test_failed.connect(_on_test_failed)\n\t# execute the given assertion as callable\n\tif do_await:\n\t\tawait assertion.call()\n\telse:\n\t\tassertion.call()\n\t_set_do_expect_fail(false)\n\t# get the assert instance from current tread context\n\tvar current_assert := thread_context.get_assert()\n\tif not is_instance_of(current_assert, GdUnitAssert):\n\t\t_is_failed = true\n\t\t_failure_message = \"Invalid Callable! It must be a callable of 'GdUnitAssert'\"\n\t\treturn self\n\t@warning_ignore(\"unsafe_method_access\")\n\t_failure_message = current_assert.failure_message()\n\treturn self\n\n\nfunc execute(assertion :Callable) -> GdUnitFailureAssert:\n\t@warning_ignore(\"return_value_discarded\")\n\texecute_and_await(assertion, false)\n\treturn self\n\n", "output": "func _on_test_failed(value :bool) -> void:\n\t_is_failed = value\n\nfunc is_equal(_expected: Variant) -> GdUnitFailureAssert:\n\treturn _report_error(\"Not implemented\")\n\nfunc is_not_equal(_expected: Variant) -> GdUnitFailureAssert:\n\treturn _report_error(\"Not implemented\")\n\nfunc is_null() -> GdUnitFailureAssert:\n\treturn _report_error(\"Not implemented\")\n\nfunc is_not_null() -> GdUnitFailureAssert:\n\treturn _report_error(\"Not implemented\")\n\nfunc override_failure_message(message: String) -> GdUnitFailureAssert:\n\t_custom_failure_message = message\n\treturn self\n\nfunc append_failure_message(message: String) -> GdUnitFailureAssert:\n\t_additional_failure_message = message\n\treturn self\n\nfunc is_success() -> GdUnitFailureAssert:\n\tif _is_failed:\n\t\treturn _report_error(\"Expect: assertion ends successfully.\")\n\treturn self\n\nfunc is_failed() -> GdUnitFailureAssert:\n\tif not _is_failed:\n\t\treturn _report_error(\"Expect: assertion fails.\")\n\treturn self\n\nfunc has_line(expected :int) -> GdUnitFailureAssert:\n\tvar current := GdAssertReports.get_last_error_line_number()\n\tif current != expected:\n\t\treturn _report_error(\"Expect: to failed on line '%d'\\n but was '%d'.\" % [expected, current])\n\treturn self\n\nfunc has_message(expected :String) -> GdUnitFailureAssert:"} {"instruction": "Vervollständige den GDScript-Code:", "input": "## A cutscene stops field gameplay to run a scripted event.\n##\n## A cutscene may be thought of as the videogame equivalent of a short scene in a film. For example,\n## dialogue may be displayed, the scene may switch to show key NPCs performing an event, or the\n## inventory may be altered. Gameplay on the field is [b]stopped[/b] until the cutscene concludes,\n## though this may span a combat scenario (e.g. epic bossfight).\n##\n##[br][br]\n## Cutscenes may or may not have duration, and only one cutscene may be active at a time. Field\n## gameplay is stopped for the entire duration of the active cutscene.\n## Gameplay is stopped by emitting the global [signal FieldEvents.input_paused] signal.\n## AI and player objects respond to this signal. For examples or responses to this signal, see\n## [member GamepieceController.is_paused] or [method FieldCursor._on_input_paused].\n##\n##[br][br]\n## Cutscenes are inherently custom and must be derived to do anything useful. They may be run via\n## the [method run] method and derived cutscenes will override the [method _execute] method to\n## provide custom functionality.\n##\n##[br][br]", "output": "## Cutscenes are easily extensible, taking advantage of Godot's scene architecture. A variety of\n## cutscene templates are included out-of-the-box. See [Trigger] for a type of cutscene that is\n## triggered by contact with a gamepeiece. See [Interaction] for cutscene's that are triggered by\n## the player interaction with them via a keypress or touch. Several derived temlpates (for example,\n## open-able doors) are included in res://field/cutscenes/templates.\n@icon(\"res://assets/editor/icons/Cutscene.svg\")\nclass_name Cutscene extends Node2D\n\n# Indicates if a cutscene is currently running. [b]This member should not be set externally[/b].\nstatic var _is_cutscene_in_progress: = false:\n\tset(value):\n\t\tif _is_cutscene_in_progress != value:\n\t\t\t_is_cutscene_in_progress = value\n\n\t\t\tFieldEvents.input_paused.emit(value)\n\n## Returns true if a cutscene is currently running.\nstatic func is_cutscene_in_progress() -> bool:\n\treturn _is_cutscene_in_progress\n\n## Execute the cutscene, if possible. Everything happening on the field gamestate will be\n## paused and unpaused as the cutscene starts and finishes, respectively.\nfunc run() -> void:\n\t_is_cutscene_in_progress = true\n\n\t# The _execute method may or may not be asynchronous, depending on the particular cutscene.\n\t@warning_ignore(\"redundant_await\")\n\tawait _execute()\n\n\t_is_cutscene_in_progress = false\n\n## Play out the specific events of the cutscene.\n## This method is intended to be overridden by derived cutscene types.\n## [br][br]May or may not be asynchronous.\nfunc _execute() -> void:\n\tpass\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "extends GdUnitSignalAssert\n\nconst DEFAULT_TIMEOUT := 2000\n\nvar _signal_collector :GdUnitSignalCollector\nvar _emitter :Object\nvar _current_failure_message :String = \"\"\nvar _custom_failure_message :String = \"\"\nvar _additional_failure_message: String = \"\"\nvar _line_number := -1\nvar _timeout := DEFAULT_TIMEOUT\nvar _interrupted := false\n\n\nfunc _init(emitter :Object) -> void:\n\t# save the actual assert instance on the current thread context\n\tvar context := GdUnitThreadManager.get_current_context()\n\tcontext.set_assert(self)\n\t_signal_collector = context.get_signal_collector()\n\t_line_number = GdUnitAssertions.get_line_number()\n\t_emitter = emitter\n\tGdAssertReports.reset_last_error_line_number()\n\n\nfunc _notification(what :int) -> void:\n\tif what == NOTIFICATION_PREDELETE:\n\t\t_interrupted = true\n\t\tif is_instance_valid(_emitter):\n\t\t\t_signal_collector.unregister_emitter(_emitter)\n\t\t_emitter = null\n\n\nfunc report_success() -> GdUnitAssert:\n\tGdAssertReports.report_success()\n\treturn self\n\n\nfunc report_warning(message :String) -> GdUnitAssert:\n\tGdAssertReports.report_warning(message, GdUnitAssertions.get_line_number())\n\treturn self\n\n\nfunc report_error(failure :String) -> GdUnitAssert:\n\t_current_failure_message = GdAssertMessages.build_failure_message(failure, _additional_failure_message, _custom_failure_message)\n\tGdAssertReports.report_error(_current_failure_message, _line_number)\n\treturn self\n\n\nfunc failure_message() -> String:\n\treturn _current_failure_message\n\n\nfunc override_failure_message(message: String) -> GdUnitSignalAssert:\n\t_custom_failure_message = message\n\treturn self\n\n", "output": "func append_failure_message(message: String) -> GdUnitSignalAssert:\n\t_additional_failure_message = message\n\treturn self\n\nfunc wait_until(timeout := 2000) -> GdUnitSignalAssert:\n\tif timeout <= 0:\n\t\t@warning_ignore(\"return_value_discarded\")\n\t\treport_warning(\"Invalid timeout parameter, allowed timeouts must be greater than 0, use default timeout instead!\")\n\t\t_timeout = DEFAULT_TIMEOUT\n\telse:\n\t\t_timeout = timeout\n\treturn self\n\nfunc is_null() -> GdUnitSignalAssert:\n\tif _emitter != null:\n\t\treturn report_error(GdAssertMessages.error_is_null(_emitter))\n\treturn report_success()\n\nfunc is_not_null() -> GdUnitSignalAssert:\n\tif _emitter == null:\n\t\treturn report_error(GdAssertMessages.error_is_not_null())\n\treturn report_success()\n\nfunc is_equal(_expected: Variant) -> GdUnitSignalAssert:\n\treturn report_error(\"Not implemented\")\n\nfunc is_not_equal(_expected: Variant) -> GdUnitSignalAssert:\n\treturn report_error(\"Not implemented\")\n\n# Verifies the signal exists checked the emitter\nfunc is_signal_exists(signal_or_name: Variant) -> GdUnitSignalAssert:\n\tif not (signal_or_name is String or signal_or_name is Signal):\n\t\treturn report_error(\"Invalid signal_name: expected String or Signal, but is '%s'\" % type_string(typeof(signal_or_name)))\n\n\tvar signal_name := _to_signal_name(signal_or_name)\n\n\tif not _emitter.has_signal(signal_name):\n\t\t@warning_ignore(\"return_value_discarded\")\n\t\treport_error(\"The signal '%s' not exists checked object '%s'.\" % [signal_name, _emitter.get_class()])\n\treturn self\n\n# Verifies that given signal is emitted until waiting time\nfunc is_emitted(signal_name: Variant, ...signal_args: Array) -> GdUnitSignalAssert:"} {"instruction": "Vervollständige den GDScript-Code:", "input": "@tool\nextends Gamepiece\n\n@export var item_type: Inventory.ItemTypes\n@export var amount: = 1", "output": "\n@onready var interaction: = $Interaction as Interaction\n\nfunc _ready() -> void:\n\tsuper._ready()\n\n\tif not Engine.is_editor_hint():\n\t\tinteraction.item_type = item_type\n\t\tinteraction.amount = amount\n"} {"instruction": "Erstelle eine GDScript-Funktion namens 'get_behavior_at':", "input": "", "output": "func get_behavior_at(index: int) -> Dictionary:\n\tif _behaviors.size() > index:\n\t\treturn _behaviors[index]\n\tprinterr(\"Tried to get index \" + str(index) + \" in array of size \" + str(_behaviors.size()))\n\treturn {}", "source": "extracted_function"} {"instruction": "Vervollständige den GDScript-Code:", "input": "@tool\nextends Node3D\n\n@export_range(0, 1, 0.1) var fade := 0.0:\n\tset(value):\n\t\tfade = value\n\t\tif is_inside_tree():\n\t\t\t_update_fade()", "output": "\nvar material: ShaderMaterial\n\nfunc _update_fade() -> void:\n\tif fade == 0.0:\n\t\t$MeshInstance3D.visible = false\n\telse:\n\t\tif material:\n\t\t\tmaterial.set_shader_parameter(&\"albedo\", Color(0.0, 0.0, 0.0, fade))\n\t\t$MeshInstance3D.visible = true\n\nfunc _ready() -> void:\n\tmaterial = $MeshInstance3D.material_override\n\t_update_fade()\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 Godot-Klasse 'Directions' die von RefCounted erbt mit folgenden Funktionen: angle_to_direction, vector_to_direction", "input": "", "output": "## A utility class converting between Godot angles (+'ve x axis is 0 rads) and cardinal points.\nclass_name Directions\nextends RefCounted\n\n## The cardinal points, in clockwise order starting from North.\nenum Points { NORTH, EAST, SOUTH, WEST }\n\n## The direction corresponding to a cardinal point as a [Vector2i] value. NORTH is Vector2i(0, -1), etc.\nconst MAPPINGS: = {\n\tDirections.Points.NORTH: Vector2i.UP,\n\tDirections.Points.EAST: Vector2i.RIGHT,\n\tDirections.Points.SOUTH: Vector2i.DOWN,\n\tDirections.Points.WEST: Vector2i.LEFT,\n}\n\n## Convert an angle, such as from [method Vector2.angle], to a [constant Points].\nstatic func angle_to_direction(angle: float) -> Points:\n\tif angle <= -PI / 4.0 and angle > -3.0 * PI / 4.0:\n\t\treturn Points.NORTH\n\telif angle <= PI / 4.0 and angle > -PI / 4.0:\n\t\treturn Points.EAST\n\telif angle <= 3.0 * PI / 4.0 and angle > PI / 4.0:\n\t\treturn Points.SOUTH\n\n\treturn Points.WEST\n\nstatic func vector_to_direction(vector: Vector2) -> Points:\n\treturn angle_to_direction(vector.angle())\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 CharacterBody2D\n# @category - Specialized agents\nclass_name GSAICharacterBody2DAgent\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 CharacterBody2D to keep track of\nvar body: CharacterBody2D: set = _set_body\n\n# The type of movement the body executes\nvar movement_type: int\n\nvar _last_position: Vector2\nvar _body_ref: WeakRef\n\n\nfunc _init(_body: CharacterBody2D, _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: CharacterBody2D = _body_ref.get_ref()\n\tif not _body:\n\t\treturn\n", "output": "\tif not _body.is_inside_tree():\n\t\treturn\n\n\t_body.velocity = GSAIUtils.to_vector2(linear_velocity + accel * delta).limit_length(linear_speed_max)\n\tif apply_linear_drag:\n\t\t_body.velocity = _body.velocity.lerp(Vector2.ZERO, linear_drag_percentage)\n\n\t_body.move_and_slide()\n\n\tif calculate_velocities:\n\t\tlinear_velocity = GSAIUtils.to_vector3(_body.velocity)\n\nfunc _apply_collide_steering(accel: Vector3, delta: float) -> void:\n\tvar _body: CharacterBody2D = _body_ref.get_ref()\n\tif not _body:\n\t\treturn\n\n\t_body.velocity = GSAIUtils.to_vector2(\n\t\t\tGSAIUtils.clampedv3(linear_velocity + accel * delta, linear_speed_max)\n\t\t)\n\n\tif apply_linear_drag:\n\t\t_body.velocity = _body.velocity.lerp(Vector2.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 = GSAIUtils.to_vector3(_body.velocity)\n\nfunc _apply_position_steering(accel: Vector3, delta: float) -> void:\n\tvar _body: CharacterBody2D = _body_ref.get_ref()\n\tif not _body:\n\t\treturn\n\n\tvar velocity := GSAIUtils.clampedv3(linear_velocity + accel * delta, linear_speed_max)\n\tif apply_linear_drag:\n\t\tvelocity = velocity.lerp(Vector3.ZERO, linear_drag_percentage)\n\t_body.global_position += GSAIUtils.to_vector2(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: CharacterBody2D = _body_ref.get_ref()\n\tif not _body:\n\t\treturn\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 '_init':", "input": "", "output": "func _init() -> void:\n\tfor stat in _stats_list:\n\t\t_modifiers[stat] = []\n\t\t_cache[stat] = 0.0\n\n# Call this function from your node's ready function, before accessing the stats. This ensures\n# they're all loaded.\nfunc initialize() -> void:\n\t_update_all()\n\n# Get the final value of a stat, with all modifiers applied to it.\nfunc 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": "# Produces a linear acceleration that moves the agent along the specified path.\n# @category - Individual behaviors\nclass_name GSAIFollowPath\nextends GSAIArrive\n\n# The path to follow and travel along.\nvar path: GSAIPath\n# The distance along the path to generate the next target position.\nvar path_offset := 0.0\n\n# Whether to use `GSAIArrive` behavior on an open path.\nvar is_arrive_enabled := true\n# The amount of time in the future to predict the owning agent's position along\n# the path. Setting it to 0.0 will force non-predictive path following.\nvar prediction_time := 0.0\n\n\nfunc _init(agent: GSAISteeringAgent, _path: GSAIPath, _path_offset := 0.0, _prediction_time := 0.0) -> void:", "output": "\tsuper._init(agent, null)\n\tself.path = _path\n\tself.path_offset = _path_offset\n\tself.prediction_time = _prediction_time\n\nfunc _calculate_steering(acceleration: GSAITargetAcceleration) -> void:\n\tvar location := (\n\t\tagent.position\n\t\tif prediction_time == 0\n\t\telse agent.position + (agent.linear_velocity * prediction_time)\n\t)\n\n\tvar distance := path.calculate_distance(location)\n\tvar target_distance := distance + path_offset\n\n\tif prediction_time > 0 and path.is_open:\n\t\tif target_distance < path.calculate_distance(agent.position):\n\t\t\ttarget_distance = path.length\n\n\tvar target_position := path.calculate_target_position(target_distance)\n\n\tif is_arrive_enabled and path.is_open:\n\t\tif path_offset >= 0:\n\t\t\tif target_distance > path.length - deceleration_radius:\n\t\t\t\t_arrive(acceleration, target_position)\n\t\t\t\treturn\n\t\telse:\n\t\t\tif target_distance < deceleration_radius:\n\t\t\t\t_arrive(acceleration, target_position)\n\t\t\t\treturn\n\n\tacceleration.linear = (target_position - agent.position).normalized()\n\tacceleration.linear *= agent.linear_acceleration_max\n\tacceleration.angular = 0\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "extends Node3D\n\nvar tween : Tween\nvar active_hand : XRController3D\n\n\n# Called when the node enters the scene tree for the first time.\nfunc _ready():\n\t$XROrigin3D/LeftHand/Pointer.visible = false\n\t$XROrigin3D/RightHand/Pointer.visible = true\n\tactive_hand = $XROrigin3D/RightHand\n\n\n# Callback for our tween to set the energy level on our active pointer.\nfunc _update_energy(new_value : float):\n\tvar pointer = active_hand.get_node(^\"Pointer\")\n\tvar material : ShaderMaterial = pointer.material_override\n\tif material:\n\t\tmaterial.set_shader_parameter(&\"energy\", new_value)\n\n", "output": "# Start our tween to show a pulse on our click.\nfunc _do_tween_energy():\n\tif tween:\n\t\ttween.kill()\n\n\ttween = create_tween()\n\ttween.tween_method(_update_energy, 5.0, 1.0, 0.5)\n\n# Called if left hand trigger is pressed.\nfunc _on_left_hand_button_pressed(action_name):\n\tif action_name == \"select\":\n\t\t# Make the left hand the active pointer.\n\t\t$XROrigin3D/LeftHand/Pointer.visible = true\n\t\t$XROrigin3D/RightHand/Pointer.visible = false\n\n\t\tactive_hand = $XROrigin3D/LeftHand\n\t\t$XROrigin3D/OpenXRCompositionLayerEquirect.controller = active_hand\n\n\t\t# Make a visual pulse.\n\t\t_do_tween_energy()\n\n\t\t# And make us feel it.\n\t\t# NOTE: `frequence == 0.0` => XR runtime chooses optimal frequency for a given controller.\n\t\tactive_hand.trigger_haptic_pulse(\"haptic\", 0.0, 1.0, 0.5, 0.0)\n\n# Called if right hand trigger is pressed.\nfunc _on_right_hand_button_pressed(action_name):\n\tif action_name == \"select\":\n\t\t# Make the right hand the active pointer.\n\t\t$XROrigin3D/LeftHand/Pointer.visible = false\n\t\t$XROrigin3D/RightHand/Pointer.visible = true\n\n\t\tactive_hand = $XROrigin3D/RightHand\n\t\t$XROrigin3D/OpenXRCompositionLayerEquirect.controller = active_hand\n\n\t\t# Make a visual pulse.\n\t\t_do_tween_energy()\n\n\t\t# And make us feel it.\n\t\t# NOTE: `frequence == 0.0` => XR runtime chooses optimal frequency for a given controller.\n\t\tactive_hand.trigger_haptic_pulse(\"haptic\", 0.0, 1.0, 0.5, 0.0)\n"} {"instruction": "Erstelle eine GDScript-Funktion namens '_init':", "input": "", "output": "func _init(current: Variant, type_check := true) -> void:\n\t_type_check = type_check\n\t_current_value_provider = DefaultValueProvider.new(current)\n\t_base = GdUnitAssertImpl.new(current)\n\t# save the actual assert instance on the current thread context\n\tGdUnitThreadManager.get_current_context().set_assert(self)\n\tif not _validate_value_type(current):\n\t\t@warning_ignore(\"return_value_discarded\")\n\t\treport_error(\"GdUnitArrayAssert inital error, unexpected type <%s>\" % GdObjects.typeof_as_string(current))\n\nfunc _notification(event: int) -> void:\n\tif event == NOTIFICATION_PREDELETE:\n\t\tif _base != null:\n\t\t\t_base.notification(event)\n\t\t\t_base = null\n\nfunc report_success() -> GdUnitArrayAssert:\n\t@warning_ignore(\"return_value_discarded\")\n\t_base.report_success()\n\treturn self\n\nfunc report_error(error: String) -> GdUnitArrayAssert:\n\t@warning_ignore(\"return_value_discarded\")\n\t_base.report_error(error)\n\treturn self\n\nfunc failure_message() -> String:\n\treturn _base.failure_message()\n\nfunc override_failure_message(message: String) -> GdUnitArrayAssert:\n\t@warning_ignore(\"return_value_discarded\")\n\t_base.override_failure_message(message)\n\treturn self\n\nfunc append_failure_message(message: String) -> GdUnitArrayAssert:\n\t@warning_ignore(\"return_value_discarded\")\n\t_base.append_failure_message(message)\n\treturn self\n\nfunc _validate_value_type(value: Variant) -> bool:\n\treturn value == null or GdArrayTools.is_array_type(value)\n\nfunc get_current_value() -> Variant:\n\treturn _current_value_provider.get_value()\n\nfunc max_length(left: Variant, right: Variant) -> int:\n\tvar ls := str(left).length()\n\tvar rs := str(right).length()\n\treturn rs if ls < rs else ls\n\n# gdlint: disable=function-name\nfunc _toPackedStringArray(value: Variant) -> PackedStringArray:\n\tif GdArrayTools.is_array_type(value):\n\t\t@warning_ignore(\"unsafe_cast\")\n\t\treturn PackedStringArray(value as Array)\n\treturn PackedStringArray([str(value)])\n\nfunc _array_equals_div(current: Variant, expected: Variant, case_sensitive: bool = false) -> Array:\n\tvar current_value := _toPackedStringArray(current)\n\tvar expected_value := _toPackedStringArray(expected)\n\tvar index_report := Array()\n\tfor index in current_value.size():\n\t\tvar c := current_value[index]\n\t\tif index < expected_value.size():\n\t\t\tvar e := expected_value[index]\n\t\t\tif not GdObjects.equals(c, e, case_sensitive):\n\t\t\t\tvar length := max_length(c, e)\n\t\t\t\tcurrent_value[index] = GdAssertMessages.format_invalid(c.lpad(length))\n\t\t\t\texpected_value[index] = e.lpad(length)\n\t\t\t\tindex_report.push_back({\"index\": index, \"current\": c, \"expected\": e}"} {"instruction": "Vervollständige den GDScript-Code:", "input": "extends Node\n\nexport(PackedScene) var mob_scene\n\n\nfunc _ready():\n\trandomize()\n\t$UserInterface/Retry.hide()\n\n\nfunc _unhandled_input(event):\n\tif event.is_action_pressed(\"ui_accept\") and $UserInterface/Retry.visible:", "output": "\t\t# warning-ignore:return_value_discarded\n\t\tget_tree().reload_current_scene()\n\nfunc _on_MobTimer_timeout():\n\t# Create a new instance of the Mob scene.\n\tvar mob = mob_scene.instance()\n\n\t# Choose a random location on the SpawnPath.\n\tvar mob_spawn_location = get_node(\"SpawnPath/SpawnLocation\")\n\tmob_spawn_location.unit_offset = randf()\n\n\t# Communicate the spawn location and the player's location to the mob.\n\tvar player_position = $Player.transform.origin\n\tmob.initialize(mob_spawn_location.translation, player_position)\n\n\t# Spawn the mob by adding it to the Main scene.\n\tadd_child(mob)\n\t# We connect the mob to the score label to update the score upon squashing a mob.\n\tmob.connect(\"squashed\", $UserInterface/ScoreLabel, \"_on_Mob_squashed\")\n\nfunc _on_Player_hit():\n\t$MobTimer.stop()\n\t$UserInterface/Retry.show()\n"} {"instruction": "Erstelle eine Godot-Klasse 'AreaTransition' die von Trigger erbt mit folgenden Funktionen: _ready, _on_area_entered, _on_blackout", "input": "", "output": "@tool\n\nclass_name AreaTransition extends Trigger\n\n@export var arrival_coordinates: Vector2:\n\tset(value):\n\t\tarrival_coordinates = value\n\n\t\tif Engine.is_editor_hint():\n\t\t\tif not is_inside_tree():\n\t\t\t\tawait ready\n\n\t\t\tvar target = $Destination as Sprite2D\n\t\t\ttarget.position = arrival_coordinates - position\n\n#TODO: this will become a property of a given area once proper gameplay areas have been implemented.\n@export var new_music: AudioStream\n\n# The blackout timer is used to wait between fade-out and fade-in. No delay looks odd.\n@onready var _blackout_timer: = $BlackoutTimer as Timer\n\nfunc _ready() -> void:\n\tsuper._ready()\n\n\tif not Engine.is_editor_hint():\n\t\t$Destination.queue_free()\n\n# Area transitions are given several opportunities to \"do something\" at various stages, such as\n# before the camera fades away, after it has faded, and immediately after it re-appears in the new\n# area.\n# This could include all manner of shenanigans, such as dropping in the on the Big Baddie's\n# monologue, showing the player's stalker after the player has left the scene, or playing out an\n# event that the player then walks into the middle of.\nfunc _on_area_entered(area: Area2D) -> void:\n\t# Pausing the field immediately will deactivate physics objects, which are in the middle of\n\t# processing (hence _on_area_entered). We need to wait a frame before pausing anything.\n\tawait get_tree().process_frame\n\n\t# Pause the field gamestate to prevent the player from wandering off mid-transition.\n\t_is_cutscene_in_progress = true\n\n\t# Cover the screen to hide the area transition.\n\tTransition.cover(0.25)\n\tawait Transition.finished\n\n\t# Move the gamepiece to it's new position and update the camera immediately.\n\tvar gamepiece: = area.owner as Gamepiece\n\tif gamepiece:\n\t\tgamepiece.stop()\n\t\tgamepiece.position = arrival_coordinates\n\t\tGamepieceRegistry.move_gamepiece(gamepiece, Gameboard.pixel_to_cell(arrival_coordinates))\n\n\t\tCamera.reset_position()\n\n\t# Let the screen rest in darkness for a little"} {"instruction": "Vervollständige den GDScript-Code:", "input": "## An exceptionally simple item inventory that tracks which items the player has picked up.\n## Normally, inventory design would be more complex. In particular, you would want to separate the\n## inventory data structures from the UI implementation, as should be done in a future update to\n## the OpenRPG project.\n## In this case, we just want to show the player which items have been picked up so that we can demo\n## a variety of RPG events.\nclass_name UIInventory extends HBoxContainer\n\n# Keep track of the inventory item packed scene to easily instantiate new items.\nvar _ITEM_SCENE: = preload(\"res://src/field/ui/inventory/ui_inventory_item.tscn\")\n\n\nfunc _ready() -> void:\n\tvar inventory: = Inventory.restore()\n\t\n\tfor item_name in Inventory.ItemTypes:", "output": "\t\t_update_item(Inventory.ItemTypes[item_name], inventory)\n\tinventory.item_changed.connect(_on_inventory_item_changed.bind(inventory))\n\nfunc get_ui_item(item_id: Inventory.ItemTypes) -> UIInventoryItem:\n\tfor child in get_children():\n\t\tvar item: = child as UIInventoryItem\n\t\tif item and item.ID == item_id:\n\t\t\treturn item\n\treturn null\n\nfunc _update_item(item_id: Inventory.ItemTypes, inventory: Inventory) -> void:\n\tvar amount: = inventory.get_item_count(item_id)\n\tvar item: = get_ui_item(item_id)\n\n\tif amount > 0:\n\t\tif not item:\n\t\t\titem = _ITEM_SCENE.instantiate() as UIInventoryItem\n\t\t\titem.ID = item_id\n\t\t\titem.texture = Inventory.get_item_icon(item_id)\n\t\t\tadd_child(item)\n\n\t\titem.count = amount\n\n\telse:\n\t\tif item:\n\t\t\titem.queue_free()\n\nfunc _on_inventory_item_changed(item_type: Inventory.ItemTypes, inventory: Inventory) -> void:\n\t_update_item(item_type, inventory)\n"} {"instruction": "Erstelle eine Godot-Klasse 'GdUnitAssert' die von RefCounted erbt mit folgenden Funktionen: is_null, is_not_null, is_equal, is_not_equal, test_player_inventory", "input": "", "output": "## Base interface of all GdUnit asserts\n@abstract class_name GdUnitAssert\nextends RefCounted\n\n## Verifies that the current value is null.\n@abstract func is_null() -> GdUnitAssert\n\n## Verifies that the current value is not null.\n@abstract func is_not_null() -> GdUnitAssert\n\n## Verifies that the current value is equal to expected one.\n@abstract func is_equal(expected: Variant) -> GdUnitAssert\n\n## Verifies that the current value is not equal to expected one.\n@abstract func is_not_equal(expected: Variant) -> GdUnitAssert\n\n## Overrides the default failure message by given custom message.[br]\n## This function allows you to replace the automatically generated failure message with a more specific\n## or user-friendly message that better describes the test failure context.[br]\n## Usage:\n## [codeblock]\n##\t\t# Override with custom context-specific message\n##\t\tfunc test_player_inventory():\n##\t\t assert_that(player.get_item_count(\"sword\"))\\\n##\t\t .override_failure_message(\"Player should have exactly one sword\")\\\n##\t\t .is_equal(1)\n## [/codeblock]\n@abstract func override_failure_message(message: String) -> GdUnitAssert\n\n## Appends a custom message to the failure message.[br]\n## This can be used to add additional information to the generated failure message\n## while keeping the original assertion details for better debugging context.[br]\n## Usage:\n## [codeblock]\n##\t\t# Add context to existing failure message\n##\t\tfunc test_player_health():\n##\t\t assert_that(player.health)\\\n##\t\t .append_failure_message(\"Player was damaged by: %s\" % last_damage_source)\\\n##\t\t .is_greater(0)\n## [/codeblock]\n@abstract func append_failure_message(message: String) -> GdUnitAssert\n"} {"instruction": "Erstelle eine Godot-Klasse 'GSAISpecializedAgent' die von GSAISteeringAgent erbt mit folgenden Funktionen: _apply_steering", "input": "", "output": "# A base class for a specialized steering agent that updates itself every frame\n# so the user does not have to. All other specialized agents derive from this.\n# @category - Specialized agents\n# @tags - abstract\nclass_name GSAISpecializedAgent\nextends GSAISteeringAgent\n\n# If `true`, calculates linear and angular velocities based on the previous\n# frame. When `false`, the user must keep those values updated.\nvar calculate_velocities := true\n\n# If `true`, interpolates the current linear velocity towards 0 by the\n# `linear_drag_percentage` value.\n# Does not apply to `RigidBody` and `RigidBody2D` nodes.\nvar apply_linear_drag := true\n\n# If `true`, interpolates the current angular velocity towards 0 by the\n# `angular_drag_percentage` value.\n# Does not apply to `RigidBody` and `RigidBody2D` nodes.\nvar apply_angular_drag := true\n\n# The percentage between the current linear velocity and 0 to interpolate by if\n# `apply_linear_drag` is true.\n# Does not apply to `RigidBody` and `RigidBody2D` nodes.\nvar linear_drag_percentage := 0.0\n\n# The percentage between the current angular velocity and 0 to interpolate by if\n# `apply_angular_drag` is true.\n# Does not apply to `RigidBody` and `RigidBody2D` nodes.\nvar angular_drag_percentage := 0.0\n\nvar _last_orientation: float\nvar _applied_steering := false\n\n# Moves the agent's body by target `acceleration`.\n# @tags - virtual\nfunc _apply_steering(_acceleration: GSAITargetAcceleration, _delta: float) -> void:\n\tpass\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "#*\n#* get_first_in_group.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", "output": "extends BTAction\n## Stores the first node in the [member group] on the blackboard, returning [code]SUCCESS[/code]. [br]\n## Returns [code]FAILURE[/code] if the group contains 0 nodes.\n\n## Name of the SceneTree group.\n@export var group: StringName\n\n## Blackboard variable in which the task will store the acquired node.\n@export var output_var: StringName = &\"target\"\n\nfunc _generate_name() -> String:\n\treturn \"GetFirstNodeInGroup \\\"%s\\\" ➜%s\" % [\n\t\tgroup,\n\t\tLimboUtility.decorate_var(output_var)\n\t\t]\n\nfunc _tick(_delta: float) -> Status:\n\tvar nodes: Array[Node] = agent.get_tree().get_nodes_in_group(group)\n\tif nodes.size() == 0:\n\t\treturn FAILURE\n\tblackboard.set_var(output_var, nodes[0])\n\treturn SUCCESS\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "# Represents an agent with only a location and an orientation.\n# @category - Base types\nclass_name GSAIAgentLocation", "output": "\n# The agent's position in space.\nvar position := Vector3.ZERO\n# The agent's orientation on its Y axis rotation.\nvar orientation := 0.0\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "@tool\nextends Node3D\n\n@export_range(0, 1, 0.1) var fade := 0.0:\n\tset(value):\n\t\tfade = value\n\t\tif is_inside_tree():\n\t\t\t_update_fade()", "output": "\nvar material: ShaderMaterial\n\nfunc _update_fade() -> void:\n\tif fade == 0.0:\n\t\t$MeshInstance3D.visible = false\n\telse:\n\t\tif material:\n\t\t\tmaterial.set_shader_parameter(&\"albedo\", Color(0.0, 0.0, 0.0, fade))\n\t\t$MeshInstance3D.visible = true\n\nfunc _ready() -> void:\n\tmaterial = $MeshInstance3D.material_override\n\t_update_fade()\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "# Steers the agent to avoid obstacles in its path. Approximates obstacles as\n# spheres.\n# @category - Group behaviors\nclass_name GSAIAvoidCollisions\nextends GSAIGroupBehavior\n\nvar _first_neighbor: GSAISteeringAgent\nvar _shortest_time: float\nvar _first_minimum_separation: float\nvar _first_distance: float\nvar _first_relative_position: Vector3\nvar _first_relative_velocity: Vector3\n\n\nfunc _init(agent: GSAISteeringAgent, proximity: GSAIProximity) -> void:\n\tsuper._init(agent, proximity)\n\n\nfunc _calculate_steering(acceleration: GSAITargetAcceleration) -> void:\n\t_shortest_time = INF\n\t_first_neighbor = null\n\t_first_minimum_separation = 0\n\t_first_distance = 0\n\n\tvar neighbor_count := proximity._find_neighbors(_callback)", "output": "\n\tif neighbor_count == 0 or not _first_neighbor:\n\t\tacceleration.set_zero()\n\telse:\n\t\tif (\n\t\t\t_first_minimum_separation <= 0\n\t\t\tor _first_distance < agent.bounding_radius + _first_neighbor.bounding_radius\n\t\t):\n\t\t\tacceleration.linear = _first_neighbor.position - agent.position\n\t\telse:\n\t\t\tacceleration.linear = (\n\t\t\t\t_first_relative_position\n\t\t\t\t+ (_first_relative_velocity * _shortest_time)\n\t\t\t)\n\n\tacceleration.linear = (acceleration.linear.normalized() * -agent.linear_acceleration_max)\n\tacceleration.angular = 0\n\n# Callback for the proximity to call when finding neighbors. Keeps track of every `neighbor`\n# that was found but only keeps the one the owning agent will most likely collide with.\n# @tags - virtual\nfunc _report_neighbor(neighbor: GSAISteeringAgent) -> bool:\n\tvar relative_position := neighbor.position - agent.position\n\tvar relative_velocity := neighbor.linear_velocity - agent.linear_velocity\n\tvar relative_speed_squared := relative_velocity.length_squared()\n\n\tif relative_speed_squared == 0:\n\t\treturn false\n\telse:\n\t\tvar time_to_collision = -relative_position.dot(relative_velocity) / relative_speed_squared\n\n\t\tif time_to_collision <= 0 or time_to_collision >= _shortest_time:\n\t\t\treturn false\n\t\telse:\n\t\t\tvar distance = relative_position.length()\n\t\t\tvar minimum_separation: float = (\n\t\t\t\tdistance\n\t\t\t\t- sqrt(relative_speed_squared) * time_to_collision\n\t\t\t)\n\t\t\tif minimum_separation > agent.bounding_radius + neighbor.bounding_radius:\n\t\t\t\treturn false\n\t\t\telse:\n\t\t\t\t_shortest_time = time_to_collision\n\t\t\t\t_first_neighbor = neighbor\n\t\t\t\t_first_minimum_separation = minimum_separation\n\t\t\t\t_first_distance = distance\n\t\t\t\t_first_relative_position = relative_position\n\t\t\t\t_first_relative_velocity = relative_velocity\n\t\t\t\treturn true"} {"instruction": "Vervollständige den GDScript-Code:", "input": "# Animates a black screen that covers the entire screen - keeps transitions\n# from simply going menu-game or game-menu in an abrupt and jarring way.\nextends TextureRect\n\nsignal animation_finished\n\n@export var duration_fade_in := 0.5\n@export var duration_fade_out := 2.5\n\nvar is_playing := false\n\nvar tween : Tween\n\n\n# Animate from the current modulate color until the node is fully transparent.\nfunc fade_in() -> void:", "output": "\ttween = create_tween()\n\ttween.finished.connect(_on_Tween_tween_completed)\n\ttween.tween_property(\n\t\tself,\n\t\t\"modulate\",\n\t\tColor.TRANSPARENT,\n\t\tduration_fade_in\n\t).from_current().set_ease(Tween.EASE_OUT).set_trans(Tween.TRANS_LINEAR)\n\tshow()\n\ttween.play()\n\tis_playing = true\n\n# Animate from the current modulate color until the node is fully black.\nfunc fade_out(is_delayed: bool = false) -> void:\n\ttween = create_tween()\n\ttween.finished.connect(_on_Tween_tween_completed)\n\ttween.tween_property(\n\t\tself,\n\t\t\"modulate\",\n\t\tColor.WHITE,\n\t\tduration_fade_out\n\t).from_current().set_delay(duration_fade_out if is_delayed else 0.0).set_ease(Tween.EASE_OUT).set_trans(Tween.TRANS_LINEAR)\n\tshow()\n\ttween.play()\n\tis_playing = true\n\nfunc _on_Tween_tween_completed() -> void:\n\tanimation_finished.emit()\n\tif modulate == Color.TRANSPARENT:\n\t\thide()\n\tis_playing = false\n"} {"instruction": "Erstelle eine Godot-Klasse 'InteractionTemplateConversation' die von Interaction erbt mit folgenden Funktionen: _execute, _on_dialogic_signal_event", "input": "", "output": "@tool\n\nclass_name InteractionTemplateConversation extends Interaction\n\n@export var timeline: DialogicTimeline\n\nfunc _execute() -> void:\n\tif timeline:\n\t\tDialogic.start_timeline(timeline)\n\n\t\tDialogic.signal_event.connect(_on_dialogic_signal_event)\n\n\t\t# Wait for the timeline to finish before ending the event.\n\t\tawait Dialogic.timeline_ended\n\n\t\tDialogic.signal_event.disconnect(_on_dialogic_signal_event)\n\nfunc _on_dialogic_signal_event(_argument: String) -> void:\n\tpass\n"} {"instruction": "Erstelle eine GDScript-Funktion namens '_init':", "input": "", "output": "func _init(agent: GSAISteeringAgent) -> void:\n\tsuper._init(agent)\n\n# Appends a behavior to the internal array along with its `weight`.\nfunc add(behavior: GSAISteeringBehavior, weight: float) -> void:\n\tbehavior.agent = agent\n\t_behaviors.append({behavior = behavior, weight = weight}", "source": "extracted_function"} {"instruction": "Vervollständige den GDScript-Code:", "input": "class_name GdUnitArrayAssertImpl\nextends GdUnitArrayAssert\n\n\nvar _base: GdUnitAssertImpl\nvar _current_value_provider: ValueProvider\nvar _type_check: bool\n\n\nfunc _init(current: Variant, type_check := true) -> void:\n\t_type_check = type_check\n\t_current_value_provider = DefaultValueProvider.new(current)\n\t_base = GdUnitAssertImpl.new(current)\n\t# save the actual assert instance on the current thread context\n\tGdUnitThreadManager.get_current_context().set_assert(self)\n\tif not _validate_value_type(current):\n\t\t@warning_ignore(\"return_value_discarded\")\n\t\treport_error(\"GdUnitArrayAssert inital error, unexpected type <%s>\" % GdObjects.typeof_as_string(current))\n\n\nfunc _notification(event: int) -> void:\n\tif event == NOTIFICATION_PREDELETE:\n\t\tif _base != null:\n\t\t\t_base.notification(event)\n\t\t\t_base = null\n\n\nfunc report_success() -> GdUnitArrayAssert:\n\t@warning_ignore(\"return_value_discarded\")\n\t_base.report_success()\n\treturn self\n\n\nfunc report_error(error: String) -> GdUnitArrayAssert:\n\t@warning_ignore(\"return_value_discarded\")\n\t_base.report_error(error)\n\treturn self\n\n\nfunc failure_message() -> String:\n\treturn _base.failure_message()\n\n\nfunc override_failure_message(message: String) -> GdUnitArrayAssert:\n\t@warning_ignore(\"return_value_discarded\")\n\t_base.override_failure_message(message)\n\treturn self\n\n\nfunc append_failure_message(message: String) -> GdUnitArrayAssert:\n\t@warning_ignore(\"return_value_discarded\")\n\t_base.append_failure_message(message)\n\treturn self\n\n\nfunc _validate_value_type(value: Variant) -> bool:\n\treturn value == null or GdArrayTools.is_array_type(value)\n\n\nfunc get_current_value() -> Variant:\n\treturn _current_value_provider.get_value()\n\n\nfunc max_length(left: Variant, right: Variant) -> int:\n\tvar ls := str(left).length()\n\tvar rs := str(right).length()\n\treturn rs if ls < rs else ls\n\n\n# gdlint: disable=function-name\nfunc _toPackedStringArray(value: Variant) -> PackedStringArray:\n\tif GdArrayTools.is_array_type(value):\n\t\t@warning_ignore(\"unsafe_cast\")\n\t\treturn PackedStringArray(value as Array)\n\treturn PackedStringArray([str(value)])\n\n\nfunc _array_equals_div(current: Variant, expected: Variant, case_sensitive: bool = false) -> Array:\n\tvar current_value := _toPackedStringArray(current)\n\tvar expected_value := _toPackedStringArray(expected)\n\tvar index_report := Array()\n\tfor index in current_value.size():\n\t\tvar c := current_value[index]\n\t\tif index < expected_value.size():\n\t\t\tvar e := expected_value[index]\n\t\t\tif not GdObjects.equals(c, e, case_sensitive):\n\t\t\t\tvar length := max_length(c, e)\n\t\t\t\tcurrent_value[index] = GdAssertMessages.format_invalid(c.lpad(length))\n\t\t\t\texpected_value[index] = e.lpad(length)\n\t\t\t\tindex_report.push_back({\"index\": index, \"current\": c, \"expected\": e})\n\t\telse:\n\t\t\tcurrent_value[index] = GdAssertMessages.format_invalid(c)\n\t\t\tindex_report.push_back({\"index\": index, \"current\": c, \"expected\": \"\"})\n\n\tfor index in range(current_value.size(), expected_value.size()):\n\t\tvar value := expected_value[index]\n\t\texpected_value[index] = GdAssertMessages.format_invalid(value)\n\t\tindex_report.push_back({\"index\": index, \"current\": \"\", \"expected\": value})\n\treturn [current_value, expected_value, index_report]\n\n\nfunc _array_div(compare_mode: GdObjects.COMPARE_MODE, left: Array[Variant], right: Array[Variant], _same_order := false) -> Array[Variant]:\n\tvar not_expect := left.duplicate(true)\n\tvar not_found := right.duplicate(true)\n\tfor index_c in left.size():\n\t\tvar c: Variant = left[index_c]\n\t\tfor index_e in right.size():\n\t\t\tvar e: Variant = right[index_e]\n\t\t\tif GdObjects.equals(c, e, false, compare_mode):\n\t\t\t\tGdArrayTools.erase_value(not_expect, e)\n\t\t\t\tGdArrayTools.erase_value(not_found, c)\n\t\t\t\tbreak\n\treturn [not_expect, not_found]\n\n\nfunc _contains(expected: Array, compare_mode: GdObjects.COMPARE_MODE) -> GdUnitArrayAssert:\n\tvar by_reference := compare_mode == GdObjects.COMPARE_MODE.OBJECT_REFERENCE\n\tvar current_value: Variant = get_current_value()\n\tvar expected_value: Variant = _extract_variadic_value(expected)\n\tif not _validate_value_type(expected_value):\n\t\treturn report_error(\"ERROR: expected value: <%s>\\n is not a Array Type!\" % GdObjects.typeof_as_string(expected_value))\n\n\tif current_value == null:\n\t\treturn report_error(GdAssertMessages.error_arr_contains(current_value, expected_value, [], expected_value, by_reference))\n\t@warning_ignore(\"unsafe_cast\")\n\tvar diffs := _array_div(compare_mode, current_value as Array[Variant], expected_value as Array[Variant])\n\t#var not_expect := diffs[0] as Array\n\tvar not_found: Array = diffs[1]\n\tif not not_found.is_empty():\n\t\treturn report_error(GdAssertMessages.error_arr_contains(current_value, expected_value, [], not_found, by_reference))\n\treturn report_success()\n\n\nfunc _contains_exactly(expected: Array, compare_mode: GdObjects.COMPARE_MODE) -> GdUnitArrayAssert:\n\tvar current_value: Variant = get_current_value()\n\tvar expected_value: Variant = _extract_variadic_value(expected)\n\tif not _validate_value_type(expected_value):\n\t\treturn report_error(\"ERROR: expected value: <%s>\\n is not a Array Type!\" % GdObjects.typeof_as_string(expected_value))\n\n\tif current_value == null:\n\t\treturn report_error(GdAssertMessages.error_arr_contains_exactly(null, expected_value, [], expected_value, compare_mode))", "output": "\t# has same content in same order\n\tif _is_equal(current_value, expected_value, false, compare_mode):\n\t\treturn report_success()\n\t# check has same elements but in different order\n\tif _is_equals_sorted(current_value, expected_value, false, compare_mode):\n\t\treturn report_error(GdAssertMessages.error_arr_contains_exactly(current_value, expected_value, [], [], compare_mode))\n\t# find the difference\n\t@warning_ignore(\"unsafe_cast\")\n\tvar diffs := _array_div(compare_mode,\n\t\tcurrent_value as Array[Variant],\n\t\texpected_value as Array[Variant],\n\t\tGdObjects.COMPARE_MODE.PARAMETER_DEEP_TEST)\n\tvar not_expect: Array[Variant] = diffs[0]\n\tvar not_found: Array[Variant] = diffs[1]\n\treturn report_error(GdAssertMessages.error_arr_contains_exactly(current_value, expected_value, not_expect, not_found, compare_mode))\n\nfunc _contains_exactly_in_any_order(expected: Array, compare_mode: GdObjects.COMPARE_MODE) -> GdUnitArrayAssert:\n\tvar current_value: Variant = get_current_value()\n\tvar expected_value: Variant = _extract_variadic_value(expected)\n\tif not _validate_value_type(expected_value):\n\t\treturn report_error(\"ERROR: expected value: <%s>\\n is not a Array Type!\" % GdObjects.typeof_as_string(expected_value))\n\n\tif current_value == null:\n\t\treturn report_error(GdAssertMessages.error_arr_contains_exactly_in_any_order(current_value, expected_value, [],\n\t\t\texpected_value, compare_mode))\n\t# find the difference\n\t@warning_ignore(\"unsafe_cast\")\n\tvar diffs := _array_div(compare_mode, current_value as Array[Variant], expected_value as Array[Variant], false)\n\tvar not_expect: Array[Variant] = diffs[0]\n\tvar not_found: Array[Variant] = diffs[1]\n\tif not_expect.is_empty() and not_found.is_empty():\n\t\treturn report_success()\n\treturn report_error(GdAssertMessages.error_arr_contains_exactly_in_any_order(current_value, expected_value, not_expect,\n\t\tnot_found, compare_mode))\n\nfunc _not_contains(expected: Array, compare_mode: GdObjects.COMPARE_MODE) -> GdUnitArrayAssert:\n\tvar current_value: Variant = get_current_value()\n\tvar expected_value: Variant = _extract_variadic_value(expected)\n\tif not _validate_value_type(expected_value):\n\t\treturn report_error(\"ERROR: expected value: <%s>\\n is not a Array Type!\" % GdObjects.typeof_as_string(expected_value))\n\tif current_value == null:\n\t\treturn report_error(GdAssertMessages.error_arr_contains_exactly_in_any_order(current_value, expected_value, [],\n\t\t\texpected_value, compare_mode))\n\t@warning_ignore(\"unsafe_cast\")\n\tvar diffs := _array_div(compare_mode, current_value as Array[Variant], expected_value as Array[Variant])\n\tvar found: Array[Variant] = diffs[0]\n\t@warning_ignore(\"unsafe_cast\")\n\tif found.size() == (current_value as Array).size():"} {"instruction": "Erstelle eine Godot-Klasse 'XRHandFallbackModifier3D' die von SkeletonModifier3D erbt mit folgenden Funktionen: _process_modification", "input": "", "output": "class_name XRHandFallbackModifier3D\nextends SkeletonModifier3D\n\n## This node implements a fallback if the hand tracking API is not available\n## or if one of the data sources is not supported by the XR runtime.\n## It uses trigger and grip inputs from the normal controller tracker to\n## animate the index finger and bottom 3 fingers respectively.\n\n## Action to use for animating index finger.\n@export var trigger_action : String = \"trigger\"\n\n## Action to use for animating bottom 3 fingers.\n@export var grip_action : String = \"grip\"\n\n# Called by our skeleton logic when this modifier needs to apply its modifications.\nfunc _process_modification() -> void:\n\t# Get our skeleton.\n\tvar skeleton: Skeleton3D = get_skeleton()\n\tif !skeleton:\n\t\treturn\n\n\t# Find our parent controller\n\tvar parent = get_parent()\n\twhile parent and not parent is XRNode3D:\n\t\tparent = parent.get_parent()\n\tif !parent:\n\t\treturn\n\n\t# Check if we have an active hand tracker,\n\t# if so, we don't need our fallback!\n\tvar xr_parent : XRNode3D = parent\n\tif not xr_parent.tracker in [ \"left_hand\", \"right_hand\" ]:\n\t\treturn\n\n\tvar trigger : float = 0.0\n\tvar grip : float = 0.0\n\n\t# Check our tracker for trigger and grip values\n\tvar tracker : XRControllerTracker = XRServer.get_tracker(xr_parent.tracker)\n\tif tracker:\n\t\tvar trigger_value : Variant = tracker.get_input(trigger_action)\n\t\tif trigger_value:\n\t\t\ttrigger = trigger_value\n\n\t\tvar grip_value : Variant = tracker.get_input(grip_action)\n\t\tif grip_value:\n\t\t\tgrip = grip_value\n\n\t# Now position bones\n\tvar bone_count = skeleton.get_bone_count()\n\tfor i in bone_count:\n\t\tvar t : Transform3D = skeleton.get_bone_rest(i)\n\n\t\t# We animate based on bone_name.\n\t\t# For now just hardcoded values.\n\t\t# Note that we position all bones in case we need to reset some.\n\t\tvar bone_name = skeleton.get_bone_name(i)\n\t\tif bone_name == \"LeftHand\":\n\t\t\t# Offset to center our palm, this requires the use of the palm pose!\n\t\t\tt.origin += Vector3(-0.015, 0.0, 0.04)\n\t\telif bone_name == \"RightHand\":\n\t\t\t# Offset to"} {"instruction": "Vervollständige den GDScript-Code:", "input": "## Handles mouse/touch events for the field gamestate.\n##\n## The field cursor's role is to determine whether or not the input event occurs over a particular\n## cell and how that cell should be highlighted.\nclass_name FieldCursor\nextends TileMapLayer\n\n## Emitted when the highlighted cell changes to a new value. An invalid cell is indicated by a value\n## of [constant Gameboard.INVALID_CELL].\nsignal focus_changed(old_focus: Vector2i, new_focus: Vector2i)\n\n## Emitted when a cell is selected via input event.\nsignal selected(selected_cell: Vector2i)\n\n## The cell currently highlighted by the cursor.\n##\n## [br][br]A focus of [constant Gameboard.INVALID_CELL] indicates that there is no highlight.\nvar focus: = Gameboard.INVALID_CELL:\n\tset = set_focus\n\n\nfunc _ready() -> void:\n\tFieldEvents.input_paused.connect(_on_input_paused)\n\n", "output": "func _unhandled_input(event: InputEvent) -> void:\n\tif event is InputEventMouseMotion:\n\t\tget_viewport().set_input_as_handled()\n\t\tset_focus(_get_cell_under_mouse())\n\n\telif event.is_action_released(\"select\"):\n\t\tget_viewport().set_input_as_handled()\n\n\t\tselected.emit(_get_cell_under_mouse())\n\t\tFieldEvents.cell_selected.emit(_get_cell_under_mouse())\n\n## Change the highlighted cell to a new value. A value of [constant Gameboard.INVALID_CELL] will\n## indicate that there is no highlighted cell.\n## [br][br][b]Note:[/b] Values will be limited to [member valid_cells] if valid_cells is not empty.\n## Values outside of valid_cells will not be focused.\nfunc set_focus(value: Vector2i) -> void:\n\tif value == focus:\n\t\treturn\n\n\tvar old_focus: = focus\n\tfocus = value\n\n\tclear()\n\n\tif focus != Gameboard.INVALID_CELL:\n\t\tset_cell(focus, 0, Vector2i(1, 5), 0)\n\t\t#set_cell(0, focus, 0, Vector2(1, 5))\n\n\tfocus_changed.emit(old_focus, focus)\n\tFieldEvents.cell_highlighted.emit(focus)\n\n# Convert mouse/touch coordinates to a gameboard cell.\nfunc _get_cell_under_mouse() -> Vector2i:\n\t# The mouse coordinates need to be corrected for any scale or position changes in the scene.\n\tvar mouse_position: = ((get_global_mouse_position()-global_position) / global_scale)\n\tvar cell_under_mouse: = Gameboard.pixel_to_cell(mouse_position)\n\n\tif not Gameboard.pathfinder.has_cell(cell_under_mouse):\n\t\tcell_under_mouse = Gameboard.INVALID_CELL\n\n\treturn cell_under_mouse\n\nfunc _on_input_paused(is_paused: bool) -> void:\n\tset_process_unhandled_input(!is_paused)\n\n\tif is_paused:\n\t\tset_focus(Gameboard.INVALID_CELL)"} {"instruction": "Vervollständige den GDScript-Code:", "input": "@tool\nclass_name Pickup extends Trigger\n\n@export var item_type: Inventory.ItemTypes:\n\tset(value):\n\t\titem_type = value\n\t\t\n\t\tif not is_inside_tree():", "output": "\t\t\tawait ready\n\n\t\t_sprite.texture = Inventory.get_item_icon(item_type)\n\n@export var amount: = 1\n\n@onready var _anim: AnimationPlayer = $AnimationPlayer\n@onready var _sprite: Sprite2D = $Sprite2D\n\nfunc _execute() -> void:\n\t_anim.play(\"PickupAnimations/obtain\")\n\tInventory.restore().add(item_type, amount)\n\n\tawait _anim.animation_finished\n\tqueue_free()\n"} {"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": "Erstelle eine Godot-Klasse 'CollisionHands3D' die von AnimatableBody3D erbt mit folgenden Funktionen: _ready, _physics_process", "input": "", "output": "class_name CollisionHands3D\nextends AnimatableBody3D\n\nfunc _ready():\n\t# Make sure these are set correctly.\n\ttop_level = true\n\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": "## An Assertion Tool to verify String values\n@abstract class_name GdUnitStringAssert\nextends GdUnitAssert\n\n\n## Verifies that the current value is null.\n@abstract func is_null() -> GdUnitStringAssert\n\n\n## Verifies that the current value is not null.\n@abstract func is_not_null() -> GdUnitStringAssert\n\n\n## Verifies that the current value is equal to the given one.\n@abstract func is_equal(expected: Variant) -> GdUnitStringAssert\n\n\n## Verifies that the current String is equal to the given one, ignoring case considerations.\n@abstract func is_equal_ignoring_case(expected: Variant) -> GdUnitStringAssert\n\n\n## Verifies that the current value is not equal to expected one.\n@abstract func is_not_equal(expected: Variant) -> GdUnitStringAssert\n", "output": "\n## Verifies that the current String is not equal to the given one, ignoring case considerations.\n@abstract func is_not_equal_ignoring_case(expected: Variant) -> GdUnitStringAssert\n\n## Overrides the default failure message by given custom message.\n@abstract func override_failure_message(message: String) -> GdUnitStringAssert\n\n## Appends a custom message to the failure message.\n@abstract func append_failure_message(message: String) -> GdUnitStringAssert\n\n## Verifies that the current String is empty, it has a length of 0.\n@abstract func is_empty() -> GdUnitStringAssert\n\n## Verifies that the current String is not empty, it has a length of minimum 1.\n@abstract func is_not_empty() -> GdUnitStringAssert\n\n## Verifies that the current String contains the given String.\n@abstract func contains(expected: String) -> GdUnitStringAssert\n\n## Verifies that the current String does not contain the given String.\n@abstract func not_contains(expected: String) -> GdUnitStringAssert\n\n## Verifies that the current String does not contain the given String, ignoring case considerations.\n@abstract func contains_ignoring_case(expected: String) -> GdUnitStringAssert\n\n## Verifies that the current String does not contain the given String, ignoring case considerations.\n@abstract func not_contains_ignoring_case(expected: String) -> GdUnitStringAssert\n\n## Verifies that the current String starts with the given prefix.\n@abstract func starts_with(expected: String) -> GdUnitStringAssert\n\n## Verifies that the current String ends with the given suffix.\n@abstract func ends_with(expected: String) -> GdUnitStringAssert\n\n## Verifies that the current String has the expected length by used comparator.\n@abstract func has_length(length: int, comparator: int = Comparator.EQUAL) -> GdUnitStringAssert\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "@tool\nextends Node3D\n\n@export_range(0, 1, 0.1) var fade := 0.0:\n\tset(value):\n\t\tfade = value\n\t\tif is_inside_tree():\n\t\t\t_update_fade()", "output": "\nvar material: ShaderMaterial\n\nfunc _update_fade() -> void:\n\tif fade == 0.0:\n\t\t$MeshInstance3D.visible = false\n\telse:\n\t\tif material:\n\t\t\tmaterial.set_shader_parameter(&\"albedo\", Color(0.0, 0.0, 0.0, fade))\n\t\t$MeshInstance3D.visible = true\n\nfunc _ready() -> void:\n\tmaterial = $MeshInstance3D.material_override\n\t_update_fade()\n"} {"instruction": "Erstelle eine Godot-Klasse 'Door' die von AreaTransition erbt mit folgenden Funktionen: _ready, open, _on_area_entered, _on_blackout", "input": "", "output": "@tool\nclass_name Door extends AreaTransition\n\n# A locked door will block movement by placing a dummy gamepiece on the cell occupied by the door.\nconst GP_SCENE: = preload(\"res://src/field/gamepieces/gamepiece.tscn\")\n\n@export var is_locked: = false:\n\tset(value):\n\t\tif value != is_locked:\n\t\t\tis_locked = value\n\n\t\t\tif not is_inside_tree():\n\t\t\t\tawait ready\n\n\t\t\tif is_locked:\n\t\t\t\tif _dummy_gp == null:\n\t\t\t\t\t_dummy_gp = GP_SCENE.instantiate()\n\t\t\t\t\t_dummy_gp.name = \"CellBlocker\"\n\t\t\t\t\t_closed_door.add_child(_dummy_gp)\n\n\t\t\telse:\n\t\t\t\topen()\n\t\t\t\tif _dummy_gp != null:\n\t\t\t\t\t_dummy_gp.queue_free()\n\t\t\t\t\t_dummy_gp = null\n\n# Keep a reference to the object used to block movement through a locked door.\n# Note that this gamepiece has no animation, movement, etc. It exists to occupy a board cell.\nvar _dummy_gp: Gamepiece = null\n\n@onready var _anim: = $AnimationPlayer as AnimationPlayer\n@onready var _closed_door: = $Area2D/ClosedDoor as Sprite2D\n\nfunc _ready() -> void:\n\tsuper._ready()\n\nfunc open() -> void:\n\t# Do not open the door if it is already open.\n\tif not _closed_door.visible:\n\t\treturn\n\n\telif is_locked:\n\t\t_anim.play(\"locked\")\n\n\telse:\n\t\t_anim.play(\"open\")\n\tawait _anim.animation_finished\n\nfunc _on_area_entered(area: Area2D) -> void:\n\t# Only open the door if it is closed.\n\tif _closed_door.visible:\n\t\t_anim.play(\"open\")\n\n\tawait super._on_area_entered(area)\n\nfunc _on_blackout() -> void:\n\tsuper._on_blackout()\n\n\t#TODO: this becomes redundant when world area loading is implemented.\n\t_anim.play(\"RESET\")\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "# Code-based special effect that animates a set of lines extending out to\n# represent a 'pop'. For full effect, make a popping noise with your mouth.\nextends Node2D\n\n@export var color := Color.BLUE\n@export var radius := 200.0\n@export var lines := 12\n@export var length_max := 100.0\n@export var distance_start := 10.0\n@export var distance_max := 30.0\n@export var duration := 0.35\n\nvar current_length := 0.0\nvar current_distance := 10.0", "output": "var elapsed := 0.0\n\nfunc _ready() -> void:\n\tset_as_top_level(true)\n\nfunc _draw() -> void:\n\tvar angle_iteration := 360.0 / lines\n\tfor i in range(lines):\n\t\tvar angle := i * angle_iteration\n\t\tvar direction := GSAIUtils.angle_to_vector2(deg_to_rad(angle))\n\t\tdraw_line(\n\t\t\tdirection * current_distance,\n\t\t\t(direction * current_distance) + direction * current_length,\n\t\t\tcolor\n\t\t)\n\nfunc _process(delta: float) -> void:\n\telapsed += delta\n\tvar t := elapsed / duration\n\tcurrent_distance = lerpf(distance_start, distance_max, t)\n\tcurrent_length = lerpf(0, length_max, t)\n\tqueue_redraw()\n\tif t >= duration:\n\t\tqueue_free()\n"} {"instruction": "Erstelle eine Godot-Klasse 'BattlerRoster' die von Node erbt mit folgenden Funktionen: get_battlers, get_player_battlers, _filter_players, get_enemy_battlers, _filter_enemies", "input": "", "output": "## The BattlerRoster provides easy access to combat participants.\n##\n## The roster is a central means of accessing all the [Battler]s in a combat, providing utility\n## methods to filter them for a number of criteria (player, enemy, is_alive, etc.).\n##\n## Note that Battlers must be a descendent (though not necessarily a direct child) of the roster\n## to be included in combat.\n@icon(\"icon_turn_queue.png\")\nclass_name BattlerRoster extends Node\n\n## Returns all Battlers existing in the current combat.\nfunc get_battlers() -> Array[Battler]:\n\tvar battler_list: Array[Battler] = []\n\tbattler_list.assign(find_children(\"*\", \"Battler\"))\n\treturn battler_list\n\n## Returns all existing player Battlers.\nfunc get_player_battlers() -> Array[Battler]:\n\treturn get_battlers().filter(\n\t\tfunc _filter_players(battler: Battler):\n\t\t\treturn battler.is_player\n\t)\n\n## Returns all existing Battlers that are opposed to the player.\nfunc get_enemy_battlers() -> Array[Battler]:\n\treturn get_battlers().filter(\n\t\tfunc _filter_enemies(battler: Battler):\n\t\t\treturn not battler.is_player\n\t)\n\n## Filter an array of Battlers to return only whose health points are currently greater than 0.\nfunc find_live_battlers(battlers: Array[Battler]) -> Array[Battler]:\n\treturn battlers.filter(func(battler: Battler): return battler.stats.health > 0)\n\n## Filter an array of Battlers to find those who are active but do not yet have a cached action (see\n## [member Battler.cached_action]).\nfunc find_battlers_needing_actions(battlers: Array[Battler]) -> Array[Battler]:\n\treturn battlers.filter(\n\t\tfunc _filter_actors(actor: Battler) -> bool:\n\t\t\treturn actor.is_active and actor.cached_action == null\n\t)\n\n## Filter an array of Battlers to find those who may take an action. That is, they are active (see\n## [member Battler.is_active]) and have a cached action ready (see [member Battler.cached_action]).\nfunc find_ready_to_act_battlers(battlers: Array[Battler]) -> Array[Battler]:\n\treturn battlers.filter(\n\t\tfunc _filter_actors(actor: B"} {"instruction": "Vervollständige den GDScript-Code:", "input": "extends OpenXRCompositionLayerEquirect\n\nconst NO_INTERSECTION = Vector2(-1.0, -1.0)\n\n@export var controller : XRController3D\n@export var button_action : String = \"select\"\n\nvar was_pressed : bool = false\nvar was_intersect : Vector2 = NO_INTERSECTION\n\n\n# Pass input events on to viewport.\nfunc _input(event):\n\tif not layer_viewport:\n\t\treturn\n\n\tif event is InputEventMouse:\n\t\t# Desktop mouse events do not translate so ignore.\n\t\treturn\n\n\t# Anything else, just pass on!\n\tlayer_viewport.push_input(event)\n\n\n# Convert the intersect point reurned by intersects_ray to local coords in the viewport.\nfunc _intersect_to_viewport_pos(intersect : Vector2) -> Vector2i:\n\tif layer_viewport and intersect != NO_INTERSECTION:", "output": "\t\tvar pos : Vector2 = intersect * Vector2(layer_viewport.size)\n\t\treturn Vector2i(pos)\n\telse:\n\t\treturn Vector2i(-1, -1)\n\n# Called every frame. 'delta' is the elapsed time since the previous frame.\nfunc _process(_delta):\n\tif not controller:\n\t\treturn\n\tif not layer_viewport:\n\t\treturn\n\n\tvar controller_t : Transform3D = controller.global_transform\n\tvar intersect : Vector2 = intersects_ray(controller_t.origin, -controller_t.basis.z)\n\n\tif intersect != NO_INTERSECTION:\n\t\tvar is_pressed : bool = controller.is_button_pressed(button_action)\n\n\t\tif was_intersect != NO_INTERSECTION and intersect != was_intersect:\n\t\t\t# Pointer moved\n\t\t\tvar event : InputEventMouseMotion = InputEventMouseMotion.new()\n\t\t\tvar from : Vector2 = _intersect_to_viewport_pos(was_intersect)\n\t\t\tvar to : Vector2 = _intersect_to_viewport_pos(intersect)\n\t\t\tif was_pressed:\n\t\t\t\tevent.button_mask = MOUSE_BUTTON_MASK_LEFT\n\t\t\tevent.relative = to - from\n\t\t\tevent.position = to\n\t\t\tlayer_viewport.push_input(event)\n\n\t\tif not is_pressed and was_pressed:\n\t\t\t# Button was let go?\n\t\t\tvar event : InputEventMouseButton = InputEventMouseButton.new()\n\t\t\tevent.button_index = MOUSE_BUTTON_LEFT\n\t\t\tevent.pressed = false\n\t\t\tevent.position = _intersect_to_viewport_pos(intersect)\n\t\t\tlayer_viewport.push_input(event)\n\n\t\telif is_pressed and not was_pressed:\n\t\t\t# Button was pressed?\n\t\t\tvar event : InputEventMouseButton = InputEventMouseButton.new()\n\t\t\tevent.button_index = MOUSE_BUTTON_LEFT\n\t\t\tevent.button_mask = MOUSE_BUTTON_MASK_LEFT\n\t\t\tevent.pressed = true\n\t\t\tevent.position = _intersect_to_viewport_pos(intersect)\n\t\t\tlayer_viewport.push_input(event)\n\n\t\twas_pressed = is_pressed\n\t\twas_intersect = intersect\n"} {"instruction": "Erstelle eine Godot-Klasse 'MathUtils' die von Node erbt mit folgenden Funktionen: get_triangle_circumcircle_radius", "input": "", "output": "# Helper global object that holds helpful mathematics functions that are not\n# part of Godot.\nclass_name MathUtils\nextends Node\n\n# Returns the radius of a circumcircle for a triangle.\n# The circumscribed circle or circumcircle of a polygon is a circle that passes\n# through all the vertices of the polygon.\n# Adapted from an algorithm by [mutoo](https://gist.github.com/mutoo/5617691)\nstatic func get_triangle_circumcircle_radius(vertices: PackedVector2Array) -> float:\n\tassert(vertices.size() == 3)\n\n\tvar a := vertices[0]\n\tvar b := vertices[1]\n\tvar c := vertices[2]\n\n\tvar A := b.x - a.x\n\tvar B := b.y - a.y\n\tvar C := c.x - a.x\n\tvar D := c.y - a.y\n\tvar E := A * (a.x + b.x) + B * (a.y + b.y)\n\tvar F := C * (a.x + c.x) + D * (a.y + c.y)\n\tvar G := 2 * (A * (c.y - b.y) - B * (c.x - b.x))\n\tvar dx: float\n\tvar dy: float\n\n\tif abs(G) < 0.000001:\n\t\tdx = (max(a.x, max(b.x, c.x))) * 0.5\n\t\tdy = (max(a.y, max(b.y, c.y))) * 0.5\n\telse:\n\t\tdx = ((D * E - B * F) / G) - a.x\n\t\tdy = ((A * F - C * E) / G) - a.y\n\n\treturn sqrt(dx * dx + dy * dy)\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "extends Control\n\n@onready var item_list: ItemList = $ItemList\n\nfunc _ready() -> void:\n\tfor item in AudioServer.get_output_device_list():\n\t\titem_list.add_item(item)\n\n\tvar device := AudioServer.get_output_device()\n\tfor i in item_list.get_item_count():\n\t\tif device == item_list.get_item_text(i):\n\t\t\titem_list.select(i)\n\t\t\tbreak\n", "output": "\nfunc _process(_delta: float) -> void:\n\tvar speaker_mode_text: String = \"Stereo\"\n\tvar speaker_mode := AudioServer.get_speaker_mode()\n\n\tif speaker_mode == AudioServer.SPEAKER_SURROUND_31:\n\t\tspeaker_mode_text = \"Surround 3.1\"\n\telif speaker_mode == AudioServer.SPEAKER_SURROUND_51:\n\t\tspeaker_mode_text = \"Surround 5.1\"\n\telif speaker_mode == AudioServer.SPEAKER_SURROUND_71:\n\t\tspeaker_mode_text = \"Surround 7.1\"\n\n\t$DeviceInfo.text = \"Current Device: \" + AudioServer.get_output_device() + \"\\n\"\n\t$DeviceInfo.text += \"Speaker Mode: \" + speaker_mode_text\n\nfunc _on_Button_button_down() -> void:\n\tfor item in item_list.get_selected_items():\n\t\tvar device := item_list.get_item_text(item)\n\t\tAudioServer.set_output_device(device)\n\nfunc _on_Play_Audio_button_down() -> void:\n\tif $AudioStreamPlayer.playing:\n\t\t$AudioStreamPlayer.stop()\n\t\t$PlayAudio.text = \"Play Audio\"\n\telse:\n\t\t$AudioStreamPlayer.play()\n\t\t$PlayAudio.text = \"Stop Audio\"\n"} {"instruction": "Erstelle eine Godot-Klasse 'GdUnitBoolAssert' die von GdUnitAssert erbt mit folgenden Funktionen: is_null, is_not_null, is_equal, is_not_equal, override_failure_message", "input": "", "output": "## An Assertion Tool to verify boolean values\n@abstract class_name GdUnitBoolAssert\nextends GdUnitAssert\n\n## Verifies that the current value is null.\n@abstract func is_null() -> GdUnitBoolAssert\n\n## Verifies that the current value is not null.\n@abstract func is_not_null() -> GdUnitBoolAssert\n\n## Verifies that the current value is equal to the given one.\n@abstract func is_equal(expected: Variant) -> GdUnitBoolAssert\n\n## Verifies that the current value is not equal to the given one.\n@abstract func is_not_equal(expected: Variant) -> GdUnitBoolAssert\n\n## Overrides the default failure message by given custom message.\n@abstract func override_failure_message(message: String) -> GdUnitBoolAssert\n\n## Appends a custom message to the failure message.\n@abstract func append_failure_message(message: String) -> GdUnitBoolAssert\n\n## Verifies that the current value is true.\n@abstract func is_true() -> GdUnitBoolAssert\n\n## Verifies that the current value is false.\n@abstract func is_false() -> GdUnitBoolAssert\n"} {"instruction": "Erstelle eine Godot-Klasse 'CollisionHands3D' die von AnimatableBody3D erbt mit folgenden Funktionen: _ready, _physics_process", "input": "", "output": "class_name CollisionHands3D\nextends AnimatableBody3D\n\nfunc _ready():\n\t# Make sure these are set correctly.\n\ttop_level = true\n\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": "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 Godot-Klasse 'CombatAI' die von Node erbt mit folgenden Funktionen: select_action", "input": "", "output": "## The base class responsible for AI-controlled Battlers.\n##\n## For now, this simply selects a random [BattlerAction] and picks a random target, if one is\n## available.\nclass_name CombatAI extends Node\n\n## Defines the max number of loops that the controller will search for a valid action. If no valid\n## action has been found after this number of iterations, the AI Battler will pass its turn.\nconst ITERATION_MAX: = 60\n\n## This controller randomly chooses an action from the Battler's [member Battler.actions] and then\n## randomly chooses a target.\nfunc select_action(source: Battler) -> void:\n\t# Keep track of how many times the controller has tried to find a valid action. In the event\n\t# that the controller fails ITERATION_MAX times, it will cease searching for an action.\n\t# We do this because it is possible that the designer may create a scenario where there are\n\t# no valid actions to choose, in which case the AI would loop forever finding a valid action.\n\tvar iteration_counter = 0\n\n\tif not source.actions.is_empty():\n\t\twhile iteration_counter < ITERATION_MAX:\n\t\t\t# Randomly choose an action.\n\t\t\tvar action_index: = randi() % source.actions.size()\n\n\t\t\tvar selected_action: = source.actions[action_index]\n\t\t\tvar action: BattlerAction = selected_action.duplicate()\n\t\t\taction.battler_roster = selected_action.battler_roster\n\t\t\taction.source = selected_action.source\n\n\t\t\t# Randomly choose a target.\n\t\t\tvar possible_targets: = action.get_possible_targets()\n\t\t\tvar targets: Array[Battler] = []\n\t\t\tif action.targets_all():\n\t\t\t\ttargets = possible_targets\n\t\t\telse:\n\t\t\t\tvar target_index: = randi() % possible_targets.size()\n\t\t\t\ttargets.append(possible_targets[target_index])\n\n\t\t\t# If there are valid targets, register the action and exit the search loop.\n\t\t\tif not targets.is_empty():\n\t\t\t\taction.cached_targets = targets\n\t\t\t\tsource.cached_action = action\n\t\t\t\treturn\n\n\t\t\titeration_counter += 1\n"} {"instruction": "Erstelle eine Godot-Klasse 'GSAIRigidBody3DAgent' die von GSAISpecializedAgent erbt mit folgenden Funktionen: _init, _apply_steering, _set_body, _on_SceneTree_frame", "input": "", "output": "# A specialized steering agent that updates itself every frame so the user does\n# not have to using a RigidBody3D\n# @category - Specialized agents\nclass_name GSAIRigidBody3DAgent\nextends GSAISpecializedAgent\n\n# The RigidBody3D to keep track of\nvar body: RigidBody3D: set = _set_body\n\nvar _last_position: Vector3\nvar _body_ref: WeakRef\n\nfunc _init(_body: RigidBody3D) -> void:\n\tif not _body.is_inside_tree():\n\t\tawait(_body).ready\n\tself.body = _body\n\n\t# warning-ignore:return_value_discarded\n\t_body.get_tree().physics_frame.connect(_on_SceneTree_frame)\n\n# Moves the agent's `body` by target `acceleration`.\n# @tags - virtual\nfunc _apply_steering(acceleration: GSAITargetAcceleration, _delta: float) -> void:\n\tvar _body: RigidBody3D = _body_ref.get_ref()\n\tif not _body:\n\t\treturn\n\n\t_applied_steering = true\n\t_body.apply_central_impulse(acceleration.linear)\n\t_body.apply_torque_impulse(Vector3.UP * acceleration.angular)\n\tif calculate_velocities:\n\t\tlinear_velocity = _body.linear_velocity\n\t\tangular_velocity = _body.angular_velocity.y\n\nfunc _set_body(value: RigidBody3D) -> void:\n\tbody = value\n\t_body_ref = weakref(value)\n\n\t_last_position = value.transform.origin\n\t_last_orientation = value.rotation.y\n\n\tposition = _last_position\n\torientation = _last_orientation\n\nfunc _on_SceneTree_frame() -> void:\n\tvar _body: RigidBody3D = _body_ref.get_ref()\n\tif not _body:\n\t\treturn\n\n\tif not _body.is_inside_tree():\n\t\treturn\n\n\tvar current_position := _body.transform.origin\n\tvar current_orientation := _body.rotation.y\n\n\tposition = current_position\n\torientation = current_orientation\n\n\tif calculate_velocities:\n\t\tif _applied_steering:\n\t\t\t_applied_steering = false\n\t\telse:\n\t\t\tlinear_velocity = _body.linear_velocity\n\t\t\tangular_velocity = _body.angular_velocity.y\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "extends Node2D\n\nconst VU_COUNT = 16\nconst FREQ_MAX = 11050.0\n\nconst WIDTH = 800\nconst HEIGHT = 250\nconst HEIGHT_SCALE = 8.0\nconst MIN_DB = 60\nconst ANIMATION_SPEED = 0.1\n\nvar spectrum: AudioEffectSpectrumAnalyzerInstance\nvar min_values: Array[float] = []\nvar max_values: Array[float] = []\n\nfunc _draw() -> void:\n\t@warning_ignore(\"integer_division\")\n\tvar w := WIDTH / VU_COUNT\n\tfor i in VU_COUNT:\n\t\tvar min_height = min_values[i]\n\t\tvar max_height = max_values[i]\n\t\tvar height = lerp(min_height, max_height, ANIMATION_SPEED)\n\n\t\tdraw_rect(\n\t\t\t\tRect2(w * i, HEIGHT - height, w - 2, height),\n\t\t\t\tColor.from_hsv(float(VU_COUNT * 0.6 + i * 0.5) / VU_COUNT, 0.5, 0.6)\n\t\t\t)", "output": "\t\tdraw_line(\n\t\t\t\tVector2(w * i, HEIGHT - height),\n\t\t\t\tVector2(w * i + w - 2, HEIGHT - height),\n\t\t\t\tColor.from_hsv(float(VU_COUNT * 0.6 + i * 0.5) / VU_COUNT, 0.5, 1.0),\n\t\t\t\t2.0,\n\t\t\t\ttrue\n\t\t\t)\n\n\t\t# Draw a reflection of the bars with lower opacity.\n\t\tdraw_rect(\n\t\t\t\tRect2(w * i, HEIGHT, w - 2, height),\n\t\t\t\tColor.from_hsv(float(VU_COUNT * 0.6 + i * 0.5) / VU_COUNT, 0.5, 0.6) * Color(1, 1, 1, 0.125)\n\t\t\t)\n\t\tdraw_line(\n\t\t\t\tVector2(w * i, HEIGHT + height),\n\t\t\t\tVector2(w * i + w - 2, HEIGHT + height),\n\t\t\t\tColor.from_hsv(float(VU_COUNT * 0.6 + i * 0.5) / VU_COUNT, 0.5, 1.0) * Color(1, 1, 1, 0.125),\n\t\t\t\t2.0,\n\t\t\t\ttrue\n\t\t\t)\n\nfunc _process(_delta: float) -> void:\n\tvar data: Array[float] = []\n\tvar prev_hz := 0.0\n\n\tfor i in range(1, VU_COUNT + 1):\n\t\tvar hz := i * FREQ_MAX / VU_COUNT\n\t\tvar magnitude := spectrum.get_magnitude_for_frequency_range(prev_hz, hz).length()\n\t\tvar energy := clampf((MIN_DB + linear_to_db(magnitude)) / MIN_DB, 0, 1)\n\t\tvar height := energy * HEIGHT * HEIGHT_SCALE\n\t\tdata.append(height)\n\t\tprev_hz = hz\n\n\tfor i in VU_COUNT:\n\t\tif data[i] > max_values[i]:\n\t\t\tmax_values[i] = data[i]\n\t\telse:\n\t\t\tmax_values[i] = lerpf(max_values[i], data[i], ANIMATION_SPEED)\n\n\t\tif data[i] <= 0.0:\n\t\t\tmin_values[i] = lerpf(min_values[i], 0.0, ANIMATION_SPEED)\n\n\t# Sound plays back continuously, so the graph needs to be updated every frame.\n\tqueue_redraw()\n\nfunc _ready() -> void:\n\tspectrum = AudioServer.get_bus_effect_instance(0, 0)\n\tmin_values.resize(VU_COUNT)"} {"instruction": "Vervollständige den GDScript-Code:", "input": "# Primary node that takes care of sending setup instructions to some of the\n# game's sub-systems; passing along the location of the map viewport for\n# mappable objects, informing pirates of obstacles in the world, and \n# giving the player access to the game camera.\nextends Node\n\nvar _spawned_positions := []\nvar _world_objects := []\n\n@onready var map: MapView = $MapView\n@onready var camera := $GameWorld/Camera\n@onready var hud := $UI/HUD\n\n\nfunc _ready() -> void:\n\tEvents.station_spawned.connect(_on_Spawner_station_spawned)", "output": "\tEvents.asteroid_spawned.connect(_on_Spawner_asteroid_spawned)\n\tEvents.pirate_spawned.connect(_on_Spawner_pirate_spawned)\n\n\tcamera.setup_camera_map(map)\n\n\tObjectRegistry.register_distortion_parent($DistortMaskView/SubViewport)\n\tcamera.setup_distortion_camera()\n\nfunc _input(event: InputEvent) -> void:\n\tif event.is_action_pressed(\"toggle_fullscreen\"):\n\t\tget_window().mode = Window.MODE_EXCLUSIVE_FULLSCREEN if (not ((get_window().mode == Window.MODE_EXCLUSIVE_FULLSCREEN) or (get_window().mode == Window.MODE_FULLSCREEN))) else Window.MODE_WINDOWED\n\t\tget_viewport().set_input_as_handled()\n\nfunc _on_Spawner_pirate_spawned(pirate: PirateShip) -> void:\n\tpirate.setup_world_objects(_world_objects)\n\tEvents.node_spawned.emit(pirate)\n\nfunc _on_Spawner_station_spawned(station: DockingPoint, player: PlayerShip) -> void:\n\t_world_objects.append(weakref(station))\n\n\thud.initialize(player)\n\tplayer.grab_camera(camera)\n\tEvents.node_spawned.emit(station)\n\tEvents.node_spawned.emit(player)\n\nfunc _on_Spawner_asteroid_spawned(asteroid: DockingPoint) -> void:\n\t_world_objects.append(weakref(asteroid))\n\tEvents.node_spawned.emit(asteroid)\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "## An assertion tool to verify for Godot runtime errors like assert() and push notifications like push_error().\n@abstract class_name GdUnitGodotErrorAssert\nextends GdUnitAssert\n\n\n## Verifies that the current value is null.\n@abstract func is_null() -> GdUnitGodotErrorAssert\n\n\n## Verifies that the current value is not null.\n@abstract func is_not_null() -> GdUnitGodotErrorAssert\n\n\n## Verifies that the current value is equal to the given one.\n@abstract func is_equal(expected: Variant) -> GdUnitGodotErrorAssert\n\n\n## Verifies that the current value is not equal to expected one.\n@abstract func is_not_equal(expected: Variant) -> GdUnitGodotErrorAssert\n", "output": "\n## Overrides the default failure message by given custom message.\n@abstract func override_failure_message(message: String) -> GdUnitGodotErrorAssert\n\n## Appends a custom message to the failure message.\n@abstract func append_failure_message(message: String) -> GdUnitGodotErrorAssert\n\n## Verifies if the executed code runs without any runtime errors\n## Usage:\n## [codeblock]\n##\t\tawait assert_error().is_success()\n## [/codeblock]\n@abstract func is_success() -> GdUnitGodotErrorAssert\n\n## Verifies if the executed code runs into a runtime error\n## Usage:\n## [codeblock]\n##\t\tawait assert_error().is_runtime_error()\n## [/codeblock]\n@abstract func is_runtime_error(expected_error: Variant) -> GdUnitGodotErrorAssert\n\n## Verifies if the executed code has a push_warning() used\n## Usage:\n## [codeblock]\n##\t\tawait assert_error().is_push_warning()\n## [/codeblock]\n@abstract func is_push_warning(expected_warning: Variant) -> GdUnitGodotErrorAssert\n\n## Verifies if the executed code has a push_error() used\n## Usage:\n## [codeblock]\n##\t\tawait assert_error().is_push_error()\n## [/codeblock]\n@abstract func is_push_error(expected_error: Variant) -> GdUnitGodotErrorAssert\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "# A desired linear and angular amount of acceleration requested by the steering\n# system.\n# @category - Base types\nclass_name GSAITargetAcceleration\n\n# Linear acceleration\nvar linear := Vector3.ZERO\n# Angular acceleration\nvar angular := 0.0\n\n", "output": "# Sets the linear and angular components to 0.\nfunc set_zero() -> void:\n\tlinear.x = 0.0\n\tlinear.y = 0.0\n\tlinear.z = 0.0\n\tangular = 0.0\n\n# Adds `accel`'s components, multiplied by `scalar`, to this one.\nfunc add_scaled_accel(accel: GSAITargetAcceleration, scalar: float) -> void:\n\tlinear += accel.linear * scalar\n\tangular += accel.angular * scalar\n\n# Returns the squared magnitude of the linear and angular components.\nfunc get_magnitude_squared() -> float:\n\treturn linear.length_squared() + angular * angular\n\n# Returns the magnitude of the linear and angular components.\nfunc get_magnitude() -> float:\n\treturn sqrt(get_magnitude_squared())\n"} {"instruction": "Erstelle eine Godot-Klasse 'Hitbox' die von Area2D erbt mit folgenden Funktionen: _ready, _area_entered, get_knockback", "input": "", "output": "#*\n#* hitbox.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#*\nclass_name Hitbox\nextends Area2D\n## Area that deals damage.\n\n## Damage value to apply.\n@export var damage: float = 1.0\n\n## Push back the victim.\n@export var knockback_enabled: bool = false\n\n## Desired pushback speed.\n@export var knockback_strength: float = 500.0\n\nfunc _ready() -> void:\n\tarea_entered.connect(_area_entered)\n\nfunc _area_entered(hurtbox: Hurtbox) -> void:\n\tif hurtbox.owner == owner:\n\t\treturn\n\thurtbox.take_damage(damage, get_knockback(), self)\n\nfunc get_knockback() -> Vector2:\n\tvar knockback: Vector2\n\tif knockback_enabled:\n\t\tknockback = Vector2.RIGHT.rotated(global_rotation) * knockback_strength\n\treturn knockback\n"} {"instruction": "Erstelle eine Godot-Klasse 'GdUnitFailureAssert' die von GdUnitAssert erbt mit folgenden Funktionen: is_null, is_not_null, is_equal, is_not_equal, override_failure_message", "input": "", "output": "## An assertion tool to verify GDUnit asserts.\n## This assert is for internal use only, to verify that failed asserts work as expected.\n@abstract class_name GdUnitFailureAssert\nextends GdUnitAssert\n\n## Verifies that the current value is null.\n@abstract func is_null() -> GdUnitFailureAssert\n\n## Verifies that the current value is not null.\n@abstract func is_not_null() -> GdUnitFailureAssert\n\n## Verifies that the current value is equal to the given one.\n@abstract func is_equal(expected: Variant) -> GdUnitFailureAssert\n\n## Verifies that the current value is not equal to expected one.\n@abstract func is_not_equal(expected: Variant) -> GdUnitFailureAssert\n\n## Overrides the default failure message by given custom message.\n@abstract func override_failure_message(message: String) -> GdUnitFailureAssert\n\n## Appends a custom message to the failure message.\n@abstract func append_failure_message(message: String) -> GdUnitFailureAssert\n\n## Verifies if the executed assert was successful\n@abstract func is_success() -> GdUnitFailureAssert\n\n## Verifies if the executed assert has failed\n@abstract func is_failed() -> GdUnitFailureAssert\n\n## Verifies the failure line is equal to expected one.\n@abstract func has_line(expected: int) -> GdUnitFailureAssert\n\n## Verifies the failure message is equal to expected one.\n@abstract func has_message(expected: String) -> GdUnitFailureAssert\n\n## Verifies that the failure message starts with the expected message.\n@abstract func starts_with_message(expected: String) -> GdUnitFailureAssert\n\n## Verifies that the failure message contains the expected message.\n@abstract func contains_message(expected: String) -> GdUnitFailureAssert\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "extends KinematicBody\n\n# Emitted when the player jumped on the mob.\nsignal squashed\n\n# Minimum speed of the mob in meters per second.\nexport var min_speed = 10\n# Maximum speed of the mob in meters per second.\nexport var max_speed = 18\n\nvar velocity = Vector3.ZERO\n\n", "output": "func _physics_process(_delta):\n\t# warning-ignore:return_value_discarded\n\tmove_and_slide(velocity)\n\nfunc initialize(start_position, player_position):\n\tlook_at_from_position(start_position, player_position, Vector3.UP)\n\trotate_y(rand_range(-PI / 4, PI / 4))\n\n\tvar random_speed = rand_range(min_speed, max_speed)\n\t# We calculate a forward velocity first, which represents the speed.\n\tvelocity = Vector3.FORWARD * random_speed\n\t# We then rotate the vector based on the mob's Y rotation to move in the direction it's looking.\n\tvelocity = velocity.rotated(Vector3.UP, rotation.y)\n\n\t$AnimationPlayer.playback_speed = random_speed / min_speed\n\nfunc squash():\n\temit_signal(\"squashed\")\n\tqueue_free()\n\nfunc _on_VisibilityNotifier_screen_exited():\n\tqueue_free()\n"} {"instruction": "Erstelle eine Godot-Klasse 'GameboardLayer' die von TileMapLayer erbt mit folgenden Funktionen: _ready, _on_tree_exiting, is_cell_clear, _update_cells", "input": "", "output": "## A variation of [TileMapLayer] that is used to create the [Gameboard].\n##\n## Comes setup with a few tools used by designers to setup maps, specifying which cells may be\n## moved to or from. Multiple GameboardLayers may exist simultaneously to allow developers to\n## affect the gameboard with more than one layer.\n##\n## These collision layers may also dynamically change, with the changes being reflected\n## by the gameboard and pathfinder.\nclass_name GameboardLayer extends TileMapLayer\n\n## Emitted whenever the collision state of the tile map changes.\n##\n## The GameboardLayer's tile map may change without changing which cells are blocked or\n## are open for movement. In this case, the signal is not emitted. However, it is emitted whenever\n## the map is added or removed from the game, in addition to when there is a change in blocked/clear\n## cells.\nsignal cells_changed(cleared_cells: Array[Vector2i], blocked_cells: Array[Vector2i])\n\n## The group name of all [GameboardLayer] that will be checked for blocked/walkable cells.\nconst GROUP: = \"GameboardTileMapLayers\"\n\n## The name of the \"custom data layer\" that determines whether or not a cell is blocked/walkable.\n## The returned value will be a boolean reflecting if a cell is blocked or not. Fetches the value\n## via [method TileData.get_custom_data].\n##\n## If the data layer is not present in the [Tileset], then all cells in this [TileMapLayer] will,\n## by default, block movement.\nconst BLOCKED_CELL_DATA_LAYER: = \"IsCellBlocked\"\n\n# A false value will cause is_cell_clear to always return true. This is used to flag when the\n# TileMapLayers is being cleaned up an should no longer affect the pathfinder.\nvar _affects_collision: = true\n\nfunc _ready() -> void:\n\tadd_to_group(GROUP)\n\tGameboard.register_gameboard_layer(self)\n\n\ttree_exiting.connect(\n\t\tfunc _on_tree_exiting() -> void:\n\t\t\t_affects_collision = false\n\n\t\t\tvar blocked_cells: Array[Vector2i] = []\n\t\t\tcells_changed.emit(get_used_cells(), blocked_cells)\n\t)\n\n## Returns true if th"} {"instruction": "Erstelle eine GDScript-Funktion namens '_ready':", "input": "", "output": "func _ready():\n\tblackboard = blackboard.duplicate()\n\t_data[DEFAULT] = blackboard\n\nfunc 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] = {}"} {"instruction": "Erstelle eine Godot-Klasse 'Interaction' die von Cutscene erbt mit folgenden Funktionen: _ready, _on_button_pressed, _get_configuration_warnings, _unhandled_input, _update_input_state", "input": "", "output": "@tool\n\n## A [Cutscene] that is triggered by the presence of the player and the player's input.\n##\n## An active Interaction may be run by the player walking up to it and 'interacting' with it,\n## usually via something as ubiquitous as the spacebar key. Common examples found in most RPGs are\n## NPC conversations, opening treasure chests, activating a save point, etc.\n## An edge case occurs when the player clicks on an interaction, though the player is far away. We\n## only want to report the top-most interaction as being clicked.\n##\n##[br][br]\n## Interactions handle player input directly and are activated according to the presence of the\n## player's interaction collision shape, which occupies the cell faced by the player's character.\n@icon(\"res://assets/editor/icons/Interaction.svg\")\nclass_name Interaction extends Cutscene\n\n## An active [code]Interaction[/code] may be run, whereas one that is inactive may only be run\n## directly through code via the [method Cutscene.run] method.\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\t_update_input_state()\n\n\t\t\tif not is_inside_tree():\n\t\t\t\tawait ready\n\n\t\t\t# We use \"Visible Collision Shapes\" to debug positions on the gameboard, so we'll want\n\t\t\t# to change the state of child collision shapes.These could be either CollisionShape2Ds\n\t\t\t# or CollisionPolygon2Ds.\n\t\t\t# Note that we only want to disable the collision shapes of objects that are actually\n\t\t\t# connected to this Interaction.\n\t\t\tfor data in get_incoming_connections():\n\t\t\t\tvar callable: = data[\"callable\"] as Callable\n\t\t\t\tif callable == _on_area_entered :\n\t\t\t\t\tvar connected_area: = data[\"signal\"].get_object() as Area2D\n\t\t\t\t\tif connected_area:\n\t\t\t\t\t\tfor node in connected_area.find_children(\"*\", \"CollisionShape2D\"):\n\t\t\t\t\t\t\t(node as CollisionShape2D).disabled = !is_active\n\t\t\t\t\t\tfor node in connected_area.find_children(\"*\", \"CollisionPolygon2D\"):\n\t\t\t\t\t\t\t(node as CollisionPolygon2D).disabled = !is_active\n\n# Track overl"} {"instruction": "Vervollständige den GDScript-Code:", "input": "extends Node3D\n\nsignal session_begun\nsignal focus_lost\nsignal focus_gained\nsignal pose_recentered\n\n@export var maximum_refresh_rate: int = 90\n\nvar xr_interface: OpenXRInterface\nvar xr_is_focused := false\n\n\nfunc get_vr_render_size():\n\tif xr_interface and xr_interface.is_initialized():\n\t\treturn xr_interface.get_render_target_size()\n\telse:\n\t\treturn Vector2(0.0, 0.0)\n\n\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 the Project Settings.\")\n\n\t\t# Connect the OpenXR events.\n\t\txr_interface.session_begun.connect(_on_openxr_session_begun)\n\t\txr_interface.session_visible.connect(_on_openxr_visible_state)", "output": "\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 the 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_begun.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:\n\t\tprint(\"OpenXR lost focus\")"} {"instruction": "Erstelle eine GDScript-Funktion namens '_ready':", "input": "", "output": "func _ready() -> void:\n\tawait owner.ready\n\tstate.enter()\n\nfunc _unhandled_input(event: InputEvent) -> void:\n\tstate.unhandled_input(event)\n\nfunc _physics_process(delta: float) -> void:\n\tstate.physics_process(delta)\n\nfunc transition_to(target_state_path: String, msg: Dictionary = {}", "source": "extracted_function"} {"instruction": "Vervollständige den GDScript-Code:", "input": "# Calculates an angular acceleration to match an agent's orientation to its\n# direction of travel.\n# @category - Individual behaviors\nclass_name GSAILookWhereYouGo\nextends GSAIMatchOrientation\n\n", "output": "func _init(agent: GSAISteeringAgent, use_z := false) -> void:\n\tsuper._init(agent, null, use_z)\n\nfunc _calculate_steering(accel: GSAITargetAcceleration) -> void:\n\tif agent.linear_velocity.length_squared() < agent.zero_linear_speed_threshold:\n\t\taccel.set_zero()\n\telse:\n\t\tvar orientation := (\n\t\t\tGSAIUtils.vector3_to_angle(agent.linear_velocity)\n\t\t\tif use_z\n\t\t\telse GSAIUtils.vector2_to_angle(GSAIUtils.to_vector2(agent.linear_velocity))\n\t\t)\n\t\t_match_orientation(accel, orientation)\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "extends GdUnitBoolAssert\n\nvar _base: GdUnitAssertImpl\n\n\nfunc _init(current :Variant) -> void:\n\t_base = GdUnitAssertImpl.new(current)\n\t# save the actual assert instance on the current thread context\n\tGdUnitThreadManager.get_current_context().set_assert(self)\n\tif not GdUnitAssertions.validate_value_type(current, TYPE_BOOL):\n\t\t@warning_ignore(\"return_value_discarded\")\n\t\treport_error(\"GdUnitBoolAssert inital error, unexpected type <%s>\" % GdObjects.typeof_as_string(current))\n\n\nfunc _notification(event :int) -> void:\n\tif event == NOTIFICATION_PREDELETE:\n\t\tif _base != null:\n\t\t\t_base.notification(event)\n\t\t\t_base = null\n\n\nfunc current_value() -> Variant:\n\treturn _base.current_value()\n\n\nfunc report_success() -> GdUnitBoolAssert:\n\t@warning_ignore(\"return_value_discarded\")\n\t_base.report_success()\n\treturn self", "output": "\nfunc report_error(error :String) -> GdUnitBoolAssert:\n\t@warning_ignore(\"return_value_discarded\")\n\t_base.report_error(error)\n\treturn self\n\nfunc failure_message() -> String:\n\treturn _base.failure_message()\n\nfunc override_failure_message(message: String) -> GdUnitBoolAssert:\n\t@warning_ignore(\"return_value_discarded\")\n\t_base.override_failure_message(message)\n\treturn self\n\nfunc append_failure_message(message: String) -> GdUnitBoolAssert:\n\t@warning_ignore(\"return_value_discarded\")\n\t_base.append_failure_message(message)\n\treturn self\n\nfunc is_null() -> GdUnitBoolAssert:\n\t@warning_ignore(\"return_value_discarded\")\n\t_base.is_null()\n\treturn self\n\nfunc is_not_null() -> GdUnitBoolAssert:\n\t@warning_ignore(\"return_value_discarded\")\n\t_base.is_not_null()\n\treturn self\n\nfunc is_equal(expected: Variant) -> GdUnitBoolAssert:\n\t@warning_ignore(\"return_value_discarded\")\n\t_base.is_equal(expected)\n\treturn self\n\nfunc is_not_equal(expected: Variant) -> GdUnitBoolAssert:\n\t@warning_ignore(\"return_value_discarded\")\n\t_base.is_not_equal(expected)\n\treturn self\n\nfunc is_true() -> GdUnitBoolAssert:\n\tif current_value() != true:"} {"instruction": "Vervollständige den GDScript-Code:", "input": "extends XROrigin3D\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 character_body : CharacterBody3D = $CharacterBody3D\n@onready var camera_node : XRCamera3D = $XRCamera3D\n@onready var neck_position_node : Node3D = $XRCamera3D/Neck\n@onready var black_out : Node3D = $XRCamera3D/BlackOut\n\n## Called when the user has requested their view to be recentered.\nfunc recenter() -> void:\n\t# The code here assumes the player has walked into an area they shouldn't be\n\t# and we return the player back to the character body.\n\t# But other strategies can be applied here as well such as returning the player\n\t# to a starting position or a checkpoint.\n\n\t# Calculate where our camera should be, we start with our global transform.\n\tvar new_camera_transform: Transform3D = character_body.global_transform\n\n\t# Set to the height of our neck joint.\n\tnew_camera_transform.origin.y = neck_position_node.global_position.y\n\n\t# Apply transform our our next position to get our desired camera transform.\n\tnew_camera_transform = new_camera_transform * neck_position_node.transform.inverse()\n\n\t# Remove tilt from camera transform.\n\tvar camera_transform: Transform3D = camera_node.transform\n\tvar forward_dir: Vector3 = camera_transform.basis.z\n\tforward_dir.y = 0.0\n\tcamera_transform = camera_transform.looking_at(camera_transform.origin + forward_dir.normalized(), Vector3.UP, true)\n\n\t# Update our XR location.\n\tglobal_transform = new_camera_transform * camera_transform.inverse()\n\n\t# Recenter character body.\n\tcharacter_body.transform = Transform3D()\n\n\n# `_get_movement_input()` returns our move input by querying the move action on each controller.\nfunc _get_movement_input() -> Vector2:\n\tvar movement : Vector2 = Vector2()\n\n\t# If move is not bound to one of our controllers,\n\t# that controller will return `Vector2.ZERO`.\n\tmovement += $LeftHand.get_vector2(&\"move\")\n\tmovement += $RightHand.get_vector2(&\"move\")\n", "output": "\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 := character_body.velocity\n\n\t# Remember where our player body currently is.\n\tvar org_player_body: Vector3 = character_body.global_transform.origin\n\n\t# Determine where our player body should be.\n\tvar player_body_location: Vector3 = 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\t# Attempt to move our character.\n\tcharacter_body.velocity = (player_body_location - org_player_body) / delta\n\tcharacter_body.move_and_slide()\n\n\t# Set back to our current value.\n\tcharacter_body.velocity = current_velocity\n\n\t# Check if we managed to move all the way, ignoring height change.\n\tvar movement_left := player_body_location - character_body.global_transform.origin\n\tmovement_left.y = 0.0\n\n\t# Check if we managed to move where we wanted to.\n\tvar location_offset := movement_left.length()\n\tif location_offset > 0.1:\n\t\t# We couldn't go where we wanted to, black out our screen.\n\t\tblack_out.fade = clamp((location_offset - 0.1) / 0.1, 0.0, 1.0)\n\n\t\treturn true\n\telse:\n\t\tblack_out.fade = 0.0\n\t\treturn false\n\nfunc _copy_player_rotation_to_character_body() -> void:\n\t# We only copy our forward direction to our character body, we ignore tilt.\n\tvar camera_forward := -camera_node.global_transform.basis.z\n\tvar body_forward := Vector3(camera_forward.x, 0.0, camera_forward.z)\n\n\tcharacter_body.global_transform.basis = Basis.looking_at(body_forward, Vector3.UP)\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "#!/usr/bin/env -S godot -s\nextends SceneTree\n\n\nvar _cli_runner: GdUnitTestCIRunner\n\n", "output": "func _initialize() -> void:\n\tDisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_MINIMIZED)\n\t_cli_runner = GdUnitTestCIRunner.new()\n\troot.add_child(_cli_runner)\n\n# do not use print statements on _finalize it results in random crashes\nfunc _finalize() -> void:\n\tqueue_delete(_cli_runner)\n\tif OS.is_stdout_verbose():\n\t\tprints(\"Finallize ..\")\n\t\tprints(\"-Orphan nodes report-----------------------\")\n\t\tWindow.print_orphan_nodes()\n\t\tprints(\"Finallize .. done\")\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "# Base container type that stores data to find the neighbors of an agent.\n# @category - Proximities\n# @tags - abstract\nclass_name GSAIProximity\nextends RefCounted\n\n# The owning agent whose neighbors are found in the group\nvar agent: GSAISteeringAgent", "output": "# The agents who are part of this group and could be potential neighbors\nvar agents := []\n\nfunc _init(_agent: GSAISteeringAgent, _agents: Array) -> void:\n\tself.agent = _agent\n\tself.agents = _agents\n\n# Returns a number of neighbors based on a `callback` function.\n#\n# `_find_neighbors` calls `callback` for each agent in the `agents` array and\n# adds one to the count if its `callback` returns true.\n# @tags - virtual\nfunc _find_neighbors(_callback: Callable) -> int:\n\treturn 0\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "extends Control\n\n@onready var item_list: ItemList = $ItemList\n\nfunc _ready() -> void:\n\tfor item in AudioServer.get_output_device_list():\n\t\titem_list.add_item(item)\n\n\tvar device := AudioServer.get_output_device()\n\tfor i in item_list.get_item_count():\n\t\tif device == item_list.get_item_text(i):\n\t\t\titem_list.select(i)\n\t\t\tbreak\n", "output": "\nfunc _process(_delta: float) -> void:\n\tvar speaker_mode_text: String = \"Stereo\"\n\tvar speaker_mode := AudioServer.get_speaker_mode()\n\n\tif speaker_mode == AudioServer.SPEAKER_SURROUND_31:\n\t\tspeaker_mode_text = \"Surround 3.1\"\n\telif speaker_mode == AudioServer.SPEAKER_SURROUND_51:\n\t\tspeaker_mode_text = \"Surround 5.1\"\n\telif speaker_mode == AudioServer.SPEAKER_SURROUND_71:\n\t\tspeaker_mode_text = \"Surround 7.1\"\n\n\t$DeviceInfo.text = \"Current Device: \" + AudioServer.get_output_device() + \"\\n\"\n\t$DeviceInfo.text += \"Speaker Mode: \" + speaker_mode_text\n\nfunc _on_Button_button_down() -> void:\n\tfor item in item_list.get_selected_items():\n\t\tvar device := item_list.get_item_text(item)\n\t\tAudioServer.set_output_device(device)\n\nfunc _on_Play_Audio_button_down() -> void:\n\tif $AudioStreamPlayer.playing:\n\t\t$AudioStreamPlayer.stop()\n\t\t$PlayAudio.text = \"Play Audio\"\n\telse:\n\t\t$AudioStreamPlayer.play()\n\t\t$PlayAudio.text = \"Stop Audio\"\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "extends Control\n\n\nfunc _on_toggle_music_toggled(button_pressed: bool) -> void:\n\tif button_pressed:\n\t\t$SoundEffects/Music.play()\n\telse:\n\t\t$SoundEffects/Music.stop()\n\n\nfunc _on_ding_button_pressed() -> void:\n\t$SoundEffects/Ding.play()\n\n\nfunc _on_glass_button_pressed() -> void:\n\t$SoundEffects/Glass.play()\n\n\nfunc _on_meow_button_pressed() -> void:\n\t$SoundEffects/Meow.play()\n\n\nfunc _on_beeps_button_pressed() -> void:\n\t$SoundEffects/Beeps.play()\n\n\nfunc _on_trombone_button_pressed() -> void:\n\t$SoundEffects/Trombone.play()\n\n\nfunc _on_static_button_pressed() -> void:\n\t$SoundEffects/Static.play()\n\n\nfunc _on_whistle_button_pressed() -> void:\n\t$SoundEffects/Whistle.play()", "output": "\nfunc _on_toggle_amplify_toggled(button_pressed: bool) -> void:\n\t\tAudioServer.set_bus_effect_enabled(0, 0, button_pressed)\n\nfunc _on_toggle_band_limiter_toggled(button_pressed: bool) -> void:\n\t\tAudioServer.set_bus_effect_enabled(0, 1, button_pressed)\n\nfunc _on_toggle_band_pass_filter_toggled(button_pressed: bool) -> void:\n\t\tAudioServer.set_bus_effect_enabled(0, 2, button_pressed)\n\nfunc _on_toggle_chorus_toggled(button_pressed: bool) -> void:\n\t\tAudioServer.set_bus_effect_enabled(0, 3, button_pressed)\n\nfunc _on_toggle_compressor_toggled(button_pressed: bool) -> void:\n\t\tAudioServer.set_bus_effect_enabled(0, 4, button_pressed)\n\nfunc _on_toggle_delay_toggled(button_pressed: bool) -> void:\n\t\tAudioServer.set_bus_effect_enabled(0, 5, button_pressed)\n\nfunc _on_toggle_distortion_toggled(button_pressed: bool) -> void:\n\t\tAudioServer.set_bus_effect_enabled(0, 6, button_pressed)\n\nfunc _on_toggle_eq_6_toggled(button_pressed: bool) -> void:\n\t\tAudioServer.set_bus_effect_enabled(0, 7, button_pressed)\n\nfunc _on_toggle_eq_10_toggled(button_pressed: bool) -> void:\n\t\tAudioServer.set_bus_effect_enabled(0, 8, button_pressed)\n\nfunc _on_toggle_eq_21_toggled(button_pressed: bool) -> void:\n\t\tAudioServer.set_bus_effect_enabled(0, 9, button_pressed)\n\nfunc _on_toggle_high_pass_filter_toggled(button_pressed: bool) -> void:\n\t\tAudioServer.set_bus_effect_enabled(0, 10, button_pressed)\n\nfunc _on_toggle_low_shelf_filter_toggled(button_pressed: bool) -> void:\n\t\tAudioServer.set_bus_effect_enabled(0, 11, button_pressed)\n"} {"instruction": "Erstelle eine Godot-Klasse 'GdUnitFileAssert' die von GdUnitAssert erbt mit folgenden Funktionen: is_null, is_not_null, is_equal, is_not_equal, override_failure_message", "input": "", "output": "@abstract class_name GdUnitFileAssert\nextends GdUnitAssert\n\n## Verifies that the current value is null.\n@abstract func is_null() -> GdUnitFileAssert\n\n## Verifies that the current value is not null.\n@abstract func is_not_null() -> GdUnitFileAssert\n\n## Verifies that the current value is equal to the given one.\n@abstract func is_equal(expected: Variant) -> GdUnitFileAssert\n\n## Verifies that the current value is not equal to expected one.\n@abstract func is_not_equal(expected: Variant) -> GdUnitFileAssert\n\n## Overrides the default failure message by given custom message.\n@abstract func override_failure_message(message: String) -> GdUnitFileAssert\n\n## Appends a custom message to the failure message.\n@abstract func append_failure_message(message: String) -> GdUnitFileAssert\n\n@abstract func is_file() -> GdUnitFileAssert\n\n@abstract func exists() -> GdUnitFileAssert\n\n@abstract func is_script() -> GdUnitFileAssert\n\n@abstract func contains_exactly(expected_rows :Array) -> GdUnitFileAssert\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "extends GdUnitFuncAssert\n\n\nconst GdUnitTools := preload(\"res://addons/gdUnit4/src/core/GdUnitTools.gd\")\nconst DEFAULT_TIMEOUT := 2000\n\n\nvar _current_value_provider :ValueProvider\nvar _current_failure_message :String = \"\"\nvar _custom_failure_message :String = \"\"\nvar _additional_failure_message: String = \"\"\nvar _line_number := -1\nvar _timeout := DEFAULT_TIMEOUT\nvar _interrupted := false\nvar _sleep_timer :Timer = null\n\n\nfunc _init(instance :Object, func_name :String, args := Array()) -> void:\n\t_line_number = GdUnitAssertions.get_line_number()\n\tGdAssertReports.reset_last_error_line_number()\n\t# save the actual assert instance on the current thread context\n\tGdUnitThreadManager.get_current_context().set_assert(self)\n\t# verify at first the function name exists\n\tif not instance.has_method(func_name):\n\t\t@warning_ignore(\"return_value_discarded\")\n\t\treport_error(\"The function '%s' do not exists checked instance '%s'.\" % [func_name, instance])\n\t\t_interrupted = true\n\telse:\n\t\t_current_value_provider = CallBackValueProvider.new(instance, func_name, args)\n\n\nfunc _notification(what :int) -> void:\n\tif what == NOTIFICATION_PREDELETE:\n\t\t_interrupted = true\n\t\tvar main_node :Node = (Engine.get_main_loop() as SceneTree).root\n\t\tif is_instance_valid(_current_value_provider):\n\t\t\t_current_value_provider.dispose()\n\t\t\t_current_value_provider = null\n\t\tif is_instance_valid(_sleep_timer):\n\t\t\t_sleep_timer.set_wait_time(0.0001)\n\t\t\t_sleep_timer.stop()\n\t\t\tmain_node.remove_child(_sleep_timer)\n\t\t\t_sleep_timer.free()\n\t\t\t_sleep_timer = null\n\n\nfunc report_success() -> GdUnitFuncAssert:\n\tGdAssertReports.report_success()\n\treturn self\n\n\nfunc report_error(failure :String) -> GdUnitFuncAssert:\n\t_current_failure_message = GdAssertMessages.build_failure_message(failure, _additional_failure_message, _custom_failure_message)\n\tGdAssertReports.report_error(_current_failure_message, _line_number)\n\treturn self\n\n\nfunc failure_message() -> String:\n\treturn _current_failure_message", "output": "\nfunc override_failure_message(message: String) -> GdUnitFuncAssert:\n\t_custom_failure_message = message\n\treturn self\n\nfunc append_failure_message(message: String) -> GdUnitFuncAssert:\n\t_additional_failure_message = message\n\treturn self\n\nfunc wait_until(timeout := 2000) -> GdUnitFuncAssert:\n\tif timeout <= 0:\n\t\tpush_warning(\"Invalid timeout param, alloed timeouts must be grater than 0. Use default timeout instead\")\n\t\t_timeout = DEFAULT_TIMEOUT\n\telse:\n\t\t_timeout = timeout\n\treturn self\n\nfunc is_null() -> GdUnitFuncAssert:\n\tawait _validate_callback(cb_is_null)\n\treturn self\n\nfunc is_not_null() -> GdUnitFuncAssert:\n\tawait _validate_callback(cb_is_not_null)\n\treturn self\n\nfunc is_false() -> GdUnitFuncAssert:\n\tawait _validate_callback(cb_is_false)\n\treturn self\n\nfunc is_true() -> GdUnitFuncAssert:\n\tawait _validate_callback(cb_is_true)\n\treturn self\n\nfunc is_equal(expected: Variant) -> GdUnitFuncAssert:\n\tawait _validate_callback(cb_is_equal, expected)\n\treturn self\n\nfunc is_not_equal(expected: Variant) -> GdUnitFuncAssert:\n\tawait _validate_callback(cb_is_not_equal, expected)\n\treturn self\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "@tool\nclass_name HasPositivePosition extends ConditionLeaf\n", "output": "\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": "Vervollständige den GDScript-Code:", "input": "@tool\nextends EditorPlugin\n\nvar _gd_inspector: Control\nvar _gd_console: Control\nvar _filesystem_context_menu: EditorContextMenuPlugin\nvar _editor_context_menu: EditorContextMenuPlugin\nvar _editor_code_context_menu: EditorContextMenuPlugin\n\n\nfunc _enter_tree() -> void:\n\tvar inferred_declaration: int = ProjectSettings.get_setting(\"debug/gdscript/warnings/inferred_declaration\")\n\n\tvar is_gdunit_excluded_warnings: bool = false\n\tif Engine.get_version_info().hex >= 0x40600:\n\t\tvar dirctrory_rules: Dictionary = ProjectSettings.get_setting(\"debug/gdscript/warnings/directory_rules\")\n\t\tif dirctrory_rules.has(\"res://addons/gdUnit4\") and dirctrory_rules[\"res://addons/gdUnit4\"] == 0:\n\t\t\tis_gdunit_excluded_warnings = true\n\telse:\n\t\tis_gdunit_excluded_warnings = ProjectSettings.get_setting(\"debug/gdscript/warnings/exclude_addons\")\n\tif !is_gdunit_excluded_warnings and inferred_declaration != 0:\n\t\tprinterr(\"GdUnit4: 'inferred_declaration' is set to Warning/Error!\")\n\t\tif Engine.get_version_info().hex >= 0x40600:\n\t\t\tprinterr(\"GdUnit4 is not 'inferred_declaration' save, you have to excluded the addon (debug/gdscript/warnings/directory_rules)\")\n\t\telse:\n\t\t\tprinterr(\"GdUnit4 is not 'inferred_declaration' save, you have to excluded addons (debug/gdscript/warnings/exclude_addons)\")\n\t\tprinterr(\"Loading GdUnit4 Plugin failed.\")\n\t\treturn\n\n\tif check_running_in_test_env():\n\t\t@warning_ignore(\"return_value_discarded\")\n\t\tGdUnitCSIMessageWriter.new().prints_warning(\"It was recognized that GdUnit4 is running in a test environment, therefore the GdUnit4 plugin will not be executed!\")\n\t\treturn\n", "output": "\tif Engine.get_version_info().hex < 0x40500:\n\t\tprints(\"This GdUnit4 plugin version '%s' requires Godot version '4.5' or higher to run.\" % GdUnit4Version.current())\n\t\treturn\n\tGdUnitSettings.setup()\n\t# Install the GdUnit Inspector\n\t_gd_inspector = (load(\"res://addons/gdUnit4/src/ui/GdUnitInspector.tscn\") as PackedScene).instantiate()\n\t_add_context_menus()\n\tadd_control_to_dock(EditorPlugin.DOCK_SLOT_LEFT_UR, _gd_inspector)\n\t# Install the GdUnit Console\n\t_gd_console = (load(\"res://addons/gdUnit4/src/ui/GdUnitConsole.tscn\") as PackedScene).instantiate()\n\tvar control: Control = add_control_to_bottom_panel(_gd_console, \"gdUnitConsole\")\n\t@warning_ignore(\"unsafe_method_access\")\n\tawait _gd_console.setup_update_notification(control)\n\tif GdUnit4CSharpApiLoader.is_api_loaded():\n\t\tprints(\"GdUnit4Net version '%s' loaded.\" % GdUnit4CSharpApiLoader.version())\n\telse:\n\t\tprints(\"No GdUnit4Net found.\")\n\t# Connect to be notified for script changes to be able to discover new tests\n\tGdUnitTestDiscoverGuard.instance()\n\t@warning_ignore(\"return_value_discarded\")\n\tresource_saved.connect(_on_resource_saved)\n\tprints(\"Loading GdUnit4 Plugin success\")\n\nfunc _exit_tree() -> void:\n\tif check_running_in_test_env():\n\t\treturn\n\tif is_instance_valid(_gd_inspector):\n\t\tremove_control_from_docks(_gd_inspector)\n\t\t_gd_inspector.free()\n\t_remove_context_menus()\n\tif is_instance_valid(_gd_console):\n\t\tremove_control_from_bottom_panel(_gd_console)\n\t\t_gd_console.free()\n\tvar gdUnitTools: GDScript = load(\"res://addons/gdUnit4/src/core/GdUnitTools.gd\")\n\t@warning_ignore(\"unsafe_method_access\")\n\tgdUnitTools.dispose_all(true)\n\tprints(\"Unload GdUnit4 Plugin success\")\n\nfunc check_running_in_test_env() -> bool:\n\tvar args: PackedStringArray = OS.get_cmdline_args()\n\targs.append_array(OS.get_cmdline_user_args())\n\treturn DisplayServer.get_name() == \"headless\" or args.has(\"--selftest\") or args.has(\"--add\") or args.has(\"-a\") or args.has(\"--quit-after\") or args.has(\"--import\")\n\nfunc _add_context_menus() -> void:\n\t_filesystem_context_menu = preload(\"res://addons/gdUnit4/src/ui/menu/GdUnitEditorFileSystemContextMenuHandler.gd\").new()\n\t_editor_context_menu = preload(\"res://addons/gdUnit4/src/ui/menu/GdUnitScriptEditorContextMenuHandler.gd\").new()\n\t_editor_code_context_menu = preload(\"res://addons/gdUnit4/src/ui/menu/GdUnitScriptEditorContextMenuHandler.gd\").new()"} {"instruction": "Vervollständige den GDScript-Code:", "input": "#*\n#* attack_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\n## Attack state: Perform 3-part combo attack for as long as player hits attack button.\n\n@export var animation_player: AnimationPlayer\n@export var animations: Array[StringName]\n@export var hitbox: Hitbox\n\n## Cooldown duration after third attack in the combo is complete.\n@export var combo_cooldown: float = 0.1", "output": "\nvar anim_index: int = 0\nvar last_attack_msec: int = -10000\nvar _can_enter: bool = true\n\n## This func is used to prevent entering this state using LimboState.set_guard().\n## Entry is denied for a short duration after the third attack in the combo is complete.\nfunc can_enter() -> bool:\n\treturn _can_enter\n\nfunc _enter() -> void:\n\tif (Time.get_ticks_msec() - last_attack_msec) < 200:\n\t\t# Perform next attack animation in the 3-part combo, if an attack was recently performed.\n\t\tanim_index = (anim_index + 1) % 3\n\telse:\n\t\tanim_index = 0\n\n\tvar horizontal_move: float = Input.get_axis(&\"move_left\", &\"move_right\")\n\tif not is_zero_approx(horizontal_move):\n\t\tagent.face_dir(horizontal_move)\n\n\thitbox.damage = 2 if anim_index == 2 else 1 # deal 2 damage on a third attack in the combo\n\tanimation_player.play(animations[anim_index])\n\n\tawait animation_player.animation_finished\n\tif is_active():\n\t\tget_root().dispatch(EVENT_FINISHED)\n\nfunc _exit() -> void:\n\thitbox.damage = 1\n\tlast_attack_msec = Time.get_ticks_msec()\n\tif anim_index == 2 and _can_enter:\n\t\t# Prevent entering this state for a short duration after the third attack\n\t\t# in the combo sequence is complete.\n\t\t_can_enter = false\n\t\tawait get_tree().create_timer(combo_cooldown).timeout\n\t\t_can_enter = true\n"} {"instruction": "Erstelle eine GDScript-Funktion namens '_unhandled_input':", "input": "", "output": "func _unhandled_input(event: InputEvent) -> void:\n\tstate.unhandled_input(event)\n\nfunc _physics_process(delta: float) -> void:\n\tstate.physics_process(delta)\n\nfunc transition_to(target_state_path: String, msg: Dictionary = {}"} {"instruction": "Vervollständige den GDScript-Code:", "input": "#*\n#* ninja_star.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\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 ninja_star: Sprite2D = $Root/NinjaStar\n@onready var death: GPUParticles2D = $Death\n@onready var collision_shape_2d: CollisionShape2D = $Hitbox/CollisionShape2D\n@onready var root: Node2D = $Root\n\nfunc _ready() -> void:\n\tvar tween := create_tween().set_loops()\n\ttween.tween_property(ninja_star, ^\"rotation\", TAU * 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(ninja_star, \"position:y\", -10.0, 0.5).as_relative().set_ease(Tween.EASE_OUT)\n\ttween2.tween_property(ninja_star, \"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\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 '_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] = {}"} {"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": "class_name GdUnitAwaiter\nextends RefCounted\n\n\n# Waits for a specified signal in an interval of 50ms sent from the , and terminates with an error after the specified timeout has elapsed.\n# source: the object from which the signal is emitted\n# signal_name: signal name\n# args: the expected signal arguments as an array\n# timeout: the timeout in ms, default is set to 2000ms\nfunc await_signal_on(source :Object, signal_name :String, args :Array = [], timeout_millis :int = 2000) -> Variant:\n\t# fail fast if the given source instance invalid\n\tvar assert_that := GdUnitAssertImpl.new(signal_name)\n\tvar line_number := GdUnitAssertions.get_line_number()\n\tif not is_instance_valid(source):\n\t\t@warning_ignore(\"return_value_discarded\")\n\t\tassert_that.report_error(GdAssertMessages.error_await_signal_on_invalid_instance(source, signal_name, args), line_number)\n\t\treturn await (Engine.get_main_loop() as SceneTree).process_frame\n\t# fail fast if the given source instance invalid\n\tif not is_instance_valid(source):\n\t\t@warning_ignore(\"return_value_discarded\")\n\t\tassert_that.report_error(GdAssertMessages.error_await_signal_on_invalid_instance(source, signal_name, args), line_number)\n\t\treturn await await_idle_frame()\n\tvar awaiter := GdUnitSignalAwaiter.new(timeout_millis)\n\tvar value :Variant = await awaiter.on_signal(source, signal_name, args)", "output": "\tif awaiter.is_interrupted():\n\t\tvar failure := \"await_signal_on(%s, %s) timed out after %sms\" % [signal_name, args, timeout_millis]\n\t\t@warning_ignore(\"return_value_discarded\")\n\t\tassert_that.report_error(failure, line_number)\n\treturn value\n\n# Waits for a specified signal sent from the between idle frames and aborts with an error after the specified timeout has elapsed\n# source: the object from which the signal is emitted\n# signal_name: signal name\n# args: the expected signal arguments as an array\n# timeout: the timeout in ms, default is set to 2000ms\nfunc await_signal_idle_frames(source :Object, signal_name :String, args :Array = [], timeout_millis :int = 2000) -> Variant:\n\tvar line_number := GdUnitAssertions.get_line_number()\n\t# fail fast if the given source instance invalid\n\tif not is_instance_valid(source):\n\t\t@warning_ignore(\"return_value_discarded\")\n\t\tGdUnitAssertImpl.new(signal_name)\\\n\t\t\t.report_error(GdAssertMessages.error_await_signal_on_invalid_instance(source, signal_name, args), line_number)\n\t\treturn await await_idle_frame()\n\tvar awaiter := GdUnitSignalAwaiter.new(timeout_millis, true)\n\tvar value :Variant = await awaiter.on_signal(source, signal_name, args)\n\tif awaiter.is_interrupted():\n\t\tvar failure := \"await_signal_idle_frames(%s, %s) timed out after %sms\" % [signal_name, args, timeout_millis]\n\t\t@warning_ignore(\"return_value_discarded\")\n\t\tGdUnitAssertImpl.new(signal_name).report_error(failure, line_number)\n\treturn value\n\n# Waits for for a given amount of milliseconds\n# example:\n# # waits for 100ms\n# await GdUnitAwaiter.await_millis(myNode, 100).completed\n# use this waiter and not `await get_tree().create_timer().timeout to prevent errors when a test case is timed out\nfunc await_millis(milliSec :int) -> void:\n\tvar timer :Timer = Timer.new()\n\ttimer.set_name(\"gdunit_await_millis_timer_%d\" % timer.get_instance_id())\n\t(Engine.get_main_loop() as SceneTree).root.add_child(timer)\n\ttimer.add_to_group(\"GdUnitTimers\")\n\ttimer.set_one_shot(true)\n\ttimer.start(milliSec / 1000.0)\n\tawait timer.timeout\n\ttimer.queue_free()\n\n# Waits until the next idle frame\nfunc await_idle_frame() -> void:\n\tawait (Engine.get_main_loop() as SceneTree).process_frame\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "@tool\n## Defines the properties of the playable game map.\nclass_name GameboardProperties extends Resource\n\n## Emitted whenever [member cell_size] changes.\nsignal cell_size_changed\n## Emitted whenever [member extents] changes.\nsignal extents_changed\n\n## An invalid index is not found on the gameboard. Note that this requires positive \n## [member extents].\nconst INVALID_INDEX: = -1\n", "output": "## The extents of the playable area. This property is intended for editor use and should not change\n## during gameplay, as that would change how [Pathfinder] indices are calculated.\n@export var extents: = Rect2i(0, 0, 10, 10):\n\tset(value):\n\t\textents = value\n\n\t\t# Ensure that the boundary size is greater than 0.\n\t\textents.size.x = maxi(extents.size.x, 1)\n\t\textents.size.y = maxi(extents.size.y, 1)\n\t\textents_changed.emit()\n\n## The size of each grid cell. Usually analogous to a [member TileSet.tile_size] of a\n## [GameboardLayer].\n@export var cell_size: = Vector2i(16, 16):\n\tset(value):\n\t\tcell_size = value\n\t\thalf_cell_size = cell_size/2.0\n\t\tcell_size_changed.emit()\n\nvar half_cell_size: = cell_size / 2.0\n\nfunc _to_string() -> String:\n\treturn \"\\n[GameboardProperties resource\" + \\\n\t\t\"\\nCell size: \" + str(cell_size) + \\\n\t\t\"\\nBoard extents: \" + str(extents) + \"]\"\n"} {"instruction": "Erstelle eine Godot-Klasse 'GSAIFlee' die von GSAISeek erbt mit folgenden Funktionen: _init, _calculate_steering", "input": "", "output": "# Calculates acceleration to take an agent directly away from a target agent.\n# @category - Individual behaviors\nclass_name GSAIFlee\nextends GSAISeek\n\nfunc _init(agent: GSAISteeringAgent, target: GSAIAgentLocation) -> void:\n\tsuper._init(agent, target)\n\nfunc _calculate_steering(acceleration: GSAITargetAcceleration) -> void:\n\tacceleration.linear = (\n\t\t(agent.position - target.position).normalized()\n\t\t* agent.linear_acceleration_max\n\t)\n\tacceleration.angular = 0\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "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", "output": "@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": "# Calculates acceleration to take an agent to its target's location. The\n# calculation attempts to arrive with zero remaining velocity.\n# @category - Individual behaviors\nclass_name GSAIArrive\nextends GSAISteeringBehavior\n\n# Target agent to arrive to.\nvar target: GSAIAgentLocation\n# Distance from the target for the agent to be considered successfully\n# arrived.\nvar arrival_tolerance: float\n# Distance from the target for the agent to begin slowing down.\nvar deceleration_radius: float\n# Represents the time it takes to change acceleration.\nvar time_to_reach := 0.1", "output": "\nfunc _init(agent: GSAISteeringAgent, _target: GSAIAgentLocation) -> void:\n\tsuper._init(agent)\n\tself.target = _target\n\nfunc _arrive(acceleration: GSAITargetAcceleration, target_position: Vector3) -> void:\n\tvar to_target := target_position - agent.position\n\tvar distance := to_target.length()\n\n\tif distance <= arrival_tolerance:\n\t\tacceleration.set_zero()\n\telse:\n\t\tvar desired_speed := agent.linear_speed_max\n\n\t\tif distance <= deceleration_radius:\n\t\t\tdesired_speed *= distance / deceleration_radius\n\n\t\tvar desired_velocity := to_target * desired_speed / distance\n\n\t\tdesired_velocity = ((desired_velocity - agent.linear_velocity) * 1.0 / time_to_reach)\n\n\t\tacceleration.linear = GSAIUtils.clampedv3(desired_velocity, agent.linear_acceleration_max)\n\t\tacceleration.angular = 0\n\nfunc _calculate_steering(acceleration: GSAITargetAcceleration) -> void:\n\t_arrive(acceleration, target.position)\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "extends Node3D\n\n@onready var viewport: Viewport = get_viewport()\n@onready var environment: Environment = $WorldEnvironment.environment\n@onready var fade_message : FadeMessage3D = $XROrigin3D/FadeMessage3D\n\nvar passthrough_enabled: bool = false\n\n## Switch to AR (passthrough)\nfunc switch_to_ar() -> bool:\n\tvar xr_interface: OpenXRInterface = $StartVR.get_xr_interface()\n\tif not xr_interface:\n\t\treturn false\n\n\tvar modes = xr_interface.get_supported_environment_blend_modes()\n\tif XRInterface.XR_ENV_BLEND_MODE_ALPHA_BLEND in modes:\n\t\txr_interface.environment_blend_mode = XRInterface.XR_ENV_BLEND_MODE_ALPHA_BLEND\n\telif XRInterface.XR_ENV_BLEND_MODE_ADDITIVE in modes:\n\t\txr_interface.environment_blend_mode = XRInterface.XR_ENV_BLEND_MODE_ADDITIVE\n\telse:\n\t\tpush_error(\"Passthrough not supported!\")", "output": "\t\tfade_message.text = \"Passthrough is not supported on this device\"\n\t\treturn false\n\n\tviewport.transparent_bg = true\n\tenvironment.background_mode = Environment.BG_COLOR\n\tenvironment.background_color = Color(0.0, 0.0, 0.0, 0.0)\n\treturn true\n\n## Switch to VR (exit passthrough)\nfunc switch_to_vr() -> bool:\n\tvar xr_interface: OpenXRInterface = $StartVR.get_xr_interface()\n\tif not xr_interface:\n\t\treturn false\n\n\tvar modes = xr_interface.get_supported_environment_blend_modes()\n\tif XRInterface.XR_ENV_BLEND_MODE_OPAQUE in modes:\n\t\txr_interface.environment_blend_mode = XRInterface.XR_ENV_BLEND_MODE_OPAQUE\n\telse:\n\t\tpush_error(\"Opaque not supported!\")\n\t\tfade_message.text = \"Opaque mode is not supported on this device\"\n\t\treturn false\n\n\tviewport.transparent_bg = false\n\tenvironment.background_mode = Environment.BG_SKY\n\treturn true\n\n# Called when our OpenXR session has started.\nfunc _on_start_vr_session_started():\n\t# Make sure we're in passthrough mode.\n\tpassthrough_enabled = switch_to_ar()\n\n# Called when a button is pressed on either controller.\nfunc _on_button_released(action_name):\n\tif action_name == \"ax_button\":\n\t\t# Toggle passthrough\n\t\tif passthrough_enabled:\n\t\t\tswitch_to_vr()\n\t\t\tpassthrough_enabled = false\n\t\telse:\n\t\t\tpassthrough_enabled = switch_to_ar()\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "#*\n#* health.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#*\nclass_name Health\nextends Node\n## Tracks health and emits signal when damaged or dead.\n\n## Emitted when health is reduced to 0.", "output": "signal death\n\n## Emitted when health is damaged.\nsignal damaged(amount: float, knockback: Vector2)\n\n## Initial health value.\n@export var max_health: float = 10.0\n\nvar _current: float\n\nfunc _ready() -> void:\n\t_current = max_health\n\nfunc take_damage(amount: float, knockback: Vector2) -> void:\n\tif _current <= 0.0:\n\t\treturn\n\n\t_current -= amount\n\t_current = max(_current, 0.0)\n\n\tif _current <= 0.0:\n\t\tdeath.emit()\n\telse:\n\t\tdamaged.emit(amount, knockback)\n\n## Returns current health.\nfunc get_current() -> float:\n\treturn _current\n"} {"instruction": "Erstelle eine Godot-Klasse 'CallBackValueProvider' die von ValueProvider erbt mit folgenden Funktionen: _init, get_value, dispose", "input": "", "output": "# a value provider unsing a callback to get `next` value from a certain function\nclass_name CallBackValueProvider\nextends ValueProvider\n\nvar _cb :Callable\nvar _args :Array\n\nfunc _init(instance :Object, func_name :String, args :Array = Array(), force_error := true) -> void:\n\t_cb = Callable(instance, func_name);\n\t_args = args\n\tif force_error and not _cb.is_valid():\n\t\tpush_error(\"Can't find function '%s' checked instance %s\" % [func_name, instance])\n\nfunc get_value() -> Variant:\n\tif not _cb.is_valid():\n\t\treturn null\n\tif _args.is_empty():\n\t\treturn await _cb.call()\n\treturn await _cb.callv(_args)\n\nfunc dispose() -> void:\n\t_cb = Callable()\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "@tool\nextends Node3D\n\n@export_range(0, 1, 0.1) var fade := 0.0:\n\tset(value):\n\t\tfade = value\n\t\tif is_inside_tree():\n\t\t\t_update_fade()", "output": "\nvar material: ShaderMaterial\n\nfunc _update_fade() -> void:\n\tif fade == 0.0:\n\t\t$MeshInstance3D.visible = false\n\telse:\n\t\tif material:\n\t\t\tmaterial.set_shader_parameter(&\"albedo\", Color(0.0, 0.0, 0.0, fade))\n\t\t$MeshInstance3D.visible = true\n\nfunc _ready() -> void:\n\tmaterial = $MeshInstance3D.material_override\n\t_update_fade()\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "extends GdUnitFloatAssert\n\nvar _base: GdUnitAssertImpl\n\n\nfunc _init(current :Variant) -> void:\n\t_base = GdUnitAssertImpl.new(current)\n\t# save the actual assert instance on the current thread context\n\tGdUnitThreadManager.get_current_context().set_assert(self)\n\tif not GdUnitAssertions.validate_value_type(current, TYPE_FLOAT):\n\t\t@warning_ignore(\"return_value_discarded\")\n\t\treport_error(\"GdUnitFloatAssert inital error, unexpected type <%s>\" % GdObjects.typeof_as_string(current))\n\n\nfunc _notification(event :int) -> void:\n\tif event == NOTIFICATION_PREDELETE:\n\t\tif _base != null:\n\t\t\t_base.notification(event)\n\t\t\t_base = null\n\n\nfunc current_value() -> Variant:\n\treturn _base.current_value()\n\n\nfunc report_success() -> GdUnitFloatAssert:\n\t@warning_ignore(\"return_value_discarded\")\n\t_base.report_success()\n\treturn self\n\n\nfunc report_error(error :String) -> GdUnitFloatAssert:\n\t@warning_ignore(\"return_value_discarded\")\n\t_base.report_error(error)\n\treturn self\n\n\nfunc failure_message() -> String:\n\treturn _base.failure_message()\n\n\nfunc override_failure_message(message: String) -> GdUnitFloatAssert:\n\t@warning_ignore(\"return_value_discarded\")\n\t_base.override_failure_message(message)\n\treturn self\n\n\nfunc append_failure_message(message: String) -> GdUnitFloatAssert:\n\t@warning_ignore(\"return_value_discarded\")\n\t_base.append_failure_message(message)\n\treturn self\n\n", "output": "func is_null() -> GdUnitFloatAssert:\n\t@warning_ignore(\"return_value_discarded\")\n\t_base.is_null()\n\treturn self\n\nfunc is_not_null() -> GdUnitFloatAssert:\n\t@warning_ignore(\"return_value_discarded\")\n\t_base.is_not_null()\n\treturn self\n\nfunc is_equal(expected: Variant) -> GdUnitFloatAssert:\n\t@warning_ignore(\"return_value_discarded\")\n\t_base.is_equal(expected)\n\treturn self\n\nfunc is_not_equal(expected: Variant) -> GdUnitFloatAssert:\n\t@warning_ignore(\"return_value_discarded\")\n\t_base.is_not_equal(expected)\n\treturn self\n\n@warning_ignore(\"shadowed_global_identifier\")\nfunc is_equal_approx(expected :float, approx :float) -> GdUnitFloatAssert:\n\treturn is_between(expected-approx, expected+approx)\n\nfunc is_less(expected :float) -> GdUnitFloatAssert:\n\tvar current :Variant = current_value()\n\tif current == null or current >= expected:\n\t\treturn report_error(GdAssertMessages.error_is_value(Comparator.LESS_THAN, current, expected))\n\treturn report_success()\n\nfunc is_less_equal(expected :float) -> GdUnitFloatAssert:\n\tvar current :Variant = current_value()\n\tif current == null or current > expected:\n\t\treturn report_error(GdAssertMessages.error_is_value(Comparator.LESS_EQUAL, current, expected))\n\treturn report_success()\n\nfunc is_greater(expected :float) -> GdUnitFloatAssert:\n\tvar current :Variant = current_value()\n\tif current == null or current <= expected:\n\t\treturn report_error(GdAssertMessages.error_is_value(Comparator.GREATER_THAN, current, expected))\n\treturn report_success()\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "class_name GdAssertMessages\nextends Resource\n\nconst WARN_COLOR = \"#EFF883\"\nconst ERROR_COLOR = \"#CD5C5C\"\nconst VALUE_COLOR = \"#1E90FF\"\nconst SUB_COLOR := Color(1, 0, 0, .15)\nconst ADD_COLOR := Color(0, 1, 0, .15)\n\n\n# Dictionary of control characters and their readable representations\nconst CONTROL_CHARS = {\n\t\"\\n\": \"\", # Line Feed\n\t\"\\r\": \"\", # Carriage Return\n\t\"\\t\": \"\", # Tab\n\t\"\\b\": \"\", # Backspace\n\t\"\\f\": \"\", # Form Feed\n\t\"\\v\": \"\", # Vertical Tab\n\t\"\\a\": \"\", # Bell\n\t\"\u001b\": \"\" # Escape\n}\n\n\nstatic func format_dict(value :Variant) -> String:\n\tif not value is Dictionary:\n\t\treturn str(value)\n\n\tvar dict_value: Dictionary = value\n\tif dict_value.is_empty():\n\t\treturn \"{ }\"\n\tvar as_rows := var_to_str(value).split(\"\\n\")\n\tfor index in range( 1, as_rows.size()-1):\n\t\tas_rows[index] = \"\t\" + as_rows[index]\n\tas_rows[-1] = \" \" + as_rows[-1]\n\treturn \"\\n\".join(as_rows)\n\n\n# improved version of InputEvent as text\nstatic func input_event_as_text(event :InputEvent) -> String:\n\tvar text := \"\"\n\tif event is InputEventKey:\n\t\tvar key_event := event as InputEventKey\n\t\ttext += \"\"\"\n\t\t\tInputEventKey : keycode=%s (%s) pressed: %s\n\t\t\t\tphysical_keycode: %s\n\t\t\t\tlocation: %s\n\t\t\t\techo: %s\"\"\" % [\n\t\t\t\t\tkey_event.keycode,\n\t\t\t\t\tkey_event.as_text_keycode(),\n\t\t\t\t\tkey_event.pressed,\n\t\t\t\t\tkey_event.physical_keycode,\n\t\t\t\t\tkey_event.location,\n\t\t\t\t\tkey_event.echo]\n\telse:\n\t\ttext += event.as_text()\n\tif event is InputEventMouse:\n\t\tvar mouse_event := event as InputEventMouse\n\t\ttext += \"\"\"\n\t\t\t\tglobal_position: %s\"\"\" % mouse_event.global_position\n\tif event is InputEventWithModifiers:\n\t\tvar mouse_event := event as InputEventWithModifiers\n\t\ttext += \"\"\"\n\t\t\t\t--------\n\t\t\t\tmods: %s\n\t\t\t\tshift: %s\n\t\t\t\talt: %s\n\t\t\t\tcontrol: %s\n\t\t\t\tmeta: %s\n\t\t\t\tcommand: %s\"\"\" % [\n\t\t\t\t\tmouse_event.get_modifiers_mask(),\n\t\t\t\t\tmouse_event.shift_pressed,\n\t\t\t\t\tmouse_event.alt_pressed,\n\t\t\t\t\tmouse_event.ctrl_pressed,\n\t\t\t\t\tmouse_event.meta_pressed,\n\t\t\t\t\tmouse_event.command_or_control_autoremap]\n\treturn text.dedent()\n\n\nstatic func _colored_string_div(characters: String) -> String:\n\treturn colored_array_div(characters.to_utf32_buffer().to_int32_array())\n\n\nstatic func colored_array_div(characters: PackedInt32Array) -> String:\n\tif characters.is_empty():\n\t\treturn \"\"\n\tvar result := PackedInt32Array()\n\tvar index := 0\n\tvar missing_chars := PackedInt32Array()\n\tvar additional_chars := PackedInt32Array()\n\n\twhile index < characters.size():\n\t\tvar character := characters[index]\n\t\tmatch character:\n\t\t\tGdDiffTool.DIV_ADD:\n\t\t\t\tindex += 1\n\t\t\t\t@warning_ignore(\"return_value_discarded\")\n\t\t\t\tadditional_chars.append(characters[index])\n\t\t\tGdDiffTool.DIV_SUB:\n\t\t\t\tindex += 1\n\t\t\t\t@warning_ignore(\"return_value_discarded\")\n\t\t\t\tmissing_chars.append(characters[index])\n\t\t\t_:\n\t\t\t\tif not missing_chars.is_empty():\n\t\t\t\t\tresult.append_array(format_chars(missing_chars, SUB_COLOR))\n\t\t\t\t\tmissing_chars = PackedInt32Array()\n\t\t\t\tif not additional_chars.is_empty():\n\t\t\t\t\tresult.append_array(format_chars(additional_chars, ADD_COLOR))\n\t\t\t\t\tadditional_chars = PackedInt32Array()\n\t\t\t\t@warning_ignore(\"return_value_discarded\")\n\t\t\t\tresult.append(character)\n\t\tindex += 1\n\n\tresult.append_array(format_chars(missing_chars, SUB_COLOR))\n\tresult.append_array(format_chars(additional_chars, ADD_COLOR))\n\treturn result.to_byte_array().get_string_from_utf32()\n\n\nstatic func _typed_value(value :Variant) -> String:\n\treturn GdDefaultValueDecoder.decode(value)\n\n\nstatic func _warning(error :String) -> String:\n\treturn \"[color=%s]%s[/color]\" % [WARN_COLOR, error]\n\n\nstatic func _error(error :String) -> String:\n\treturn \"[color=%s]%s[/color]\" % [ERROR_COLOR, error]\n\n\nstatic func _nerror(number :Variant) -> String:\n\tmatch typeof(number):\n\t\tTYPE_INT:\n\t\t\treturn \"[color=%s]%d[/color]\" % [ERROR_COLOR, number]\n\t\tTYPE_FLOAT:\n\t\t\treturn \"[color=%s]%f[/color]\" % [ERROR_COLOR, number]\n\t\t_:\n\t\t\treturn \"[color=%s]%s[/color]\" % [ERROR_COLOR, str(number)]\n\n\nstatic func _colored(value: Variant, color: Color) -> String:\n\treturn \"[color=%s]%s[/color]\" % [color.to_html(), value]\n\n\nstatic func _colored_value(value :Variant) -> String:\n\tmatch typeof(value):\n\t\tTYPE_STRING, TYPE_STRING_NAME:\n\t\t\treturn \"'[color=%s]%s[/color]'\" % [VALUE_COLOR, _colored_string_div(str(value))]\n\t\tTYPE_INT:\n\t\t\treturn \"'[color=%s]%d[/color]'\" % [VALUE_COLOR, value]\n\t\tTYPE_FLOAT:\n\t\t\treturn \"'[color=%s]%s[/color]'\" % [VALUE_COLOR, _typed_value(value)]\n\t\tTYPE_COLOR:\n\t\t\treturn \"'[color=%s]%s[/color]'\" % [VALUE_COLOR, _typed_value(value)]\n\t\tTYPE_OBJECT:\n\t\t\tif value == null:\n\t\t\t\treturn \"'[color=%s][/color]'\" % [VALUE_COLOR]\n\t\t\tif value is InputEvent:\n\t\t\t\tvar ie: InputEvent = value\n\t\t\t\treturn \"[color=%s]<%s>[/color]\" % [VALUE_COLOR, input_event_as_text(ie)]\n\t\t\tvar obj_value: Object = value\n\t\t\tif obj_value.has_method(\"_to_string\"):\n\t\t\t\treturn \"[color=%s]<%s>[/color]\" % [VALUE_COLOR, str(value)]\n\t\t\treturn \"[color=%s]<%s>[/color]\" % [VALUE_COLOR, obj_value.get_class()]\n\t\tTYPE_DICTIONARY:\n\t\t\treturn \"'[color=%s]%s[/color]'\" % [VALUE_COLOR, format_dict(value)]\n\t\t_:\n\t\t\tif GdArrayTools.is_array_type(value):\n\t\t\t\treturn \"'[color=%s]%s[/color]'\" % [VALUE_COLOR, _typed_value(value)]\n\t\t\treturn \"'[color=%s]%s[/color]'\" % [VALUE_COLOR, value]\n\n\n\nstatic func _index_report_as_table(index_reports :Array) -> String:\n\tvar table := \"[table=3]$cells[/table]\"\n\tvar header := \"[cell][right][b]$text[/b][/right]\\t[/cell]\"\n\tvar cell := \"[cell][right]$text[/right]\\t[/cell]\"\n\tvar cells := header.replace(\"$text\", \"Index\") + header.replace(\"$text\", \"Current\") + header.replace(\"$text\", \"Expected\")\n\tfor report :Variant in index_reports:\n\t\tvar index :String = str(report[\"index\"])\n\t\tvar current :String = str(report[\"current\"])\n\t\tvar expected :String = str(report[\"expected\"])\n\t\tcells += cell.replace(\"$text\", index) + cell.replace(\"$text\", current) + cell.replace(\"$text\", expected)\n\treturn table.replace(\"$cells\", cells)\n\n\n\nstatic func orphan_warning(orphans_count: int) -> String:\n\treturn \"\"\"\n\t\t%s: Found %s possible orphan nodes.\n\t\t\tAdd %s to the end of the test to collect details.\"\"\".dedent().trim_prefix(\"\\n\") % [\n\t\t_warning(\"WARNING:\"),\n\t\t_nerror(orphans_count),\n\t\t_colored_value(\"collect_orphan_node_details()\")\n\t]\n\nstatic func orphan_detected_on_suite_setup(orphans: Array[GdUnitOrphanNodeInfo]) -> String:\n\treturn \"\"\"\n\t\t%s Detected %s orphan nodes!\n\t\t\t[b]Verify your test suite setup.[/b]\n\t\t%s\"\"\".dedent().trim_prefix(\"\\n\") % [\n\t\t_warning(\"WARNING:\"),\n\t\t_nerror(orphans.size()),\n\t\t_build_orphan_node_stacktrace(orphans)]\n\n\nstatic func orphan_detected_on_test_setup(orphans: Array[GdUnitOrphanNodeInfo]) -> String:\n\treturn \"\"\"\n\t\t\t%s Detected %s orphan nodes on test setup!\n\t\t\t\t[b]Check before_test() and after_test()![/b]\n\t\t\t%s\"\"\".dedent().trim_prefix(\"\\n\") % [\n\t\t\t\t_warning(\"WARNING:\"),\n\t\t\t\t_nerror(orphans.size()),\n\t\t\t\t_build_orphan_node_stacktrace(orphans)\n\t\t\t]\n\n\nstatic func orphan_detected_on_test(orphans: Array[GdUnitOrphanNodeInfo]) -> String:\n\treturn \"\"\"\n\t\t%s Detected %s orphan nodes!\n\t\t%s\"\"\".dedent().trim_prefix(\"\\n\") % [\n\t\t\t_warning(\"WARNING:\"),\n\t\t\t_nerror(orphans.size()),\n\t\t\t_build_orphan_node_stacktrace(orphans)\n\t\t]\n\n\nstatic func _build_orphan_node_stacktrace(orphans: Array[GdUnitOrphanNodeInfo]) -> String:\n\tvar stack_trace := \"\\n\"\n\tfor orphan in orphans:\n\t\tstack_trace += orphan.as_trace(orphan, true) + \"\\n\"\n\treturn stack_trace.indent(\" \")\n\n\n\nstatic func fuzzer_interuped(iterations: int, error: String) -> String:\n\treturn \"%s %s %s\\n %s\" % [\n\t\t_error(\"Found an error after\"),\n\t\t_colored_value(iterations + 1),\n\t\t_error(\"test iterations\"),\n\t\terror]\n\n\nstatic func test_timeout(timeout :int) -> String:\n\treturn \"%s\\n %s\" % [_error(\"Timeout !\"), _colored_value(\"Test timed out after %s\" % LocalTime.elapsed(timeout))]\n\n\nstatic func test_session_terminated() -> String:\n\treturn \"%s\" % _error(\"Test Session Terminated\")\n\n\n# gdlint:disable = mixed-tabs-and-spaces", "output": "static func test_suite_skipped(hint :String, skip_count :int) -> String:\n\treturn \"\"\"\n\t\t%s\n\t\t Skipped %s tests\n\t\t Reason: %s\n\t\t\"\"\".dedent().trim_prefix(\"\\n\")\\\n\t\t% [_error(\"The Entire test-suite is skipped!\"), _colored_value(skip_count), _colored_value(hint)]\n\nstatic func test_skipped(hint :String) -> String:\n\treturn \"\"\"\n\t\t%s\n\t\t Reason: %s\n\t\t\"\"\".dedent().trim_prefix(\"\\n\")\\\n\t\t% [_error(\"This test is skipped!\"), _colored_value(hint)]\n\nstatic func error_not_implemented() -> String:\n\treturn _error(\"Test not implemented!\")\n\nstatic func error_is_null(current :Variant) -> String:\n\treturn \"%s %s but was %s\" % [_error(\"Expecting:\"), _colored_value(null), _colored_value(current)]\n\nstatic func error_is_not_null() -> String:\n\treturn \"%s %s\" % [_error(\"Expecting: not to be\"), _colored_value(null)]\n\nstatic func error_equal(current :Variant, expected :Variant, index_reports :Array = []) -> String:\n\tvar report := \"\"\"\n\t\t%s\n\t\t %s\n\t\t but was\n\t\t %s\"\"\".dedent().trim_prefix(\"\\n\") % [_error(\"Expecting:\"), _colored_value(expected), _colored_value(current)]\n\tif not index_reports.is_empty():\n\t\treport += \"\\n\\n%s\\n%s\" % [_error(\"Differences found:\"), _index_report_as_table(index_reports)]\n\treturn report\n\nstatic func error_not_equal(current :Variant, expected :Variant) -> String:\n\treturn \"%s\\n %s\\n not equal to\\n %s\" % [_error(\"Expecting:\"), _colored_value(expected), _colored_value(current)]\n\nstatic func error_not_equal_case_insensetiv(current :Variant, expected :Variant) -> String:\n\treturn \"%s\\n %s\\n not equal to (case insensitiv)\\n %s\" % [\n\t\t\t_error(\"Expecting:\"), _colored_value(expected), _colored_value(current)]\n\nstatic func error_is_empty(current :Variant) -> String:"} {"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": "## A utility class converting between Godot angles (+'ve x axis is 0 rads) and cardinal points.\nclass_name Directions\nextends RefCounted\n\n## The cardinal points, in clockwise order starting from North.\nenum Points { NORTH, EAST, SOUTH, WEST }\n\n## The direction corresponding to a cardinal point as a [Vector2i] value. NORTH is Vector2i(0, -1), etc.\nconst MAPPINGS: = {\n\tDirections.Points.NORTH: Vector2i.UP,", "output": "\tDirections.Points.EAST: Vector2i.RIGHT,\n\tDirections.Points.SOUTH: Vector2i.DOWN,\n\tDirections.Points.WEST: Vector2i.LEFT,\n}\n\n## Convert an angle, such as from [method Vector2.angle], to a [constant Points].\nstatic func angle_to_direction(angle: float) -> Points:\n\tif angle <= -PI / 4.0 and angle > -3.0 * PI / 4.0:\n\t\treturn Points.NORTH\n\telif angle <= PI / 4.0 and angle > -PI / 4.0:\n\t\treturn Points.EAST\n\telif angle <= 3.0 * PI / 4.0 and angle > PI / 4.0:\n\t\treturn Points.SOUTH\n\n\treturn Points.WEST\n\nstatic func vector_to_direction(vector: Vector2) -> Points:\n\treturn angle_to_direction(vector.angle())\n"} {"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 = {}", "source": "extracted_function"} {"instruction": "Erstelle eine GDScript-Funktion namens 'cell_to_pixel':", "input": "", "output": "func cell_to_pixel(cell_coordinates: Vector2i) -> Vector2:\n\treturn Vector2(cell_coordinates * properties.cell_size) + properties.half_cell_size\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\nfunc get_cell_under_node(node: Node2D) -> Vector2i:\n\treturn pixel_to_cell(node.global_position/node.global_scale)\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\n\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)\n\t\tvar removed_cells: = _remove_cells_from_pathfinder(blocked_cells)\n\n\t\t_connect_new_pathfinder_cells(added_cells)\n\t\tif not added_cells.is_empty() or not removed_cells.is_empty():\n\t\t\tpathfinder_changed.emit(added_cells.values(), removed_cells)\n\t)\n\n# Add cells to the pathfinder, checking that there are no blocking tiles on any GameboardLayers.\n# Returns a dictionary representing the cells that are actually added to the pathfinder (may differ\n# from cleared_cells). Key = cell id (int, see cell_to_index), value = coordinate (Vector2i)\nfunc _add_cells_to_pathfinder(cleared_cells: Array[Vector2i]) -> Dictionary[int, Vector2i]:\n\tvar added_cells: Dictionary[int, Vector2i] = {}", "source": "extracted_function"} {"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 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 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": "Vervollständige den GDScript-Code:", "input": "# Virtual base class for stats (health, speed...) that support upgrades.\n#\n# You must call `initialize()` to initialize the stats' values. This ensures that they are in sync\n# with the values modified in Godot's inspector.\n#\n# Each stat should be a floating point value, and we recommend to make them private properties, as\n# they should be read-only. To get a stat's calculated value, with modifiers, see `get_stat()`.\nclass_name Stats\nextends Resource\n\nsignal stat_changed(stat, old_value, new_value)\n\n# Stores a cached array of property names that are stats as strings, that we use to find and\n# calculate the stats with upgrades from the base stats.\nvar _stats_list := _get_stats_list()\n# Modifiers has a list of modifiers for each property in `_stats_list`. A modifier is a dict that\n# requires a key named `value`. The value of a modifier can be positive or negative.\nvar _modifiers := {}\n# Stores the cached values for the computed stats\nvar _cache := {}\n\n\n# Initializes the keys in the modifiers dict, ensuring they all exist, without going through the\n# property's setter.\nfunc _init() -> void:\n\tfor stat in _stats_list:\n\t\t_modifiers[stat] = []\n\t\t_cache[stat] = 0.0\n\n\n# Call this function from your node's ready function, before accessing the stats. This ensures\n# they're all loaded.\nfunc initialize() -> void:\n\t_update_all()\n\n", "output": "# Get the final value of a stat, with all modifiers applied to it.\nfunc 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 = {}\n\t_update_all()\n\n# Calculates the final value of a single stat, its based value with all modifiers applied.\nfunc _update(stat: String = \"\") -> void:\n\tvar value_start: float = self.get(_stats_list[stat])\n\tvar value = value_start\n\tfor modifier in _modifiers[stat]:\n\t\tvalue += modifier\n\t_cache[stat] = value\n\tstat_changed.emit(stat, value_start, value)\n\n# Recalculates every stat from the base stat, with modifiers.\nfunc _update_all() -> void:\n\tfor stat in _stats_list:\n\t\t_update(stat)\n"} {"instruction": "Erstelle eine GDScript-Funktion namens '_init':", "input": "", "output": "func _init(current: Variant, type_check := true) -> void:\n\t_type_check = type_check\n\t_current_value_provider = DefaultValueProvider.new(current)\n\t_base = GdUnitAssertImpl.new(current)\n\t# save the actual assert instance on the current thread context\n\tGdUnitThreadManager.get_current_context().set_assert(self)\n\tif not _validate_value_type(current):\n\t\t@warning_ignore(\"return_value_discarded\")\n\t\treport_error(\"GdUnitArrayAssert inital error, unexpected type <%s>\" % GdObjects.typeof_as_string(current))\n\nfunc _notification(event: int) -> void:\n\tif event == NOTIFICATION_PREDELETE:\n\t\tif _base != null:\n\t\t\t_base.notification(event)\n\t\t\t_base = null\n\nfunc report_success() -> GdUnitArrayAssert:\n\t@warning_ignore(\"return_value_discarded\")\n\t_base.report_success()\n\treturn self\n\nfunc report_error(error: String) -> GdUnitArrayAssert:\n\t@warning_ignore(\"return_value_discarded\")\n\t_base.report_error(error)\n\treturn self\n\nfunc failure_message() -> String:\n\treturn _base.failure_message()\n\nfunc override_failure_message(message: String) -> GdUnitArrayAssert:\n\t@warning_ignore(\"return_value_discarded\")\n\t_base.override_failure_message(message)\n\treturn self\n\nfunc append_failure_message(message: String) -> GdUnitArrayAssert:\n\t@warning_ignore(\"return_value_discarded\")\n\t_base.append_failure_message(message)\n\treturn self\n\nfunc _validate_value_type(value: Variant) -> bool:\n\treturn value == null or GdArrayTools.is_array_type(value)\n\nfunc get_current_value() -> Variant:\n\treturn _current_value_provider.get_value()\n\nfunc max_length(left: Variant, right: Variant) -> int:\n\tvar ls := str(left).length()\n\tvar rs := str(right).length()\n\treturn rs if ls < rs else ls\n\n# gdlint: disable=function-name\nfunc _toPackedStringArray(value: Variant) -> PackedStringArray:\n\tif GdArrayTools.is_array_type(value):\n\t\t@warning_ignore(\"unsafe_cast\")\n\t\treturn PackedStringArray(value as Array)\n\treturn PackedStringArray([str(value)])\n\nfunc _array_equals_div(current: Variant, expected: Variant, case_sensitive: bool = false) -> Array:\n\tvar current_value := _toPackedStringArray(current)\n\tvar expected_value := _toPackedStringArray(expected)\n\tvar index_report := Array()\n\tfor index in current_value.size():\n\t\tvar c := current_value[index]\n\t\tif index < expected_value.size():\n\t\t\tvar e := expected_value[index]\n\t\t\tif not GdObjects.equals(c, e, case_sensitive):\n\t\t\t\tvar length := max_length(c, e)\n\t\t\t\tcurrent_value[index] = GdAssertMessages.format_invalid(c.lpad(length))\n\t\t\t\texpected_value[index] = e.lpad(length)\n\t\t\t\tindex_report.push_back({\"index\": index, \"current\": c, \"expected\": e}", "source": "extracted_function"} {"instruction": "Vervollständige den GDScript-Code:", "input": "extends Button\n\n\nfunc _ready() -> void:\n\tpressed.connect(_toggle_fullscreen)\n", "output": "\t# Set scaling properties and base resolution\n\tget_window().mode = Window.MODE_FULLSCREEN\n\tget_window().content_scale_aspect = Window.CONTENT_SCALE_ASPECT_KEEP\n\tget_window().content_scale_mode = Window.CONTENT_SCALE_MODE_CANVAS_ITEMS\n\tget_window().content_scale_size = Vector2i(1920,1080)\n\nfunc _toggle_fullscreen() -> void:\n\tif get_window().mode != Window.MODE_FULLSCREEN:\n\t\tget_window().mode = Window.MODE_FULLSCREEN\n\telse:\n\t\tget_window().mode = Window.MODE_MAXIMIZED\n"} {"instruction": "Erstelle eine Godot-Klasse 'Fuzzers' die von Resource erbt mit folgenden Funktionen: rand_str, boolean, rangei, rangef, rangev2", "input": "", "output": "## 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## 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## 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()\n\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"} {"instruction": "Vervollständige den GDScript-Code:", "input": "## An Assertion Tool to verify boolean values\n@abstract class_name GdUnitBoolAssert\nextends GdUnitAssert\n\n\n## Verifies that the current value is null.\n@abstract func is_null() -> GdUnitBoolAssert\n\n\n## Verifies that the current value is not null.\n@abstract func is_not_null() -> GdUnitBoolAssert\n", "output": "\n## Verifies that the current value is equal to the given one.\n@abstract func is_equal(expected: Variant) -> GdUnitBoolAssert\n\n## Verifies that the current value is not equal to the given one.\n@abstract func is_not_equal(expected: Variant) -> GdUnitBoolAssert\n\n## Overrides the default failure message by given custom message.\n@abstract func override_failure_message(message: String) -> GdUnitBoolAssert\n\n## Appends a custom message to the failure message.\n@abstract func append_failure_message(message: String) -> GdUnitBoolAssert\n\n## Verifies that the current value is true.\n@abstract func is_true() -> GdUnitBoolAssert\n\n## Verifies that the current value is false.\n@abstract func is_false() -> GdUnitBoolAssert\n"} {"instruction": "Erstelle eine GDScript-Funktion namens 'pixel_to_cell':", "input": "", "output": "func 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\nfunc get_cell_under_node(node: Node2D) -> Vector2i:\n\treturn pixel_to_cell(node.global_position/node.global_scale)\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\n\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)\n\t\tvar removed_cells: = _remove_cells_from_pathfinder(blocked_cells)\n\n\t\t_connect_new_pathfinder_cells(added_cells)\n\t\tif not added_cells.is_empty() or not removed_cells.is_empty():\n\t\t\tpathfinder_changed.emit(added_cells.values(), removed_cells)\n\t)\n\n# Add cells to the pathfinder, checking that there are no blocking tiles on any GameboardLayers.\n# Returns a dictionary representing the cells that are actually added to the pathfinder (may differ\n# from cleared_cells). Key = cell id (int, see cell_to_index), value = coordinate (Vector2i)\nfunc _add_cells_to_pathfinder(cleared_cells: Array[Vector2i]) -> Dictionary[int, Vector2i]:\n\tvar added_cells: Dictionary[int, Vector2i] = {}", "source": "extracted_function"} {"instruction": "Erstelle eine Godot-Klasse 'GSAIArrive' die von GSAISteeringBehavior erbt mit folgenden Funktionen: _init, _arrive, _calculate_steering", "input": "", "output": "# Calculates acceleration to take an agent to its target's location. The\n# calculation attempts to arrive with zero remaining velocity.\n# @category - Individual behaviors\nclass_name GSAIArrive\nextends GSAISteeringBehavior\n\n# Target agent to arrive to.\nvar target: GSAIAgentLocation\n# Distance from the target for the agent to be considered successfully\n# arrived.\nvar arrival_tolerance: float\n# Distance from the target for the agent to begin slowing down.\nvar deceleration_radius: float\n# Represents the time it takes to change acceleration.\nvar time_to_reach := 0.1\n\nfunc _init(agent: GSAISteeringAgent, _target: GSAIAgentLocation) -> void:\n\tsuper._init(agent)\n\tself.target = _target\n\nfunc _arrive(acceleration: GSAITargetAcceleration, target_position: Vector3) -> void:\n\tvar to_target := target_position - agent.position\n\tvar distance := to_target.length()\n\n\tif distance <= arrival_tolerance:\n\t\tacceleration.set_zero()\n\telse:\n\t\tvar desired_speed := agent.linear_speed_max\n\n\t\tif distance <= deceleration_radius:\n\t\t\tdesired_speed *= distance / deceleration_radius\n\n\t\tvar desired_velocity := to_target * desired_speed / distance\n\n\t\tdesired_velocity = ((desired_velocity - agent.linear_velocity) * 1.0 / time_to_reach)\n\n\t\tacceleration.linear = GSAIUtils.clampedv3(desired_velocity, agent.linear_acceleration_max)\n\t\tacceleration.angular = 0\n\nfunc _calculate_steering(acceleration: GSAITargetAcceleration) -> void:\n\t_arrive(acceleration, target.position)\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "class_name MusicPlayer extends Node\n\n@onready var _anim: = $AnimationPlayer as AnimationPlayer\n@onready var _track: = $AudioStreamPlayer as AudioStreamPlayer\n\n\nfunc play(new_stream: AudioStream, time_in: = 0.0, time_out: = 0.0) -> void:\n\tif new_stream == _track.stream:\n\t\treturn\n\t\n\tif is_playing():\n\t\tif is_equal_approx(time_out, 0.0):\n\t\t\ttime_out = 0.005\n\t\t\n\t\t_anim.speed_scale = 1.0/time_out\n\t\t_anim.play(\"fade_out\")\n\t\tawait _anim.animation_finished", "output": "\n\t\t_track.stop()\n\n\t_track.stream = new_stream\n\tif is_equal_approx(time_in, 0.0):\n\t\ttime_in = 0.005\n\n\t_track.volume_db = -50.0\n\t_track.play()\n\t_anim.speed_scale = 1.0/time_in\n\t_anim.play(\"fade_in\")\n\tawait _anim.animation_finished\n\n\t_anim.speed_scale = 1.0\n\nfunc stop(time_out: = 0.0) -> void:\n\tif is_equal_approx(time_out, 0.0):\n\t\ttime_out = 0.005\n\n\t_anim.speed_scale = 1.0/time_out\n\t_anim.play(\"fade_out\")\n\tawait _anim.animation_finished\n\n\t_track.stop()\n\t_track.stream = null\n\nfunc is_playing() -> bool:\n\treturn _track.playing\n\nfunc get_playing_track() -> AudioStream:\n\treturn _track.stream\n"} {"instruction": "Erstelle eine GDScript-Funktion namens '_notification':", "input": "", "output": "func _notification(event: int) -> void:\n\tif event == NOTIFICATION_PREDELETE:\n\t\tif _base != null:\n\t\t\t_base.notification(event)\n\t\t\t_base = null\n\nfunc report_success() -> GdUnitArrayAssert:\n\t@warning_ignore(\"return_value_discarded\")\n\t_base.report_success()\n\treturn self\n\nfunc report_error(error: String) -> GdUnitArrayAssert:\n\t@warning_ignore(\"return_value_discarded\")\n\t_base.report_error(error)\n\treturn self\n\nfunc failure_message() -> String:\n\treturn _base.failure_message()\n\nfunc override_failure_message(message: String) -> GdUnitArrayAssert:\n\t@warning_ignore(\"return_value_discarded\")\n\t_base.override_failure_message(message)\n\treturn self\n\nfunc append_failure_message(message: String) -> GdUnitArrayAssert:\n\t@warning_ignore(\"return_value_discarded\")\n\t_base.append_failure_message(message)\n\treturn self\n\nfunc _validate_value_type(value: Variant) -> bool:\n\treturn value == null or GdArrayTools.is_array_type(value)\n\nfunc get_current_value() -> Variant:\n\treturn _current_value_provider.get_value()\n\nfunc max_length(left: Variant, right: Variant) -> int:\n\tvar ls := str(left).length()\n\tvar rs := str(right).length()\n\treturn rs if ls < rs else ls\n\n# gdlint: disable=function-name\nfunc _toPackedStringArray(value: Variant) -> PackedStringArray:\n\tif GdArrayTools.is_array_type(value):\n\t\t@warning_ignore(\"unsafe_cast\")\n\t\treturn PackedStringArray(value as Array)\n\treturn PackedStringArray([str(value)])\n\nfunc _array_equals_div(current: Variant, expected: Variant, case_sensitive: bool = false) -> Array:\n\tvar current_value := _toPackedStringArray(current)\n\tvar expected_value := _toPackedStringArray(expected)\n\tvar index_report := Array()\n\tfor index in current_value.size():\n\t\tvar c := current_value[index]\n\t\tif index < expected_value.size():\n\t\t\tvar e := expected_value[index]\n\t\t\tif not GdObjects.equals(c, e, case_sensitive):\n\t\t\t\tvar length := max_length(c, e)\n\t\t\t\tcurrent_value[index] = GdAssertMessages.format_invalid(c.lpad(length))\n\t\t\t\texpected_value[index] = e.lpad(length)\n\t\t\t\tindex_report.push_back({\"index\": index, \"current\": c, \"expected\": e}", "source": "extracted_function"} {"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": "# Determines any agent that is in the specified list as being neighbors with the owner agent if\n# they lie within the specified radius.\n# @category - Proximities\nclass_name GSAIRadiusProximity\nextends GSAIProximity\n\n# The radius around the owning agent to find neighbors in\nvar radius := 0.0\n\nvar _last_frame := 0\nvar _scene_tree: SceneTree\n\n\nfunc _init(agent: GSAISteeringAgent, agents: Array, _radius: float) -> void:\n\tsuper._init(agent, agents)\n\tself.radius = _radius\n\t_scene_tree = Engine.get_main_loop()\n\n", "output": "# Returns a number of neighbors based on a `callback` function.\n#\n# `_find_neighbors` calls `callback` for each agent in the `agents` array that lie within\n# the radius around the owning agent and adds one to the count if its `callback` returns true.\n# @tags - virtual\nfunc _find_neighbors(callback: Callable) -> int:\n\tvar agent_count := agents.size()\n\tvar neighbor_count := 0\n\n\tvar current_frame := _scene_tree.get_frame() if _scene_tree else -_last_frame\n\tif current_frame != _last_frame:\n\t\t_last_frame = current_frame\n\n\t\tvar owner_position := agent.position\n\n\t\tfor i in range(agent_count):\n\t\t\tvar current_agent := agents[i] as GSAISteeringAgent\n\n\t\t\tif current_agent != agent:\n\t\t\t\tvar distance_squared := owner_position.distance_squared_to(current_agent.position)\n\n\t\t\t\tvar range_to := radius + current_agent.bounding_radius\n\n\t\t\t\tif distance_squared < range_to * range_to:\n\t\t\t\t\tif callback.call(current_agent):\n\t\t\t\t\t\tcurrent_agent.is_tagged = true\n\t\t\t\t\t\tneighbor_count += 1\n\t\t\t\t\t\tcontinue\n\n\t\t\tcurrent_agent.is_tagged = false\n\telse:\n\t\tfor i in range(agent_count):\n\t\t\tvar current_agent = agents[i] as GSAISteeringAgent\n\n\t\t\tif current_agent != agent and current_agent.is_tagged:\n\t\t\t\tif callback.call(current_agent):\n\t\t\t\t\tneighbor_count += 1\n\n\treturn neighbor_count\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "@tool\nextends ActionLeaf\n\n@export var modulate_color:Color = Color.WHITE\n@export var interpolation_time:float = 3.0\n\nvar current_color\nvar tween\n\nfunc tick(actor: Node, _blackboard: Blackboard) -> int:", "output": "\n\tif current_color != modulate_color and actor.modulate != modulate_color:\n\t\tif tween != null:\n\t\t\ttween.stop()\n\t\tcurrent_color = modulate_color\n\t\ttween = create_tween()\\\n\t\t.set_ease(Tween.EASE_IN_OUT)\\\n\t\t.set_trans(Tween.TRANS_CUBIC)\n\t\ttween.tween_property(actor, \"modulate\", current_color, interpolation_time)\\\n\t\t.finished.connect(_finished.bind(actor))\n\n\tif current_color != null:\n\t\treturn RUNNING\n\telse:\n\t\treturn SUCCESS\n\nfunc _finished(actor: Node) -> void:\n\tcurrent_color = null\n\ttween = null\n\tif actor is ColorChangingSprite:\n\t\tactor.color_changed.emit()\n"} {"instruction": "Erstelle eine Godot-Klasse 'PianoKey' die von Control erbt mit folgenden Funktionen: setup, activate, deactivate", "input": "", "output": "class_name PianoKey\nextends Control\n\nvar pitch_scale: float\n\n@onready var key: ColorRect = $Key\n@onready var start_color: Color = key.color\n@onready var color_timer: Timer = $ColorTimer\n\nfunc setup(pitch_index: int) -> void:\n\tname = \"PianoKey\" + str(pitch_index)\n\tvar exponent := (pitch_index - 69.0) / 12.0\n\tpitch_scale = pow(2, exponent)\n\nfunc activate() -> void:\n\tkey.color = (Color.YELLOW + start_color) / 2\n\tvar audio := AudioStreamPlayer.new()\n\tadd_child(audio)\n\taudio.stream = preload(\"res://piano_keys/A440.wav\")\n\taudio.pitch_scale = pitch_scale\n\taudio.play()\n\tcolor_timer.start()\n\tawait get_tree().create_timer(8.0).timeout\n\taudio.queue_free()\n\nfunc deactivate() -> void:\n\tkey.color = start_color\n"} {"instruction": "Erstelle eine GDScript-Funktion namens 'pixel_to_cell':", "input": "", "output": "func 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\nfunc get_cell_under_node(node: Node2D) -> Vector2i:\n\treturn pixel_to_cell(node.global_position/node.global_scale)\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\n\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)\n\t\tvar removed_cells: = _remove_cells_from_pathfinder(blocked_cells)\n\n\t\t_connect_new_pathfinder_cells(added_cells)\n\t\tif not added_cells.is_empty() or not removed_cells.is_empty():\n\t\t\tpathfinder_changed.emit(added_cells.values(), removed_cells)\n\t)\n\n# Add cells to the pathfinder, checking that there are no blocking tiles on any GameboardLayers.\n# Returns a dictionary representing the cells that are actually added to the pathfinder (may differ\n# from cleared_cells). Key = cell id (int, see cell_to_index), value = coordinate (Vector2i)\nfunc _add_cells_to_pathfinder(cleared_cells: Array[Vector2i]) -> Dictionary[int, Vector2i]:\n\tvar added_cells: Dictionary[int, Vector2i] = {}"} {"instruction": "Erstelle eine GDScript-Funktion namens '_ready':", "input": "", "output": "func _ready() -> void:\n\tawait owner.ready\n\tstate.enter()\n\nfunc _unhandled_input(event: InputEvent) -> void:\n\tstate.unhandled_input(event)\n\nfunc _physics_process(delta: float) -> void:\n\tstate.physics_process(delta)\n\nfunc transition_to(target_state_path: String, msg: Dictionary = {}"} {"instruction": "Erstelle eine Godot-Klasse 'GSAICharacterBody3DAgent' die von GSAISpecializedAgent erbt mit folgenden Funktionen: _init, _apply_steering, _apply_sliding_steering, _apply_collide_steering, _apply_position_steering", "input": "", "output": "# 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\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# 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\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\n\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 + acc"} {"instruction": "Erstelle eine Godot-Klasse 'StateMachine' die von Node erbt mit folgenden Funktionen: _init, _ready, _unhandled_input, _physics_process, transition_to", "input": "", "output": "# Generic State Machine. Initializes states and delegates engine callbacks\n# (_physics_process, _unhandled_input) to the active state.\nextends Node\nclass_name StateMachine\n\n@export var initial_state := NodePath()\n\n@onready var state: State = get_node(initial_state): set = set_state\n@onready var _state_name := state.name\n\nfunc _init() -> void:\n\tadd_to_group(\"state_machine\")\n\nfunc _ready() -> void:\n\tawait owner.ready\n\tstate.enter()\n\nfunc _unhandled_input(event: InputEvent) -> void:\n\tstate.unhandled_input(event)\n\nfunc _physics_process(delta: float) -> void:\n\tstate.physics_process(delta)\n\nfunc transition_to(target_state_path: String, msg: Dictionary = {}) -> void:\n\tif not has_node(target_state_path):\n\t\treturn\n\n\tvar target_state := get_node(target_state_path)\n\n\tstate.exit()\n\tself.state = target_state\n\tstate.enter(msg)\n\nfunc set_state(value: State) -> void:\n\tstate = value\n\t_state_name = state.name\n"} {"instruction": "Erstelle eine GDScript-Funktion namens '_physics_process':", "input": "", "output": "func _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}", "source": "extracted_function"} {"instruction": "Vervollständige den GDScript-Code:", "input": "@tool\n\n## A Gamepiece is a scene that moves about and is snapped to the gameboard.\n##\n## Gamepieces, like other scenes in Godot, are expected to be composed from other nodes (i.e. an AI\n## [GamepieceController], a collision shape, or a [Sprite2D], for example). Gamepieces themselves\n## are 'dumb' objects that do nothing but occupy and move about the gameboard.\n##\n## [br][br][b]Note:[/b] The [code]gameboard[/code] is considered to be the playable area on which a\n## Gamepiece may be placed. The gameboard is made up of cells, each of which may be occupied by one\n## or more gamepieces.\n@icon(\"res://assets/editor/icons/Gamepiece.svg\")\nclass_name Gamepiece extends Path2D\n\n## Emitted when a gamepiece is about to finish travlling to its destination cell. The remaining\n## distance that the gamepiece could travel is based on how far the gamepiece has travelled this\n## frame. [br][br]\n## The signal is emitted prior to wrapping up the path and traveller, allowing other objects to\n## extend the move path, if necessary.\nsignal arriving(remaining_distance: float)\n\n## Emitted when the gamepiece has finished travelling to its destination cell.\nsignal arrived\n\n## Emitted when the gamepiece's [member direction] changes, usually as it travels about the board.\nsignal direction_changed(new_direction: Directions.Points)\n\n## A [GamepieceAnimation] packed scene that will be automatically added to the gamepiece. Other\n## scene types will not be accepted.\n@export var animation_scene: PackedScene:\n\tset(value):\n\t\tanimation_scene = value\n\n\t\tif not is_inside_tree():\n\t\t\tawait ready\n\n\t\tif animation:\n\t\t\tanimation.queue_free()\n\t\t\tanimation = null\n\n\t\tif animation_scene:\n\t\t\t# Check to make sure that the supplied scene instantiates as a GamepieceAnimation.\n\t\t\tvar new_scene: = animation_scene.instantiate()\n\t\t\tanimation = new_scene as GamepieceAnimation\n\t\t\tif not animation:\n\t\t\t\tprinterr(\"Gamepiece '%s' cannot accept '%s' as \" % [name, new_scene.name],\n\t\t\t\t\t\"gamepiece_gfx_scene. '%s' is not a GamepieceGFX object!\" % new_scene.name)\n\t\t\t\tnew_scene.free()\n\t\t\t\tanimation_scene = null\n\t\t\t\treturn\n\n\t\t\tfollower.add_child(animation)\n\n## The gamepiece will traverse a movement path at [code]move_speed[/code] pixels per second.\n##\n## Note that extremely high speeds (finish a long path in a single frame) will produce\n## unexpected results.\n@export var move_speed: = 64.0\n\n## The visual representation of the gamepiece, set automatically based on [member animation_scene].\n## Usually the animation is only changed by the gamepiece itself, though the designer may want to\n## play different animations sometimes (such as during a cutscene).\nvar animation: GamepieceAnimation = null\n\n## The [code]direction[/code] is a unit vector that points where the gamepiece is 'looking'.", "output": "## In the event that the gamepiece is moving along a path, direction is updated automatically as\n## long as the gamepiece continues to move.\nvar direction: = Directions.Points.SOUTH:\n\tset(value):\n\t\tif value != direction:\n\t\t\tdirection = value\n\n\t\t\tif not is_inside_tree():\n\t\t\t\tawait ready\n\n\t\t\tanimation.direction = direction\n\t\t\tdirection_changed.emit(direction)\n\n## The position at the centre of the cell currently occupied by the gamepiece. Note that this\n## differs from the gamepiece's position while it is moving.\nvar rest_position: = Vector2.ZERO\n\n## The position at the centre of the cell to which the gamepiece is currently moving (and which it\n## currently occupies, as it moves towards it).\n## Compare this with the Gamepiece's position, which is kept constant at the move path's origin\n## until the gamepiece has arrived at its destination. Compare also with the position of the path\n## follower, at which the GamepieceAnimation is rendered.\nvar destination: Vector2\n\n## Node2Ds may want to follow the gamepiece's animation, rather than position (which updates only at\n## the end of a path). Nodes may follow a travelling gamepiece by receiving the path follower's\n## transform.\n##\n## The [member RemoteTransform2D.remote_path] is reserved for the player camera, but other nodes\n## may access the anchor's position directly.\n@onready var animation_transform: = $PathFollow2D/CameraAnchor as RemoteTransform2D\n\n# The following objects allow the gamepiece to appear to move smoothly around the gameboard.\n# Please note that the path is decoupled from the gamepiece's position (scale is set to match\n# the gamepiece in _ready(), however) in order to simplify path management. All path coordinates may\n# be provided in game-world coordinates and will remain relative to the origin even as the\n# gamepiece's position changes.\n@onready var follower: = $PathFollow2D as PathFollow2D\n\nfunc _ready() -> void:\n\tset_process(false)\n\n\tif not Engine.is_editor_hint() and is_inside_tree():\n\t\t# Some gamepieces may be added to the scene before the Gameboard properties are set. In that\n\t\t# case, wait for Gameboard dimensions to be set before registering the gamepiece.\n\t\tif Gameboard.properties == null:\n\t\t\tawait Gameboard.properties_set\n\n\t\t# Snap the gamepiece to the cell on which it is standing."} {"instruction": "Erstelle eine Godot-Klasse 'CombatTrigger' die von Trigger erbt mit folgenden Funktionen: _execute, _run_victory_cutscene, _run_loss_cutscene", "input": "", "output": "@tool\nclass_name CombatTrigger extends Trigger\n\n@export var combat_arena: PackedScene\n\nfunc _execute() -> void:\n\t# Let other systems know that a combat has been triggered and then wait for its outcome.\n\tFieldEvents.combat_triggered.emit(combat_arena)\n\n\tvar did_player_win: bool = await CombatEvents.combat_finished\n\n\t# The combat ends with a covered screen, and so we fix that here.\n\tTransition.clear.call_deferred(0.2)\n\tawait Transition.finished\n\n\t# We want to run post-combat events. In some cases, this may not involve much, such as playing a\n\t# game-over screen or removing an AI combat-starting gamepiece from the field.\n\t# In some cases, however, we'll want a dialogue to play or some creative event to occur if, for\n\t# example, the player lost a difficult but non-essential battle.\n\tif did_player_win:\n\t\tawait _run_victory_cutscene()\n\n\telse:\n\t\tawait _run_loss_cutscene()\n\n## The following method may be overwridden to allow for custom behaviour following a combat victory.\n## Examples include adding an item to the player's inventory, running a dialogue, removing an enemy\n## [Gamepiece], etc.\nfunc _run_victory_cutscene() -> void:\n\tawait get_tree().process_frame\n\n## The following method may be overwridden to allow for custom behaviour following a combat loss.\n## In most cases this may result in a gameover, but in others it may run a cutscene, change some\n## sort of event flag, etc.\nfunc _run_loss_cutscene() -> void:\n\tawait get_tree().process_frame\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "@tool\nextends CombatTrigger\n\n", "output": "# If the player has defeated this 'roaming encounter', remove the encounter.\nfunc _run_victory_cutscene() -> void:\n\tqueue_free()\n\n# If the player has lost to this 'roaming encounter', play the game-over screen.\nfunc _run_loss_cutscene() -> void:\n\tawait get_tree().process_frame\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "# Determines any agent that is in the specified list as being neighbors with the\n# owner agent, regardless of distance.\n# @category - Proximities\nclass_name GSAIInfiniteProximity\nextends GSAIProximity\n\n\nfunc _init(agent: GSAISteeringAgent, agents: Array) -> void:\n\tsuper._init(agent, agents)", "output": "\n# Returns a number of neighbors based on a `callback` function.\n#\n# `_find_neighbors` calls `callback` for each agent in the `agents` array and\n# adds one to the count if its `callback` returns true.\n# @tags - virtual\nfunc _find_neighbors(callback: Callable) -> int:\n\tvar neighbor_count := 0\n\tvar agent_count := agents.size()\n\tfor i in range(agent_count):\n\t\tvar current_agent := agents[i] as GSAISteeringAgent\n\n\t\tif current_agent != agent:\n\t\t\tif callback.call(current_agent):\n\t\t\t\tneighbor_count += 1\n\n\treturn neighbor_count\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "#*\n#* showcase.gd\n#* =============================================================================\n#* Copyright 2024 Serhii Snitsaruk\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\nextends Node2D\n\n@onready var behavior_tree_view: BehaviorTreeView = %BehaviorTreeView\n@onready var camera: Camera2D = $Camera2D\n@onready var agent_selection: MenuButton = %AgentSelection\n@onready var previous: Button = %Previous\n@onready var next: Button = %Next\n@onready var minimize_description: Button = %MinimizeDescription\n@onready var description: RichTextLabel = %Description\n@onready var begin_tutorial: Button = %BeginTutorial\n@onready var navigation_hint: Label = %NavigationHint\n@onready var scene_title: Label = %SceneTitle\n@onready var code_popup = %CodePopup\n@onready var code_edit = %CodeEdit\n\nvar bt_player: BTPlayer\nvar selected_tree_index: int = -1\nvar agent_files: Array[String]\nvar agents_dir: String\nvar is_tutorial: bool = false\n\n\nfunc _ready() -> void:\n\tcode_popup.hide()\n\n\tagent_selection.get_popup().id_pressed.connect(_on_agent_selection_id_pressed)\n\tprevious.pressed.connect(func(): _on_agent_selection_id_pressed(selected_tree_index - 1))\n\tnext.pressed.connect(func(): _on_agent_selection_id_pressed(selected_tree_index + 1))\n\n\t_initialize()\n\n\nfunc _physics_process(_delta: float) -> void:\n\tvar inst: BTInstance = bt_player.get_bt_instance()\n\tvar bt_data: BehaviorTreeData = BehaviorTreeData.create_from_bt_instance(inst)\n\tbehavior_tree_view.update_tree(bt_data)\n\n\nfunc _initialize() -> void:\n\tif is_tutorial:\n\t\t_populate_agent_files(\"res://demo/agents/tutorial/\")", "output": "\t\tbegin_tutorial.text = \"End Tutorial\"\n\t\tnavigation_hint.text = \"Navigate ➤\"\n\t\tscene_title.text = \"Tutorial\"\n\t\t_on_agent_selection_id_pressed(0)\n\telse:\n\t\t_populate_agent_files(\"res://demo/agents/\")\n\t\tbegin_tutorial.text = \"Begin Tutorial\"\n\t\tnavigation_hint.text = \"Select Agent ➤\"\n\t\tscene_title.text = \"Showcase\"\n\t\t_on_agent_selection_id_pressed(0)\n\nfunc _attach_camera(agent: CharacterBody2D) -> void:\n\tawait get_tree().process_frame\n\tcamera.get_parent().remove_child(camera)\n\tagent.add_child(camera)\n\tcamera.position = Vector2(400.0, 0.0)\n\nfunc _populate_agent_files(p_path: String = \"res://demo/agents/\") -> void:\n\tvar popup: PopupMenu = agent_selection.get_popup()\n\tpopup.clear()\n\tpopup.reset_size()\n\tagent_files.clear()\n\tagents_dir = p_path\n\n\tvar dir := DirAccess.open(p_path)\n\tif dir:\n\t\tdir.list_dir_begin()\n\t\tvar file_name: String = dir.get_next()\n\t\twhile file_name != \"\":\n\t\t\tif dir.current_is_dir() or file_name.begins_with(\"agent_base\"):\n\t\t\t\tfile_name = dir.get_next()\n\t\t\t\tcontinue\n\t\t\tagent_files.append(file_name.get_file().trim_suffix(\".remap\"))\n\t\t\tfile_name = dir.get_next()\n\tdir.list_dir_end()\n\n\tagent_files.sort()\n\tfor i in agent_files.size():\n\t\tpopup.add_item(agent_files[i], i)\n\nfunc _load_agent(file_name: String) -> void:\n\tvar agent_res := load(file_name) as PackedScene\n\tassert(agent_res != null)\n\n\tfor child in get_children():\n\t\tif child is CharacterBody2D and child.name != \"Dummy\":\n\t\t\tchild.die()"} {"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] = {}"} {"instruction": "Erstelle eine GDScript-Funktion namens 'set_current_report_path':", "input": "", "output": "func 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}"} {"instruction": "Erstelle eine GDScript-Funktion namens '_physics_process':", "input": "", "output": "func _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}", "source": "extracted_function"} {"instruction": "Erstelle eine Godot-Klasse 'PlayerController' die von GamepieceController erbt mit folgenden Funktionen: _ready, _on_waypoint_changed, _on_collision_triggered, _on_gamepiece_direction_changed, _unhandled_input", "input": "", "output": "@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\nfunc _ready() -> void:\n\tsuper._ready()\n\n\tif not Engine.is_editor_hint():\n\t\tadd_to_group(GROUP)\n\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\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."} {"instruction": "Erstelle eine GDScript-Funktion namens 'initialize':", "input": "", "output": "func initialize() -> void:\n\t_update_all()\n\n# Get the final value of a stat, with all modifiers applied to it.\nfunc 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 = {}"} {"instruction": "Vervollständige den GDScript-Code:", "input": "## Random action node that changes its state over time.\n##\n## Action node that returns a random status, depending on the action\n## [member weights]. Changes its status every [member reset_duration_msec]\n## milliseconds.\n@tool\nclass_name RandomAction extends ActionLeaf\n\n\n## How often this action changes its return status, in milliseconds.\n@export var reset_duration_msec: = 1000\n\n", "output": "var last_step = 0\nvar action = 0\n\n## Array of 3 floats signifying the weights of SUCCESS, FAILURE and RUNNING\n## statuses respectively.\nvar weights = [3., 3., 1.]\n\nfunc _get_random_action():\n\tvar sum = 0.\n\tfor w in weights:\n\t\tsum += w\n\tvar rnd = randf_range(0, sum)\n\tfor i in weights.size():\n\t\tif rnd <= weights[i]:\n\t\t\treturn i\n\t\trnd -= weights[i]\n\treturn weights.size() - 1\n\nfunc tick(actor: Node, blackboard: Blackboard) -> int:\n\tvar step = Time.get_ticks_msec() / reset_duration_msec\n\tif step != last_step:\n\t\taction = _get_random_action()\n\t\tlast_step = step\n\treturn action\n"} {"instruction": "Erstelle eine GDScript-Funktion namens '_process':", "input": "", "output": "func _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}", "source": "extracted_function"} {"instruction": "Vervollständige den GDScript-Code:", "input": "extends Sprite2D\n\n\nfunc _ready() -> void:\n\tPlayer.player_path_set.connect(", "output": "\t\tfunc(gamepiece: Gamepiece, destination_cell: Vector2i) -> void:\n\t\t\tif not gamepiece.arrived.is_connected(_on_gp_arrived):\n\t\t\t\tgamepiece.arrived.connect(_on_gp_arrived, CONNECT_ONE_SHOT)\n\t\t\tposition = Gameboard.cell_to_pixel(destination_cell)\n\t\t\t#show()\n\t)\n\nfunc _on_gp_arrived() -> void:\n\thide()\n"} {"instruction": "Erstelle eine GDScript-Funktion namens 'add':", "input": "", "output": "func add(behavior: GSAISteeringBehavior, weight: float) -> void:\n\tbehavior.agent = agent\n\t_behaviors.append({behavior = behavior, weight = weight}", "source": "extracted_function"} {"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": "Erstelle eine Godot-Klasse 'GSAIRadiusProximity' die von GSAIProximity erbt mit folgenden Funktionen: _init, _find_neighbors", "input": "", "output": "# Determines any agent that is in the specified list as being neighbors with the owner agent if\n# they lie within the specified radius.\n# @category - Proximities\nclass_name GSAIRadiusProximity\nextends GSAIProximity\n\n# The radius around the owning agent to find neighbors in\nvar radius := 0.0\n\nvar _last_frame := 0\nvar _scene_tree: SceneTree\n\nfunc _init(agent: GSAISteeringAgent, agents: Array, _radius: float) -> void:\n\tsuper._init(agent, agents)\n\tself.radius = _radius\n\t_scene_tree = Engine.get_main_loop()\n\n# Returns a number of neighbors based on a `callback` function.\n#\n# `_find_neighbors` calls `callback` for each agent in the `agents` array that lie within\n# the radius around the owning agent and adds one to the count if its `callback` returns true.\n# @tags - virtual\nfunc _find_neighbors(callback: Callable) -> int:\n\tvar agent_count := agents.size()\n\tvar neighbor_count := 0\n\n\tvar current_frame := _scene_tree.get_frame() if _scene_tree else -_last_frame\n\tif current_frame != _last_frame:\n\t\t_last_frame = current_frame\n\n\t\tvar owner_position := agent.position\n\n\t\tfor i in range(agent_count):\n\t\t\tvar current_agent := agents[i] as GSAISteeringAgent\n\n\t\t\tif current_agent != agent:\n\t\t\t\tvar distance_squared := owner_position.distance_squared_to(current_agent.position)\n\n\t\t\t\tvar range_to := radius + current_agent.bounding_radius\n\n\t\t\t\tif distance_squared < range_to * range_to:\n\t\t\t\t\tif callback.call(current_agent):\n\t\t\t\t\t\tcurrent_agent.is_tagged = true\n\t\t\t\t\t\tneighbor_count += 1\n\t\t\t\t\t\tcontinue\n\n\t\t\tcurrent_agent.is_tagged = false\n\telse:\n\t\tfor i in range(agent_count):\n\t\t\tvar current_agent = agents[i] as GSAISteeringAgent\n\n\t\t\tif current_agent != agent and current_agent.is_tagged:\n\t\t\t\tif callback.call(current_agent):\n\t\t\t\t\tneighbor_count += 1\n\n\treturn neighbor_count\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "extends Control\n\n@export var controller: XRController3D\n\n@onready var trigger_input_node: HSlider = $VBoxContainer/TriggerInput/HSlider\n@onready var trigger_click_node: CheckBox = $VBoxContainer/TriggerInput/CheckBox\n@onready var on_threshold_node: Label = $VBoxContainer/Thresholds/OnThreshold\n@onready var off_threshold_node: Label = $VBoxContainer/Thresholds/OffThreshold\n\n@onready var dpad_up_node: CheckBox = $VBoxContainer/DPadState/Up\n@onready var dpad_down_node: CheckBox = $VBoxContainer/DPadState/Down\n@onready var dpad_left_node: CheckBox = $VBoxContainer/DPadState/Left\n@onready var dpad_right_node: CheckBox = $VBoxContainer/DPadState/Right", "output": "\nvar off_trigger_threshold: float = 1.0\nvar on_trigger_threshold: float = 0.0\n\nfunc _process(_delta: float) -> void:\n\tif controller:\n\t\tvar trigger_input = controller.get_float(&\"trigger\")\n\t\ttrigger_input_node.value = trigger_input\n\n\t\tvar trigger_click = controller.is_button_pressed(&\"trigger_click\")\n\t\ttrigger_click_node.button_pressed = trigger_click\n\n\t\tif trigger_click:\n\t\t\toff_trigger_threshold = min(off_trigger_threshold, trigger_input)\n\t\telse:\n\t\t\ton_trigger_threshold = max(on_trigger_threshold, trigger_input)\n\n\t\ton_threshold_node.text = \"On: %0.2f\" % on_trigger_threshold\n\t\toff_threshold_node.text = \"Off: %0.2f\" % off_trigger_threshold\n\n\t\tdpad_up_node.button_pressed = controller.is_button_pressed(&\"up\")\n\t\tdpad_down_node.button_pressed = controller.is_button_pressed(&\"down\")\n\t\tdpad_left_node.button_pressed = controller.is_button_pressed(&\"left\")\n\t\tdpad_right_node.button_pressed = controller.is_button_pressed(&\"right\")\n"} {"instruction": "Erstelle eine Godot-Klasse 'GSAIAvoidCollisions' die von GSAIGroupBehavior erbt mit folgenden Funktionen: _init, _calculate_steering, _report_neighbor", "input": "", "output": "# Steers the agent to avoid obstacles in its path. Approximates obstacles as\n# spheres.\n# @category - Group behaviors\nclass_name GSAIAvoidCollisions\nextends GSAIGroupBehavior\n\nvar _first_neighbor: GSAISteeringAgent\nvar _shortest_time: float\nvar _first_minimum_separation: float\nvar _first_distance: float\nvar _first_relative_position: Vector3\nvar _first_relative_velocity: Vector3\n\nfunc _init(agent: GSAISteeringAgent, proximity: GSAIProximity) -> void:\n\tsuper._init(agent, proximity)\n\nfunc _calculate_steering(acceleration: GSAITargetAcceleration) -> void:\n\t_shortest_time = INF\n\t_first_neighbor = null\n\t_first_minimum_separation = 0\n\t_first_distance = 0\n\n\tvar neighbor_count := proximity._find_neighbors(_callback)\n\n\tif neighbor_count == 0 or not _first_neighbor:\n\t\tacceleration.set_zero()\n\telse:\n\t\tif (\n\t\t\t_first_minimum_separation <= 0\n\t\t\tor _first_distance < agent.bounding_radius + _first_neighbor.bounding_radius\n\t\t):\n\t\t\tacceleration.linear = _first_neighbor.position - agent.position\n\t\telse:\n\t\t\tacceleration.linear = (\n\t\t\t\t_first_relative_position\n\t\t\t\t+ (_first_relative_velocity * _shortest_time)\n\t\t\t)\n\n\tacceleration.linear = (acceleration.linear.normalized() * -agent.linear_acceleration_max)\n\tacceleration.angular = 0\n\n# Callback for the proximity to call when finding neighbors. Keeps track of every `neighbor`\n# that was found but only keeps the one the owning agent will most likely collide with.\n# @tags - virtual\nfunc _report_neighbor(neighbor: GSAISteeringAgent) -> bool:\n\tvar relative_position := neighbor.position - agent.position\n\tvar relative_velocity := neighbor.linear_velocity - agent.linear_velocity\n\tvar relative_speed_squared := relative_velocity.length_squared()\n\n\tif relative_speed_squared == 0:\n\t\treturn false\n\telse:\n\t\tvar time_to_collision = -relative_position.dot(relative_velocity) / relative_speed_squared\n\n\t\tif time_to_collision <= 0 or time_to_collision >= _shortest_time:\n\t\t\treturn false\n\t\telse:\n\t\t\tvar distance = relative_position.length()\n\t\t\tvar minimum_sepa"} {"instruction": "Vervollständige den GDScript-Code:", "input": "extends Node3D\n\n\nvar webxr_interface: WebXRInterface\nvar vr_supported: bool = false\n\n@onready var left_controller = $XROrigin3D/LeftController\n\n\nfunc _ready() -> void:\n\t$CanvasLayer/EnterVRButton.pressed.connect(_on_enter_vr_button_pressed)\n\n\twebxr_interface = XRServer.find_interface(\"WebXR\")\n\tif webxr_interface:\n\t\t# WebXR uses a lot of asynchronous callbacks, so we connect to various\n\t\t# signals in order to receive them.\n\t\twebxr_interface.session_supported.connect(_webxr_session_supported)\n\t\twebxr_interface.session_started.connect(_webxr_session_started)\n\t\twebxr_interface.session_ended.connect(_webxr_session_ended)\n\t\twebxr_interface.session_failed.connect(_webxr_session_failed)\n\n\t\twebxr_interface.select.connect(_webxr_on_select)\n\t\twebxr_interface.selectstart.connect(_webxr_on_select_start)\n\t\twebxr_interface.selectend.connect(_webxr_on_select_end)\n\n\t\twebxr_interface.squeeze.connect(_webxr_on_squeeze)\n\t\twebxr_interface.squeezestart.connect(_webxr_on_squeeze_start)\n\t\twebxr_interface.squeezeend.connect(_webxr_on_squeeze_end)\n\n\t\t# This returns immediately - our _webxr_session_supported() method\n\t\t# (which we connected to the \"session_supported\" signal above) will\n\t\t# be called sometime later to let us know if it's supported or not.\n\t\twebxr_interface.is_session_supported(\"immersive-vr\")\n\n\t$XROrigin3D/LeftController.button_pressed.connect(_on_left_controller_button_pressed)\n\t$XROrigin3D/LeftController.button_released.connect(_on_left_controller_button_released)\n\n\nfunc _webxr_session_supported(session_mode: String, supported: bool) -> void:\n\tif session_mode == \"immersive-vr\":\n\t\tvr_supported = supported\n\n\nfunc _on_enter_vr_button_pressed() -> void:\n\tif not vr_supported:", "output": "\t\tOS.alert(\"Your browser doesn't support VR\")\n\t\treturn\n\n\t# We want an immersive VR session, as opposed to AR (\"immersive-ar\") or a\n\t# simple 3DoF viewer (\"viewer\").\n\twebxr_interface.session_mode = \"immersive-vr\"\n\t# \"bounded-floor\" is room scale, \"local-floor\" is a standing or sitting\n\t# experience (it puts you 1.6m above the ground if you have 3DoF headset),\n\t# whereas as \"local\" puts you down at the XROrigin3D.\n\t# This list means it\"ll first try to request \"bounded-floor\", then\n\t# fallback on \"local-floor\" and ultimately \"local\", if nothing else is\n\t# supported.\n\twebxr_interface.requested_reference_space_types = \"bounded-floor, local-floor, local\"\n\t# In order to use \"local-floor\" or \"bounded-floor\" we must also\n\t# mark the features as required or optional.\n\twebxr_interface.required_features = \"local-floor\"\n\twebxr_interface.optional_features = \"bounded-floor\"\n\n\t# This will return false if we're unable to even request the session,\n\t# however, it can still fail asynchronously later in the process, so we\n\t# only know if it's really succeeded or failed when our\n\t# _webxr_session_started() or _webxr_session_failed() methods are called.\n\tif not webxr_interface.initialize():\n\t\tOS.alert(\"Failed to initialize WebXR\")\n\t\treturn\n\nfunc _webxr_session_started() -> void:\n\t$CanvasLayer.visible = false\n\t# This tells Godot to start rendering to the headset.\n\tget_viewport().use_xr = true\n\t# This will be the reference space type you ultimately got, out of the\n\t# types that you requested above. This is useful if you want the game to\n\t# work a little differently in \"bounded-floor\" versus \"local-floor\".\n\tprint(\"Reference space type: \" + webxr_interface.reference_space_type)\n\t# This will be the list of features that were successfully enabled\n\t# (except on browsers that don't support this property).\n\tprint(\"Enabled features: \", webxr_interface.enabled_features)\n\nfunc _webxr_session_ended() -> void:\n\t$CanvasLayer.visible = true\n\t# If the user exits immersive mode, then we tell Godot to render to the web\n\t# page again.\n\tget_viewport().use_xr = false\n\nfunc _webxr_session_failed(message: String) -> void:\n\tOS.alert(\"Failed to initialize: \" + message)\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "extends Camera3D\n\n## This script allows us to place a camera in the world that provides\n## a spectator view where we see what the player sees.\n## The positioning is smoothed to create a steadycam type of effect.\n\n## Specify the XRCamera3D node we're replicating the view for.\n@export var xr_camera : XRCamera3D\n\n## Remove pitch from our camera orientation?\n@export var remove_pitch : bool = true\n\n## Speed at which we lerp, the lower the more stable our camera gets\n## at the cost of introducing more lag.\n@export_range(1.0, 60.0, 1.0) var lerp_speed : float = 10.0\n\nvar prev_camera_transform : Transform3D", "output": "var first_frame : bool = true\n\n# Called every frame. 'delta' is the elapsed time since the previous frame.\nfunc _process(delta):\n\tif current and xr_camera:\n\t\t# Note, we apply our smoothing in the local space of our XROrigin3D node.\n\t\t# This way we don't apply smoothing when game logic moves the XROrigin3D node.\n\t\t# We only apply smoothing to the physical movement of the player.\n\t\t# This makes the spectator view easier to watch by a 3rd party.\n\n\t\t# We smooth out the camera.\n\t\tvar camera_transform : Transform3D = xr_camera.transform\n\n\t\tif remove_pitch:\n\t\t\t# Remove pitch from camera.\n\t\t\tcamera_transform.basis = Basis.looking_at(camera_transform.basis.z, Vector3.UP, true)\n\n\t\tif first_frame:\n\t\t\tfirst_frame = false\n\t\telse:\n\t\t\t# We (s)lerp our physical camera movement to smooth things out.\n\t\t\tcamera_transform.basis = prev_camera_transform.basis.slerp(camera_transform.basis, delta * lerp_speed)\n\t\t\tcamera_transform.origin = prev_camera_transform.origin.lerp(camera_transform.origin, delta * lerp_speed)\n\n\t\t# Update our first person view.\n\t\tglobal_transform = xr_camera.get_parent().global_transform * camera_transform\n\n\t\t# Store camera transform for next frame.\n\t\tprev_camera_transform = camera_transform\n\telse:\n\t\t# Make sure next time we run through this we don't lerp.\n\t\tfirst_frame = true\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "#*\n#* face_target.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", "output": "extends BTAction\n## Flips the agent to face the target, returning [code]SUCCESS[/code]. [br]\n## Returns [code]FAILURE[/code] if [member target_var] is not a valid [Node2D] instance.\n\n## Blackboard variable that stores our target (expecting Node2D).\n@export var target_var: StringName = &\"target\"\n\n# Display a customized name (requires @tool).\nfunc _generate_name() -> String:\n\treturn \"FaceTarget \" + LimboUtility.decorate_var(target_var)\n\n# Called each time this task is ticked (aka executed).\nfunc _tick(_delta: float) -> Status:\n\tvar target: Node2D = blackboard.get_var(target_var)\n\tif not is_instance_valid(target):\n\t\treturn FAILURE\n\tvar dir: float = target.global_position.x - agent.global_position.x\n\tagent.velocity = Vector2.ZERO\n\tagent.face_dir(dir)\n\treturn SUCCESS\n"} {"instruction": "Erstelle eine GDScript-Funktion namens 'has_value':", "input": "", "output": "func has_value(key: Variant, blackboard_name: String = DEFAULT) -> bool:\n\treturn (\n\t\t_data.has(blackboard_name)\n\t\tand _data[blackboard_name].has(key)\n\t\tand _data[blackboard_name][key] != null\n\t)\n\nfunc erase_value(key: Variant, blackboard_name: String = DEFAULT) -> void:\n\tif _data.has(blackboard_name):\n\t\t_data[blackboard_name][key] = null\n\nfunc get_debug_data() -> Dictionary:\n\t# Avoid sending raw Objects (Nodes, Resources, etc.) over the\n\t# EngineDebugger connection, which can cause Variant marshalling errors\n\t# and break the editor debugger stream.\n\treturn _sanitize_for_debug(_data)\n\nstatic func _sanitize_for_debug(value: Variant, depth: int = 0) -> Variant:\n\t# Limit recursion depth defensively to avoid issues with deeply nested\n\t# or self‑referential data structures. At this point we only need a\n\t# human‑readable representation for the debugger UI.\n\tif depth > 4:\n\t\treturn str(value)\n\n\tvar t := typeof(value)\n\n\tmatch t:\n\t\tTYPE_DICTIONARY:\n\t\t\tvar result := {}", "source": "extracted_function"} {"instruction": "Vervollständige den GDScript-Code:", "input": "## Base interface of all GdUnit asserts\n@abstract class_name GdUnitAssert\nextends RefCounted\n\n\n## Verifies that the current value is null.\n@abstract func is_null() -> GdUnitAssert\n\n\n## Verifies that the current value is not null.\n@abstract func is_not_null() -> GdUnitAssert\n\n\n## Verifies that the current value is equal to expected one.\n@abstract func is_equal(expected: Variant) -> GdUnitAssert\n", "output": "\n## Verifies that the current value is not equal to expected one.\n@abstract func is_not_equal(expected: Variant) -> GdUnitAssert\n\n## Overrides the default failure message by given custom message.[br]\n## This function allows you to replace the automatically generated failure message with a more specific\n## or user-friendly message that better describes the test failure context.[br]\n## Usage:\n## [codeblock]\n##\t\t# Override with custom context-specific message\n##\t\tfunc test_player_inventory():\n##\t\t assert_that(player.get_item_count(\"sword\"))\\\n##\t\t .override_failure_message(\"Player should have exactly one sword\")\\\n##\t\t .is_equal(1)\n## [/codeblock]\n@abstract func override_failure_message(message: String) -> GdUnitAssert\n\n## Appends a custom message to the failure message.[br]\n## This can be used to add additional information to the generated failure message\n## while keeping the original assertion details for better debugging context.[br]\n## Usage:\n## [codeblock]\n##\t\t# Add context to existing failure message\n##\t\tfunc test_player_health():\n##\t\t assert_that(player.health)\\\n##\t\t .append_failure_message(\"Player was damaged by: %s\" % last_damage_source)\\\n##\t\t .is_greater(0)\n## [/codeblock]\n@abstract func append_failure_message(message: String) -> GdUnitAssert\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "extends XRController3D\n\n# Check if we can use our palm pose or should fallback to our grip pose.\n\n", "output": "# Called every frame. 'delta' is the elapsed time since the previous frame.\nfunc _process(delta):\n\tvar controller_tracker : XRControllerTracker = XRServer.get_tracker(tracker)\n\tif controller_tracker:\n\t\tvar new_pose : String = \"palm_pose\"\n\t\tvar xr_pose : XRPose = controller_tracker.get_pose(new_pose)\n\t\tif not xr_pose or xr_pose.tracking_confidence == XRPose.XR_TRACKING_CONFIDENCE_NONE:\n\t\t\tnew_pose = \"grip\"\n\n\t\tif pose != new_pose:\n\t\t\tpose = new_pose\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": "Vervollständige den GDScript-Code:", "input": "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\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\n\nfunc _process(_delta: float) -> void:", "output": "\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, note_delta)\n\t\telse:\n\t\t\t# Note is still hittable, so stop checking rest of the (later)\n\t\t\t# notes.\n\t\t\tbreak\n\nfunc _handle_keypress() -> void:\n\tvar note := _notes[0] as Note\n\tvar hit_delta := _get_note_delta(note)\n\tif hit_delta < -HIT_MARGIN_MISS:\n\t\t# Note is not hittable, do nothing.\n\t\tpass\n\telif -HIT_MARGIN_PERFECT <= hit_delta and hit_delta <= HIT_MARGIN_PERFECT:\n\t\t# Hit on time, perfect.\n\t\tnote.hit_perfect()\n\t\t_notes.remove_at(0)\n\t\t_hit_error_acc += hit_delta\n\t\t_hit_count += 1\n\t\t_play_stats.perfect_count += 1\n\t\t_play_stats.mean_hit_error = _hit_error_acc / _hit_count\n\t\tnote_hit.emit(note.beat, Enums.HitType.PERFECT, hit_delta)\n\telif -HIT_MARGIN_GOOD <= hit_delta and hit_delta <= HIT_MARGIN_GOOD:\n\t\t# Hit slightly off time, good."} {"instruction": "Vervollständige den GDScript-Code:", "input": "@tool\nextends BTAction\n## Selects a random position nearby within the specified range and stores it on the blackboard. [br]\n## Returns [code]SUCCESS[/code].\n\n## Minimum distance to the desired position.\n@export var range_min: float = 300.0\n\n## Maximum distance to the desired position.\n@export var range_max: float = 500.0\n", "output": "## Blackboard variable that will be used to store the desired position.\n@export var position_var: StringName = &\"pos\"\n\n# Display a customized name (requires @tool).\nfunc _generate_name() -> String:\n\treturn \"SelectRandomNearbyPos range: [%s, %s] ➜%s\" % [\n\t\trange_min, range_max,\n\t\tLimboUtility.decorate_var(position_var)]\n\n# Called each time this task is ticked (aka executed).\nfunc _tick(_delta: float) -> Status:\n\tvar pos: Vector2\n\tvar is_good_position: bool = false\n\twhile not is_good_position:\n\t\t# Randomize until we find a good position (good position == not outside the arena).\n\t\tvar angle: float = randf() * TAU\n\t\tvar rand_distance: float = randf_range(range_min, range_max)\n\t\tpos = agent.global_position + Vector2(sin(angle), cos(angle)) * rand_distance\n\t\tis_good_position = agent.is_good_position(pos)\n\tblackboard.set_var(position_var, pos)\n\treturn SUCCESS\n"} {"instruction": "Erstelle eine GDScript-Funktion namens '_init':", "input": "", "output": "func _init():\n\tname = \"BeehavePlugin\"\n\tadd_autoload_singleton(\"BeehaveGlobalMetrics\", \"metrics/beehave_global_metrics.gd\")\n\tadd_autoload_singleton(\"BeehaveGlobalDebugger\", \"debug/global_debugger.gd\")\n\n\t# Add project settings\n\tif not ProjectSettings.has_setting(\"beehave/debugger/start_detached\"):\n\t\tProjectSettings.set_setting(\"beehave/debugger/start_detached\", false)\n\t\tProjectSettings.set_initial_value(\"beehave/debugger/start_detached\", false)\n\t\tProjectSettings.add_property_info({\n\t\t\t\"name\": \"beehave/debugger/start_detached\",\n\t\t\t\"type\": TYPE_BOOL,\n\t\t\t\"hint\": PROPERTY_HINT_NONE,\n\t\t\t\"hint_string\": \"If enabled, the debugger will start in a separate window\"\n\t\t}"} {"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": "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 = {}"} {"instruction": "Vervollständige den GDScript-Code:", "input": "extends Control\n\n# A standard piano with 88 keys has keys from 21 to 108.\n# To get a different set of keys, modify these numbers.\n# A maximally extended 108-key piano goes from 12 to 119.\n# A 76-key piano goes from 23 to 98, 61-key from 36 to 96,\n# 49-key from 36 to 84, 37-key from 41 to 77, and 25-key\n# from 48 to 72. Middle C is pitch number 60, A440 is 69.\nconst START_KEY = 21\nconst END_KEY = 108\n\nconst WhiteKeyScene := preload(\"res://piano_keys/white_piano_key.tscn\")\nconst BlackKeyScene := preload(\"res://piano_keys/black_piano_key.tscn\")\n\nvar piano_key_dict := Dictionary()\n\n@onready var white_keys: HBoxContainer = $WhiteKeys\n@onready var black_keys: HBoxContainer = $BlackKeys\n\nfunc _ready() -> void:\n\tassert(not _is_note_index_sharp(_pitch_index_to_note_index(START_KEY)), \"The start key can't be a sharp note (limitation of this piano-generating algorithm). Try 21.\")\n\n\tfor i in range(START_KEY, END_KEY + 1):\n\t\tpiano_key_dict[i] = _create_piano_key(i)\n\n\tif white_keys.get_child_count() != black_keys.get_child_count():\n\t\t_add_placeholder_key(black_keys)\n\n\tOS.open_midi_inputs()\n\n\tif not OS.get_connected_midi_inputs().is_empty():\n\t\tprint(OS.get_connected_midi_inputs())\n", "output": "\nfunc _input(input_event: InputEvent) -> void:\n\tif input_event is not InputEventMIDI:\n\t\treturn\n\n\tvar midi_event: InputEventMIDI = input_event\n\tif midi_event.pitch < START_KEY or midi_event.pitch > END_KEY:\n\t\t# The given pitch isn't on the on-screen keyboard, so return.\n\t\treturn\n\n\t_print_midi_info(midi_event)\n\tvar key: PianoKey = piano_key_dict[midi_event.pitch]\n\tif midi_event.message == MIDI_MESSAGE_NOTE_ON:\n\t\tkey.activate()\n\telse:\n\t\tkey.deactivate()\n\nfunc _add_placeholder_key(container: HBoxContainer) -> void:\n\tvar placeholder := Control.new()\n\tplaceholder.size_flags_horizontal = SIZE_EXPAND_FILL\n\tplaceholder.mouse_filter = Control.MOUSE_FILTER_IGNORE\n\tplaceholder.name = &\"Placeholder\"\n\tcontainer.add_child(placeholder)\n\nfunc _create_piano_key(pitch_index: int) -> PianoKey:\n\tvar note_index := _pitch_index_to_note_index(pitch_index)\n\tvar piano_key: PianoKey\n\tif _is_note_index_sharp(note_index):\n\t\tpiano_key = BlackKeyScene.instantiate()\n\t\tblack_keys.add_child(piano_key)\n\telse:\n\t\tpiano_key = WhiteKeyScene.instantiate()\n\t\twhite_keys.add_child(piano_key)\n\t\tif _is_note_index_lacking_sharp(note_index):\n\t\t\t_add_placeholder_key(black_keys)\n\tpiano_key.setup(pitch_index)\n\treturn piano_key\n\nfunc _is_note_index_lacking_sharp(note_index: int) -> bool:\n\t# B and E, because no B# or E#\n\treturn note_index in [2, 7]\n\nfunc _is_note_index_sharp(note_index: int) -> bool:\n\t# A#, C#, D#, F#, and G#\n\treturn note_index in [1, 4, 6, 9, 11]\n"} {"instruction": "Erstelle eine GDScript-Funktion namens '_on_gamepiece_free':", "input": "", "output": "func _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": "Erstelle eine Godot-Klasse 'Comparator' die von Resource erbt mit folgenden Funktionen:", "input": "", "output": "class_name Comparator\nextends Resource\n\nenum {\n\tEQUAL,\n\tLESS_THAN,\n\tLESS_EQUAL,\n\tGREATER_THAN,\n\tGREATER_EQUAL,\n\tBETWEEN_EQUAL,\n\tNOT_BETWEEN_EQUAL,\n}\n"} {"instruction": "Erstelle eine GDScript-Funktion namens '_physics_process':", "input": "", "output": "func _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": "Vervollständige den GDScript-Code:", "input": "# A base class for a specialized steering agent that updates itself every frame\n# so the user does not have to. All other specialized agents derive from this.\n# @category - Specialized agents\n# @tags - abstract\nclass_name GSAISpecializedAgent\nextends GSAISteeringAgent\n\n# If `true`, calculates linear and angular velocities based on the previous\n# frame. When `false`, the user must keep those values updated.\nvar calculate_velocities := true\n\n# If `true`, interpolates the current linear velocity towards 0 by the \n# `linear_drag_percentage` value.", "output": "# Does not apply to `RigidBody` and `RigidBody2D` nodes.\nvar apply_linear_drag := true\n\n# If `true`, interpolates the current angular velocity towards 0 by the\n# `angular_drag_percentage` value.\n# Does not apply to `RigidBody` and `RigidBody2D` nodes.\nvar apply_angular_drag := true\n\n# The percentage between the current linear velocity and 0 to interpolate by if\n# `apply_linear_drag` is true.\n# Does not apply to `RigidBody` and `RigidBody2D` nodes.\nvar linear_drag_percentage := 0.0\n\n# The percentage between the current angular velocity and 0 to interpolate by if\n# `apply_angular_drag` is true.\n# Does not apply to `RigidBody` and `RigidBody2D` nodes.\nvar angular_drag_percentage := 0.0\n\nvar _last_orientation: float\nvar _applied_steering := false\n\n# Moves the agent's body by target `acceleration`.\n# @tags - virtual\nfunc _apply_steering(_acceleration: GSAITargetAcceleration, _delta: float) -> void:\n\tpass\n"} {"instruction": "Erstelle eine Godot-Klasse 'GSAIInfiniteProximity' die von GSAIProximity erbt mit folgenden Funktionen: _init, _find_neighbors", "input": "", "output": "# Determines any agent that is in the specified list as being neighbors with the\n# owner agent, regardless of distance.\n# @category - Proximities\nclass_name GSAIInfiniteProximity\nextends GSAIProximity\n\nfunc _init(agent: GSAISteeringAgent, agents: Array) -> void:\n\tsuper._init(agent, agents)\n\n# Returns a number of neighbors based on a `callback` function.\n#\n# `_find_neighbors` calls `callback` for each agent in the `agents` array and\n# adds one to the count if its `callback` returns true.\n# @tags - virtual\nfunc _find_neighbors(callback: Callable) -> int:\n\tvar neighbor_count := 0\n\tvar agent_count := agents.size()\n\tfor i in range(agent_count):\n\t\tvar current_agent := agents[i] as GSAISteeringAgent\n\n\t\tif current_agent != agent:\n\t\t\tif callback.call(current_agent):\n\t\t\t\tneighbor_count += 1\n\n\treturn neighbor_count\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "extends Node3D\n\n\nvar webxr_interface: WebXRInterface\nvar vr_supported: bool = false\n\n@onready var left_controller = $XROrigin3D/LeftController\n\n\nfunc _ready() -> void:\n\t$CanvasLayer/EnterVRButton.pressed.connect(_on_enter_vr_button_pressed)\n\n\twebxr_interface = XRServer.find_interface(\"WebXR\")\n\tif webxr_interface:\n\t\t# WebXR uses a lot of asynchronous callbacks, so we connect to various\n\t\t# signals in order to receive them.\n\t\twebxr_interface.session_supported.connect(_webxr_session_supported)\n\t\twebxr_interface.session_started.connect(_webxr_session_started)\n\t\twebxr_interface.session_ended.connect(_webxr_session_ended)\n\t\twebxr_interface.session_failed.connect(_webxr_session_failed)\n\n\t\twebxr_interface.select.connect(_webxr_on_select)\n\t\twebxr_interface.selectstart.connect(_webxr_on_select_start)\n\t\twebxr_interface.selectend.connect(_webxr_on_select_end)\n\n\t\twebxr_interface.squeeze.connect(_webxr_on_squeeze)\n\t\twebxr_interface.squeezestart.connect(_webxr_on_squeeze_start)\n\t\twebxr_interface.squeezeend.connect(_webxr_on_squeeze_end)\n\n\t\t# This returns immediately - our _webxr_session_supported() method\n\t\t# (which we connected to the \"session_supported\" signal above) will\n\t\t# be called sometime later to let us know if it's supported or not.\n\t\twebxr_interface.is_session_supported(\"immersive-vr\")\n\n\t$XROrigin3D/LeftController.button_pressed.connect(_on_left_controller_button_pressed)\n\t$XROrigin3D/LeftController.button_released.connect(_on_left_controller_button_released)\n\n\nfunc _webxr_session_supported(session_mode: String, supported: bool) -> void:\n\tif session_mode == \"immersive-vr\":\n\t\tvr_supported = supported\n\n\nfunc _on_enter_vr_button_pressed() -> void:\n\tif not vr_supported:", "output": "\t\tOS.alert(\"Your browser doesn't support VR\")\n\t\treturn\n\n\t# We want an immersive VR session, as opposed to AR (\"immersive-ar\") or a\n\t# simple 3DoF viewer (\"viewer\").\n\twebxr_interface.session_mode = \"immersive-vr\"\n\t# \"bounded-floor\" is room scale, \"local-floor\" is a standing or sitting\n\t# experience (it puts you 1.6m above the ground if you have 3DoF headset),\n\t# whereas as \"local\" puts you down at the XROrigin3D.\n\t# This list means it\"ll first try to request \"bounded-floor\", then\n\t# fallback on \"local-floor\" and ultimately \"local\", if nothing else is\n\t# supported.\n\twebxr_interface.requested_reference_space_types = \"bounded-floor, local-floor, local\"\n\t# In order to use \"local-floor\" or \"bounded-floor\" we must also\n\t# mark the features as required or optional.\n\twebxr_interface.required_features = \"local-floor\"\n\twebxr_interface.optional_features = \"bounded-floor\"\n\n\t# This will return false if we're unable to even request the session,\n\t# however, it can still fail asynchronously later in the process, so we\n\t# only know if it's really succeeded or failed when our\n\t# _webxr_session_started() or _webxr_session_failed() methods are called.\n\tif not webxr_interface.initialize():\n\t\tOS.alert(\"Failed to initialize WebXR\")\n\t\treturn\n\nfunc _webxr_session_started() -> void:\n\t$CanvasLayer.visible = false\n\t# This tells Godot to start rendering to the headset.\n\tget_viewport().use_xr = true\n\t# This will be the reference space type you ultimately got, out of the\n\t# types that you requested above. This is useful if you want the game to\n\t# work a little differently in \"bounded-floor\" versus \"local-floor\".\n\tprint(\"Reference space type: \" + webxr_interface.reference_space_type)\n\t# This will be the list of features that were successfully enabled\n\t# (except on browsers that don't support this property).\n\tprint(\"Enabled features: \", webxr_interface.enabled_features)\n\nfunc _webxr_session_ended() -> void:\n\t$CanvasLayer.visible = true\n\t# If the user exits immersive mode, then we tell Godot to render to the web\n\t# page again.\n\tget_viewport().use_xr = false\n\nfunc _webxr_session_failed(message: String) -> void:\n\tOS.alert(\"Failed to initialize: \" + message)\n"} {"instruction": "Erstelle eine GDScript-Funktion namens '_process':", "input": "", "output": "func _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": "Vervollständige den GDScript-Code:", "input": "## The visual representation of a [Battler].\n##\n## Battler animations respond visually to a closed set of stimiuli, such as receiving a hit or \n## moving to a position. These animations often represent a single character or a class of enemies\n## and are added as children to a given Battler.\n##\n## [br][br]Note: BattlerAnims must be children of a Battler object to function correctly!\n@tool\nclass_name BattlerAnim extends Marker2D\n\n## Dictates how far the battler moves forwards and backwards at the beginning/end of its turn.\nconst MOVE_OFFSET: = 140.0\n\n## Determines which direction the battler faces on the screen.\nenum Direction { LEFT, RIGHT }\n\n## Emitted whenever an action-based animation wants to apply an effect. May be triggered multiple\n## times per animation.\n@warning_ignore(\"unused_signal\")\nsignal action_triggered\n\n## Forward AnimationPlayer's same signal.\nsignal animation_finished(name)\n\n## An icon that shows up on the turn bar.\n@export var battler_icon: Texture\n\n## Determines which direction the [BattlerAnim] faces. This is generally set by whichever \"side\"\n## the battler is on, player or enemy.\n@export var direction: = Direction.RIGHT:\n\tset(value):\n\t\tdirection = value\n\t\t\n\t\tscale.x = 1\n\t\tif direction == Direction.LEFT:\n\t\t\tscale.x = -1\n\n## Determines the time it takes for the [BattlerAnim] to slide forward or backward when its turn\n## comes up.\n@export var select_move_time: = 0.3\n\nvar _move_tween: Tween = null\nvar _rest_position: = Vector2.ZERO\n\n@onready var front: = $FrontAnchor as Marker2D\n@onready var top: = $TopAnchor as Marker2D", "output": "\n@onready var _anim: = $Pivot/AnimationPlayer as AnimationPlayer\n\nfunc _ready() -> void:\n\t_anim.animation_finished.connect(\n\t\tfunc _on_animation_player_finished(anim_name: String) -> void:\n\t\t\tanimation_finished.emit(anim_name)\n\t)\n\n\t_rest_position = position\n\n## Setup the BattlerAnim object to respond to gameplay signals from a [Battler] class.\nfunc setup(battler: Battler, facing: Direction) -> void:\n\t# BattlerAnim objects are assigned in-editor and created dynamically both in-game and in-editor.\n\t# We do not want the BattlerAnim objects to be saved with the CombatArena scenes, since they are\n\t# instantiated at runtime, so they should not be assigned an owner when in the editor.\n\t# However, in gameplay the BattlerAnim class must have an owner, as these objects need to be\n\t# discoverable by Node::find_children(). This allows us to wait for animations to finish playing\n\t# before ending combat, for example.\n\tif not Engine.is_editor_hint():\n\t\towner = battler\n\n\tdirection = facing\n\n\tbattler.health_depleted.connect(\n\t\tfunc _on_battler_health_depleted() -> void:\n\t\t\t_anim.play(\"die\")\n\t)\n\tbattler.hit_received.connect(\n\t\tfunc _on_battler_hit_received(value: int) -> void:\n\t\t\tif value > 0: _anim.play(\"hurt\")\n\t)\n\tbattler.selection_toggled.connect(\n\t\tfunc _on_battler_selection_toggled(value) -> void:\n\t\t\tif value: move_forward(select_move_time)\n\t\t\telse: move_to_rest(select_move_time)\n\t)\n\n## A function that wraps around the animation players' `play()` function, delegating the work to the\n## `AnimationPlayerDamage` node when necessary.\nfunc play(anim_name: String) -> void:\n\tassert(_anim.has_animation(anim_name), \"Battler animation '%s' does not have animation '%s'!\"\n\t\t% [name, anim_name])\n\n\t_anim.play(anim_name)\n"} {"instruction": "Erstelle eine GDScript-Funktion namens 'cell_to_pixel':", "input": "", "output": "func cell_to_pixel(cell_coordinates: Vector2i) -> Vector2:\n\treturn Vector2(cell_coordinates * properties.cell_size) + properties.half_cell_size\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\nfunc get_cell_under_node(node: Node2D) -> Vector2i:\n\treturn pixel_to_cell(node.global_position/node.global_scale)\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\n\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)\n\t\tvar removed_cells: = _remove_cells_from_pathfinder(blocked_cells)\n\n\t\t_connect_new_pathfinder_cells(added_cells)\n\t\tif not added_cells.is_empty() or not removed_cells.is_empty():\n\t\t\tpathfinder_changed.emit(added_cells.values(), removed_cells)\n\t)\n\n# Add cells to the pathfinder, checking that there are no blocking tiles on any GameboardLayers.\n# Returns a dictionary representing the cells that are actually added to the pathfinder (may differ\n# from cleared_cells). Key = cell id (int, see cell_to_index), value = coordinate (Vector2i)\nfunc _add_cells_to_pathfinder(cleared_cells: Array[Vector2i]) -> Dictionary[int, Vector2i]:\n\tvar added_cells: Dictionary[int, Vector2i] = {}"} {"instruction": "Erstelle eine GDScript-Funktion namens '_process':", "input": "", "output": "func _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}"} {"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": "extends Panel\n\nenum SyncSource {\n\tSYSTEM_CLOCK,\n\tSOUND_CLOCK,\n}\n\nconst BPM = 116\nconst BARS = 4\n\nconst COMPENSATE_FRAMES = 2\nconst COMPENSATE_HZ = 60.0\n\nvar playing: bool = false\nvar sync_source := SyncSource.SYSTEM_CLOCK\n\n# Used by system clock.\nvar time_begin: float", "output": "var time_delay: float\n\nfunc _process(_delta: float) -> void:\n\tif not playing or not $Player.playing:\n\t\treturn\n\n\tvar time := 0.0\n\tif sync_source == SyncSource.SYSTEM_CLOCK:\n\t\t# Obtain from ticks.\n\t\ttime = (Time.get_ticks_usec() - time_begin) / 1000000.0\n\t\t# Compensate.\n\t\ttime -= time_delay\n\telif sync_source == SyncSource.SOUND_CLOCK:\n\t\ttime = $Player.get_playback_position() + AudioServer.get_time_since_last_mix() - AudioServer.get_output_latency() + (1 / COMPENSATE_HZ) * COMPENSATE_FRAMES\n\n\tvar beat := int(time * BPM / 60.0)\n\tvar seconds := int(time)\n\tvar seconds_total := int($Player.stream.get_length())\n\t@warning_ignore(\"integer_division\")\n\t$Label.text = str(\"BEAT: \", beat % BARS + 1, \"/\", BARS, \" TIME: \", seconds / 60, \":\", str(seconds % 60).pad_zeros(2), \" / \", seconds_total / 60, \":\", str(seconds_total % 60).pad_zeros(2))\n\nfunc _on_PlaySystem_pressed() -> void:\n\tsync_source = SyncSource.SYSTEM_CLOCK\n\ttime_begin = Time.get_ticks_usec()\n\ttime_delay = AudioServer.get_time_to_next_mix() + AudioServer.get_output_latency()\n\tplaying = true\n\t$Player.play()\n\nfunc _on_PlaySound_pressed() -> void:\n\tsync_source = SyncSource.SOUND_CLOCK\n\tplaying = true\n\t$Player.play()\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "@tool\nextends BeehaveTree\n\n\n@export_range(1, 100) var randomize_node_count: int = 20\n@export var randomize_tree: bool = false:\n\tset(v):\n\t\tif !v:\n\t\t\treturn\n\t\trandomize_tree = false\n\t\t_randomize_tree()\n\n\nclass TNode extends RefCounted:\n\tvar children = []\n\n\nvar long_name_suffix = \"LooooooooongNameSuffix\"\n\n\nfunc get_name_suffix():\n\tvar r = randi_range(0, 0)\n\tif r:", "output": "\t\treturn long_name_suffix\n\treturn \"\"\n\nvar tree_root: TNode\nvar tree_nodes = []\n\nfunc _get_random_node():\n\treturn tree_nodes[randi_range(0, tree_nodes.size() - 1)]\n\nfunc _make_random_tree():\n\t# One node (the root) is already created\n\ttree_root = TNode.new()\n\ttree_nodes = [tree_root]\n\tfor i in randomize_node_count - 1:\n\t\tvar n = _get_random_node()\n\t\tvar new_node = TNode.new()\n\t\tn.children.append(new_node)\n\t\ttree_nodes.append(new_node)\n\nfunc _parse_tree_node(parent, node, index: int):\n\tvar n\n\tif node.children.size() > 1:\n\t\tn = SelectorReactiveComposite.new()\n\t\tn.name = \"SelectorReactiveComposite%s-%d\" % [get_name_suffix(), index]\n\telif node.children.size() == 1:\n\t\tn = InverterDecorator.new()\n\t\tn.name = \"InverterDecorator%s-%d\" % [get_name_suffix(), index]\n\telse:\n\t\tn = RandomAction.new()\n\t\tn.name = \"RandomAction%s-%d\" % [get_name_suffix(), index]\n\tparent.add_child(n)\n\tif Engine.is_editor_hint():\n\t\tn.owner = get_tree().get_edited_scene_root()\n\tvar i = 0\n\tfor ch in node.children:\n\t\t_parse_tree_node(n, ch, i)\n\t\ti += 1\n\nfunc _randomize_tree():\n\tfor ch in get_children():\n\t\tremove_child(ch)\n\t\tch.queue_free()\n\t_make_random_tree()\n\t_parse_tree_node(self, tree_root, 0)\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "## Find all collision shapes of a given mask within a specified search radius.\n##\n## The CollisionFinder is used to search for objects that contain a [CollisionObject2D]. In the \n## OpenRPG it serves as the cornerstone of the [Gameboard]/[Gamepiece] system, since objects \n## (gamepieces, terrain, etc.) are found dynamically by collision shape.\n##\n## [br][br]For example, to see if a given cell is occupied a CollisionFinder would be used to \n## [method search] for collision shapes at that cell's location.\n##\n## [br][br][b]Note:[/b] physics objects update on the physics 'tick' so changes in position often\n## need a single frame before they may be found by [method search].\nclass_name CollisionFinder\nextends RefCounted\n\n## Cache the search parameters to quickly perform multiple searches.", "output": "var query_parameters: PhysicsShapeQueryParameters2D\n\n# Cache the space state that will be queried.\nvar _space_state: PhysicsDirectSpaceState2D\n\nfunc _init(space_state: PhysicsDirectSpaceState2D, search_radius: float, collision_mask: int,\n\t\tfind_areas: = true) -> void:\n\t_space_state = space_state\n\n\tvar query_shape: = CircleShape2D.new()\n\tquery_shape.radius = search_radius\n\n\tquery_parameters = PhysicsShapeQueryParameters2D.new()\n\tquery_parameters.shape = query_shape\n\tquery_parameters.collision_mask = collision_mask\n\tquery_parameters.collide_with_areas = find_areas\n\n## Find all collision shapes intersecting the query shape at position (in global coordinates).\n##\n## Please see [method PhysicsDirectSpaceState2D.intersect_shape] for possible return values.\n## [br][br][b]Note:[/b] [code]position[/code] must be given in global coordinates.\nfunc search(position: Vector2) -> Array[Dictionary]:\n\t# To find collision shapes we'll query the PhysicsDirectSpaceState2D (usually from the main\n\t# viewport's current World2D). Any intersecting collision shape matching the provided collision\n\t# mask will be included in the results.\n\tquery_parameters.transform.origin = position\n\n\treturn _space_state.intersect_shape(query_parameters)\n"} {"instruction": "Erstelle eine GDScript-Funktion namens '_init':", "input": "", "output": "func _init(agent: GSAISteeringAgent) -> void:\n\tsuper._init(agent)\n\n# Appends a behavior to the internal array along with its `weight`.\nfunc add(behavior: GSAISteeringBehavior, weight: float) -> void:\n\tbehavior.agent = agent\n\t_behaviors.append({behavior = behavior, weight = weight}", "source": "extracted_function"} {"instruction": "Vervollständige den GDScript-Code:", "input": "extends Node\n\nvar thread\nvar mutex\nvar semaphore\nvar exit_thread = false\n\nvar time_max = 100 # Milliseconds.\n\nvar queue = []\nvar pending = {}\n\nfunc _lock(_caller):\n\tmutex.lock()\n\n\nfunc _unlock(_caller):\n\tmutex.unlock()\n\n\nfunc _post(_caller):\n\tsemaphore.post()\n\n\nfunc _wait(_caller):\n\tsemaphore.wait()\n\n\nfunc queue_resource(path, p_in_front = false):\n\t_lock(\"queue_resource\")\n\tif path in pending:\n\t\t_unlock(\"queue_resource\")\n\t\treturn\n\telif ResourceLoader.has_cached(path):\n\t\tvar res = ResourceLoader.load(path)\n\t\tpending[path] = res\n\t\t_unlock(\"queue_resource\")\n\t\treturn\n\telse:\n\t\tvar res = ResourceLoader.load_interactive(path)\n\t\tres.set_meta(\"path\", path)\n\t\tif p_in_front:\n\t\t\tqueue.insert(0, res)\n\t\telse:\n\t\t\tqueue.push_back(res)\n\t\tpending[path] = res\n\t\t_post(\"queue_resource\")\n\t\t_unlock(\"queue_resource\")\n\t\treturn\n\n\nfunc cancel_resource(path):\n\t_lock(\"cancel_resource\")\n\tif path in pending:\n\t\tif pending[path] is ResourceInteractiveLoader:", "output": "\t\t\tqueue.erase(pending[path])\n\t\tpending.erase(path)\n\t_unlock(\"cancel_resource\")\n\nfunc get_progress(path):\n\t_lock(\"get_progress\")\n\tvar ret = -1\n\tif path in pending:\n\t\tif pending[path] is ResourceInteractiveLoader:\n\t\t\tret = float(pending[path].get_stage()) / float(pending[path].get_stage_count())\n\t\telse:\n\t\t\tret = 1.0\n\t_unlock(\"get_progress\")\n\treturn ret\n\nfunc is_ready(path):\n\tvar ret\n\t_lock(\"is_ready\")\n\tif path in pending:\n\t\tret = !(pending[path] is ResourceInteractiveLoader)\n\telse:\n\t\tret = false\n\t_unlock(\"is_ready\")\n\treturn ret\n\nfunc _wait_for_resource(res, path):\n\t_unlock(\"wait_for_resource\")\n\twhile true:\n\t\tRenderingServer.force_sync()\n\t\tOS.delay_usec(16000) # Wait approximately 1 frame.\n\t\t_lock(\"wait_for_resource\")\n\t\tif queue.size() == 0 || queue[0] != res:\n\t\t\treturn pending[path]\n\t\t_unlock(\"wait_for_resource\")\n\nfunc get_resource(path):\n\t_lock(\"get_resource\")\n\tif path in pending:\n\t\tif pending[path] is ResourceInteractiveLoader:\n\t\t\tvar res = pending[path]\n\t\t\tif res != queue[0]:\n\t\t\t\tvar pos = queue.find(res)\n\t\t\t\tqueue.remove(pos)\n\t\t\t\tqueue.insert(0, res)\n\n\t\t\tres = _wait_for_resource(res, path)"} {"instruction": "Vervollständige den GDScript-Code:", "input": "extends Node\n\nsignal scroll_speed_changed(speed: float)\n\n@export var use_filtered_playback: bool = true\n", "output": "@export var enable_metronome: bool = false\n@export var input_latency_ms: int = 20\n\n@export var scroll_speed: float = 400:\n\tset(value):\n\t\tif scroll_speed != value:\n\t\t\tscroll_speed = value\n\t\t\tscroll_speed_changed.emit(value)\n@export var show_offsets: bool = false\n\n@export var selected_chart: ChartData.Chart = ChartData.Chart.THE_COMEBACK\n"} {"instruction": "Erstelle eine Godot-Klasse 'GSAIPriority' die von GSAISteeringBehavior erbt mit folgenden Funktionen: _init, add, get_behavior_at, _calculate_steering", "input": "", "output": "# Container for multiple behaviors that returns the result of the first child\n# behavior with non-zero acceleration.\n# @category - Combination behaviors\nclass_name GSAIPriority\nextends GSAISteeringBehavior\n\nvar _behaviors := []\n\n# The index of the last behavior the container prioritized.\nvar last_selected_index: int\n# If a behavior's acceleration is lower than this threshold, the container\n# considers it has an acceleration of zero.\nvar zero_threshold: float\n\nfunc _init(agent: GSAISteeringAgent, _zero_threshold := 0.001) -> void:\n\tsuper._init(agent)\n\tself.zero_threshold = _zero_threshold\n\n# Appends a steering behavior as a child of this container.\nfunc add(behavior: GSAISteeringBehavior) -> void:\n\t_behaviors.append(behavior)\n\n# Returns the behavior at the position in the pool referred to by `index`, or\n# `null` if no behavior was found.\nfunc get_behavior_at(index: int) -> GSAISteeringBehavior:\n\tif _behaviors.size() > index:\n\t\treturn _behaviors[index]\n\tprinterr(\"Tried to get index \" + str(index) + \" in array of size \" + str(_behaviors.size()))\n\treturn null\n\nfunc _calculate_steering(accel: GSAITargetAcceleration) -> void:\n\tvar threshold_squared := zero_threshold * zero_threshold\n\n\tlast_selected_index = -1\n\n\tvar size := _behaviors.size()\n\n\tif size > 0:\n\t\tfor i in range(size):\n\t\t\tlast_selected_index = i\n\t\t\tvar behavior: GSAISteeringBehavior = _behaviors[i]\n\t\t\tbehavior.calculate_steering(accel)\n\n\t\t\tif accel.get_magnitude_squared() > threshold_squared:\n\t\t\t\tbreak\n\telse:\n\t\taccel.set_zero()\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "@abstract class_name GdUnitFileAssert\nextends GdUnitAssert\n\n\n## Verifies that the current value is null.\n@abstract func is_null() -> GdUnitFileAssert\n\n\n## Verifies that the current value is not null.\n@abstract func is_not_null() -> GdUnitFileAssert\n\n\n## Verifies that the current value is equal to the given one.", "output": "@abstract func is_equal(expected: Variant) -> GdUnitFileAssert\n\n## Verifies that the current value is not equal to expected one.\n@abstract func is_not_equal(expected: Variant) -> GdUnitFileAssert\n\n## Overrides the default failure message by given custom message.\n@abstract func override_failure_message(message: String) -> GdUnitFileAssert\n\n## Appends a custom message to the failure message.\n@abstract func append_failure_message(message: String) -> GdUnitFileAssert\n\n@abstract func is_file() -> GdUnitFileAssert\n\n@abstract func exists() -> GdUnitFileAssert\n\n@abstract func is_script() -> GdUnitFileAssert\n\n@abstract func contains_exactly(expected_rows :Array) -> GdUnitFileAssert\n"} {"instruction": "Erstelle eine GDScript-Funktion namens '_init':", "input": "", "output": "func _init(agent: GSAISteeringAgent) -> void:\n\tsuper._init(agent)\n\n# Appends a behavior to the internal array along with its `weight`.\nfunc add(behavior: GSAISteeringBehavior, weight: float) -> void:\n\tbehavior.agent = agent\n\t_behaviors.append({behavior = behavior, weight = weight}"} {"instruction": "Vervollständige den GDScript-Code:", "input": "extends Control\n\nvar effect: AudioEffect\nvar recording: AudioStreamWAV\n\nvar stereo: bool = true\nvar mix_rate := 44100 # This is the default mix rate on recordings.\nvar format := AudioStreamWAV.FORMAT_16_BITS # This is the default format on recordings.\n\n\nfunc _ready() -> void:\n\tvar idx := AudioServer.get_bus_index(&\"Record\")\n\teffect = AudioServer.get_bus_effect(idx, 0)\n\n\nfunc _on_record_button_pressed() -> void:\n\tif effect.is_recording_active():\n\t\trecording = effect.get_recording()\n\t\t$PlayButton.disabled = false\n\t\t$SaveButton.disabled = false\n\t\teffect.set_recording_active(false)\n\t\trecording.set_mix_rate(mix_rate)\n\t\trecording.set_format(format)\n\t\trecording.set_stereo(stereo)\n\t\t$RecordButton.text = \"Record\"\n\t\t$Status.text = \"\"\n\telse:\n\t\t$PlayButton.disabled = true\n\t\t$SaveButton.disabled = true\n\t\teffect.set_recording_active(true)\n\t\t$RecordButton.text = \"Stop\"\n\t\t$Status.text = \"Status: Recording...\"\n", "output": "\nfunc _on_play_button_pressed() -> void:\n\tprint_rich(\"\\n[b]Playing recording:[/b] %s\" % recording)\n\tprint_rich(\"[b]Format:[/b] %s\" % (\"8-bit uncompressed\" if recording.format == 0 else \"16-bit uncompressed\" if recording.format == 1 else \"IMA ADPCM compressed\"))\n\tprint_rich(\"[b]Mix rate:[/b] %s Hz\" % recording.mix_rate)\n\tprint_rich(\"[b]Stereo:[/b] %s\" % (\"Yes\" if recording.stereo else \"No\"))\n\tvar data := recording.get_data()\n\tprint_rich(\"[b]Size:[/b] %s bytes\" % data.size())\n\t$AudioStreamPlayer.stream = recording\n\t$AudioStreamPlayer.play()\n\nfunc _on_play_music_pressed() -> void:\n\tif $AudioStreamPlayer2.playing:\n\t\t$AudioStreamPlayer2.stop()\n\t\t$PlayMusic.text = \"Play Music\"\n\telse:\n\t\t$AudioStreamPlayer2.play()\n\t\t$PlayMusic.text = \"Stop Music\"\n\nfunc _on_save_button_pressed() -> void:\n\tvar save_path: String = $SaveButton/Filename.text\n\trecording.save_to_wav(save_path)\n\t$Status.text = \"Status: Saved WAV file to: %s\\n(%s)\" % [save_path, ProjectSettings.globalize_path(save_path)]\n\nfunc _on_mix_rate_option_button_item_selected(index: int) -> void:\n\tmatch index:\n\t\t0:\n\t\t\tmix_rate = 11025\n\t\t1:\n\t\t\tmix_rate = 16000\n\t\t2:\n\t\t\tmix_rate = 22050\n\t\t3:\n\t\t\tmix_rate = 32000\n\t\t4:\n\t\t\tmix_rate = 44100\n\t\t5:\n\t\t\tmix_rate = 48000\n\tif recording != null:\n\t\trecording.set_mix_rate(mix_rate)\n\nfunc _on_format_option_button_item_selected(index: int) -> void:\n\tmatch index:\n\t\t0:\n\t\t\tformat = AudioStreamWAV.FORMAT_8_BITS\n\t\t1:"} {"instruction": "Vervollständige den GDScript-Code:", "input": "## An Assertion Tool to verify Vector values\n@abstract class_name GdUnitVectorAssert\nextends GdUnitAssert\n\n\n## Verifies that the current value is null.\n@abstract func is_null() -> GdUnitVectorAssert\n\n\n## Verifies that the current value is not null.\n@abstract func is_not_null() -> GdUnitVectorAssert\n\n\n## Verifies that the current value is equal to the given one.\n@abstract func is_equal(expected: Variant) -> GdUnitVectorAssert\n\n\n## Verifies that the current value is not equal to expected one.", "output": "@abstract func is_not_equal(expected: Variant) -> GdUnitVectorAssert\n\n## Verifies that the current and expected value are approximately equal.\n@abstract func is_equal_approx(expected: Variant, approx: Variant) -> GdUnitVectorAssert\n\n## Overrides the default failure message by given custom message.\n@abstract func override_failure_message(message: String) -> GdUnitVectorAssert\n\n## Appends a custom message to the failure message.\n@abstract func append_failure_message(message: String) -> GdUnitVectorAssert\n\n## Verifies that the current value is less than the given one.\n@abstract func is_less(expected: Variant) -> GdUnitVectorAssert\n\n## Verifies that the current value is less than or equal the given one.\n@abstract func is_less_equal(expected: Variant) -> GdUnitVectorAssert\n\n## Verifies that the current value is greater than the given one.\n@abstract func is_greater(expected: Variant) -> GdUnitVectorAssert\n\n## Verifies that the current value is greater than or equal the given one.\n@abstract func is_greater_equal(expected: Variant) -> GdUnitVectorAssert\n\n## Verifies that the current value is between the given boundaries (inclusive).\n@abstract func is_between(from: Variant, to: Variant) -> GdUnitVectorAssert\n\n## Verifies that the current value is not between the given boundaries (inclusive).\n@abstract func is_not_between(from: Variant, to: Variant) -> GdUnitVectorAssert\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "@tool\n## Encapsulates [Gamepiece] animation as an optional component.\n##\n## Allows playing animations that automatically adapt to the parent\n## [Gamepiece]'s direction by calling [method play]. Transitions between\n## animations are handled automatically, including changes to direction.\n## [br][br][b]Note:[/b] This is usually not added to the scene tree directly by\n## the designer.\n##\n## Rather, it is typically added to a [Gamepiece] through the [member Gamepiece.animation_scene]\n## property.\n@icon(\"res://assets/editor/icons/GamepieceAnimation.svg\")\nclass_name GamepieceAnimation extends Marker2D\n\n## Name of the animation sequence used to reset animation properties to default.\n## Note that this animation is only played for a single frame during animation\n## transitions.\nconst RESET_SEQUENCE_KEY: = \"RESET\"\n\n## Mapping that pairs cardinal [constant Directions.Points] with a [String] suffix.\nconst DIRECTION_SUFFIXES: = {\n\tDirections.Points.NORTH: \"_n\",\n\tDirections.Points.EAST: \"_e\",\n\tDirections.Points.SOUTH: \"_s\",\n\tDirections.Points.WEST: \"_w\",\n}\n\n## The animation currently being played.\nvar current_sequence_id: = \"\":\n\tset = play\n\n## The direction faced by the gamepiece.\n##\n## Animations may optionally be direction-based. Setting the direction will use\n## directional animations if they are available; otherwise non-directional\n## animations will be used.\nvar direction: = Directions.Points.SOUTH:", "output": "\tset = set_direction\n\n@onready var _anim: = $AnimationPlayer as AnimationPlayer\n\n## Change the currently playing animation to a new value, if it exists.\n##\n## Animations may be added with or without a directional suffix (i.e. _n for\n## north/up). Directional animations will be preferred with direction-less\n## animations as a fallback.\nfunc play(value: String) -> void:\n\tif value == current_sequence_id:\n\t\treturn\n\n\tif not is_inside_tree():\n\t\tawait ready\n\n\t# We need to check to see if the animation is valid. First of all, look for\n\t# a directional equivalent - e.g. idle_n. If that fails, look for the new\n\t# sequence id itself.\n\tvar sequence_suffix: String = DIRECTION_SUFFIXES.get(direction, \"\")\n\tif _anim.has_animation(value + sequence_suffix):\n\t\tcurrent_sequence_id = value\n\t\t_swap_animation(value + sequence_suffix, false)\n\n\telif _anim.has_animation(value):\n\t\tcurrent_sequence_id = value\n\t\t_swap_animation(value, false)\n\n## Change the animation's direction.\n##\n## If the currently running animation has a directional variant matching the new\n## direction it will be played. Otherwise the direction-less animation will\n## play.\nfunc set_direction(value: Directions.Points) -> void:\n\tif value == direction:\n\t\treturn\n\n\tdirection = value\n\n\tif not is_inside_tree():\n\t\tawait ready\n\n\tvar sequence_suffix: String = DIRECTION_SUFFIXES.get(direction, \"\")\n\tif _anim.has_animation(current_sequence_id + sequence_suffix):\n\t\t_swap_animation(current_sequence_id + sequence_suffix, true)\n\n\telif _anim.has_animation(current_sequence_id):\n\t\t_swap_animation(current_sequence_id, true)"} {"instruction": "Vervollständige den GDScript-Code:", "input": "extends OpenXRCompositionLayerEquirect\n\nconst NO_INTERSECTION = Vector2(-1.0, -1.0)\n\n@export var controller : XRController3D\n@export var button_action : String = \"select\"\n\nvar was_pressed : bool = false\nvar was_intersect : Vector2 = NO_INTERSECTION\n\n\n# Pass input events on to viewport.\nfunc _input(event):\n\tif not layer_viewport:\n\t\treturn\n\n\tif event is InputEventMouse:\n\t\t# Desktop mouse events do not translate so ignore.\n\t\treturn\n\n\t# Anything else, just pass on!\n\tlayer_viewport.push_input(event)\n\n\n# Convert the intersect point reurned by intersects_ray to local coords in the viewport.\nfunc _intersect_to_viewport_pos(intersect : Vector2) -> Vector2i:\n\tif layer_viewport and intersect != NO_INTERSECTION:", "output": "\t\tvar pos : Vector2 = intersect * Vector2(layer_viewport.size)\n\t\treturn Vector2i(pos)\n\telse:\n\t\treturn Vector2i(-1, -1)\n\n# Called every frame. 'delta' is the elapsed time since the previous frame.\nfunc _process(_delta):\n\tif not controller:\n\t\treturn\n\tif not layer_viewport:\n\t\treturn\n\n\tvar controller_t : Transform3D = controller.global_transform\n\tvar intersect : Vector2 = intersects_ray(controller_t.origin, -controller_t.basis.z)\n\n\tif intersect != NO_INTERSECTION:\n\t\tvar is_pressed : bool = controller.is_button_pressed(button_action)\n\n\t\tif was_intersect != NO_INTERSECTION and intersect != was_intersect:\n\t\t\t# Pointer moved\n\t\t\tvar event : InputEventMouseMotion = InputEventMouseMotion.new()\n\t\t\tvar from : Vector2 = _intersect_to_viewport_pos(was_intersect)\n\t\t\tvar to : Vector2 = _intersect_to_viewport_pos(intersect)\n\t\t\tif was_pressed:\n\t\t\t\tevent.button_mask = MOUSE_BUTTON_MASK_LEFT\n\t\t\tevent.relative = to - from\n\t\t\tevent.position = to\n\t\t\tlayer_viewport.push_input(event)\n\n\t\tif not is_pressed and was_pressed:\n\t\t\t# Button was let go?\n\t\t\tvar event : InputEventMouseButton = InputEventMouseButton.new()\n\t\t\tevent.button_index = MOUSE_BUTTON_LEFT\n\t\t\tevent.pressed = false\n\t\t\tevent.position = _intersect_to_viewport_pos(intersect)\n\t\t\tlayer_viewport.push_input(event)\n\n\t\telif is_pressed and not was_pressed:\n\t\t\t# Button was pressed?\n\t\t\tvar event : InputEventMouseButton = InputEventMouseButton.new()\n\t\t\tevent.button_index = MOUSE_BUTTON_LEFT\n\t\t\tevent.button_mask = MOUSE_BUTTON_MASK_LEFT\n\t\t\tevent.pressed = true\n\t\t\tevent.position = _intersect_to_viewport_pos(intersect)\n\t\t\tlayer_viewport.push_input(event)\n\n\t\twas_pressed = is_pressed\n\t\twas_intersect = intersect\n"} {"instruction": "Erstelle eine Godot-Klasse 'GamepieceAnimation' die von Marker2D erbt mit folgenden Funktionen: play, set_direction, _swap_animation", "input": "", "output": "@tool\n## Encapsulates [Gamepiece] animation as an optional component.\n##\n## Allows playing animations that automatically adapt to the parent\n## [Gamepiece]'s direction by calling [method play]. Transitions between\n## animations are handled automatically, including changes to direction.\n## [br][br][b]Note:[/b] This is usually not added to the scene tree directly by\n## the designer.\n##\n## Rather, it is typically added to a [Gamepiece] through the [member Gamepiece.animation_scene]\n## property.\n@icon(\"res://assets/editor/icons/GamepieceAnimation.svg\")\nclass_name GamepieceAnimation extends Marker2D\n\n## Name of the animation sequence used to reset animation properties to default.\n## Note that this animation is only played for a single frame during animation\n## transitions.\nconst RESET_SEQUENCE_KEY: = \"RESET\"\n\n## Mapping that pairs cardinal [constant Directions.Points] with a [String] suffix.\nconst DIRECTION_SUFFIXES: = {\n\tDirections.Points.NORTH: \"_n\",\n\tDirections.Points.EAST: \"_e\",\n\tDirections.Points.SOUTH: \"_s\",\n\tDirections.Points.WEST: \"_w\",\n}\n\n## The animation currently being played.\nvar current_sequence_id: = \"\":\n\tset = play\n\n## The direction faced by the gamepiece.\n##\n## Animations may optionally be direction-based. Setting the direction will use\n## directional animations if they are available; otherwise non-directional\n## animations will be used.\nvar direction: = Directions.Points.SOUTH:\n\tset = set_direction\n\n@onready var _anim: = $AnimationPlayer as AnimationPlayer\n\n## Change the currently playing animation to a new value, if it exists.\n##\n## Animations may be added with or without a directional suffix (i.e. _n for\n## north/up). Directional animations will be preferred with direction-less\n## animations as a fallback.\nfunc play(value: String) -> void:\n\tif value == current_sequence_id:\n\t\treturn\n\n\tif not is_inside_tree():\n\t\tawait ready\n\n\t# We need to check to see if the animation is valid. First of all, look for\n\t# a directional equivalent - e.g. idle_n. If that fa"} {"instruction": "Vervollständige den GDScript-Code:", "input": "@tool\n\nclass_name AreaTransition extends Trigger\n\n@export var arrival_coordinates: Vector2:\n\tset(value):\n\t\tarrival_coordinates = value\n\t\t\n\t\tif Engine.is_editor_hint():\n\t\t\tif not is_inside_tree():\n\t\t\t\tawait ready\n\t\t\t\n\t\t\tvar target = $Destination as Sprite2D\n\t\t\ttarget.position = arrival_coordinates - position\n\n\n#TODO: this will become a property of a given area once proper gameplay areas have been implemented.\n@export var new_music: AudioStream\n\n# The blackout timer is used to wait between fade-out and fade-in. No delay looks odd.\n@onready var _blackout_timer: = $BlackoutTimer as Timer\n\n\nfunc _ready() -> void:\n\tsuper._ready()\n\t", "output": "\tif not Engine.is_editor_hint():\n\t\t$Destination.queue_free()\n\n# Area transitions are given several opportunities to \"do something\" at various stages, such as\n# before the camera fades away, after it has faded, and immediately after it re-appears in the new\n# area.\n# This could include all manner of shenanigans, such as dropping in the on the Big Baddie's\n# monologue, showing the player's stalker after the player has left the scene, or playing out an\n# event that the player then walks into the middle of.\nfunc _on_area_entered(area: Area2D) -> void:\n\t# Pausing the field immediately will deactivate physics objects, which are in the middle of\n\t# processing (hence _on_area_entered). We need to wait a frame before pausing anything.\n\tawait get_tree().process_frame\n\n\t# Pause the field gamestate to prevent the player from wandering off mid-transition.\n\t_is_cutscene_in_progress = true\n\n\t# Cover the screen to hide the area transition.\n\tTransition.cover(0.25)\n\tawait Transition.finished\n\n\t# Move the gamepiece to it's new position and update the camera immediately.\n\tvar gamepiece: = area.owner as Gamepiece\n\tif gamepiece:\n\t\tgamepiece.stop()\n\t\tgamepiece.position = arrival_coordinates\n\t\tGamepieceRegistry.move_gamepiece(gamepiece, Gameboard.pixel_to_cell(arrival_coordinates))\n\n\t\tCamera.reset_position()\n\n\t# Let the screen rest in darkness for a little while. Revealing the screen immediately with no\n\t# delay looks 'off'.\n\t_blackout_timer.start()\n\tawait _blackout_timer.timeout\n\n\t# All kinds of shenanigans could happen once the screen blacks out. It may be asynchronous, so\n\t# give the opportunity for the designer to run a lengthy event.\n\t@warning_ignore(\"redundant_await\")\n\tawait _on_blackout()\n\n\t# Reveal the screen and unpause the field gamestate.\n\tTransition.clear(0.10)\n\tawait Transition.finished\n\n\t# Finally, unpause the field gameplay, allowing the player to move again.\n\t_is_cutscene_in_progress = false\n"} {"instruction": "Erstelle eine GDScript-Funktion namens 'get_value':", "input": "", "output": "func get_value(\n\tkey: Variant, default_value: Variant = null, blackboard_name: String = DEFAULT\n) -> Variant:\n\tif has_value(key, blackboard_name):\n\t\treturn _data[blackboard_name].get(key, default_value)\n\treturn default_value\n\nfunc has_value(key: Variant, blackboard_name: String = DEFAULT) -> bool:\n\treturn (\n\t\t_data.has(blackboard_name)\n\t\tand _data[blackboard_name].has(key)\n\t\tand _data[blackboard_name][key] != null\n\t)\n\nfunc erase_value(key: Variant, blackboard_name: String = DEFAULT) -> void:\n\tif _data.has(blackboard_name):\n\t\t_data[blackboard_name][key] = null\n\nfunc get_debug_data() -> Dictionary:\n\t# Avoid sending raw Objects (Nodes, Resources, etc.) over the\n\t# EngineDebugger connection, which can cause Variant marshalling errors\n\t# and break the editor debugger stream.\n\treturn _sanitize_for_debug(_data)\n\nstatic func _sanitize_for_debug(value: Variant, depth: int = 0) -> Variant:\n\t# Limit recursion depth defensively to avoid issues with deeply nested\n\t# or self‑referential data structures. At this point we only need a\n\t# human‑readable representation for the debugger UI.\n\tif depth > 4:\n\t\treturn str(value)\n\n\tvar t := typeof(value)\n\n\tmatch t:\n\t\tTYPE_DICTIONARY:\n\t\t\tvar result := {}", "source": "extracted_function"} {"instruction": "Erstelle eine GDScript-Funktion namens 'format_dict':", "input": "", "output": "func format_dict(value :Variant) -> String:\n\tif not value is Dictionary:\n\t\treturn str(value)\n\n\tvar dict_value: Dictionary = value\n\tif dict_value.is_empty():\n\t\treturn \"{ }", "source": "extracted_function"} {"instruction": "Vervollständige den GDScript-Code:", "input": "extends Node3D\n\n## The position of this node will be updated if a camera tracker is available.\n@export var tracked_camera : Node3D:\n\tset(value):\n\t\ttracked_camera = value\n\t\tif tracked_camera:\n\t\t\t%CameraRemoteTransform3D.remote_path = tracked_camera.get_path()\n\t\telse:\n\t\t\t%CameraRemoteTransform3D.remote_path = NodePath()\n\n# Enable the left or right pointer?\nvar left_or_right: int = 1", "output": "\n# Enable the pointer on the last controller we pressed a button on.\nfunc _enable_pointer():\n\t$XROrigin3D/LeftHandAim/XRPointer.enabled = left_or_right == 0\n\t$XROrigin3D/RightHandAim/XRPointer.enabled = left_or_right == 1\n\n# Called when the node enters the scene tree for the first time.\nfunc _ready():\n\t_enable_pointer()\n\n# We pressed a button on our left hand.\nfunc _on_left_hand_aim_button_pressed(_name):\n\t# Toggle to left hand.\n\tif left_or_right != 0:\n\t\tleft_or_right = 0\n\t\t_enable_pointer()\n\n# We pressed a button on our right hand.\nfunc _on_right_hand_aim_button_pressed(_name):\n\t# Toggle to right hand.\n\tif left_or_right != 1:\n\t\tleft_or_right = 1\n\t\t_enable_pointer()\n"} {"instruction": "Erstelle eine GDScript-Funktion namens 'add':", "input": "", "output": "func add(behavior: GSAISteeringBehavior, weight: float) -> void:\n\tbehavior.agent = agent\n\t_behaviors.append({behavior = behavior, weight = weight}"} {"instruction": "Vervollständige den GDScript-Code:", "input": "# Creates, maintains, and organizes spawned special effects or projectiles; \n# objects that should be untied from their spawners' lifespan when freed.\nextends Node\n\n@onready var _effects := $Effects\n@onready var _projectiles := $Projectiles\n@onready var _distortions: SubViewport\n", "output": "\nfunc register_effect(effect: Node) -> void:\n\t_effects.add_child(effect)\n\nfunc register_projectile(projectile: Node) -> void:\n\t_projectiles.add_child(projectile)\n\nfunc register_distortion_effect(effect: Node2D) -> void:\n\tif is_instance_valid(_distortions):\n\t\t_distortions.add_child(effect)\n\nfunc register_distortion_parent(viewport: SubViewport) -> void:\n\t_distortions = viewport\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "extends Node3D\n\n@onready var viewport: Viewport = get_viewport()\n@onready var environment: Environment = $WorldEnvironment.environment\n@onready var fade_message : FadeMessage3D = $XROrigin3D/FadeMessage3D\n\nvar passthrough_enabled: bool = false\n\n## Switch to AR (passthrough)\nfunc switch_to_ar() -> bool:\n\tvar xr_interface: OpenXRInterface = $StartVR.get_xr_interface()\n\tif not xr_interface:\n\t\treturn false\n\n\tvar modes = xr_interface.get_supported_environment_blend_modes()\n\tif XRInterface.XR_ENV_BLEND_MODE_ALPHA_BLEND in modes:\n\t\txr_interface.environment_blend_mode = XRInterface.XR_ENV_BLEND_MODE_ALPHA_BLEND\n\telif XRInterface.XR_ENV_BLEND_MODE_ADDITIVE in modes:\n\t\txr_interface.environment_blend_mode = XRInterface.XR_ENV_BLEND_MODE_ADDITIVE\n\telse:\n\t\tpush_error(\"Passthrough not supported!\")", "output": "\t\tfade_message.text = \"Passthrough is not supported on this device\"\n\t\treturn false\n\n\tviewport.transparent_bg = true\n\tenvironment.background_mode = Environment.BG_COLOR\n\tenvironment.background_color = Color(0.0, 0.0, 0.0, 0.0)\n\treturn true\n\n## Switch to VR (exit passthrough)\nfunc switch_to_vr() -> bool:\n\tvar xr_interface: OpenXRInterface = $StartVR.get_xr_interface()\n\tif not xr_interface:\n\t\treturn false\n\n\tvar modes = xr_interface.get_supported_environment_blend_modes()\n\tif XRInterface.XR_ENV_BLEND_MODE_OPAQUE in modes:\n\t\txr_interface.environment_blend_mode = XRInterface.XR_ENV_BLEND_MODE_OPAQUE\n\telse:\n\t\tpush_error(\"Opaque not supported!\")\n\t\tfade_message.text = \"Opaque mode is not supported on this device\"\n\t\treturn false\n\n\tviewport.transparent_bg = false\n\tenvironment.background_mode = Environment.BG_SKY\n\treturn true\n\n# Called when our OpenXR session has started.\nfunc _on_start_vr_session_started():\n\t# Make sure we're in passthrough mode.\n\tpassthrough_enabled = switch_to_ar()\n\n# Called when a button is pressed on either controller.\nfunc _on_button_released(action_name):\n\tif action_name == \"ax_button\":\n\t\t# Toggle passthrough\n\t\tif passthrough_enabled:\n\t\t\tswitch_to_vr()\n\t\t\tpassthrough_enabled = false\n\t\telse:\n\t\t\tpassthrough_enabled = switch_to_ar()\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "# Calculates an angular acceleration to match an agent's orientation to that of\n# its target. Attempts to make the agent arrive with zero remaining angular\n# velocity.\n# @category - Individual behaviors\nclass_name GSAIMatchOrientation\nextends GSAISteeringBehavior\n\n# The target orientation for the behavior to try and match rotations to.\nvar target: GSAIAgentLocation\n# The amount of distance in radians for the behavior to consider itself close\n# enough to be matching the target agent's rotation.\nvar alignment_tolerance: float\n# The amount of distance in radians from the goal to start slowing down.\nvar deceleration_radius: float\n# The amount of time to reach the target velocity\nvar time_to_reach: float = 0.1\n# Whether to use the X and Z components instead of X and Y components when\n# determining angles. X and Z should be used in 3D.", "output": "var use_z: bool\n\nfunc _init(agent: GSAISteeringAgent, _target: GSAIAgentLocation, _use_z := false) -> void:\n\tsuper._init(agent)\n\tself.use_z = _use_z\n\tself.target = _target\n\nfunc _match_orientation(acceleration: GSAITargetAcceleration, desired_orientation: float) -> void:\n\tvar rotation := wrapf(desired_orientation - agent.orientation, -PI, PI)\n\n\tvar rotation_size := absf(rotation)\n\n\tif rotation_size <= alignment_tolerance:\n\t\tacceleration.set_zero()\n\telse:\n\t\tvar desired_rotation := agent.angular_speed_max\n\n\t\tif rotation_size <= deceleration_radius:\n\t\t\tdesired_rotation *= rotation_size / deceleration_radius\n\n\t\tdesired_rotation *= rotation / rotation_size\n\n\t\tacceleration.angular = ((desired_rotation - agent.angular_velocity) / time_to_reach)\n\n\t\tvar limited_acceleration := absf(acceleration.angular)\n\t\tif limited_acceleration > agent.angular_acceleration_max:\n\t\t\tacceleration.angular *= (agent.angular_acceleration_max / limited_acceleration)\n\n\tacceleration.linear = Vector3.ZERO\n\nfunc _calculate_steering(acceleration: GSAITargetAcceleration) -> void:\n\t_match_orientation(acceleration, target.orientation)\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "# Presents a confirmation screen whether the player really intends on leaving\n# the game back to the main menu or not.\nextends MarginContainer\n\n@onready var yes_button := $VBoxContainer/HBoxContainer/YesButton\n@onready var no_button := $VBoxContainer/HBoxContainer/NoButton\n@onready var menu_sounds: MenuSoundPlayer = $MenuSoundPlayer\n\n\nfunc _ready() -> void:\n\tvisible = false\n\tset_process_input(false)\n\tfor button in [yes_button, no_button]:\n\t\tbutton.connect(\"focus_entered\", _on_Button_focus_entered)\n\n\nfunc _input(event: InputEvent) -> void:", "output": "\tif event.is_action_pressed(\"ui_cancel\"):\n\t\tclose()\n\t\tget_viewport().set_input_as_handled()\n\nfunc open() -> void:\n\tget_tree().paused = true\n\tmenu_sounds.play_open()\n\tshow()\n\tno_button.grab_focus()\n\tset_process_input(true)\n\nfunc close() -> void:\n\tmenu_sounds.play_close()\n\tget_tree().paused = false\n\tset_process_input(false)\n\thide()\n\nfunc request_quit() -> void:\n\tEvents.quit_requested.emit()\n\tclose()\n\nfunc _on_YesButton_pressed() -> void:\n\trequest_quit()\n\nfunc _on_NoButton_pressed() -> void:\n\tclose()\n\nfunc _on_Button_focus_entered() -> void:\n\tmenu_sounds.play_hide()\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "## An autoload that provides easy access to the player's state, including both Combat and Field\n## details.\n## Reference to the player's party, inventory, and currently active character are found here.\n## Additionally, game-wide player based signals are emitted from here.\nextends Node\n\n## Emitted whenever the player's gamepiece changes.", "output": "signal gamepiece_changed\n\n## Emitted when the player sets a movement path for their focused gamepiece.\n## The destination is the last cell in the path.\n@warning_ignore(\"unused_signal\")\nsignal player_path_set(gamepiece: Gamepiece, destination_cell: Vector2i)\n\n## The gamepeice that the player is currently controlling. This is a read-only property.\nvar gamepiece: Gamepiece = null:\n\tset(value):\n\t\tif value != gamepiece:\n\t\t\tgamepiece = value\n\t\t\tgamepiece_changed.emit()\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "# Represents a path made up of Vector3 waypoints, split into segments path\n# follow behaviors can use.\n# @category - Base types\nclass_name GSAIPath\nextends RefCounted\n\n# If `false`, the path loops.\nvar is_open: bool\n# Total length of the path.\nvar length: float\n\nvar _segments: Array\n\nvar _nearest_point_on_segment: Vector3\nvar _nearest_point_on_path: Vector3\n\n\nfunc _init(waypoints: Array, _is_open := false) -> void:\n\tself.is_open = _is_open\n\tcreate_path(waypoints)\n\t_nearest_point_on_segment = waypoints[0]\n\t_nearest_point_on_path = waypoints[0]\n\n\n# Creates a path from a list of waypoints.\nfunc create_path(waypoints: Array) -> void:\n\tif not waypoints or waypoints.size() < 2:\n\t\tprinterr(\"Waypoints cannot be null and must contain at least two (2) waypoints.\")\n\t\treturn\n\n\t_segments = []\n\tlength = 0\n\tvar current: Vector3 = waypoints.front()\n\tvar previous: Vector3\n\n\tfor i in range(1, waypoints.size(), 1):\n\t\tprevious = current\n\t\tif i < waypoints.size():\n\t\t\tcurrent = waypoints[i]\n\t\telif is_open:\n\t\t\tbreak\n\t\telse:\n\t\t\tcurrent = waypoints[0]\n\t\tvar segment := GSAISegment.new(previous, current)", "output": "\t\tlength += segment.length\n\t\tsegment.cumulative_length = length\n\t\t_segments.append(segment)\n\n# Returns the distance from `agent_current_position` to the next waypoint.\nfunc calculate_distance(agent_current_position: Vector3) -> float:\n\tif _segments.size() == 0:\n\t\treturn 0.0\n\tvar smallest_distance_squared: float = INF\n\tvar nearest_segment: GSAISegment\n\tfor i in range(_segments.size()):\n\t\tvar segment: GSAISegment = _segments[i]\n\t\tvar distance_squared := _calculate_point_segment_distance_squared(\n\t\t\tsegment.begin, segment.end, agent_current_position\n\t\t)\n\n\t\tif distance_squared < smallest_distance_squared:\n\t\t\t_nearest_point_on_path = _nearest_point_on_segment\n\t\t\tsmallest_distance_squared = distance_squared\n\t\t\tnearest_segment = segment\n\n\tvar length_on_path := (\n\t\tnearest_segment.cumulative_length\n\t\t- _nearest_point_on_path.distance_to(nearest_segment.end)\n\t)\n\n\treturn length_on_path\n\n# Calculates a target position from the path's starting point based on the `target_distance`.\nfunc calculate_target_position(target_distance: float) -> Vector3:\n\tif is_open:\n\t\ttarget_distance = clamp(target_distance, 0.0, length)\n\telse:\n\t\tif target_distance < 0:\n\t\t\ttarget_distance = length + fmod(target_distance, length)\n\t\telif target_distance > length:\n\t\t\ttarget_distance = fmod(target_distance, length)\n\n\tvar desired_segment: GSAISegment\n\tfor i in range(_segments.size()):\n\t\tvar segment: GSAISegment = _segments[i]\n\t\tif segment.cumulative_length >= target_distance:\n\t\t\tdesired_segment = segment\n\t\t\tbreak\n\n\tif not desired_segment:\n\t\tdesired_segment = _segments.back()\n"} {"instruction": "Erstelle eine GDScript-Funktion namens '_process':", "input": "", "output": "func _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": "extends Node2D\n\nconst Simple := preload(\"res://demo/agents/01_agent_melee_simple.tscn\")\nconst Charger := preload(\"res://demo/agents/02_agent_charger.tscn\")\nconst Imp := preload(\"res://demo/agents/03_agent_imp.tscn\")\nconst Skirmisher := preload(\"res://demo/agents/04_agent_skirmisher.tscn\")\nconst Ranged := preload(\"res://demo/agents/05_agent_ranged.tscn\")\nconst Combo := preload(\"res://demo/agents/06_agent_melee_combo.tscn\")\nconst Nuanced := preload(\"res://demo/agents/07_agent_melee_nuanced.tscn\")\nconst Demon := preload(\"res://demo/agents/08_agent_demon.tscn\")\nconst Summoner := preload(\"res://demo/agents/09_agent_summoner.tscn\")\n\nconst WAVES: Array = [\n\t[Simple, Simple, Nuanced],\n\t[Simple, Nuanced, Charger],\n\t[Simple, Simple, Simple, Ranged, Nuanced],\n\t[Simple, Simple, Summoner],\n\t[Ranged, Skirmisher, Nuanced, Simple, Simple],\n\t[Nuanced, Nuanced, Combo, Ranged, Simple],\n\t[Demon, Charger, Simple, Simple, Simple, Skirmisher],\n\t[Demon, Demon, Nuanced, Combo],\n\t[Summoner, Ranged, Nuanced, Nuanced, Ranged, Skirmisher, Simple],\n\t[Demon, Demon, Summoner, Skirmisher, Nuanced, Nuanced, Combo],\n]\n\n@export var wave_index: int = -1\n@export var agents_alive: int = 0\n", "output": "@onready var gong: StaticBody2D = $Gong\n@onready var player: CharacterBody2D = $Player\n@onready var spawn_points: Node2D = $SpawnPoints\n@onready var hp_bar: TextureProgressBar = %HPBar\n@onready var round_counter: Label = %RoundCounter\n\nfunc _ready() -> void:\n\thp_bar.max_value = player.get_health().max_health\n\tplayer.get_health().damaged.connect(func(_a,_b): hp_bar.value = player.get_health().get_current())\n\tplayer.death.connect(_on_player_death)\n\nfunc _update_round_counter() -> void:\n\tround_counter.text = \"Round %s/%s\" % [wave_index + 1, WAVES.size()]\n\nfunc _on_gong_gong_struck() -> void:\n\t_start_round()\n\nfunc _start_round() -> void:\n\twave_index += 1\n\tif wave_index >= WAVES.size():\n\t\tplayer.set_victorious()\n\t\tround_counter.text = \"Victorious!\"\n\t\treturn\n\n\tawait get_tree().create_timer(3.0).timeout\n\t_update_round_counter()\n\n\tvar spawns: Array = spawn_points.get_children()\n\tspawns.shuffle()\n\tfor i in WAVES[wave_index].size():\n\t\tvar agent_resource: PackedScene = WAVES[wave_index][i]\n\t\tvar agent: CharacterBody2D = agent_resource.instantiate()\n\t\tadd_child(agent)\n\t\tagent.global_position = spawns[i].global_position\n\t\tagent.death.connect(_on_agent_death)\n\t\tagent.play_summoning_effect()\n\t\tagents_alive += 1\n\nfunc _on_agent_death() -> void:\n\tagents_alive -= 1\n\tif agents_alive == 0:\n\t\t_start_round()\n\nfunc _on_player_death() -> void:"} {"instruction": "Vervollständige den GDScript-Code:", "input": "extends Node3D\n\n@export_enum(\"Left\", \"Right\") var hand : int = 0\n\n@export var fallback_mesh : Node3D\n\n# Called every frame. 'delta' is the elapsed time since the previous frame.\nfunc _process(delta):\n\tvar text = \"\"\n\n\tif hand == 0:\n\t\ttext += \"Left hand\\n\"\n\telse:\n\t\ttext += \"Right hand\\n\"\n\n\tvar controller_tracker : XRPositionalTracker = XRServer.get_tracker(&\"left_hand\" if hand == 0 else &\"right_hand\")\n\tif controller_tracker:\n\t\tvar profile = controller_tracker.profile.replace(\"/interaction_profiles/\", \"\").replace(\"/\", \" \")\n\t\ttext += \"\\nProfile: \" + profile + \"\\n\"\n\n\t\tvar pose : XRPose = controller_tracker.get_pose(&\"palm_pose\")\n\t\tif pose and pose.tracking_confidence != XRPose.XR_TRACKING_CONFIDENCE_NONE:", "output": "\t\t\ttext +=\" - Using palm pose\\n\"\n\t\telse:\n\t\t\tpose = controller_tracker.get_pose(&\"grip\")\n\t\t\tif pose:\n\t\t\t\ttext +=\" - Using grip pose\\n\"\n\n\t\tif pose:\n\t\t\tif pose.tracking_confidence == XRPose.XR_TRACKING_CONFIDENCE_NONE:\n\t\t\t\ttext += \"- No tracking data\\n\"\n\t\t\telif pose.tracking_confidence == XRPose.XR_TRACKING_CONFIDENCE_LOW:\n\t\t\t\ttext += \"- Low confidence tracking data\\n\"\n\t\t\telif pose.tracking_confidence == XRPose.XR_TRACKING_CONFIDENCE_HIGH:\n\t\t\t\ttext += \"- High confidence tracking data\\n\"\n\t\t\telse:\n\t\t\t\ttext += \"- Unknown tracking data %d \\n\" % [ pose.tracking_confidence ]\n\t\telse:\n\t\t\ttext += \"- No pose data\\n\"\n\telse:\n\t\ttext += \"\\nNo controller tracker found!\\n\"\n\n\tvar hand_tracker : XRHandTracker = XRServer.get_tracker(&\"/user/hand_tracker/left\" if hand == 0 else &\"/user/hand_tracker/right\")\n\tif hand_tracker:\n\t\ttext += \"\\nHand tracker found\\n\"\n\n\t\t# Report data source specified\n\t\tif hand_tracker.hand_tracking_source == XRHandTracker.HAND_TRACKING_SOURCE_UNKNOWN:\n\t\t\ttext += \"- Source: unknown\\n\"\n\t\telif hand_tracker.hand_tracking_source == XRHandTracker.HAND_TRACKING_SOURCE_UNOBSTRUCTED:\n\t\t\ttext += \"- Source: optical hand tracking\\n\"\n\t\telif hand_tracker.hand_tracking_source == XRHandTracker.HAND_TRACKING_SOURCE_CONTROLLER:\n\t\t\ttext += \"- Source: inferred from controller\\n\"\n\t\telif hand_tracker.hand_tracking_source == XRHandTracker.HAND_TRACKING_SOURCE_NOT_TRACKED:\n\t\t\ttext += \"- Source: no source\\n\"\n\t\telse:\n\t\t\ttext += \"- Source: %d\\n\" % [ hand_tracker.hand_tracking_source ]\n\n\t\t# If we're not tracking, show our fallback mesh on our controller tracking.\n\t\t# If we're also not controller tracking, we can't show anything.\n\t\t# Note: this is only a sphere in this example.\n\t\tif fallback_mesh:\n\t\t\tfallback_mesh.visible = not hand_tracker.has_tracking_data\n\telse:\n\t\ttext += \"\\nNo hand tracker found!\\n\"\n\n\t$Info.text = text\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "@tool\n# An interaction that opens and closes an animated chest and adds an item to the player's inventory.\n# The item is only added the first time the player opens the chest.\nextends Interaction\n\n@export var anim: AnimationPlayer\n@export var popup: InteractionPopup\n\nvar item_type: Inventory.ItemTypes\nvar amount: = 1\n\nvar _is_open: = false", "output": "var _item_received: = false:\n\tset(value):\n\t\t_item_received = value\n\t\tif _item_received:\n\t\t\tpopup.hide_and_free()\n\n# Open or close the chest, depending on whether it is closed or open.\n# If this is the first time opening it, apply the items inside to the player's inventory.\nfunc _execute() -> void:\n\tif _is_open:\n\t\tanim.play(\"close\")\n\t\tawait anim.animation_finished\n\t\t_is_open = false\n\n\telse:\n\t\tanim.play(\"open\")\n\t\tawait anim.animation_finished\n\n\t\tif not _item_received:\n\t\t\tInventory.restore().add(item_type, amount)\n\t\t\t_item_received = true\n\n\t\t_is_open = true\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "extends AudioStreamPlayer\n\n@export var conductor: Conductor\n\nvar _playing: bool = false\nvar _last_beat: float = -17 # 16 beat count-in\nvar _cached_latency: float = AudioServer.get_output_latency()\n", "output": "\nfunc _process(_delta: float) -> void:\n\tif not _playing:\n\t\treturn\n\n\t# Note that this implementation is flawed since every tick is rounded to the\n\t# next mix window (~11ms at the default 44100 Hz mix rate) due to Godot's\n\t# audio mix buffer. Precise audio scheduling is requested in\n\t# https://github.com/godotengine/godot-proposals/issues/1151.\n\tvar curr_beat := conductor.get_current_beat() + _cached_latency\n\tif GlobalSettings.enable_metronome and floor(curr_beat) > floor(_last_beat):\n\t\tplay()\n\t_last_beat = max(_last_beat, curr_beat)\n\nfunc start() -> void:\n\t_playing = true\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "# 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", "output": "\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": "Erstelle eine Godot-Klasse 'ScreenTransition' die von CanvasLayer erbt mit folgenden Funktionen: _ready, clear, cover, _tween_transition", "input": "", "output": "## A transition (usually between gameplay scenes) in which the screen is hidden behind an opaque\n## color and then shown again.\n##\n## Screen transitions are often used in [Cutscenes] to cover up changes in the scenery or sudden\n## changes to the loaded area. Many games begin with the screen covered and play some kind of\n## animation before transitioning (see [method reveal]) to gameplay.\n##\n## [br][br]ScreenTransitions cover or reveal the screen uniformly as a fade animation.\nclass_name ScreenTransition extends CanvasLayer\n\n## Emitted when the screen has finished the current animation, whether that is to [method cover] the\n## screen or [method reveal] the screen.\nsignal finished\n\n## The modulate color of the scene when it is to be invisible. Note that it is just\n## [constant Color.WHITE] with a zero alpha channel.\nconst CLEAR: = Color(1, 1, 1, 0)\n\n## The target modulate value of the scene when the transition covers the screen. Note that it is\n## just [constant Color.WHITE].\n## Consequently, the color of the screen transition may be set through the [member color] property.\nconst COVERED: = Color.WHITE\n\nvar _tween: Tween\n\n@onready var _color_rect: = $ColorRect as ColorRect\n\nfunc _ready() -> void:\n\t# The screen transitions need to run over the gameplay, which is instantiated below all\n\t# autoloads (including this class). Therefore, we want to move the ScreenTransition object to\n\t# the very bottom of the SceneTree's child list.\n\t# We cannot do so during ready, in which this node's parents are not yet ready. Therefore the\n\t# call to move_child must be deferred a frame.\n\tget_parent().move_child.call_deferred(self, get_parent().get_child_count()-1)\n\n\t# Allow the mouse through the transition GUI elements.\n\t_color_rect.mouse_filter = Control.MOUSE_FILTER_IGNORE\n\n\t# By default, do NOT have the ColorRect covering the screen.\n\tshow()\n\tclear()\n\n## Hide the ColorRect instantly, unless the duration argument is non-zero.\n## This method is a coroutine that will finish once the s"} {"instruction": "Erstelle eine Godot-Klasse 'GSAICohesion' die von GSAIGroupBehavior erbt mit folgenden Funktionen: _init, _calculate_steering, _report_neighbor", "input": "", "output": "# Calculates an acceleration that attempts to move the agent towards the center\n# of mass of the agents in the area defined by the `GSAIProximity`.\n# @category - Group behaviors\nclass_name GSAICohesion\nextends GSAIGroupBehavior\n\nvar _center_of_mass: Vector3\n\nfunc _init(agent: GSAISteeringAgent, proximity: GSAIProximity) -> void:\n\tsuper._init(agent, proximity)\n\nfunc _calculate_steering(acceleration: GSAITargetAcceleration) -> void:\n\tacceleration.set_zero()\n\t_center_of_mass = Vector3.ZERO\n\tvar neighbor_count = proximity._find_neighbors(_callback)\n\tif neighbor_count > 0:\n\t\t_center_of_mass *= 1.0 / neighbor_count\n\t\tacceleration.linear = (\n\t\t\t(_center_of_mass - agent.position).normalized()\n\t\t\t* agent.linear_acceleration_max\n\t\t)\n\n# Callback for the proximity to call when finding neighbors. Adds `neighbor`'s position\n# to the center of mass of the group.\n# @tags - virtual\nfunc _report_neighbor(neighbor: GSAISteeringAgent) -> bool:\n\t_center_of_mass += neighbor.position\n\treturn true\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "# Copyright (c) 2023 Patryk Kalinowski (patrykkalinowski.com)\n# SPDX-License-Identifier: MIT\n\n## Implementation of the 1€ filter (https://gery.casiez.net/1euro/).[br]\n## Modification of https://github.com/patrykkalinowski/godot-xr-kit/blob/master/addons/xr-kit/smooth-input-filter/scripts/one_euro_filter.gd\nclass_name OneEuroFilter\n\nvar min_cutoff: float\nvar beta: float\nvar d_cutoff: float\nvar x_filter: LowPassFilter\nvar dx_filter: LowPassFilter\n\nfunc _init(args: Variant) -> void:\n\tmin_cutoff = args.cutoff\n\tbeta = args.beta\n\td_cutoff = args.cutoff", "output": "\tx_filter = LowPassFilter.new()\n\tdx_filter = LowPassFilter.new()\n\nfunc alpha(rate: float, cutoff: float) -> float:\n\tvar tau: float = 1.0 / (2 * PI * cutoff)\n\tvar te: float = 1.0 / rate\n\n\treturn 1.0 / (1.0 + tau/te)\n\nfunc filter(value: float, delta: float) -> float:\n\tvar rate: float = 1.0 / delta\n\tvar dx: float = (value - x_filter.last_value) * rate\n\n\tvar edx: float = dx_filter.filter(dx, alpha(rate, d_cutoff))\n\tvar cutoff: float = min_cutoff + beta * abs(edx)\n\treturn x_filter.filter(value, alpha(rate, cutoff))\n\nclass LowPassFilter:\n\tvar last_value: float\n\n\tfunc _init() -> void:\n\t\tlast_value = 0\n\n\tfunc filter(value: float, alpha: float) -> float:\n\t\tvar result := alpha * value + (1 - alpha) * last_value\n\t\tlast_value = result\n\n\t\treturn result\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 Godot-Klasse 'GdUnitGodotErrorAssert' die von GdUnitAssert erbt mit folgenden Funktionen: is_null, is_not_null, is_equal, is_not_equal, override_failure_message", "input": "", "output": "## An assertion tool to verify for Godot runtime errors like assert() and push notifications like push_error().\n@abstract class_name GdUnitGodotErrorAssert\nextends GdUnitAssert\n\n## Verifies that the current value is null.\n@abstract func is_null() -> GdUnitGodotErrorAssert\n\n## Verifies that the current value is not null.\n@abstract func is_not_null() -> GdUnitGodotErrorAssert\n\n## Verifies that the current value is equal to the given one.\n@abstract func is_equal(expected: Variant) -> GdUnitGodotErrorAssert\n\n## Verifies that the current value is not equal to expected one.\n@abstract func is_not_equal(expected: Variant) -> GdUnitGodotErrorAssert\n\n## Overrides the default failure message by given custom message.\n@abstract func override_failure_message(message: String) -> GdUnitGodotErrorAssert\n\n## Appends a custom message to the failure message.\n@abstract func append_failure_message(message: String) -> GdUnitGodotErrorAssert\n\n## Verifies if the executed code runs without any runtime errors\n## Usage:\n## [codeblock]\n##\t\tawait assert_error().is_success()\n## [/codeblock]\n@abstract func is_success() -> GdUnitGodotErrorAssert\n\n## Verifies if the executed code runs into a runtime error\n## Usage:\n## [codeblock]\n##\t\tawait assert_error().is_runtime_error()\n## [/codeblock]\n@abstract func is_runtime_error(expected_error: Variant) -> GdUnitGodotErrorAssert\n\n## Verifies if the executed code has a push_warning() used\n## Usage:\n## [codeblock]\n##\t\tawait assert_error().is_push_warning()\n## [/codeblock]\n@abstract func is_push_warning(expected_warning: Variant) -> GdUnitGodotErrorAssert\n\n## Verifies if the executed code has a push_error() used\n## Usage:\n## [codeblock]\n##\t\tawait assert_error().is_push_error()\n## [/codeblock]\n@abstract func is_push_error(expected_error: Variant) -> GdUnitGodotErrorAssert\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "## A signal bus to connect distant scenes to various field-exclusive events.\nextends Node\n\n## Set this object's process priority to a very high number.\n## We want the Field Event manager's _process method to run after all Gamepieces and Controllers.\nconst PROCESS_PRIORITY: = 99999999\n\n## Emitted when the cursor moves to a new position on the field gameboard.\n@warning_ignore(\"unused_signal\")\nsignal cell_highlighted(cell: Vector2i)\n\n## Emitted when the player selects a cell on the field gameboard via the [FieldCursor].\n@warning_ignore(\"unused_signal\")\nsignal cell_selected(cell: Vector2i)", "output": "\n## Emitted when the player selects a cell that is covered by an [Interaction].\n@warning_ignore(\"unused_signal\")\nsignal interaction_selected(interaction: Interaction)\n\n### Emitted when the player moves over a cell containing a [Trigger].\n#@warning_ignore(\"unused_signal\")\n#signal interaction_selected(interaction: Interaction)\n\n## Emitted whenever a combat is triggered. This will lead to a transition from the field 'state' to\n## a combat 'state'.\n@warning_ignore(\"unused_signal\")\nsignal combat_triggered(arena: PackedScene)\n\n## Emitted when a [Cutscene] begins, signalling that the player should yield control of their\n## character to the cutscene code.\n@warning_ignore(\"unused_signal\")\nsignal cutscene_began\n\n## Emitted when a [Cutscene] ends, restoring normal mode of play.\n@warning_ignore(\"unused_signal\")\nsignal cutscene_ended\n\n## Emitted whenever ALL input within the field state is to be paused or resumed.\n## Typically emitted by combat, dialogues, etc.\n@warning_ignore(\"unused_signal\")\nsignal input_paused(is_paused: bool)\n"} {"instruction": "Erstelle eine Godot-Klasse 'GSAIProximity' die von RefCounted erbt mit folgenden Funktionen: _init, _find_neighbors", "input": "", "output": "# Base container type that stores data to find the neighbors of an agent.\n# @category - Proximities\n# @tags - abstract\nclass_name GSAIProximity\nextends RefCounted\n\n# The owning agent whose neighbors are found in the group\nvar agent: GSAISteeringAgent\n# The agents who are part of this group and could be potential neighbors\nvar agents := []\n\nfunc _init(_agent: GSAISteeringAgent, _agents: Array) -> void:\n\tself.agent = _agent\n\tself.agents = _agents\n\n# Returns a number of neighbors based on a `callback` function.\n#\n# `_find_neighbors` calls `callback` for each agent in the `agents` array and\n# adds one to the count if its `callback` returns true.\n# @tags - virtual\nfunc _find_neighbors(_callback: Callable) -> int:\n\treturn 0\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "## An Assertion Tool to verify function callback values\n@abstract class_name GdUnitFuncAssert\nextends GdUnitAssert\n\n\n## Verifies that the current value is null.\n@abstract func is_null() -> GdUnitFuncAssert\n\n\n## Verifies that the current value is not null.\n@abstract func is_not_null() -> GdUnitFuncAssert\n\n\n## Verifies that the current value is equal to the given one.", "output": "@abstract func is_equal(expected: Variant) -> GdUnitFuncAssert\n\n## Verifies that the current value is not equal to expected one.\n@abstract func is_not_equal(expected: Variant) -> GdUnitFuncAssert\n\n## Overrides the default failure message by given custom message.\n@abstract func override_failure_message(message: String) -> GdUnitFuncAssert\n\n## Appends a custom message to the failure message.\n@abstract func append_failure_message(message: String) -> GdUnitFuncAssert\n\n## Verifies that the current value is true.\n@abstract func is_true() -> GdUnitFuncAssert\n\n## Verifies that the current value is false.\n@abstract func is_false() -> GdUnitFuncAssert\n\n## Sets the timeout in ms to wait the function returnd the expected value, if the time over a failure is emitted.[br]\n## e.g.[br]\n## do wait until 5s the function `is_state` is returns 10 [br]\n## [code]assert_func(instance, \"is_state\").wait_until(5000).is_equal(10)[/code]\n@abstract func wait_until(timeout: int) -> GdUnitFuncAssert\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "#*\n#* move_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## Move state.", "output": "\nconst VERTICAL_FACTOR := 0.8\n\n@export var animation_player: AnimationPlayer\n@export var animation: StringName\n@export var speed: float = 500.0\n\nfunc _enter() -> void:\n\tanimation_player.play(animation, 0.1)\n\nfunc _update(_delta: float) -> void:\n\tvar horizontal_move: float = Input.get_axis(&\"move_left\", &\"move_right\")\n\tvar vertical_move: float = Input.get_axis(&\"move_up\", &\"move_down\")\n\n\tif not is_zero_approx(horizontal_move):\n\t\tagent.face_dir(horizontal_move)\n\n\tvar desired_velocity := Vector2(horizontal_move, vertical_move * VERTICAL_FACTOR) * speed\n\tagent.move(desired_velocity)\n\n\tif horizontal_move == 0.0 and vertical_move == 0.0:\n\t\tget_root().dispatch(EVENT_FINISHED)\n"} {"instruction": "Erstelle eine Godot-Klasse 'GdUnitAssertions' die von RefCounted erbt mit folgenden Funktionen: _init, __lazy_load, validate_value_type, get_line_number", "input": "", "output": "# Preloads all GdUnit assertions\nclass_name GdUnitAssertions\nextends RefCounted\n\n@warning_ignore(\"return_value_discarded\")\nfunc _init() -> void:\n\t# preload all gdunit assertions to speedup testsuite loading time\n\t# gdlint:disable=private-method-call\n\t@warning_ignore_start(\"return_value_discarded\")\n\tGdUnitAssertions.__lazy_load(\"res://addons/gdUnit4/src/asserts/GdUnitAssertImpl.gd\")\n\tGdUnitAssertions.__lazy_load(\"res://addons/gdUnit4/src/asserts/GdUnitBoolAssertImpl.gd\")\n\tGdUnitAssertions.__lazy_load(\"res://addons/gdUnit4/src/asserts/GdUnitStringAssertImpl.gd\")\n\tGdUnitAssertions.__lazy_load(\"res://addons/gdUnit4/src/asserts/GdUnitIntAssertImpl.gd\")\n\tGdUnitAssertions.__lazy_load(\"res://addons/gdUnit4/src/asserts/GdUnitFloatAssertImpl.gd\")\n\tGdUnitAssertions.__lazy_load(\"res://addons/gdUnit4/src/asserts/GdUnitVectorAssertImpl.gd\")\n\tGdUnitAssertions.__lazy_load(\"res://addons/gdUnit4/src/asserts/GdUnitArrayAssertImpl.gd\")\n\tGdUnitAssertions.__lazy_load(\"res://addons/gdUnit4/src/asserts/GdUnitDictionaryAssertImpl.gd\")\n\tGdUnitAssertions.__lazy_load(\"res://addons/gdUnit4/src/asserts/GdUnitFileAssertImpl.gd\")\n\tGdUnitAssertions.__lazy_load(\"res://addons/gdUnit4/src/asserts/GdUnitObjectAssertImpl.gd\")\n\tGdUnitAssertions.__lazy_load(\"res://addons/gdUnit4/src/asserts/GdUnitResultAssertImpl.gd\")\n\tGdUnitAssertions.__lazy_load(\"res://addons/gdUnit4/src/asserts/GdUnitFuncAssertImpl.gd\")\n\tGdUnitAssertions.__lazy_load(\"res://addons/gdUnit4/src/asserts/GdUnitSignalAssertImpl.gd\")\n\tGdUnitAssertions.__lazy_load(\"res://addons/gdUnit4/src/asserts/GdUnitFailureAssertImpl.gd\")\n\tGdUnitAssertions.__lazy_load(\"res://addons/gdUnit4/src/asserts/GdUnitGodotErrorAssertImpl.gd\")\n\t@warning_ignore_restore(\"return_value_discarded\")\n\n### We now load all used asserts and tool scripts into the cache according to the principle of \"lazy loading\"\n### in order to noticeably reduce the loading time of the test suite.\n# We go this hard way to increase the loading performance to avoid reparsing all the used scrip"} {"instruction": "Vervollständige den GDScript-Code:", "input": "## A tuple implementation for GdUnit4 test assertions and value extraction.\n## @tutorial(GdUnit4 Array Assertions): https://mikeschulze.github.io/gdUnit4/latest/testing/assert-array/#extractv\n## @tutorial(GdUnit4 Testing Framework): https://mikeschulze.github.io/gdUnit4/\n## [br]\n## The GdUnitTuple class is a utility container designed specifically for the GdUnit4\n## testing framework. It enables advanced assertion operations, particularly when\n## extracting and comparing multiple values from complex test results.\n## [br]\n## [b]Primary Use Cases in Testing:[/b] [br]\n## - Extracting multiple properties from test objects with [method extractv]## [br]\n## - Grouping related assertion values for comparison## [br]\n## - Returning multiple values from test helper methods## [br]\n## - Organizing expected vs actual value pairs in assertions## [br]\n## [br]\n## [b]Example Usage in Tests:[/b]\n## [codeblock]\n## func test_player_stats_after_level_up():\n## var player = Player.new()\n## player.level_up()\n##\n## # Extract multiple properties using tuple\n## assert_array([player]) \\\n## .extractv(extr(\"name\"), extr(\"level\"), extr(\"hp\")) \\\n## .contains(tuple(\"Hero\", 2, 150))\n##\n## func test_enemy_spawn_positions():\n## var enemies: Array = spawn_enemies(3)\n##\n## # Verify multiple enemies have correct position data", "output": "## assert_array(enemies) \\\n## .extractv(extr(\"position.x\"), extr(\"position.y\")) \\\n## .contains_exactly([\n## tuple(100, 200),\n## tuple(150, 200),\n## tuple(200, 200)\n## ])\n## [/codeblock]\n## [br]\n## [b]Integration with GdUnit4 Assertions:[/b] [br]\n## Tuples work seamlessly with array assertion methods like: [br]\n## - [code]contains()[/code] - Check if extracted values contain specific tuples [br]\n## - [code]contains_exactly()[/code] - Verify exact tuple matches [br]\n## - [code]is_equal()[/code] - Compare tuple equality [br]\n## [br]\n## [b]Note:[/b] This class is part of the GdUnit4 testing framework's internal\n## utilities and is primarily intended for use within test assertions rather\n## than production code.\nclass_name GdUnitTuple\nextends RefCounted\n\nvar _values: Array = []\n\n## Initializes a new GdUnitTuple with test values.\n## [br]\n## Creates a tuple to hold multiple values extracted from test objects\n## or expected values for assertions. Commonly used with the [code]tuple()[/code]\n## helper function in GdUnit4 tests.\n## [br]\n## [b]Parameters:[/b]\n## - [code]...args[/code]: Variable number of values to store.\nfunc _init(...args: Array) -> void:\n\t_values = args\n\n## Returns the tuple's values as an array for assertion comparisons.\n## [br]\n## Provides access to the stored test values. Used internally by GdUnit4's\n## assertion system when comparing tuples in test validations.\n## [br]\n## [b]Returns:[/b]\n## An [Array] containing all values stored in the tuple.\nfunc values() -> Array:\n\treturn _values\n\n## Returns a string representation for test output and debugging.\n## [br]\n## Formats the tuple for display in test results, error messages, and debug logs."} {"instruction": "Vervollständige den GDScript-Code:", "input": "extends GdUnitDictionaryAssert\n\nvar _base: GdUnitAssertImpl\n\n\nfunc _init(current :Variant) -> void:\n\t_base = GdUnitAssertImpl.new(current)\n\t# save the actual assert instance on the current thread context\n\tGdUnitThreadManager.get_current_context().set_assert(self)\n\tif not GdUnitAssertions.validate_value_type(current, TYPE_DICTIONARY):\n\t\t@warning_ignore(\"return_value_discarded\")\n\t\treport_error(\"GdUnitDictionaryAssert inital error, unexpected type <%s>\" % GdObjects.typeof_as_string(current))\n\n\nfunc _notification(event :int) -> void:\n\tif event == NOTIFICATION_PREDELETE:\n\t\tif _base != null:\n\t\t\t_base.notification(event)\n\t\t\t_base = null\n\n\nfunc report_success() -> GdUnitDictionaryAssert:\n\t@warning_ignore(\"return_value_discarded\")\n\t_base.report_success()\n\treturn self\n\n\nfunc report_error(error :String) -> GdUnitDictionaryAssert:\n\t@warning_ignore(\"return_value_discarded\")\n\t_base.report_error(error)\n\treturn self\n\n\nfunc failure_message() -> String:\n\treturn _base.failure_message()\n\n\nfunc override_failure_message(message: String) -> GdUnitDictionaryAssert:\n\t@warning_ignore(\"return_value_discarded\")\n\t_base.override_failure_message(message)\n\treturn self\n\n\nfunc append_failure_message(message: String) -> GdUnitDictionaryAssert:\n\t@warning_ignore(\"return_value_discarded\")\n\t_base.append_failure_message(message)\n\treturn self\n\n\nfunc current_value() -> Variant:\n\treturn _base.current_value()\n\n\nfunc is_null() -> GdUnitDictionaryAssert:\n\t@warning_ignore(\"return_value_discarded\")\n\t_base.is_null()\n\treturn self\n\n\nfunc is_not_null() -> GdUnitDictionaryAssert:\n\t@warning_ignore(\"return_value_discarded\")\n\t_base.is_not_null()\n\treturn self\n\n\nfunc is_equal(expected: Variant) -> GdUnitDictionaryAssert:\n\tvar current :Variant = current_value()\n\tif current == null:\n\t\treturn report_error(GdAssertMessages.error_equal(null, GdAssertMessages.format_dict(expected)))", "output": "\tif not GdObjects.equals(current, expected):\n\t\tvar c := GdAssertMessages.format_dict(current)\n\t\tvar e := GdAssertMessages.format_dict(expected)\n\t\treturn report_error(GdAssertMessages.error_equal(c, e))\n\treturn report_success()\n\nfunc is_not_equal(expected: Variant) -> GdUnitDictionaryAssert:\n\tvar current: Variant = current_value()\n\tif GdObjects.equals(current, expected):\n\t\treturn report_error(GdAssertMessages.error_not_equal(current, expected))\n\treturn report_success()\n\n@warning_ignore(\"unused_parameter\", \"shadowed_global_identifier\")\nfunc is_same(expected :Variant) -> GdUnitDictionaryAssert:\n\tvar current :Variant = current_value()\n\tif current == null:\n\t\treturn report_error(GdAssertMessages.error_equal(null, GdAssertMessages.format_dict(expected)))\n\tif not is_same(current, expected):\n\t\tvar c := GdAssertMessages.format_dict(current)\n\t\tvar e := GdAssertMessages.format_dict(expected)\n\t\treturn report_error(GdAssertMessages.error_is_same(c, e))\n\treturn report_success()\n\n@warning_ignore(\"unused_parameter\", \"shadowed_global_identifier\")\nfunc is_not_same(expected :Variant) -> GdUnitDictionaryAssert:\n\tvar current :Variant = current_value()\n\tif is_same(current, expected):\n\t\treturn report_error(GdAssertMessages.error_not_same(current, expected))\n\treturn report_success()\n\nfunc is_empty() -> GdUnitDictionaryAssert:\n\tvar current :Variant = current_value()\n\t@warning_ignore(\"unsafe_cast\")\n\tif current == null or not (current as Dictionary).is_empty():\n\t\treturn report_error(GdAssertMessages.error_is_empty(current))\n\treturn report_success()\n\nfunc is_not_empty() -> GdUnitDictionaryAssert:\n\tvar current :Variant = current_value()\n\t@warning_ignore(\"unsafe_cast\")\n\tif current == null or (current as Dictionary).is_empty():\n\t\treturn report_error(GdAssertMessages.error_is_not_empty())\n\treturn report_success()\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}", "source": "extracted_function"} {"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 Node3D\n\nvar xr_interface : MobileVRInterface\n\n# Called when the node enters the scene tree for the first time.\nfunc _ready():\n\txr_interface = XRServer.find_interface(\"Native mobile\")\n\tif xr_interface and xr_interface.initialize():\n\t\t# Disable lens distortion.\n\t\t#xr_interface.k1 = 0.0\n\t\t#xr_interface.k2 = 0.0", "output": "\n\t\t# Set up viewport.\n\t\tvar vp = get_viewport()\n\t\tvp.use_xr = true\n\t\tvp.vrs_mode = Viewport.VRS_XR\n\telse:\n\t\t# How did we get here?\n\t\tget_tree().quit()\n\nfunc _process(delta):\n\tvar dir : Vector2 = Vector2()\n\n\tif Input.is_action_pressed(&\"ui_left\"):\n\t\tdir.x = -1.0\n\telif Input.is_action_pressed(&\"ui_right\"):\n\t\tdir.x = 1.0\n\tif Input.is_action_pressed(&\"ui_up\"):\n\t\tdir.y = -1.0\n\telif Input.is_action_pressed(&\"ui_down\"):\n\t\tdir.y = 1.0\n\n\t$XROrigin3D.global_position += $XROrigin3D.global_transform.basis.x * dir.x * delta\n\t$XROrigin3D.global_position += $XROrigin3D.global_transform.basis.z * dir.y * delta\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "@tool\nextends GamepieceController\n\n## The points in the path_to_follow will be used to generate the waypoints that the controller will\n## follow.\n@export var path_to_follow: Line2D:\n\tset(value):\n\t\tpath_to_follow = value\n\t\tupdate_configuration_warnings()\n\nvar _current_waypoint_index: = -1\nvar _path_origin: = Vector2.ZERO\nvar _start_cell: = Vector2i.ZERO\n\n# The Gamepiece will wait for the timer to elapse before starting on its path.\n# The timer will also trigger between iterations of the path. This means that after the gamepiece\n# has looped back to the original point it will wait for _timer.timeout before beginning the next\n# loop.\n# The timer will also trigger if the path becomes blocked, for some reason.\n@onready var _timer: Timer = $WaitTimer\n\n\nfunc _ready() -> void:\n\tif not Engine.is_editor_hint():\n\t\tpath_to_follow.hide()\n\t\t_path_origin = _gamepiece.position\n\t\t\n\t\t# The controller cannot find a path until the pathfinder has updated, and changes may\n\t\t# require a new path. Update whenever the pathfinder changes.\n\t\tGameboard.pathfinder_changed.connect(\n\t\t\tfunc _on_pathfinder_changed(_added, _removed) -> void:\n\t\t\t\t# Log an error if the path described by path_to_follow cannot be traversed.\n\t\t\t\tif not _find_move_path():\n\t\t\t\t\t#printerr(\"Failed to find a path_to_follow for '%s'!\" % _gamepiece.name)\n\t\t\t\t\treturn\n\t\t)\n\t\t\n\t\t_timer.one_shot = true\n\t\t_timer.timeout.connect(_move_to_next_waypoint)\n\t\t_timer.start()\n\t\n\tsuper._ready()\n\n\n# Override GamepieceController's default implementation to preserve the move_path and to make use\n# of the wait timer, if it is active.\nfunc set_is_active(value: bool) -> void:\n\tis_active = value\n\t\n\t## Pause/unpause the wait timer to match the controller's 'paused state'. This is only really\n\t## relevant if the controller is currently waiting to run the next loop.\n\t_timer.paused = !is_active\n\t\n\t## Otherwise, if the gamepiece is in transit, pick up where it had left off.\n\tif _timer.is_stopped():\n\t\t_move_to_next_waypoint()\n\n#func set_is_paused(paused: bool) -> void:\n\t#is_paused = paused\n\t#\n\t## Pause/unpause the wait timer to match the controller's 'paused state'. This is only really\n\t## relevant if the controller is currently waiting to run the next loop.\n\t#_timer.paused = is_paused\n\t#\n\t## Otherwise, if the gamepiece is in transit, pick up where it had left off.\n\t#if not paused:\n\t\t#if _current_waypoint_index > 0 and _current_waypoint_index < _waypoints.size() - 1 and \\\n\t\t\t\t#not is_cell_blocked(_waypoints[_current_waypoint_index]):\n\t\t\t#_gamepiece.travel_to_cell(_waypoints[_current_waypoint_index])\n\n\nfunc _get_configuration_warnings() -> PackedStringArray:\n\tvar warnings: PackedStringArray = []", "output": "\n\t# Node exports are currently broken.\n\tif not path_to_follow:\n\t\twarnings.append(\"The path loop controller needs a valid Line2D to follow!\")\n\n\treturn warnings\n\n# Try to convert the path_to_follow into a series of cells for the gamepiece to move to.\n# Loop through the points in the Line2D, using Gameboard.pathfinder to find a path to each. Also\n# searches for the shortest path from the last point to the first point.\n# This method will fail if there is no valid path on the Gameboard between line points.\nfunc _find_move_path() -> bool:\n\tmove_path.clear()\n\n\t# A path needs at least two points.\n\tif path_to_follow.get_point_count() <= 1:\n\t\treturn false\n\n\t# Add the first cell to the path, since subsequent additions will have the first cell removed.\n\t_start_cell = Gameboard.pixel_to_cell(path_to_follow.get_point_position(0) + _path_origin)\n\t#move_path.append(Gameboard.pixel_to_cell(path_to_follow.get_point_position(0) + _path_origin))\n\n\t# Create a looping path from the points specified by path_to_follow. Will fail if a path cannot\n\t# be found between some of the path_to_follow's points.\n\tfor i in range(1, path_to_follow.get_point_count()):\n\t\tvar source: = Gameboard.pixel_to_cell(path_to_follow.get_point_position(i-1) + _path_origin)\n\t\tvar target: = Gameboard.pixel_to_cell(path_to_follow.get_point_position(i) + _path_origin)\n\n\t\tvar path_segment: = Gameboard.pathfinder.get_path_to_cell(source, target,\n\t\t\tPathfinder.FLAG_ALLOW_SOURCE_OCCUPANT | Pathfinder.FLAG_ALLOW_TARGET_OCCUPANT)\n\t\tif path_segment.is_empty():\n\t\t\t#push_error(\"'%s' PathLoopAiController::_find_waypoints_from_line2D() error - \" % name +\n\t\t\t\t#\"Failed to find a path between cells %s and %s.\" % [source, target])\n\t\t\treturn false\n\n\t\tmove_path.append_array(path_segment)\n\n\t# Finally, connect the ending and starting cells to complete the loop.\n\tvar last_pos: = path_to_follow.get_point_position(path_to_follow.get_point_count()-1) \\\n\t\t+ _path_origin\n\tvar last_cell: = Gameboard.pixel_to_cell(last_pos)\n\tvar first_cell: = Gameboard.pixel_to_cell(path_to_follow.get_point_position(0) + _path_origin)\n\n\t# If we've made it this far there must be a path between the first and last cell.\n\tif last_cell != first_cell:\n\t\tmove_path.append_array(Gameboard.pathfinder.get_path_to_cell(last_cell, first_cell,\n\t\t\tPathfinder.FLAG_ALLOW_SOURCE_OCCUPANT | Pathfinder.FLAG_ALLOW_TARGET_OCCUPANT))\n\treturn true\n"} {"instruction": "Erstelle eine Godot-Klasse 'GSAIMatchOrientation' die von GSAISteeringBehavior erbt mit folgenden Funktionen: _init, _match_orientation, _calculate_steering", "input": "", "output": "# Calculates an angular acceleration to match an agent's orientation to that of\n# its target. Attempts to make the agent arrive with zero remaining angular\n# velocity.\n# @category - Individual behaviors\nclass_name GSAIMatchOrientation\nextends GSAISteeringBehavior\n\n# The target orientation for the behavior to try and match rotations to.\nvar target: GSAIAgentLocation\n# The amount of distance in radians for the behavior to consider itself close\n# enough to be matching the target agent's rotation.\nvar alignment_tolerance: float\n# The amount of distance in radians from the goal to start slowing down.\nvar deceleration_radius: float\n# The amount of time to reach the target velocity\nvar time_to_reach: float = 0.1\n# Whether to use the X and Z components instead of X and Y components when\n# determining angles. X and Z should be used in 3D.\nvar use_z: bool\n\nfunc _init(agent: GSAISteeringAgent, _target: GSAIAgentLocation, _use_z := false) -> void:\n\tsuper._init(agent)\n\tself.use_z = _use_z\n\tself.target = _target\n\nfunc _match_orientation(acceleration: GSAITargetAcceleration, desired_orientation: float) -> void:\n\tvar rotation := wrapf(desired_orientation - agent.orientation, -PI, PI)\n\n\tvar rotation_size := absf(rotation)\n\n\tif rotation_size <= alignment_tolerance:\n\t\tacceleration.set_zero()\n\telse:\n\t\tvar desired_rotation := agent.angular_speed_max\n\n\t\tif rotation_size <= deceleration_radius:\n\t\t\tdesired_rotation *= rotation_size / deceleration_radius\n\n\t\tdesired_rotation *= rotation / rotation_size\n\n\t\tacceleration.angular = ((desired_rotation - agent.angular_velocity) / time_to_reach)\n\n\t\tvar limited_acceleration := absf(acceleration.angular)\n\t\tif limited_acceleration > agent.angular_acceleration_max:\n\t\t\tacceleration.angular *= (agent.angular_acceleration_max / limited_acceleration)\n\n\tacceleration.linear = Vector3.ZERO\n\nfunc _calculate_steering(acceleration: GSAITargetAcceleration) -> void:\n\t_match_orientation(acceleration, target.orientation)\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "# Calculates acceleration to take an agent directly away from a target agent.\n# @category - Individual behaviors\nclass_name GSAIFlee\nextends GSAISeek\n", "output": "\nfunc _init(agent: GSAISteeringAgent, target: GSAIAgentLocation) -> void:\n\tsuper._init(agent, target)\n\nfunc _calculate_steering(acceleration: GSAITargetAcceleration) -> void:\n\tacceleration.linear = (\n\t\t(agent.position - target.position).normalized()\n\t\t* agent.linear_acceleration_max\n\t)\n\tacceleration.angular = 0\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "extends Control\n\n## The utterance ID to use for text to speech.\nvar id := 0\n\nvar ut_map := {}\nvar vs: Array[Dictionary]\n\nfunc _ready() -> void:\n\t# Get voice data.\n\tvs = DisplayServer.tts_get_voices()\n\tvar root: TreeItem = $Tree.create_item()\n\t$Tree.set_hide_root(true)\n\t$Tree.set_column_title(0, \"Name\")\n\t$Tree.set_column_title(1, \"Language\")\n\t$Tree.set_column_titles_visible(true)\n\tfor v in vs:\n\t\tvar child: TreeItem = $Tree.create_item(root)\n\t\tchild.set_text(0, v[\"name\"])\n\t\tchild.set_metadata(0, v[\"id\"])\n\t\tchild.set_text(1, v[\"language\"])\n\t$Log.text += \"%d voices available.\\n\" % [vs.size()]\n\t$Log.text += \"=======\\n\"\n\n\t# Ensure the first voice added to the list is preselected.\n\t$Tree.get_root().get_child(0).select(0)\n\n\t# Add callbacks.\n\tDisplayServer.tts_set_utterance_callback(DisplayServer.TTS_UTTERANCE_STARTED, _on_utterance_start)\n\tDisplayServer.tts_set_utterance_callback(DisplayServer.TTS_UTTERANCE_ENDED, _on_utterance_end)\n\tDisplayServer.tts_set_utterance_callback(DisplayServer.TTS_UTTERANCE_CANCELED, _on_utterance_error)\n\tDisplayServer.tts_set_utterance_callback(DisplayServer.TTS_UTTERANCE_BOUNDARY, _on_utterance_boundary)\n\n\nfunc _process(_delta: float) -> void:\n\t$ButtonPause.button_pressed = DisplayServer.tts_is_paused()\n\tif DisplayServer.tts_is_speaking():\n\t\t$ColorRect.color = Color(0.9, 0.3, 0.1)\n\telse:\n\t\t$ColorRect.color = Color(1, 1, 1)\n\n\nfunc _on_utterance_boundary(pos: int, ut_id: int) -> void:\n\t$RichTextLabel.text = \"[bgcolor=yellow][color=black]\" + ut_map[ut_id].substr(0, pos) + \"[/color][/bgcolor]\" + ut_map[ut_id].substr(pos, -1)\n\n\nfunc _on_utterance_start(ut_id: int) -> void:\n\t$Log.text += \"Utterance %d started.\\n\" % [ut_id]\n\n", "output": "func _on_utterance_end(ut_id: int) -> void:\n\t$RichTextLabel.text = \"[bgcolor=yellow][color=black]\" + ut_map[ut_id] + \"[/color][/bgcolor]\"\n\t$Log.text += \"Utterance %d ended.\\n\" % [ut_id]\n\tut_map.erase(ut_id)\n\nfunc _on_utterance_error(ut_id: int) -> void:\n\t$RichTextLabel.text = \"\"\n\t$Log.text += \"Utterance %d canceled/failed.\\n\" % [ut_id]\n\tut_map.erase(ut_id)\n\nfunc _on_button_stop_pressed() -> void:\n\tDisplayServer.tts_stop()\n\nfunc _on_button_pause_pressed() -> void:\n\tif $ButtonPause.pressed:\n\t\tDisplayServer.tts_pause()\n\telse:\n\t\tDisplayServer.tts_resume()\n\nfunc _on_button_speak_pressed() -> void:\n\tif $Tree.get_selected():\n\t\t$Log.text += \"Utterance %d queried.\\n\" % [id]\n\t\tut_map[id] = $Utterance.text\n\t\tDisplayServer.tts_speak($Utterance.text, $Tree.get_selected().get_metadata(0), $HSliderVolume.value, $HSliderPitch.value, $HSliderRate.value, id, false)\n\t\tid += 1\n\telse:\n\t\tOS.alert(\"No voice selected.\\nSelect a voice in the list, then try using Speak again.\")\n\nfunc _on_button_int_speak_pressed() -> void:\n\tif $Tree.get_selected():\n\t\t$Log.text += \"Utterance %d interrupted.\\n\" % [id]\n\t\tut_map[id] = $Utterance.text\n\t\tDisplayServer.tts_speak($Utterance.text, $Tree.get_selected().get_metadata(0), $HSliderVolume.value, $HSliderPitch.value, $HSliderRate.value, id, true)\n\t\tid += 1\n\telse:\n\t\tOS.alert(\"No voice selected.\\nSelect a voice in the list, then try using Interrupt again.\")\n\nfunc _on_button_clear_log_pressed() -> void:\n\t$Log.text = \"\"\n\nfunc _on_HSliderRate_value_changed(value: float) -> void:\n\t$HSliderRate/Value.text = \"%.2fx\" % value\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "# Base type for group-based steering behaviors.\n# @category - Base types\nclass_name GSAIGroupBehavior\nextends GSAISteeringBehavior\n\n# Container to find neighbors of the agent and calculate group behavior.\nvar proximity: GSAIProximity", "output": "\nvar _callback := Callable(self, \"_report_neighbor\")\n\nfunc _init(agent: GSAISteeringAgent, _proximity: GSAIProximity) -> void:\n\tsuper._init(agent)\n\tself.proximity = _proximity\n\n# Internal callback for the behavior to define whether or not a member is\n# relevant\n# @tags - virtual\nfunc _report_neighbor(_neighbor: GSAISteeringAgent) -> bool:\n\treturn false\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "# Base class for all steering behaviors.\n#\n# Steering behaviors calculate the linear and the angular acceleration to be\n# to the agent that owns them.\n#\n# The `calculate_steering` function is the entry point for all behaviors.\n# Individual steering behaviors encapsulate the steering logic.\n# @category - Base types\nclass_name GSAISteeringBehavior\n", "output": "# If `false`, all calculations return zero amounts of acceleration.\nvar is_enabled := true\n# The AI agent on which the steering behavior bases its calculations.\nvar agent: GSAISteeringAgent\n\nfunc _init(_agent: GSAISteeringAgent) -> void:\n\tself.agent = _agent\n\n# Sets the `acceleration` with the behavior's desired amount of acceleration.\nfunc calculate_steering(acceleration: GSAITargetAcceleration) -> void:\n\tif is_enabled:\n\t\t_calculate_steering(acceleration)\n\telse:\n\t\tacceleration.set_zero()\n\nfunc _calculate_steering(acceleration: GSAITargetAcceleration) -> void:\n\tacceleration.set_zero()\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "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\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\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\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", "output": "# 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"} {"instruction": "Vervollständige den GDScript-Code:", "input": "extends Control\n\nvar button_count : int = 0\n\n", "output": "func _input(event):\n\tif event is InputEventMouseMotion:\n\t\t# Move our cursor\n\t\tvar mouse_motion : InputEventMouseMotion = event\n\t\t$Cursor.position = mouse_motion.position - Vector2(16, 16)\n\nfunc _on_button_pressed():\n\tbutton_count = button_count + 1\n\t$CountLabel.text = \"The button has been pressed %d times!\" % [ button_count ]\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "# Preloads all GdUnit assertions\nclass_name GdUnitAssertions\nextends RefCounted\n\n\n@warning_ignore(\"return_value_discarded\")\nfunc _init() -> void:\n\t# preload all gdunit assertions to speedup testsuite loading time\n\t# gdlint:disable=private-method-call\n\t@warning_ignore_start(\"return_value_discarded\")\n\tGdUnitAssertions.__lazy_load(\"res://addons/gdUnit4/src/asserts/GdUnitAssertImpl.gd\")\n\tGdUnitAssertions.__lazy_load(\"res://addons/gdUnit4/src/asserts/GdUnitBoolAssertImpl.gd\")\n\tGdUnitAssertions.__lazy_load(\"res://addons/gdUnit4/src/asserts/GdUnitStringAssertImpl.gd\")\n\tGdUnitAssertions.__lazy_load(\"res://addons/gdUnit4/src/asserts/GdUnitIntAssertImpl.gd\")\n\tGdUnitAssertions.__lazy_load(\"res://addons/gdUnit4/src/asserts/GdUnitFloatAssertImpl.gd\")\n\tGdUnitAssertions.__lazy_load(\"res://addons/gdUnit4/src/asserts/GdUnitVectorAssertImpl.gd\")\n\tGdUnitAssertions.__lazy_load(\"res://addons/gdUnit4/src/asserts/GdUnitArrayAssertImpl.gd\")\n\tGdUnitAssertions.__lazy_load(\"res://addons/gdUnit4/src/asserts/GdUnitDictionaryAssertImpl.gd\")\n\tGdUnitAssertions.__lazy_load(\"res://addons/gdUnit4/src/asserts/GdUnitFileAssertImpl.gd\")\n\tGdUnitAssertions.__lazy_load(\"res://addons/gdUnit4/src/asserts/GdUnitObjectAssertImpl.gd\")\n\tGdUnitAssertions.__lazy_load(\"res://addons/gdUnit4/src/asserts/GdUnitResultAssertImpl.gd\")\n\tGdUnitAssertions.__lazy_load(\"res://addons/gdUnit4/src/asserts/GdUnitFuncAssertImpl.gd\")\n\tGdUnitAssertions.__lazy_load(\"res://addons/gdUnit4/src/asserts/GdUnitSignalAssertImpl.gd\")", "output": "\tGdUnitAssertions.__lazy_load(\"res://addons/gdUnit4/src/asserts/GdUnitFailureAssertImpl.gd\")\n\tGdUnitAssertions.__lazy_load(\"res://addons/gdUnit4/src/asserts/GdUnitGodotErrorAssertImpl.gd\")\n\t@warning_ignore_restore(\"return_value_discarded\")\n\n### We now load all used asserts and tool scripts into the cache according to the principle of \"lazy loading\"\n### in order to noticeably reduce the loading time of the test suite.\n# We go this hard way to increase the loading performance to avoid reparsing all the used scripts\n# for more detailed info -> https://github.com/godotengine/godot/issues/67400\n# gdlint:disable=function-name\nstatic func __lazy_load(script_path :String) -> GDScript:\n\treturn ResourceLoader.load(script_path, \"GDScript\", ResourceLoader.CACHE_MODE_REUSE)\n\nstatic func validate_value_type(value :Variant, type :Variant.Type) -> bool:\n\treturn value == null or typeof(value) == type\n\n# Scans the current stack trace for the root cause to extract the line number\nstatic func get_line_number() -> int:\n\tvar stack_trace := get_stack()\n\tif stack_trace == null or stack_trace.is_empty():\n\t\treturn -1\n\tfor index in stack_trace.size():\n\t\tvar stack_info :Dictionary = stack_trace[index]\n\t\tvar function :String = stack_info.get(\"function\")\n\t\t# we catch helper asserts to skip over to return the correct line number\n\t\tif function.begins_with(\"assert_\"):\n\t\t\tcontinue\n\t\tif function.begins_with(\"test_\"):\n\t\t\treturn stack_info.get(\"line\")\n\t\tvar source :String = stack_info.get(\"source\")\n\t\tif source.is_empty() \\\n\t\t\tor source.begins_with(\"user://\") \\\n\t\t\tor source.ends_with(\"GdUnitAssert.gd\") \\\n\t\t\tor source.ends_with(\"GdUnitAssertions.gd\") \\\n\t\t\tor source.ends_with(\"AssertImpl.gd\") \\\n\t\t\tor source.ends_with(\"GdUnitTestSuite.gd\") \\\n\t\t\tor source.ends_with(\"GdUnitSceneRunnerImpl.gd\") \\\n\t\t\tor source.ends_with(\"GdUnitObjectInteractions.gd\") \\\n\t\t\tor source.ends_with(\"GdUnitObjectInteractionsVerifier.gd\") \\\n\t\t\tor source.ends_with(\"GdUnitAwaiter.gd\"):\n\t\t\tcontinue\n\t\treturn stack_info.get(\"line\")\n\treturn -1\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "# a value provider unsing a callback to get `next` value from a certain function\nclass_name CallBackValueProvider\nextends ValueProvider\n\nvar _cb :Callable\nvar _args :Array\n\n", "output": "func _init(instance :Object, func_name :String, args :Array = Array(), force_error := true) -> void:\n\t_cb = Callable(instance, func_name);\n\t_args = args\n\tif force_error and not _cb.is_valid():\n\t\tpush_error(\"Can't find function '%s' checked instance %s\" % [func_name, instance])\n\nfunc get_value() -> Variant:\n\tif not _cb.is_valid():\n\t\treturn null\n\tif _args.is_empty():\n\t\treturn await _cb.call()\n\treturn await _cb.callv(_args)\n\nfunc dispose() -> void:\n\t_cb = Callable()\n"} {"instruction": "Erstelle eine Godot-Klasse 'GdUnitFuncAssert' die von GdUnitAssert erbt mit folgenden Funktionen: is_null, is_not_null, is_equal, is_not_equal, override_failure_message", "input": "", "output": "## An Assertion Tool to verify function callback values\n@abstract class_name GdUnitFuncAssert\nextends GdUnitAssert\n\n## Verifies that the current value is null.\n@abstract func is_null() -> GdUnitFuncAssert\n\n## Verifies that the current value is not null.\n@abstract func is_not_null() -> GdUnitFuncAssert\n\n## Verifies that the current value is equal to the given one.\n@abstract func is_equal(expected: Variant) -> GdUnitFuncAssert\n\n## Verifies that the current value is not equal to expected one.\n@abstract func is_not_equal(expected: Variant) -> GdUnitFuncAssert\n\n## Overrides the default failure message by given custom message.\n@abstract func override_failure_message(message: String) -> GdUnitFuncAssert\n\n## Appends a custom message to the failure message.\n@abstract func append_failure_message(message: String) -> GdUnitFuncAssert\n\n## Verifies that the current value is true.\n@abstract func is_true() -> GdUnitFuncAssert\n\n## Verifies that the current value is false.\n@abstract func is_false() -> GdUnitFuncAssert\n\n## Sets the timeout in ms to wait the function returnd the expected value, if the time over a failure is emitted.[br]\n## e.g.[br]\n## do wait until 5s the function `is_state` is returns 10 [br]\n## [code]assert_func(instance, \"is_state\").wait_until(5000).is_equal(10)[/code]\n@abstract func wait_until(timeout: int) -> GdUnitFuncAssert\n"} {"instruction": "Erstelle eine Godot-Klasse 'FieldCamera' die von Camera2D erbt mit folgenden Funktionen: _ready, reset_position, _on_viewport_resized", "input": "", "output": "## 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@export var gamepiece: Gamepiece:\n\tset(value):\n\t\tif gamepiece:\n\t\t\tgamepiece.animation_transform.remote_path = \"\"\n\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\nfunc _ready() -> void:\n\tget_viewport().size_changed.connect(_on_viewport_resized)\n\t_on_viewport_resized()\n\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 gameboar"} {"instruction": "Vervollständige den GDScript-Code:", "input": "## 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\n\nfunc _ready() -> void:\n\t# Ensure that playback state is always updating, otherwise the smoothing\n\t# filter causes issues.", "output": "\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"} {"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": "extends Control\n\n## The utterance ID to use for text to speech.\nvar id := 0\n\nvar ut_map := {}\nvar vs: Array[Dictionary]\n\nfunc _ready() -> void:\n\t# Get voice data.\n\tvs = DisplayServer.tts_get_voices()\n\tvar root: TreeItem = $Tree.create_item()\n\t$Tree.set_hide_root(true)\n\t$Tree.set_column_title(0, \"Name\")\n\t$Tree.set_column_title(1, \"Language\")\n\t$Tree.set_column_titles_visible(true)\n\tfor v in vs:\n\t\tvar child: TreeItem = $Tree.create_item(root)\n\t\tchild.set_text(0, v[\"name\"])\n\t\tchild.set_metadata(0, v[\"id\"])\n\t\tchild.set_text(1, v[\"language\"])\n\t$Log.text += \"%d voices available.\\n\" % [vs.size()]\n\t$Log.text += \"=======\\n\"\n\n\t# Ensure the first voice added to the list is preselected.\n\t$Tree.get_root().get_child(0).select(0)\n\n\t# Add callbacks.\n\tDisplayServer.tts_set_utterance_callback(DisplayServer.TTS_UTTERANCE_STARTED, _on_utterance_start)\n\tDisplayServer.tts_set_utterance_callback(DisplayServer.TTS_UTTERANCE_ENDED, _on_utterance_end)\n\tDisplayServer.tts_set_utterance_callback(DisplayServer.TTS_UTTERANCE_CANCELED, _on_utterance_error)\n\tDisplayServer.tts_set_utterance_callback(DisplayServer.TTS_UTTERANCE_BOUNDARY, _on_utterance_boundary)\n\n\nfunc _process(_delta: float) -> void:\n\t$ButtonPause.button_pressed = DisplayServer.tts_is_paused()\n\tif DisplayServer.tts_is_speaking():\n\t\t$ColorRect.color = Color(0.9, 0.3, 0.1)\n\telse:\n\t\t$ColorRect.color = Color(1, 1, 1)\n\n\nfunc _on_utterance_boundary(pos: int, ut_id: int) -> void:\n\t$RichTextLabel.text = \"[bgcolor=yellow][color=black]\" + ut_map[ut_id].substr(0, pos) + \"[/color][/bgcolor]\" + ut_map[ut_id].substr(pos, -1)\n\n\nfunc _on_utterance_start(ut_id: int) -> void:\n\t$Log.text += \"Utterance %d started.\\n\" % [ut_id]\n\n", "output": "func _on_utterance_end(ut_id: int) -> void:\n\t$RichTextLabel.text = \"[bgcolor=yellow][color=black]\" + ut_map[ut_id] + \"[/color][/bgcolor]\"\n\t$Log.text += \"Utterance %d ended.\\n\" % [ut_id]\n\tut_map.erase(ut_id)\n\nfunc _on_utterance_error(ut_id: int) -> void:\n\t$RichTextLabel.text = \"\"\n\t$Log.text += \"Utterance %d canceled/failed.\\n\" % [ut_id]\n\tut_map.erase(ut_id)\n\nfunc _on_button_stop_pressed() -> void:\n\tDisplayServer.tts_stop()\n\nfunc _on_button_pause_pressed() -> void:\n\tif $ButtonPause.pressed:\n\t\tDisplayServer.tts_pause()\n\telse:\n\t\tDisplayServer.tts_resume()\n\nfunc _on_button_speak_pressed() -> void:\n\tif $Tree.get_selected():\n\t\t$Log.text += \"Utterance %d queried.\\n\" % [id]\n\t\tut_map[id] = $Utterance.text\n\t\tDisplayServer.tts_speak($Utterance.text, $Tree.get_selected().get_metadata(0), $HSliderVolume.value, $HSliderPitch.value, $HSliderRate.value, id, false)\n\t\tid += 1\n\telse:\n\t\tOS.alert(\"No voice selected.\\nSelect a voice in the list, then try using Speak again.\")\n\nfunc _on_button_int_speak_pressed() -> void:\n\tif $Tree.get_selected():\n\t\t$Log.text += \"Utterance %d interrupted.\\n\" % [id]\n\t\tut_map[id] = $Utterance.text\n\t\tDisplayServer.tts_speak($Utterance.text, $Tree.get_selected().get_metadata(0), $HSliderVolume.value, $HSliderPitch.value, $HSliderRate.value, id, true)\n\t\tid += 1\n\telse:\n\t\tOS.alert(\"No voice selected.\\nSelect a voice in the list, then try using Interrupt again.\")\n\nfunc _on_button_clear_log_pressed() -> void:\n\t$Log.text = \"\"\n\nfunc _on_HSliderRate_value_changed(value: float) -> void:\n\t$HSliderRate/Value.text = \"%.2fx\" % value\n"} {"instruction": "Erstelle eine GDScript-Funktion namens 'get_behavior_at':", "input": "", "output": "func get_behavior_at(index: int) -> Dictionary:\n\tif _behaviors.size() > index:\n\t\treturn _behaviors[index]\n\tprinterr(\"Tried to get index \" + str(index) + \" in array of size \" + str(_behaviors.size()))\n\treturn {}"} {"instruction": "Erstelle eine Godot-Klasse 'GSAIFollowPath' die von GSAIArrive erbt mit folgenden Funktionen: _init, _calculate_steering", "input": "", "output": "# Produces a linear acceleration that moves the agent along the specified path.\n# @category - Individual behaviors\nclass_name GSAIFollowPath\nextends GSAIArrive\n\n# The path to follow and travel along.\nvar path: GSAIPath\n# The distance along the path to generate the next target position.\nvar path_offset := 0.0\n\n# Whether to use `GSAIArrive` behavior on an open path.\nvar is_arrive_enabled := true\n# The amount of time in the future to predict the owning agent's position along\n# the path. Setting it to 0.0 will force non-predictive path following.\nvar prediction_time := 0.0\n\nfunc _init(agent: GSAISteeringAgent, _path: GSAIPath, _path_offset := 0.0, _prediction_time := 0.0) -> void:\n\tsuper._init(agent, null)\n\tself.path = _path\n\tself.path_offset = _path_offset\n\tself.prediction_time = _prediction_time\n\nfunc _calculate_steering(acceleration: GSAITargetAcceleration) -> void:\n\tvar location := (\n\t\tagent.position\n\t\tif prediction_time == 0\n\t\telse agent.position + (agent.linear_velocity * prediction_time)\n\t)\n\n\tvar distance := path.calculate_distance(location)\n\tvar target_distance := distance + path_offset\n\n\tif prediction_time > 0 and path.is_open:\n\t\tif target_distance < path.calculate_distance(agent.position):\n\t\t\ttarget_distance = path.length\n\n\tvar target_position := path.calculate_target_position(target_distance)\n\n\tif is_arrive_enabled and path.is_open:\n\t\tif path_offset >= 0:\n\t\t\tif target_distance > path.length - deceleration_radius:\n\t\t\t\t_arrive(acceleration, target_position)\n\t\t\t\treturn\n\t\telse:\n\t\t\tif target_distance < deceleration_radius:\n\t\t\t\t_arrive(acceleration, target_position)\n\t\t\t\treturn\n\n\tacceleration.linear = (target_position - agent.position).normalized()\n\tacceleration.linear *= agent.linear_acceleration_max\n\tacceleration.angular = 0\n"} {"instruction": "Erstelle eine Godot-Klasse 'Combat' die von CanvasLayer erbt mit folgenden Funktionen: _ready, setup, next_round, _select_next_player_action, _on_selected_battler_action_cached", "input": "", "output": "## 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@onread"} {"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}"} {"instruction": "Erstelle eine Godot-Klasse 'GdUnitStringAssert' 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 String values\n@abstract class_name GdUnitStringAssert\nextends GdUnitAssert\n\n## Verifies that the current value is null.\n@abstract func is_null() -> GdUnitStringAssert\n\n## Verifies that the current value is not null.\n@abstract func is_not_null() -> GdUnitStringAssert\n\n## Verifies that the current value is equal to the given one.\n@abstract func is_equal(expected: Variant) -> GdUnitStringAssert\n\n## Verifies that the current String is equal to the given one, ignoring case considerations.\n@abstract func is_equal_ignoring_case(expected: Variant) -> GdUnitStringAssert\n\n## Verifies that the current value is not equal to expected one.\n@abstract func is_not_equal(expected: Variant) -> GdUnitStringAssert\n\n## Verifies that the current String is not equal to the given one, ignoring case considerations.\n@abstract func is_not_equal_ignoring_case(expected: Variant) -> GdUnitStringAssert\n\n## Overrides the default failure message by given custom message.\n@abstract func override_failure_message(message: String) -> GdUnitStringAssert\n\n## Appends a custom message to the failure message.\n@abstract func append_failure_message(message: String) -> GdUnitStringAssert\n\n## Verifies that the current String is empty, it has a length of 0.\n@abstract func is_empty() -> GdUnitStringAssert\n\n## Verifies that the current String is not empty, it has a length of minimum 1.\n@abstract func is_not_empty() -> GdUnitStringAssert\n\n## Verifies that the current String contains the given String.\n@abstract func contains(expected: String) -> GdUnitStringAssert\n\n## Verifies that the current String does not contain the given String.\n@abstract func not_contains(expected: String) -> GdUnitStringAssert\n\n## Verifies that the current String does not contain the given String, ignoring case considerations.\n@abstract func contains_ignoring_case(expected: String) -> GdUnitStringAssert\n\n## Verifies that the current String does not contain the given String, ignoring case considerati"} {"instruction": "Erstelle eine GDScript-Funktion namens '_init':", "input": "", "output": "func _init() -> void:\n\tadd_to_group(\"state_machine\")\n\nfunc _ready() -> void:\n\tawait owner.ready\n\tstate.enter()\n\nfunc _unhandled_input(event: InputEvent) -> void:\n\tstate.unhandled_input(event)\n\nfunc _physics_process(delta: float) -> void:\n\tstate.physics_process(delta)\n\nfunc transition_to(target_state_path: String, msg: Dictionary = {}"} {"instruction": "Vervollständige den GDScript-Code:", "input": "class_name XRHandFallbackModifier3D\nextends SkeletonModifier3D\n\n## This node implements a fallback if the hand tracking API is not available\n## or if one of the data sources is not supported by the XR runtime.\n## It uses trigger and grip inputs from the normal controller tracker to\n## animate the index finger and bottom 3 fingers respectively.\n\n## Action to use for animating index finger.\n@export var trigger_action : String = \"trigger\"\n\n## Action to use for animating bottom 3 fingers.\n@export var grip_action : String = \"grip\"\n\n# Called by our skeleton logic when this modifier needs to apply its modifications.\nfunc _process_modification() -> void:\n\t# Get our skeleton.\n\tvar skeleton: Skeleton3D = get_skeleton()\n\tif !skeleton:\n\t\treturn\n\n\t# Find our parent controller\n\tvar parent = get_parent()\n\twhile parent and not parent is XRNode3D:\n\t\tparent = parent.get_parent()\n\tif !parent:\n\t\treturn", "output": "\n\t# Check if we have an active hand tracker,\n\t# if so, we don't need our fallback!\n\tvar xr_parent : XRNode3D = parent\n\tif not xr_parent.tracker in [ \"left_hand\", \"right_hand\" ]:\n\t\treturn\n\n\tvar trigger : float = 0.0\n\tvar grip : float = 0.0\n\n\t# Check our tracker for trigger and grip values\n\tvar tracker : XRControllerTracker = XRServer.get_tracker(xr_parent.tracker)\n\tif tracker:\n\t\tvar trigger_value : Variant = tracker.get_input(trigger_action)\n\t\tif trigger_value:\n\t\t\ttrigger = trigger_value\n\n\t\tvar grip_value : Variant = tracker.get_input(grip_action)\n\t\tif grip_value:\n\t\t\tgrip = grip_value\n\n\t# Now position bones\n\tvar bone_count = skeleton.get_bone_count()\n\tfor i in bone_count:\n\t\tvar t : Transform3D = skeleton.get_bone_rest(i)\n\n\t\t# We animate based on bone_name.\n\t\t# For now just hardcoded values.\n\t\t# Note that we position all bones in case we need to reset some.\n\t\tvar bone_name = skeleton.get_bone_name(i)\n\t\tif bone_name == \"LeftHand\":\n\t\t\t# Offset to center our palm, this requires the use of the palm pose!\n\t\t\tt.origin += Vector3(-0.015, 0.0, 0.04)\n\t\telif bone_name == \"RightHand\":\n\t\t\t# Offset to center our palm, this requires the use of the palm pose!\n\t\t\tt.origin += Vector3(0.015, 0.0, 0.04)\n\t\telif bone_name == \"LeftIndexDistal\" or bone_name == \"LeftIndexIntermediate\" \\\n\t\t\tor bone_name == \"RightIndexDistal\" or bone_name == \"RightIndexIntermediate\":\n\t\t\tvar r : Transform3D\n\t\t\tt = t * r.rotated(Vector3(1.0, 0.0, 0.0), deg_to_rad(45.0) * trigger)\n\t\telif bone_name == \"LeftIndexProximal\" or bone_name == \"RightIndexProximal\":\n\t\t\tvar r : Transform3D\n\t\t\tt = t * r.rotated(Vector3(1.0, 0.0, 0.0), deg_to_rad(20.0) * trigger)\n\t\telif bone_name == \"LeftMiddleDistal\" or bone_name == \"LeftMiddleIntermediate\" or bone_name == \"LeftMiddleProximal\" \\\n\t\t\t\tor bone_name == \"RightMiddleDistal\" or bone_name == \"RightMiddleIntermediate\" or bone_name == \"RightMiddleProximal\" \\\n\t\t\t\tor bone_name == \"LeftRingDistal\" or bone_name == \"LeftRingIntermediate\" or bone_name == \"LeftRingProximal\" \\\n\t\t\t\tor bone_name == \"RightRingDistal\" or bone_name == \"RightRingIntermediate\" or bone_name == \"RightRingProximal\" \\\n\t\t\t\tor bone_name == \"LeftLittleDistal\" or bone_name == \"LeftLittleIntermediate\" or bone_name == \"LeftLittleProximal\" \\\n\t\t\t\tor bone_name == \"RightLittleDistal\" or bone_name == \"RightLittleIntermediate\" or bone_name == \"RightLittleProximal\":\n\t\t\tvar r : Transform3D"} {"instruction": "Erstelle eine GDScript-Funktion namens 'physics_process':", "input": "", "output": "func physics_process(_delta: float) -> void:\n\tpass\n\nfunc enter(_msg: Dictionary = {}", "source": "extracted_function"} {"instruction": "Vervollständige den GDScript-Code:", "input": "extends XRNode3D\n\n## Detect which tracker we should use to position our hand, we prefer\n## hand tracking as this works in unison with our hand skeleton updates.\n\n## Hand for which to get our tracking data.\n@export_enum(\"Left\",\"Right\") var hand : int = 0\n\n# Called every frame. 'delta' is the elapsed time since the previous frame.\nfunc _process(delta):\n\tvar new_tracker : String\n\n\t# Check if our hand tracker is usable\n\tnew_tracker = \"/user/hand_tracker/left\" if hand == 0 \\", "output": "\t\telse \"/user/hand_tracker/right\"\n\tvar hand_tracker : XRHandTracker = XRServer.get_tracker(new_tracker)\n\tif hand_tracker and hand_tracker.has_tracking_data:\n\t\tif tracker != new_tracker:\n\t\t\tprint(\"Switching to left hand tracker\" if hand == 0 \\\n\t\t\t\telse \"Switching to right hand tracker\")\n\t\t\ttracker = new_tracker\n\t\t\tpose = \"default\"\n\n\t\treturn\n\n\t# Else fallback to our controller tracker\n\tnew_tracker = \"left_hand\" if hand == 0 else \"right_hand\"\n\tvar controller_tracker : XRControllerTracker = XRServer.get_tracker(new_tracker)\n\tif controller_tracker:\n\t\tif tracker != new_tracker:\n\t\t\tprint(\"Switching to left controller tracker\" if hand == 0 \\\n\t\t\t\telse \"Switching to right controller tracker\")\n\t\t\ttracker = new_tracker\n\n\t\tvar new_pose : String = \"palm_pose\"\n\t\tvar xr_pose : XRPose = controller_tracker.get_pose(new_pose)\n\t\tif not xr_pose or xr_pose.tracking_confidence == XRPose.XR_TRACKING_CONFIDENCE_NONE:\n\t\t\tnew_pose = \"grip\"\n\n\t\tif pose != new_pose:\n\t\t\tpose = new_pose\n"} {"instruction": "Erstelle eine Godot-Klasse 'UIInventoryItem' die von TextureRect erbt mit folgenden Funktionen: set_count", "input": "", "output": "## An inventory item, tracking both it's UI representation and underlying data.\n## Will be replaced in future iterations of the OpenRPG project.\n## Please see UIInventory for additional information.\nclass_name UIInventoryItem extends TextureRect\n\nvar ID: = Inventory.ItemTypes.KEY\n\nvar count: = 0:\n\tset = set_count\n\n@onready var _count_label: = $Count as Label\n\nfunc set_count(value: int) -> void:\n\tcount = max(value, 0)\n\tif count == 0:\n\t\tqueue_free()\n\n\telif count > 1:\n\t\t_count_label.show()\n\t\t_count_label.text = str(count)\n\n\telse:\n\t\t_count_label.hide()\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "extends Node2D\n\nvar _audio_samples := [\n\tpreload(\"explosion_01.wav\"),\n\tpreload(\"explosion_02.wav\"),\n\tpreload(\"explosion_03.wav\"),\n\tpreload(\"explosion_04.wav\"),\n]\n", "output": "@export var Shockwave: PackedScene\n\n@onready var audio: AudioStreamPlayer2D = $AudioStreamPlayer2D\n@onready var anim: AnimationPlayer = $AnimationPlayer\n\nfunc _ready() -> void:\n\tEvents.explosion_occurred.emit()\n\n\taudio.stream = _audio_samples[randi() % _audio_samples.size()]\n\taudio.play()\n\tvar shockwave := Shockwave.instantiate()\n\tObjectRegistry.register_distortion_effect(shockwave)\n\tshockwave.global_position = global_position\n\tshockwave.emitting = true\n\tshockwave.get_node(\"LifeSpan\").autostart = true\n\n\tanim.play(&\"Explode\")\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "#*\n#* code_edit.gd\n#* =============================================================================\n#* Copyright 2024 Serhii Snitsaruk\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\nextends CodeEdit\n\nconst RESERVED_WORDS := [\n\t\t# Control flow.\n\t\t\"break\",\n\t\t\"continue\",\n\t\t\"elif\",\n\t\t\"else\",\n\t\t\"for\",\n\t\t\"if\",\n\t\t\"match\",\n\t\t\"pass\",\n\t\t\"return\",\n\t\t\"when\",\n\t\t\"while\",\n\t\t# Declarations.\n\t\t\"class\",\n\t\t\"class_name\",\n\t\t\"const\",\n\t\t\"enum\",\n\t\t\"extends\",\n\t\t\"func\",\n\t\t\"namespace\",\n\t\t\"signal\",\n\t\t\"static\",\n\t\t\"trait\",\n\t\t\"var\",\n\t\t# Other keywords.\n\t\t\"await\",\n\t\t\"breakpoint\",\n\t\t\"self\",\n\t\t\"super\",\n\t\t\"yield\",\n\t\t# Operators.\n\t\t\"and\",\n\t\t\"as\",", "output": "\t\t\"in\",\n\t\t\"is\",\n\t\t\"not\",\n\t\t\"or\",\n\t\t# Special values.\n\t\t\"false\",\n\t\t\"null\",\n\t\t\"true\",\n\t\t# Constants.\n\t\t\"INF\",\n\t\t\"NAN\",\n\t\t\"PI\",\n\t\t\"TAU\",\n\t\t# Functions.\n\t\t\"assert\",\n\t\t\"preload\",\n]\n\nconst TYPE_WORDS := [\n\t\"bool\",\n\t\"int\",\n\t\"float\",\n\t\"void\",\n\t\"String\",\n\t\"Vector2\",\n\t\"Vector2i\",\n\t\"Rect2\",\n\t\"Rect2i\",\n\t\"Vector3\",\n\t\"Vector3i\",\n\t\"Transform2D\",\n\t\"Vector4\",\n\t\"Vector4i\",\n\t\"Plane\",\n\t\"Quaternion\",\n\t\"AABB\",\n\t\"Basis\",\n\t\"Transform3D\",\n\t\"Projection\",\n\t\"Color\",\n\t\"StringName\",\n\t\"NodePath\",\n\t\"RID\",\n\t\"Callable\",\n\t\"Signal\",\n\t\"Dictionary\",\n\t\"Array\",\n\t\"PackedByteArray\",\n\t\"PackedInt32Array\",\n\t\"PackedInt64Array\","} {"instruction": "Erstelle eine Godot-Klasse 'GamepieceController' die von Node2D erbt mit folgenden Funktionen: _ready, _on_input_paused, _get_configuration_warnings, _notification, move_along_path", "input": "", "output": "@tool\n@icon(\"res://assets/editor/icons/IconGamepieceController.svg\")\nclass_name GamepieceController extends Node2D\n\n## Emitted whenever the gamepiece begins moving towards a new cell in its [member move_path].\nsignal waypoint_changed(waypoint: Vector2i)\n\n## An active controller will receive inputs (player or otherwise). An inactive controller does\n## nothing. This is useful, for example, when toggling of gamepiece movement during cutscenes.\nvar is_active: = false:\n\tset = set_is_active\n\n## Keep track of a move path. The controller will check that the path is clear each time the\n## gamepiece needs to continue on to the next cell.\nvar move_path: Array[Vector2i] = []:\n\tset = move_along_path\nvar _current_waypoint: Vector2i:\n\tset(value):\n\t\tif value != _current_waypoint:\n\t\t\t_current_waypoint = value\n\t\t\twaypoint_changed.emit(_current_waypoint)\n\n# The controller operates on its direct parent, which must be a gamepiece object.\nvar _gamepiece: Gamepiece\n\nfunc _ready() -> void:\n\tset_process(false)\n\tset_physics_process(false)\n\n\tif not Engine.is_editor_hint():\n\t\tis_active = true\n\n\t\t_gamepiece.arriving.connect(_on_gamepiece_arriving)\n\t\t_gamepiece.arrived.connect(_on_gamepiece_arrived)\n\n\t\tFieldEvents.input_paused.connect(\n\t\t\tfunc _on_input_paused(value: bool) -> void:\n\t\t\t\tis_active = !value\n\t\t)\n\nfunc _get_configuration_warnings() -> PackedStringArray:\n\tvar warnings: PackedStringArray = []\n\tif not _gamepiece:\n\t\twarnings.append(\"This object must be a child of a gamepiece!\")\n\n\treturn warnings\n\nfunc _notification(what: int) -> void:\n\tif what == NOTIFICATION_PARENTED:\n\t\t_gamepiece = get_parent() as Gamepiece\n\t\tupdate_configuration_warnings()\n\nfunc move_along_path(value: Array[Vector2i]) -> void:\n\tmove_path = value\n\t_move_to_next_waypoint()\n\n## Set whether or not the controller may exert control over the gamepiece.\n## There are a number of occasions (such as cutscenes or combat) where gamepieces are inactive.\nfunc set_is_active(value: bool) -> void:\n\tis_active = value\n\t_move_"} {"instruction": "Erstelle eine Godot-Klasse 'Health' die von Node erbt mit folgenden Funktionen: _ready, take_damage, get_current", "input": "", "output": "#*\n#* health.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#*\nclass_name Health\nextends Node\n## Tracks health and emits signal when damaged or dead.\n\n## Emitted when health is reduced to 0.\nsignal death\n\n## Emitted when health is damaged.\nsignal damaged(amount: float, knockback: Vector2)\n\n## Initial health value.\n@export var max_health: float = 10.0\n\nvar _current: float\n\nfunc _ready() -> void:\n\t_current = max_health\n\nfunc take_damage(amount: float, knockback: Vector2) -> void:\n\tif _current <= 0.0:\n\t\treturn\n\n\t_current -= amount\n\t_current = max(_current, 0.0)\n\n\tif _current <= 0.0:\n\t\tdeath.emit()\n\telse:\n\t\tdamaged.emit(amount, knockback)\n\n## Returns current health.\nfunc get_current() -> float:\n\treturn _current\n"} {"instruction": "Erstelle eine GDScript-Funktion namens 'format_dict':", "input": "", "output": "func format_dict(value :Variant) -> String:\n\tif not value is Dictionary:\n\t\treturn str(value)\n\n\tvar dict_value: Dictionary = value\n\tif dict_value.is_empty():\n\t\treturn \"{ }"} {"instruction": "Erstelle eine Godot-Klasse 'CombatArena' die von Control erbt mit folgenden Funktionen: get_battler_roster", "input": "", "output": "## An arena is the editor-configured environment for a battle. It is a Control node that contains\n## the combat participants and details (such as background, foreground, music, etc.).\nclass_name CombatArena extends Control\n\n## The music that will be automatically played during this combat instance.\n@export var music: AudioStream\n\n## Retrieve the list of the combat participants, in [BattlerRoster] form.\nfunc get_battler_roster() -> BattlerRoster:\n\treturn $Battlers as BattlerRoster\n"} {"instruction": "Erstelle eine Godot-Klasse 'GSAIRigidBody2DAgent' die von GSAISpecializedAgent erbt mit folgenden Funktionen: _init, _apply_steering, _set_body, _on_SceneTree_frame", "input": "", "output": "# A specialized steering agent that updates itself every frame so the user does\n# not have to using a RigidBody2D\n# @category - Specialized agents\nclass_name GSAIRigidBody2DAgent\nextends GSAISpecializedAgent\n\n# The RigidBody2D to keep track of\nvar body: RigidBody2D: set = _set_body\n\nvar _last_position: Vector2\nvar _body_ref: WeakRef\n\nfunc _init(_body: RigidBody2D) -> void:\n\tif not _body.is_inside_tree():\n\t\tawait(_body).ready\n\tself.body = _body\n\n\t# warning-ignore:return_value_discarded\n\t_body.get_tree().physics_frame.connect(_on_SceneTree_frame)\n\n# Moves the agent's `body` by target `acceleration`.\n# @tags - virtual\nfunc _apply_steering(acceleration: GSAITargetAcceleration, _delta: float) -> void:\n\tvar _body: RigidBody2D = _body_ref.get_ref()\n\tif not _body:\n\t\treturn\n\n\t_applied_steering = true\n\t_body.apply_central_impulse(GSAIUtils.to_vector2(acceleration.linear))\n\t_body.apply_torque_impulse(acceleration.angular)\n\tif calculate_velocities:\n\t\tlinear_velocity = GSAIUtils.to_vector3(_body.linear_velocity)\n\t\tangular_velocity = _body.angular_velocity\n\nfunc _set_body(value: RigidBody2D) -> void:\n\tbody = value\n\t_body_ref = weakref(value)\n\n\t_last_position = value.global_position\n\t_last_orientation = value.rotation\n\n\tposition = GSAIUtils.to_vector3(_last_position)\n\torientation = _last_orientation\n\nfunc _on_SceneTree_frame() -> void:\n\tvar _body: RigidBody2D = _body_ref.get_ref()\n\tif not _body:\n\t\treturn\n\n\tif not _body.is_inside_tree():\n\t\treturn\n\n\tvar current_position := _body.global_position\n\tvar current_orientation := _body.rotation\n\n\tposition = GSAIUtils.to_vector3(current_position)\n\torientation = current_orientation\n\n\tif calculate_velocities:\n\t\tif _applied_steering:\n\t\t\t_applied_steering = false\n\t\telse:\n\t\t\tlinear_velocity = GSAIUtils.to_vector3(_body.linear_velocity)\n\t\t\tangular_velocity = _body.angular_velocity\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": "# Generic State Machine. Initializes states and delegates engine callbacks\n# (_physics_process, _unhandled_input) to the active state.\nextends Node\nclass_name StateMachine\n\n@export var initial_state := NodePath()\n\n@onready var state: State = get_node(initial_state): set = set_state\n@onready var _state_name := state.name\n\n\nfunc _init() -> void:\n\tadd_to_group(\"state_machine\")\n", "output": "\nfunc _ready() -> void:\n\tawait owner.ready\n\tstate.enter()\n\nfunc _unhandled_input(event: InputEvent) -> void:\n\tstate.unhandled_input(event)\n\nfunc _physics_process(delta: float) -> void:\n\tstate.physics_process(delta)\n\nfunc transition_to(target_state_path: String, msg: Dictionary = {}) -> void:\n\tif not has_node(target_state_path):\n\t\treturn\n\n\tvar target_state := get_node(target_state_path)\n\n\tstate.exit()\n\tself.state = target_state\n\tstate.enter(msg)\n\nfunc set_state(value: State) -> void:\n\tstate = value\n\t_state_name = state.name\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "# Calculates acceleration to take an agent away from where a target agent is\n# moving.\n# @category - Individual behaviors\nclass_name GSAIEvade", "output": "extends GSAIPursue\n\nfunc _init(agent: GSAISteeringAgent, target: GSAISteeringAgent, predict_time_max := 1.0):\n\tsuper._init(agent, target, predict_time_max)\n\nfunc _get_modified_acceleration() -> float:\n\treturn -agent.linear_acceleration_max\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}", "source": "extracted_function"} {"instruction": "Erstelle eine GDScript-Funktion namens '_ready':", "input": "", "output": "func _ready():\n\tblackboard = blackboard.duplicate()\n\t_data[DEFAULT] = blackboard\n\nfunc 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": "Erstelle eine Godot-Klasse 'GdUnitTuple' die von RefCounted erbt mit folgenden Funktionen: test_player_stats_after_level_up, test_enemy_spawn_positions, _init, values, _to_string", "input": "", "output": "## A tuple implementation for GdUnit4 test assertions and value extraction.\n## @tutorial(GdUnit4 Array Assertions): https://mikeschulze.github.io/gdUnit4/latest/testing/assert-array/#extractv\n## @tutorial(GdUnit4 Testing Framework): https://mikeschulze.github.io/gdUnit4/\n## [br]\n## The GdUnitTuple class is a utility container designed specifically for the GdUnit4\n## testing framework. It enables advanced assertion operations, particularly when\n## extracting and comparing multiple values from complex test results.\n## [br]\n## [b]Primary Use Cases in Testing:[/b] [br]\n## - Extracting multiple properties from test objects with [method extractv]## [br]\n## - Grouping related assertion values for comparison## [br]\n## - Returning multiple values from test helper methods## [br]\n## - Organizing expected vs actual value pairs in assertions## [br]\n## [br]\n## [b]Example Usage in Tests:[/b]\n## [codeblock]\n## func test_player_stats_after_level_up():\n## var player = Player.new()\n## player.level_up()\n##\n## # Extract multiple properties using tuple\n## assert_array([player]) \\\n## .extractv(extr(\"name\"), extr(\"level\"), extr(\"hp\")) \\\n## .contains(tuple(\"Hero\", 2, 150))\n##\n## func test_enemy_spawn_positions():\n## var enemies: Array = spawn_enemies(3)\n##\n## # Verify multiple enemies have correct position data\n## assert_array(enemies) \\\n## .extractv(extr(\"position.x\"), extr(\"position.y\")) \\\n## .contains_exactly([\n## tuple(100, 200),\n## tuple(150, 200),\n## tuple(200, 200)\n## ])\n## [/codeblock]\n## [br]\n## [b]Integration with GdUnit4 Assertions:[/b] [br]\n## Tuples work seamlessly with array assertion methods like: [br]\n## - [code]contains()[/code] - Check if extracted values contain specific tuples [br]\n## - [code]contains_exactly()[/code] - Verify exact tuple matches [br]\n## - [code]is_equal()[/code] - Compare tuple equality [br]\n## [br]\n## [b]Note:[/b] This class is part of the GdUnit4 te"} {"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 'Pathfinder' die von AStar2D erbt mit folgenden Funktionen: _init, _on_gamepiece_moved, _on_gamepiece_free, has_cell, can_move_to", "input": "", "output": "## A wrapper for [AStar2D] that allows working with [Vector2i] coordinates.\n##\n## Additionally provides utility methods for easily dealing with cell availability and passability.\nclass_name Pathfinder\nextends AStar2D\n\n## When finding a path, we may want to ignore certain cells that are occupied by Gamepeices.\n## These flags specify which disabled cells will still allow the path through.\n##\n## Ignore the occupant of the source cell when searching for a path via [method path_to_cell].\n## This is especially useful when wanting to find a path for a gamepiece from their current cell.\nconst FLAG_ALLOW_SOURCE_OCCUPANT = 1 << 0\n## Ignore the occupant of the target cell when searching for a path via [method path_to_cell].\nconst FLAG_ALLOW_TARGET_OCCUPANT = 1 << 1\n## Ignore all gamepieces on the pathfinder cells when searching for a path via\n## [method path_to_cell].\nconst FLAG_ALLOW_ALL_OCCUPANTS = 1 << 2\n\nfunc _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_disa"} {"instruction": "Erstelle eine Godot-Klasse 'PickupHandler3D' die von Area3D erbt mit folgenden Funktionen: _update_detect_range, _update_closest_body, _get_parent_controller, _ready, _physics_process", "input": "", "output": "@tool\nclass_name PickupHandler3D\nextends Area3D\n\n# This area3D class detects all physics bodies based on\n# PickupAbleBody3D within range and handles the logic\n# for selecting the closest one and allowing pickup\n# of that object.\n\n# Detect range specifies within what radius we detect\n# objects we can pick up.\n@export var detect_range : float = 0.3:\n\tset(value):\n\t\tdetect_range = value\n\t\tif is_inside_tree():\n\t\t\t_update_detect_range()\n\t\t\t_update_closest_body()\n\n# Pickup Action specifies the action in the OpenXR\n# action map that triggers our pickup function.\n@export var pickup_action : String = \"pickup\"\n\nvar closest_body : PickupAbleBody3D\nvar picked_up_body: PickupAbleBody3D\nvar was_pickup_pressed : bool = false\n\n# Update our detection range.\nfunc _update_detect_range() -> void:\n\tvar shape : SphereShape3D = $CollisionShape3D.shape\n\tif shape:\n\t\tshape.radius = detect_range\n\n# Update our closest body.\nfunc _update_closest_body() -> void:\n\t# Do not do this when we're in the editor.\n\tif Engine.is_editor_hint():\n\t\treturn\n\n\t# Do not check this if we've picked something up.\n\tif picked_up_body:\n\t\tif closest_body:\n\t\t\tclosest_body.remove_is_closest(self)\n\t\t\tclosest_body = null\n\n\t\treturn\n\n\t# Find the body that is currently the closest.\n\tvar new_closest_body : PickupAbleBody3D\n\tvar closest_distance : float = 1000000.0\n\n\tfor body in get_overlapping_bodies():\n\t\tif body is PickupAbleBody3D and not body.is_picked_up():\n\t\t\tvar distance_squared = (body.global_position - global_position).length_squared()\n\t\t\tif distance_squared < closest_distance:\n\t\t\t\tnew_closest_body = body\n\t\t\t\tclosest_distance = distance_squared\n\n\t# Unchanged? Just exit\n\tif closest_body == new_closest_body:\n\t\treturn\n\n\t# We had a closest body\n\tif closest_body:\n\t\tclosest_body.remove_is_closest(self)\n\n\tclosest_body = new_closest_body\n\tif closest_body:\n\t\tclosest_body.add_is_closest(self)\n\n# Get our controller that we are a child of\nfunc _get_parent_controller() -> XRController3D:\n\tvar parent : Node = get_parent()\n\twhile p"} {"instruction": "Vervollständige den GDScript-Code:", "input": "@tool\n## An animated pop-up graphic. These are often found, for example, in dialogue bubbles to\n## demonstrate the need for player input.\nclass_name UIPopup extends Node2D\n\n## Emitted when the popup has completely disappeared.\nsignal disappeared\n\n## The states in which a popup may exist.\nenum States { HIDDEN, SHOWN, HIDING, SHOWING}\n\n# The target state of the popup. Setting it to true or false will cause a change in behaviour.\n# True if the popup should be shown or false if the popup should be hidden.\n# Note that this shows the TARGET state of the popup, so _is_shown may be false even while the\n# popup is appearing.\nvar _is_shown: = false:\n\tset(value):\n\t\t_is_shown = value\n\t\t\n\t\tif not is_inside_tree():\n\t\t\tawait ready\n\t\t\n\t\tif _is_shown and _state == States.HIDDEN:\n\t\t\t_anim.play(\"appear\")\n\t\t\t_state = States.SHOWING\n\t\t\n\t\t# A fully shown, idling popup bounces slightly to draw the player's eye. Note that there is\n\t\t# a small wait time between bounces so that the popup doesn't look overly energetic.\n\t\t# Unfortunately, this creates an edge case for smooth animation (see _on_bounce_finished). \n\t\t#\n\t\t# Basically, if the bounce animation isn't playing, but the popup is waiting for the next \n\t\t# 'bounce', we want to be able to hide the popup immediately, rather than wait for 'wait'\n\t\t# a fraction of a second for the animation to finish playing, which looks 'off'.\n\t\t#\n\t\t# So, we check here to see if the popup is sitting in this 'wait' window, where it can be", "output": "\t\t# immediately hidden and still look smooth as butter.\n\t\telif not _is_shown and _anim.current_animation == \"bounce_wait\":\n\t\t\t_anim.play(\"disappear\")\n\t\t\t_state = States.HIDING\n\n# Track what is currently happening to the popup.\nvar _state: = States.HIDDEN\n\n@onready var _anim: = $AnimationPlayer as AnimationPlayer\n@onready var _sprite: = $Sprite2D as Sprite2D\n\nfunc _ready() -> void:\n\tif not Engine.is_editor_hint():\n\t\t_sprite.scale = Vector2.ZERO\n\t\t_anim.animation_finished.connect(_on_animation_finished)\n\n## Wait for the popup to disappear cleanly before freeing. If the popup is already hidden, it may be\n## freed immediately.\n## This is useful for smoothly removing a poup from an external object.\nfunc hide_and_free() -> void:\n\tif _state != States.HIDDEN:\n\t\t_is_shown = false\n\t\tawait disappeared\n\tqueue_free()\n\n# Please see the note attached embedded in _is_shown's setter.\n# A peculiarity of the bounce animation is that there is a wait time afterwards before the next\n# bounce. However, it doesn't look 'right' to wait to hide the popup until the animation has\n# finished when the bounce and wait are baked together into a single animation. Ideally, we should\n# be able to hide the popup whenever it's not growing or shrinking (or bouncing).\n#\n# Therefore, the bounce animation will check, via the following method, for whether or not the wait\n# portion of the animation should be played or if the popup should disappear beforehand.\nfunc _on_bounce_finished() -> void:\n\tif _is_shown:\n\t\t_anim.play(\"bounce_wait\")\n\n\telse:\n\t\t_anim.play(\"disappear\")\n\t\t_state = States.HIDING\n\n# An animation has finished, so we may want to change the popup's behaviour depending on whether or\n# not it has been flagged for a state change through _is_shown.\nfunc _on_animation_finished(_anim_name: String) -> void:\n\tif _state == States.HIDING:\n\t\tdisappeared.emit()"} {"instruction": "Erstelle eine GDScript-Funktion namens '_init':", "input": "", "output": "func _init() -> void:\n\tadd_to_group(\"state_machine\")\n\nfunc _ready() -> void:\n\tawait owner.ready\n\tstate.enter()\n\nfunc _unhandled_input(event: InputEvent) -> void:\n\tstate.unhandled_input(event)\n\nfunc _physics_process(delta: float) -> void:\n\tstate.physics_process(delta)\n\nfunc transition_to(target_state_path: String, msg: Dictionary = {}", "source": "extracted_function"} {"instruction": "Vervollständige den GDScript-Code:", "input": "## The BattlerRoster provides easy access to combat participants.\n##\n## The roster is a central means of accessing all the [Battler]s in a combat, providing utility\n## methods to filter them for a number of criteria (player, enemy, is_alive, etc.).\n##\n## Note that Battlers must be a descendent (though not necessarily a direct child) of the roster\n## to be included in combat.\n@icon(\"icon_turn_queue.png\")\nclass_name BattlerRoster extends Node\n\n\n## Returns all Battlers existing in the current combat.\nfunc get_battlers() -> Array[Battler]:\n\tvar battler_list: Array[Battler] = []\n\tbattler_list.assign(find_children(\"*\", \"Battler\"))\n\treturn battler_list\n\n\n## Returns all existing player Battlers.\nfunc get_player_battlers() -> Array[Battler]:\n\treturn get_battlers().filter(\n\t\tfunc _filter_players(battler: Battler):\n\t\t\treturn battler.is_player\n\t)\n", "output": "\n## Returns all existing Battlers that are opposed to the player.\nfunc get_enemy_battlers() -> Array[Battler]:\n\treturn get_battlers().filter(\n\t\tfunc _filter_enemies(battler: Battler):\n\t\t\treturn not battler.is_player\n\t)\n\n## Filter an array of Battlers to return only whose health points are currently greater than 0.\nfunc find_live_battlers(battlers: Array[Battler]) -> Array[Battler]:\n\treturn battlers.filter(func(battler: Battler): return battler.stats.health > 0)\n\n## Filter an array of Battlers to find those who are active but do not yet have a cached action (see\n## [member Battler.cached_action]).\nfunc find_battlers_needing_actions(battlers: Array[Battler]) -> Array[Battler]:\n\treturn battlers.filter(\n\t\tfunc _filter_actors(actor: Battler) -> bool:\n\t\t\treturn actor.is_active and actor.cached_action == null\n\t)\n\n## Filter an array of Battlers to find those who may take an action. That is, they are active (see\n## [member Battler.is_active]) and have a cached action ready (see [member Battler.cached_action]).\nfunc find_ready_to_act_battlers(battlers: Array[Battler]) -> Array[Battler]:\n\treturn battlers.filter(\n\t\tfunc _filter_actors(actor: Battler) -> bool:\n\t\t\treturn actor.is_active and actor.cached_action != null\n\t)\n\n## Returns true if all the specified battlers are inactive.\nfunc are_battlers_defeated(battlers: Array[Battler]) -> bool:\n\tfor battler in battlers:\n\t\tif battler.is_active:\n\t\t\treturn false\n\n\treturn true\n\nfunc _to_string() -> String:\n\tvar battlers: = get_battlers()\n\tbattlers.sort_custom(Battler.sort)\n\n\t#var msg: = \"\\n%s (CombatTurnQueue) - round %d\" % [name, round_count]\n\tvar msg: = \"\\n%s - BattlerRoster\" % name\n\tfor battler in battlers:\n\t\tmsg += \"\\n\\t\" + battler.to_string()\n\treturn msg"} {"instruction": "Vervollständige den GDScript-Code:", "input": "#*\n#* is_aligned_with_target.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", "output": "## Checks if the agent is horizontally aligned with the target. [br]\n## Returns [code]SUCCESS[/code] if the agent is horizontally aligned with the target.\n## Returns [code]FAILURE[/code] if not aligned or if target is not a valid node instance.\n\n@export var target_var: StringName = &\"target\"\n@export var tolerance: float = 30.0\n\n# Display a customized name (requires @tool).\nfunc _generate_name() -> String:\n\treturn \"IsAlignedWithTarget \" + LimboUtility.decorate_var(target_var)\n\n# Called each time this task is ticked (aka executed).\nfunc _tick(_delta: float) -> Status:\n\tvar target := blackboard.get_var(target_var) as Node2D\n\tif not is_instance_valid(target):\n\t\treturn FAILURE\n\tvar y_diff: float = absf(target.global_position.y - agent.global_position.y)\n\tif y_diff < tolerance:\n\t\treturn SUCCESS\n\treturn FAILURE\n"} {"instruction": "Erstelle eine Godot-Klasse 'GameboardProperties' die von Resource erbt mit folgenden Funktionen: _to_string", "input": "", "output": "@tool\n## Defines the properties of the playable game map.\nclass_name GameboardProperties extends Resource\n\n## Emitted whenever [member cell_size] changes.\nsignal cell_size_changed\n## Emitted whenever [member extents] changes.\nsignal extents_changed\n\n## An invalid index is not found on the gameboard. Note that this requires positive\n## [member extents].\nconst INVALID_INDEX: = -1\n\n## The extents of the playable area. This property is intended for editor use and should not change\n## during gameplay, as that would change how [Pathfinder] indices are calculated.\n@export var extents: = Rect2i(0, 0, 10, 10):\n\tset(value):\n\t\textents = value\n\n\t\t# Ensure that the boundary size is greater than 0.\n\t\textents.size.x = maxi(extents.size.x, 1)\n\t\textents.size.y = maxi(extents.size.y, 1)\n\t\textents_changed.emit()\n\n## The size of each grid cell. Usually analogous to a [member TileSet.tile_size] of a\n## [GameboardLayer].\n@export var cell_size: = Vector2i(16, 16):\n\tset(value):\n\t\tcell_size = value\n\t\thalf_cell_size = cell_size/2.0\n\t\tcell_size_changed.emit()\n\nvar half_cell_size: = cell_size / 2.0\n\nfunc _to_string() -> String:\n\treturn \"\\n[GameboardProperties resource\" + \\\n\t\t\"\\nCell size: \" + str(cell_size) + \\\n\t\t\"\\nBoard extents: \" + str(extents) + \"]\"\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "extends Control\n\nvar button_count : int = 0\n\n", "output": "func _input(event):\n\tif event is InputEventMouseMotion:\n\t\t# Move our cursor\n\t\tvar mouse_motion : InputEventMouseMotion = event\n\t\t$Cursor.position = mouse_motion.position - Vector2(16, 16)\n\nfunc _on_button_pressed():\n\tbutton_count = button_count + 1\n\t$CountLabel.text = \"The button has been pressed %d times!\" % [ button_count ]\n"} {"instruction": "Erstelle eine Godot-Klasse 'Stats' die von Resource erbt mit folgenden Funktionen: _init, initialize, get_stat, add_modifier, remove_modifier", "input": "", "output": "# Virtual base class for stats (health, speed...) that support upgrades.\n#\n# You must call `initialize()` to initialize the stats' values. This ensures that they are in sync\n# with the values modified in Godot's inspector.\n#\n# Each stat should be a floating point value, and we recommend to make them private properties, as\n# they should be read-only. To get a stat's calculated value, with modifiers, see `get_stat()`.\nclass_name Stats\nextends Resource\n\nsignal stat_changed(stat, old_value, new_value)\n\n# Stores a cached array of property names that are stats as strings, that we use to find and\n# calculate the stats with upgrades from the base stats.\nvar _stats_list := _get_stats_list()\n# Modifiers has a list of modifiers for each property in `_stats_list`. A modifier is a dict that\n# requires a key named `value`. The value of a modifier can be positive or negative.\nvar _modifiers := {}\n# Stores the cached values for the computed stats\nvar _cache := {}\n\n# Initializes the keys in the modifiers dict, ensuring they all exist, without going through the\n# property's setter.\nfunc _init() -> void:\n\tfor stat in _stats_list:\n\t\t_modifiers[stat] = []\n\t\t_cache[stat] = 0.0\n\n# Call this function from your node's ready function, before accessing the stats. This ensures\n# they're all loaded.\nfunc initialize() -> void:\n\t_update_all()\n\n# Get the final value of a stat, with all modifiers applied to it.\nfunc 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# Re"} {"instruction": "Erstelle eine GDScript-Funktion namens '_ready':", "input": "", "output": "func _ready():\n\tblackboard = blackboard.duplicate()\n\t_data[DEFAULT] = blackboard\n\nfunc 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": "# default value provider, simple returns the initial value\nclass_name DefaultValueProvider\nextends ValueProvider\n", "output": "var _value: Variant\n\nfunc _init(value: Variant) -> void:\n\t_value = value\n\nfunc get_value() -> Variant:\n\treturn _value\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "extends Control\n\n@export var controller: XRController3D\n\n@onready var trigger_input_node: HSlider = $VBoxContainer/TriggerInput/HSlider\n@onready var trigger_click_node: CheckBox = $VBoxContainer/TriggerInput/CheckBox\n@onready var on_threshold_node: Label = $VBoxContainer/Thresholds/OnThreshold\n@onready var off_threshold_node: Label = $VBoxContainer/Thresholds/OffThreshold\n\n@onready var dpad_up_node: CheckBox = $VBoxContainer/DPadState/Up\n@onready var dpad_down_node: CheckBox = $VBoxContainer/DPadState/Down\n@onready var dpad_left_node: CheckBox = $VBoxContainer/DPadState/Left\n@onready var dpad_right_node: CheckBox = $VBoxContainer/DPadState/Right", "output": "\nvar off_trigger_threshold: float = 1.0\nvar on_trigger_threshold: float = 0.0\n\nfunc _process(_delta: float) -> void:\n\tif controller:\n\t\tvar trigger_input = controller.get_float(&\"trigger\")\n\t\ttrigger_input_node.value = trigger_input\n\n\t\tvar trigger_click = controller.is_button_pressed(&\"trigger_click\")\n\t\ttrigger_click_node.button_pressed = trigger_click\n\n\t\tif trigger_click:\n\t\t\toff_trigger_threshold = min(off_trigger_threshold, trigger_input)\n\t\telse:\n\t\t\ton_trigger_threshold = max(on_trigger_threshold, trigger_input)\n\n\t\ton_threshold_node.text = \"On: %0.2f\" % on_trigger_threshold\n\t\toff_threshold_node.text = \"Off: %0.2f\" % off_trigger_threshold\n\n\t\tdpad_up_node.button_pressed = controller.is_button_pressed(&\"up\")\n\t\tdpad_down_node.button_pressed = controller.is_button_pressed(&\"down\")\n\t\tdpad_left_node.button_pressed = controller.is_button_pressed(&\"left\")\n\t\tdpad_right_node.button_pressed = controller.is_button_pressed(&\"right\")\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "@icon(\"icons/blackboard.svg\")\nclass_name Blackboard extends Node\n\nconst DEFAULT = \"default\"\n\n## The blackboard is an object that can be used to store and access data between\n## multiple nodes of the behavior tree.\n@export var blackboard: Dictionary = {}:\n\tset(b):\n\t\tblackboard = b.duplicate()\n\t\t_data[DEFAULT] = blackboard\n\nvar _data: Dictionary = {}\n\n\nfunc _ready():\n\tblackboard = blackboard.duplicate()\n\t_data[DEFAULT] = blackboard\n\n\nfunc keys() -> Array[String]:\n\tvar keys: Array[String]\n\tkeys.assign(_data.keys().duplicate())\n\treturn keys\n\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] = {}\n\n\t_data[blackboard_name][key] = value\n\n\nfunc get_value(\n\tkey: Variant, default_value: Variant = null, blackboard_name: String = DEFAULT\n) -> Variant:\n\tif has_value(key, blackboard_name):", "output": "\t\treturn _data[blackboard_name].get(key, default_value)\n\treturn default_value\n\nfunc has_value(key: Variant, blackboard_name: String = DEFAULT) -> bool:\n\treturn (\n\t\t_data.has(blackboard_name)\n\t\tand _data[blackboard_name].has(key)\n\t\tand _data[blackboard_name][key] != null\n\t)\n\nfunc erase_value(key: Variant, blackboard_name: String = DEFAULT) -> void:\n\tif _data.has(blackboard_name):\n\t\t_data[blackboard_name][key] = null\n\nfunc get_debug_data() -> Dictionary:\n\t# Avoid sending raw Objects (Nodes, Resources, etc.) over the\n\t# EngineDebugger connection, which can cause Variant marshalling errors\n\t# and break the editor debugger stream.\n\treturn _sanitize_for_debug(_data)\n\nstatic func _sanitize_for_debug(value: Variant, depth: int = 0) -> Variant:\n\t# Limit recursion depth defensively to avoid issues with deeply nested\n\t# or self‑referential data structures. At this point we only need a\n\t# human‑readable representation for the debugger UI.\n\tif depth > 4:\n\t\treturn str(value)\n\n\tvar t := typeof(value)\n\n\tmatch t:\n\t\tTYPE_DICTIONARY:\n\t\t\tvar result := {}\n\t\t\tfor key in value.keys():\n\t\t\t\tvar safe_key := _sanitize_for_debug(key, depth + 1)\n\t\t\t\tvar safe_val := _sanitize_for_debug(value[key], depth + 1)\n\t\t\t\tresult[safe_key] = safe_val\n\t\t\treturn result\n\n\t\tTYPE_ARRAY:\n\t\t\tvar arr: Array = []\n\t\t\tfor v in value:\n\t\t\t\tarr.append(_sanitize_for_debug(v, depth + 1))\n\t\t\treturn arr\n\n\t\tTYPE_OBJECT:\n\t\t\tif value == null:\n\t\t\t\treturn null"} {"instruction": "Vervollständige den GDScript-Code:", "input": "#*\n#* idle_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#* =============================================================================", "output": "#*\nextends LimboState\n## Idle state.\n\n@export var animation_player: AnimationPlayer\n@export var idle_animation: StringName\n\nfunc _enter() -> void:\n\tanimation_player.play(idle_animation, 0.1)\n\nfunc _update(_delta: float) -> void:\n\tvar horizontal_move: float = Input.get_axis(&\"move_left\", &\"move_right\")\n\tvar vertical_move: float = Input.get_axis(&\"move_up\", &\"move_down\")\n\tif horizontal_move != 0.0 or vertical_move != 0.0:\n\t\tget_root().dispatch(EVENT_FINISHED)\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "extends TileMapLayer\n\n@onready var _occupancy: TileMapLayer = $OccupancyGrid\n\n\nfunc _ready() -> void:\n\t_occupancy.tile_set = tile_set\n", "output": "\tGameboard.pathfinder_changed.connect(\n\t\tfunc _on_pathfinder_changed(added_cells: Array[Vector2i],\n\t\t\t\tremoved_cells: Array[Vector2i]) -> void:\n\t\t\tfor cell in added_cells:\n\t\t\t\tset_cell(cell, 0, Vector2i(0, 0), 0)\n\n\t\t\tfor cell in removed_cells:\n\t\t\t\tset_cell(cell) # Flag the cell as blocked.\n\t)\n\n\tGamepieceRegistry.gamepiece_moved.connect(\n\t\tfunc _on_gp_moved(_gp: Gamepiece, new_cell: Vector2i, old_cell: Vector2i) -> void:\n\t\t\t_occupancy.set_cell(old_cell)\n\t\t\t_occupancy.set_cell(new_cell, 0, Vector2i(1, 0), 0)\n\t)\n"} {"instruction": "Erstelle eine Godot-Klasse 'GdUnitObjectAssert' die von GdUnitAssert erbt mit folgenden Funktionen: is_null, is_not_null, is_equal, is_not_equal, override_failure_message", "input": "", "output": "## An Assertion Tool to verify Object values\n@abstract class_name GdUnitObjectAssert\nextends GdUnitAssert\n\n## Verifies that the current value is null.\n@abstract func is_null() -> GdUnitObjectAssert\n\n## Verifies that the current value is not null.\n@abstract func is_not_null() -> GdUnitObjectAssert\n\n## Verifies that the current value is equal to the given one.\n@abstract func is_equal(expected: Variant) -> GdUnitObjectAssert\n\n## Verifies that the current value is not equal to expected one.\n@abstract func is_not_equal(expected: Variant) -> GdUnitObjectAssert\n\n## Overrides the default failure message by given custom message.\n@abstract func override_failure_message(message: String) -> GdUnitObjectAssert\n\n## Appends a custom message to the failure message.\n@abstract func append_failure_message(message: String) -> GdUnitObjectAssert\n\n## Verifies that the current object is the same as the given one.\n@abstract func is_same(expected: Variant) -> GdUnitObjectAssert\n\n## Verifies that the current object is not the same as the given one.\n@abstract func is_not_same(expected: Variant) -> GdUnitObjectAssert\n\n## Verifies that the current object is an instance of the given type.\n@abstract func is_instanceof(type: Variant) -> GdUnitObjectAssert\n\n## Verifies that the current object is not an instance of the given type.\n@abstract func is_not_instanceof(type: Variant) -> GdUnitObjectAssert\n\n## Checks whether the current object inherits from the specified type.\n@abstract func is_inheriting(type: Variant) -> GdUnitObjectAssert\n\n## Checks whether the current object does NOT inherit from the specified type.\n@abstract func is_not_inheriting(type: Variant) -> GdUnitObjectAssert\n"} {"instruction": "Erstelle eine Godot-Klasse 'GSAIPursue' die von GSAISteeringBehavior erbt mit folgenden Funktionen: _init, _calculate_steering, _get_modified_acceleration", "input": "", "output": "# Calculates an acceleration to make an agent intercept another based on the\n# target agent's movement.\n# @category - Individual behaviors\nclass_name GSAIPursue\nextends GSAISteeringBehavior\n\n# The target agent that the behavior is trying to intercept.\nvar target: GSAISteeringAgent\n# The maximum amount of time in the future the behavior predicts the target's\n# location.\nvar predict_time_max: float\n\nfunc _init(agent: GSAISteeringAgent, _target: GSAISteeringAgent, _predict_time_max := 1.0) -> void:\n\tsuper._init(agent)\n\tself.target = _target\n\tself.predict_time_max = _predict_time_max\n\nfunc _calculate_steering(acceleration: GSAITargetAcceleration) -> void:\n\tvar target_position := target.position\n\tvar distance_squared := (target_position - agent.position).length_squared()\n\n\tvar speed_squared := agent.linear_velocity.length_squared()\n\tvar predict_time := predict_time_max\n\n\tif speed_squared > 0:\n\t\tvar predict_time_squared := distance_squared / speed_squared\n\t\tif predict_time_squared < predict_time_max * predict_time_max:\n\t\t\tpredict_time = sqrt(predict_time_squared)\n\n\tacceleration.linear = ((target_position + (target.linear_velocity * predict_time)) - agent.position).normalized()\n\tacceleration.linear *= _get_modified_acceleration()\n\n\tacceleration.angular = 0\n\nfunc _get_modified_acceleration() -> float:\n\treturn agent.linear_acceleration_max\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "extends GdUnitIntAssert\n\nvar _base: GdUnitAssertImpl\n\n\nfunc _init(current :Variant) -> void:\n\t_base = GdUnitAssertImpl.new(current)\n\t# save the actual assert instance on the current thread context\n\tGdUnitThreadManager.get_current_context().set_assert(self)\n\tif not GdUnitAssertions.validate_value_type(current, TYPE_INT):\n\t\t@warning_ignore(\"return_value_discarded\")\n\t\treport_error(\"GdUnitIntAssert inital error, unexpected type <%s>\" % GdObjects.typeof_as_string(current))\n\n\nfunc _notification(event :int) -> void:\n\tif event == NOTIFICATION_PREDELETE:\n\t\tif _base != null:\n\t\t\t_base.notification(event)\n\t\t\t_base = null\n\n\nfunc current_value() -> Variant:\n\treturn _base.current_value()\n\n\nfunc report_success() -> GdUnitIntAssert:\n\t@warning_ignore(\"return_value_discarded\")\n\t_base.report_success()\n\treturn self\n\n\nfunc report_error(error :String) -> GdUnitIntAssert:\n\t@warning_ignore(\"return_value_discarded\")\n\t_base.report_error(error)\n\treturn self\n\n\nfunc failure_message() -> String:\n\treturn _base.failure_message()\n\n\nfunc override_failure_message(message: String) -> GdUnitIntAssert:\n\t@warning_ignore(\"return_value_discarded\")\n\t_base.override_failure_message(message)\n\treturn self\n\n\nfunc append_failure_message(message: String) -> GdUnitIntAssert:\n\t@warning_ignore(\"return_value_discarded\")\n\t_base.append_failure_message(message)\n\treturn self\n\n\nfunc is_null() -> GdUnitIntAssert:\n\t@warning_ignore(\"return_value_discarded\")", "output": "\t_base.is_null()\n\treturn self\n\nfunc is_not_null() -> GdUnitIntAssert:\n\t@warning_ignore(\"return_value_discarded\")\n\t_base.is_not_null()\n\treturn self\n\nfunc is_equal(expected: Variant) -> GdUnitIntAssert:\n\t@warning_ignore(\"return_value_discarded\")\n\t_base.is_equal(expected)\n\treturn self\n\nfunc is_not_equal(expected: Variant) -> GdUnitIntAssert:\n\t@warning_ignore(\"return_value_discarded\")\n\t_base.is_not_equal(expected)\n\treturn self\n\nfunc is_less(expected :int) -> GdUnitIntAssert:\n\tvar current :Variant = current_value()\n\tif current == null or current >= expected:\n\t\treturn report_error(GdAssertMessages.error_is_value(Comparator.LESS_THAN, current, expected))\n\treturn report_success()\n\nfunc is_less_equal(expected :int) -> GdUnitIntAssert:\n\tvar current :Variant = current_value()\n\tif current == null or current > expected:\n\t\treturn report_error(GdAssertMessages.error_is_value(Comparator.LESS_EQUAL, current, expected))\n\treturn report_success()\n\nfunc is_greater(expected :int) -> GdUnitIntAssert:\n\tvar current :Variant = current_value()\n\tif current == null or current <= expected:\n\t\treturn report_error(GdAssertMessages.error_is_value(Comparator.GREATER_THAN, current, expected))\n\treturn report_success()\n\nfunc is_greater_equal(expected :int) -> GdUnitIntAssert:\n\tvar current :Variant = current_value()\n\tif current == null or current < expected:\n\t\treturn report_error(GdAssertMessages.error_is_value(Comparator.GREATER_EQUAL, current, expected))\n\treturn report_success()\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "#*\n#* player.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 \"res://demo/agents/scripts/agent_base.gd\"\n\n## Player.\n\n@export var dodge_cooldown: float = 0.4\n\n@onready var hsm: LimboHSM = $LimboHSM\n@onready var idle_state: LimboState = $LimboHSM/IdleState\n@onready var move_state: LimboState = $LimboHSM/MoveState\n@onready var attack_state: LimboState = $LimboHSM/AttackState\n@onready var dodge_state: LimboState = $LimboHSM/DodgeState\n\nvar can_dodge: bool = true\nvar attack_pressed: bool = false\n\n\nfunc _ready() -> void:\n\tsuper._ready()\n\tcan_dodge = true\n\t_init_input_events()\n\t_init_state_machine()\n\tdeath.connect(func(): remove_from_group(&\"player\"))\n\n", "output": "func _unhandled_input(event: InputEvent) -> void:\n\tif event.is_echo():\n\t\treturn\n\tif event.is_action_pressed(\"attack\"):\n\t\tattack_pressed = true\n\t\t_process_attack_input()\n\tif event.is_action_pressed(\"dodge\"):\n\t\thsm.dispatch(\"dodge!\")\n\nfunc _process_attack_input() -> void:\n\tif not attack_pressed or hsm.get_active_state() == attack_state:\n\t\treturn\n\thsm.dispatch(\"attack!\")\n\tattack_pressed = false\n\nfunc _init_state_machine() -> void:\n\thsm.add_transition(idle_state, move_state, idle_state.EVENT_FINISHED)\n\thsm.add_transition(move_state, idle_state, move_state.EVENT_FINISHED)\n\thsm.add_transition(idle_state, attack_state, \"attack!\")\n\thsm.add_transition(move_state, attack_state, \"attack!\")\n\thsm.add_transition(attack_state, move_state, attack_state.EVENT_FINISHED)\n\thsm.add_transition(hsm.ANYSTATE, dodge_state, \"dodge!\")\n\thsm.add_transition(dodge_state, move_state, dodge_state.EVENT_FINISHED)\n\n\tdodge_state.set_guard(_can_dodge)\n\tattack_state.set_guard(attack_state.can_enter)\n\n\t# Process attack input buffer when move_state is entered.\n\t# This way we can buffer the attack button presses and chain the attacks.\n\tmove_state.call_on_enter(_process_attack_input)\n\n\thsm.initialize(self)\n\thsm.set_active(true)\n\nfunc _init_input_events() -> void:\n\t# Note: Ensures that input events are present even if project.godot wasn't imported.\n\t_add_action(&\"move_left\", KEY_A)\n\t_add_action(&\"move_right\", KEY_D)\n\t_add_action(&\"move_up\", KEY_W)\n\t_add_action(&\"move_down\", KEY_S)\n\t_add_action(&\"dodge\", KEY_SPACE)\n\t_add_action(&\"attack\", KEY_ENTER, KEY_F)\n\nfunc _add_action(p_action: StringName, p_key: Key, p_alt: Key = KEY_NONE) -> void:\n\tif not InputMap.has_action(p_action):\n\t\tInputMap.add_action(p_action)"} {"instruction": "Erstelle eine Godot-Klasse 'GdAssertMessages' die von Resource erbt mit folgenden Funktionen: format_dict, input_event_as_text, _colored_string_div, colored_array_div, _typed_value", "input": "", "output": "class_name GdAssertMessages\nextends Resource\n\nconst WARN_COLOR = \"#EFF883\"\nconst ERROR_COLOR = \"#CD5C5C\"\nconst VALUE_COLOR = \"#1E90FF\"\nconst SUB_COLOR := Color(1, 0, 0, .15)\nconst ADD_COLOR := Color(0, 1, 0, .15)\n\n# Dictionary of control characters and their readable representations\nconst CONTROL_CHARS = {\n\t\"\\n\": \"\", # Line Feed\n\t\"\\r\": \"\", # Carriage Return\n\t\"\\t\": \"\", # Tab\n\t\"\\b\": \"\", # Backspace\n\t\"\\f\": \"\", # Form Feed\n\t\"\\v\": \"\", # Vertical Tab\n\t\"\\a\": \"\", # Bell\n\t\"\u001b\": \"\" # Escape\n}\n\nstatic func format_dict(value :Variant) -> String:\n\tif not value is Dictionary:\n\t\treturn str(value)\n\n\tvar dict_value: Dictionary = value\n\tif dict_value.is_empty():\n\t\treturn \"{ }\"\n\tvar as_rows := var_to_str(value).split(\"\\n\")\n\tfor index in range( 1, as_rows.size()-1):\n\t\tas_rows[index] = \"\t\" + as_rows[index]\n\tas_rows[-1] = \" \" + as_rows[-1]\n\treturn \"\\n\".join(as_rows)\n\n# improved version of InputEvent as text\nstatic func input_event_as_text(event :InputEvent) -> String:\n\tvar text := \"\"\n\tif event is InputEventKey:\n\t\tvar key_event := event as InputEventKey\n\t\ttext += \"\"\"\n\t\t\tInputEventKey : keycode=%s (%s) pressed: %s\n\t\t\t\tphysical_keycode: %s\n\t\t\t\tlocation: %s\n\t\t\t\techo: %s\"\"\" % [\n\t\t\t\t\tkey_event.keycode,\n\t\t\t\t\tkey_event.as_text_keycode(),\n\t\t\t\t\tkey_event.pressed,\n\t\t\t\t\tkey_event.physical_keycode,\n\t\t\t\t\tkey_event.location,\n\t\t\t\t\tkey_event.echo]\n\telse:\n\t\ttext += event.as_text()\n\tif event is InputEventMouse:\n\t\tvar mouse_event := event as InputEventMouse\n\t\ttext += \"\"\"\n\t\t\t\tglobal_position: %s\"\"\" % mouse_event.global_position\n\tif event is InputEventWithModifiers:\n\t\tvar mouse_event := event as InputEventWithModifiers\n\t\ttext += \"\"\"\n\t\t\t\t--------\n\t\t\t\tmods: %s\n\t\t\t\tshift: %s\n\t\t\t\talt: %s\n\t\t\t\tcontrol: %s\n\t\t\t\tmeta: %s\n\t\t\t\tcommand: %s\"\"\" % [\n\t\t\t\t\tmouse_event.get_modifiers_mask(),\n\t\t\t\t\tmouse_event.shift_pressed,\n\t\t\t\t\tmouse_event.alt_pressed,\n\t\t\t\t\tmouse_event.ctrl_pressed,\n\t\t\t\t\tmouse_event.meta_pressed,\n\t\t\t\t\tmouse_event.command_or_control_autoremap]\n\treturn text.de"} {"instruction": "Vervollständige den GDScript-Code:", "input": "# Container for multiple behaviors that returns the result of the first child\n# behavior with non-zero acceleration.\n# @category - Combination behaviors\nclass_name GSAIPriority\nextends GSAISteeringBehavior\n\nvar _behaviors := []\n\n# The index of the last behavior the container prioritized.\nvar last_selected_index: int\n# If a behavior's acceleration is lower than this threshold, the container\n# considers it has an acceleration of zero.\nvar zero_threshold: float\n\n\nfunc _init(agent: GSAISteeringAgent, _zero_threshold := 0.001) -> void:\n\tsuper._init(agent)", "output": "\tself.zero_threshold = _zero_threshold\n\n# Appends a steering behavior as a child of this container.\nfunc add(behavior: GSAISteeringBehavior) -> void:\n\t_behaviors.append(behavior)\n\n# Returns the behavior at the position in the pool referred to by `index`, or\n# `null` if no behavior was found.\nfunc get_behavior_at(index: int) -> GSAISteeringBehavior:\n\tif _behaviors.size() > index:\n\t\treturn _behaviors[index]\n\tprinterr(\"Tried to get index \" + str(index) + \" in array of size \" + str(_behaviors.size()))\n\treturn null\n\nfunc _calculate_steering(accel: GSAITargetAcceleration) -> void:\n\tvar threshold_squared := zero_threshold * zero_threshold\n\n\tlast_selected_index = -1\n\n\tvar size := _behaviors.size()\n\n\tif size > 0:\n\t\tfor i in range(size):\n\t\t\tlast_selected_index = i\n\t\t\tvar behavior: GSAISteeringBehavior = _behaviors[i]\n\t\t\tbehavior.calculate_steering(accel)\n\n\t\t\tif accel.get_magnitude_squared() > threshold_squared:\n\t\t\t\tbreak\n\telse:\n\t\taccel.set_zero()\n"} {"instruction": "Erstelle eine Godot-Klasse 'Inventory' die von Resource erbt mit folgenden Funktionen: _init, restore, add, remove, get_item_count", "input": "", "output": "@tool\n## A simple inventory implementation that includes all item types and data within the class.\nclass_name Inventory extends Resource\n\n## All item types available to add or remove from the inventory.\nenum ItemTypes { KEY, COIN, BOMB, RED_WAND, BLUE_WAND, GREEN_WAND }\n\n#TODO: I expect we'll want to have a proper inventory definition somewhere. Some folks advocate for\n# spreadsheets, but whatever it is should probably integrate with the editor so that level designers\n# can easily pick from items from a dropdown list, or something similar.\n## Icons associated with the [member ItemTypes].\nconst ICONS: = {\n\tItemTypes.KEY: preload(\"res://assets/items/key.atlastex\"),\n\tItemTypes.COIN: preload(\"res://assets/items/coin.atlastex\"),\n\tItemTypes.BOMB: preload(\"res://assets/items/bomb.atlastex\"),\n\tItemTypes.RED_WAND: preload(\"res://assets/items/wand_red.atlastex\"),\n\tItemTypes.BLUE_WAND: preload(\"res://assets/items/wand_blue.atlastex\"),\n\tItemTypes.GREEN_WAND: preload(\"res://assets/items/wand_green.atlastex\"),\n}\n\nconst INVENTORY_PATH: = \"user://inventory.tres\"\n\n## Emitted when the count of a given item type changes.\nsignal item_changed(type: ItemTypes)\n\n# Keep track of what is in the inventory. Dictionary keys are an ItemType, values are the amount.\n@export var _items: = {}\n\nfunc _init() -> void:\n\tfor item_name in ItemTypes:\n\t\t_items[ItemTypes[item_name]] = 0\n\n## Load the [Inventory] from file or create a new resource, if it was missing. Godot caches calls,\n## so this can be used every time needed.\nstatic func restore() -> Inventory:\n\tif Engine.is_editor_hint():\n\t\treturn null\n\n\tif FileAccess.file_exists(INVENTORY_PATH):\n\t\tvar inventory = ResourceLoader.load(INVENTORY_PATH) as Inventory\n\t\tif inventory:\n\t\t\treturn inventory\n\n\t# Either there is no inventory associated with this profile or the file itself could not be\n\t# loaded. Either way, a new inventory resource must be created.\n\tvar new_inventory: = Inventory.new()\n\tnew_inventory.save()\n\treturn new_inventory\n\n## Increment th"} {"instruction": "Erstelle eine GDScript-Funktion namens '_notification':", "input": "", "output": "func _notification(event: int) -> void:\n\tif event == NOTIFICATION_PREDELETE:\n\t\tif _base != null:\n\t\t\t_base.notification(event)\n\t\t\t_base = null\n\nfunc report_success() -> GdUnitArrayAssert:\n\t@warning_ignore(\"return_value_discarded\")\n\t_base.report_success()\n\treturn self\n\nfunc report_error(error: String) -> GdUnitArrayAssert:\n\t@warning_ignore(\"return_value_discarded\")\n\t_base.report_error(error)\n\treturn self\n\nfunc failure_message() -> String:\n\treturn _base.failure_message()\n\nfunc override_failure_message(message: String) -> GdUnitArrayAssert:\n\t@warning_ignore(\"return_value_discarded\")\n\t_base.override_failure_message(message)\n\treturn self\n\nfunc append_failure_message(message: String) -> GdUnitArrayAssert:\n\t@warning_ignore(\"return_value_discarded\")\n\t_base.append_failure_message(message)\n\treturn self\n\nfunc _validate_value_type(value: Variant) -> bool:\n\treturn value == null or GdArrayTools.is_array_type(value)\n\nfunc get_current_value() -> Variant:\n\treturn _current_value_provider.get_value()\n\nfunc max_length(left: Variant, right: Variant) -> int:\n\tvar ls := str(left).length()\n\tvar rs := str(right).length()\n\treturn rs if ls < rs else ls\n\n# gdlint: disable=function-name\nfunc _toPackedStringArray(value: Variant) -> PackedStringArray:\n\tif GdArrayTools.is_array_type(value):\n\t\t@warning_ignore(\"unsafe_cast\")\n\t\treturn PackedStringArray(value as Array)\n\treturn PackedStringArray([str(value)])\n\nfunc _array_equals_div(current: Variant, expected: Variant, case_sensitive: bool = false) -> Array:\n\tvar current_value := _toPackedStringArray(current)\n\tvar expected_value := _toPackedStringArray(expected)\n\tvar index_report := Array()\n\tfor index in current_value.size():\n\t\tvar c := current_value[index]\n\t\tif index < expected_value.size():\n\t\t\tvar e := expected_value[index]\n\t\t\tif not GdObjects.equals(c, e, case_sensitive):\n\t\t\t\tvar length := max_length(c, e)\n\t\t\t\tcurrent_value[index] = GdAssertMessages.format_invalid(c.lpad(length))\n\t\t\t\texpected_value[index] = e.lpad(length)\n\t\t\t\tindex_report.push_back({\"index\": index, \"current\": c, \"expected\": e}"} {"instruction": "Vervollständige den GDScript-Code:", "input": "@tool\nclass_name PickupHandler3D\nextends Area3D\n\n# This area3D class detects all physics bodies based on\n# PickupAbleBody3D within range and handles the logic\n# for selecting the closest one and allowing pickup\n# of that object.\n\n# Detect range specifies within what radius we detect\n# objects we can pick up.\n@export var detect_range : float = 0.3:\n\tset(value):\n\t\tdetect_range = value\n\t\tif is_inside_tree():\n\t\t\t_update_detect_range()\n\t\t\t_update_closest_body()\n\n# Pickup Action specifies the action in the OpenXR\n# action map that triggers our pickup function.\n@export var pickup_action : String = \"pickup\"\n\nvar closest_body : PickupAbleBody3D\nvar picked_up_body: PickupAbleBody3D\nvar was_pickup_pressed : bool = false\n\n\n# Update our detection range.\nfunc _update_detect_range() -> void:\n\tvar shape : SphereShape3D = $CollisionShape3D.shape\n\tif shape:\n\t\tshape.radius = detect_range\n\n\n# Update our closest body.\nfunc _update_closest_body() -> void:\n\t# Do not do this when we're in the editor.\n\tif Engine.is_editor_hint():\n\t\treturn\n", "output": "\t# Do not check this if we've picked something up.\n\tif picked_up_body:\n\t\tif closest_body:\n\t\t\tclosest_body.remove_is_closest(self)\n\t\t\tclosest_body = null\n\n\t\treturn\n\n\t# Find the body that is currently the closest.\n\tvar new_closest_body : PickupAbleBody3D\n\tvar closest_distance : float = 1000000.0\n\n\tfor body in get_overlapping_bodies():\n\t\tif body is PickupAbleBody3D and not body.is_picked_up():\n\t\t\tvar distance_squared = (body.global_position - global_position).length_squared()\n\t\t\tif distance_squared < closest_distance:\n\t\t\t\tnew_closest_body = body\n\t\t\t\tclosest_distance = distance_squared\n\n\t# Unchanged? Just exit\n\tif closest_body == new_closest_body:\n\t\treturn\n\n\t# We had a closest body\n\tif closest_body:\n\t\tclosest_body.remove_is_closest(self)\n\n\tclosest_body = new_closest_body\n\tif closest_body:\n\t\tclosest_body.add_is_closest(self)\n\n# Get our controller that we are a child of\nfunc _get_parent_controller() -> XRController3D:\n\tvar parent : Node = get_parent()\n\twhile parent:\n\t\tif parent is XRController3D:\n\t\t\treturn parent\n\n\t\tparent = parent.get_parent()\n\n\treturn null\n\n# Called when the node enters the scene tree for the first time.\nfunc _ready() -> void:\n\t_update_detect_range()\n\t_update_closest_body()\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "extends Camera3D\n\n## This script allows us to place a camera in the world that provides\n## a spectator view where we see what the player sees.\n## The positioning is smoothed to create a steadycam type of effect.\n\n## Specify the XRCamera3D node we're replicating the view for.\n@export var xr_camera : XRCamera3D\n\n## Remove pitch from our camera orientation?\n@export var remove_pitch : bool = true\n\n## Speed at which we lerp, the lower the more stable our camera gets\n## at the cost of introducing more lag.\n@export_range(1.0, 60.0, 1.0) var lerp_speed : float = 10.0\n\nvar prev_camera_transform : Transform3D", "output": "var first_frame : bool = true\n\n# Called every frame. 'delta' is the elapsed time since the previous frame.\nfunc _process(delta):\n\tif current and xr_camera:\n\t\t# Note, we apply our smoothing in the local space of our XROrigin3D node.\n\t\t# This way we don't apply smoothing when game logic moves the XROrigin3D node.\n\t\t# We only apply smoothing to the physical movement of the player.\n\t\t# This makes the spectator view easier to watch by a 3rd party.\n\n\t\t# We smooth out the camera.\n\t\tvar camera_transform : Transform3D = xr_camera.transform\n\n\t\tif remove_pitch:\n\t\t\t# Remove pitch from camera.\n\t\t\tcamera_transform.basis = Basis.looking_at(camera_transform.basis.z, Vector3.UP, true)\n\n\t\tif first_frame:\n\t\t\tfirst_frame = false\n\t\telse:\n\t\t\t# We (s)lerp our physical camera movement to smooth things out.\n\t\t\tcamera_transform.basis = prev_camera_transform.basis.slerp(camera_transform.basis, delta * lerp_speed)\n\t\t\tcamera_transform.origin = prev_camera_transform.origin.lerp(camera_transform.origin, delta * lerp_speed)\n\n\t\t# Update our first person view.\n\t\tglobal_transform = xr_camera.get_parent().global_transform * camera_transform\n\n\t\t# Store camera transform for next frame.\n\t\tprev_camera_transform = camera_transform\n\telse:\n\t\t# Make sure next time we run through this we don't lerp.\n\t\tfirst_frame = true\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "extends AudioStreamPlayer\n\n@export var conductor: Conductor\n\nvar _playing: bool = false\nvar _last_beat: float = -17 # 16 beat count-in\nvar _cached_latency: float = AudioServer.get_output_latency()\n", "output": "\nfunc _process(_delta: float) -> void:\n\tif not _playing:\n\t\treturn\n\n\t# Note that this implementation is flawed since every tick is rounded to the\n\t# next mix window (~11ms at the default 44100 Hz mix rate) due to Godot's\n\t# audio mix buffer. Precise audio scheduling is requested in\n\t# https://github.com/godotengine/godot-proposals/issues/1151.\n\tvar curr_beat := conductor.get_current_beat() + _cached_latency\n\tif GlobalSettings.enable_metronome and floor(curr_beat) > floor(_last_beat):\n\t\tplay()\n\t_last_beat = max(_last_beat, curr_beat)\n\nfunc start() -> void:\n\t_playing = true\n"} {"instruction": "Erstelle eine Godot-Klasse 'Blackboard' die von Node erbt mit folgenden Funktionen: _ready, keys, set_value, get_value, has_value", "input": "", "output": "@icon(\"icons/blackboard.svg\")\nclass_name Blackboard extends Node\n\nconst DEFAULT = \"default\"\n\n## The blackboard is an object that can be used to store and access data between\n## multiple nodes of the behavior tree.\n@export var blackboard: Dictionary = {}:\n\tset(b):\n\t\tblackboard = b.duplicate()\n\t\t_data[DEFAULT] = blackboard\n\nvar _data: Dictionary = {}\n\nfunc _ready():\n\tblackboard = blackboard.duplicate()\n\t_data[DEFAULT] = blackboard\n\nfunc 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] = {}\n\n\t_data[blackboard_name][key] = value\n\nfunc get_value(\n\tkey: Variant, default_value: Variant = null, blackboard_name: String = DEFAULT\n) -> Variant:\n\tif has_value(key, blackboard_name):\n\t\treturn _data[blackboard_name].get(key, default_value)\n\treturn default_value\n\nfunc has_value(key: Variant, blackboard_name: String = DEFAULT) -> bool:\n\treturn (\n\t\t_data.has(blackboard_name)\n\t\tand _data[blackboard_name].has(key)\n\t\tand _data[blackboard_name][key] != null\n\t)\n\nfunc erase_value(key: Variant, blackboard_name: String = DEFAULT) -> void:\n\tif _data.has(blackboard_name):\n\t\t_data[blackboard_name][key] = null\n\nfunc get_debug_data() -> Dictionary:\n\t# Avoid sending raw Objects (Nodes, Resources, etc.) over the\n\t# EngineDebugger connection, which can cause Variant marshalling errors\n\t# and break the editor debugger stream.\n\treturn _sanitize_for_debug(_data)\n\nstatic func _sanitize_for_debug(value: Variant, depth: int = 0) -> Variant:\n\t# Limit recursion depth defensively to avoid issues with deeply nested\n\t# or self‑referential data structures. At this point we only need a\n\t# human‑readable representation for the debugger UI.\n\tif depth > 4:\n\t\treturn str(value)\n\n\tvar t := typeof(value)\n\n\tmatch t:\n\t\tTYPE_DICTIONARY:\n\t\t\tvar result := {}\n\t\t\tfor key in value.keys():\n\t\t\t\tvar safe_key := _sanitize_f"} {"instruction": "Vervollständige den GDScript-Code:", "input": "extends CharacterBody2D\n\n@onready var animation_player: AnimationPlayer = $AnimationPlayer\n@onready var hurtbox: Hurtbox = $Hurtbox\n@onready var root: Node2D = $Root", "output": "\nfunc _on_health_damaged(_amount: float, _knockback: Vector2) -> void:\n\troot.scale.x = -signf(hurtbox.last_attack_vector.x)\n\tanimation_player.clear_queue()\n\tanimation_player.play(&\"hurt\", 0.1)\n\nfunc get_facing() -> float:\n\treturn signf(root.scale.x)\n"} {"instruction": "Erstelle eine Godot-Klasse 'UIPopup' die von Node2D erbt mit folgenden Funktionen: _ready, hide_and_free, _on_bounce_finished, _on_animation_finished", "input": "", "output": "@tool\n## An animated pop-up graphic. These are often found, for example, in dialogue bubbles to\n## demonstrate the need for player input.\nclass_name UIPopup extends Node2D\n\n## Emitted when the popup has completely disappeared.\nsignal disappeared\n\n## The states in which a popup may exist.\nenum States { HIDDEN, SHOWN, HIDING, SHOWING}\n\n# The target state of the popup. Setting it to true or false will cause a change in behaviour.\n# True if the popup should be shown or false if the popup should be hidden.\n# Note that this shows the TARGET state of the popup, so _is_shown may be false even while the\n# popup is appearing.\nvar _is_shown: = false:\n\tset(value):\n\t\t_is_shown = value\n\n\t\tif not is_inside_tree():\n\t\t\tawait ready\n\n\t\tif _is_shown and _state == States.HIDDEN:\n\t\t\t_anim.play(\"appear\")\n\t\t\t_state = States.SHOWING\n\n\t\t# A fully shown, idling popup bounces slightly to draw the player's eye. Note that there is\n\t\t# a small wait time between bounces so that the popup doesn't look overly energetic.\n\t\t# Unfortunately, this creates an edge case for smooth animation (see _on_bounce_finished).\n\t\t#\n\t\t# Basically, if the bounce animation isn't playing, but the popup is waiting for the next\n\t\t# 'bounce', we want to be able to hide the popup immediately, rather than wait for 'wait'\n\t\t# a fraction of a second for the animation to finish playing, which looks 'off'.\n\t\t#\n\t\t# So, we check here to see if the popup is sitting in this 'wait' window, where it can be\n\t\t# immediately hidden and still look smooth as butter.\n\t\telif not _is_shown and _anim.current_animation == \"bounce_wait\":\n\t\t\t_anim.play(\"disappear\")\n\t\t\t_state = States.HIDING\n\n# Track what is currently happening to the popup.\nvar _state: = States.HIDDEN\n\n@onready var _anim: = $AnimationPlayer as AnimationPlayer\n@onready var _sprite: = $Sprite2D as Sprite2D\n\nfunc _ready() -> void:\n\tif not Engine.is_editor_hint():\n\t\t_sprite.scale = Vector2.ZERO\n\t\t_anim.animation_finished.connect(_on_animation_finished)\n\n## Wait for the popu"} {"instruction": "Erstelle eine Godot-Klasse 'RandomAction' die von ActionLeaf erbt mit folgenden Funktionen: _get_random_action, tick", "input": "", "output": "## Random action node that changes its state over time.\n##\n## Action node that returns a random status, depending on the action\n## [member weights]. Changes its status every [member reset_duration_msec]\n## milliseconds.\n@tool\nclass_name RandomAction extends ActionLeaf\n\n## How often this action changes its return status, in milliseconds.\n@export var reset_duration_msec: = 1000\n\nvar last_step = 0\nvar action = 0\n\n## Array of 3 floats signifying the weights of SUCCESS, FAILURE and RUNNING\n## statuses respectively.\nvar weights = [3., 3., 1.]\n\nfunc _get_random_action():\n\tvar sum = 0.\n\tfor w in weights:\n\t\tsum += w\n\tvar rnd = randf_range(0, sum)\n\tfor i in weights.size():\n\t\tif rnd <= weights[i]:\n\t\t\treturn i\n\t\trnd -= weights[i]\n\treturn weights.size() - 1\n\nfunc tick(actor: Node, blackboard: Blackboard) -> int:\n\tvar step = Time.get_ticks_msec() / reset_duration_msec\n\tif step != last_step:\n\t\taction = _get_random_action()\n\t\tlast_step = step\n\treturn action\n"} {"instruction": "Erstelle eine GDScript-Funktion namens 'get_cell_under_node':", "input": "", "output": "func get_cell_under_node(node: Node2D) -> Vector2i:\n\treturn pixel_to_cell(node.global_position/node.global_scale)\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\n\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)\n\t\tvar removed_cells: = _remove_cells_from_pathfinder(blocked_cells)\n\n\t\t_connect_new_pathfinder_cells(added_cells)\n\t\tif not added_cells.is_empty() or not removed_cells.is_empty():\n\t\t\tpathfinder_changed.emit(added_cells.values(), removed_cells)\n\t)\n\n# Add cells to the pathfinder, checking that there are no blocking tiles on any GameboardLayers.\n# Returns a dictionary representing the cells that are actually added to the pathfinder (may differ\n# from cleared_cells). Key = cell id (int, see cell_to_index), value = coordinate (Vector2i)\nfunc _add_cells_to_pathfinder(cleared_cells: Array[Vector2i]) -> Dictionary[int, Vector2i]:\n\tvar added_cells: Dictionary[int, Vector2i] = {}", "source": "extracted_function"} {"instruction": "Vervollständige den GDScript-Code:", "input": "# Spawns the station, asteroids, and pirates when entering the game.\n# Keeps track of resources available in the world and which asteroid clusters holds it,\n# and spawns more when running low.\n# It also signals the pirate spawner when an upgrade has been made.\nclass_name GameWorld\nextends Node2D\n\n# Radius of the world in pixels.\n@export var radius := 8000.0\n\n# Minimum amount of iron that must be added when the world spawns new asteroids.\n# Used in `_spawn_asteroids`.\n@export var iron_amount_balance_level := 100.0\n# If the amouns of iron in the world goes below this threshold, spawns new asteroids.\n@export var refresh_threshold_range := 25.0\n\nvar _spawned_positions := []\nvar _world_objects := []\nvar _iron_clusters := {}\n\n@onready var rng := RandomNumberGenerator.new()\n\n@onready var station_spawner: StationSpawner = $StationSpawner\n@onready var asteroid_spawner: AsteroidSpawner = $AsteroidSpawner", "output": "@onready var pirate_spawner: PirateSpawner = $PirateSpawner\n\nfunc _ready() -> void:\n\tawait owner.ready\n\tsetup()\n\nfunc setup() -> void:\n\trng.randomize()\n\n\tEvents.upgrade_chosen.connect(_on_Events_upgrade_chosen)\n\tasteroid_spawner.cluster_depleted.connect(_on_AsteroidSpawner_cluster_depleted)\n\n\tstation_spawner.spawn_station(rng)\n\tasteroid_spawner.spawn_asteroid_clusters(rng, iron_amount_balance_level, radius)\n\tpirate_spawner.spawn_pirate_group(\n\t\trng, 0, radius, _find_largest_inoccupied_asteroid_cluster().global_position\n\t)\n\n# Returns the AsteroidCluster with the most iron that isn't occupied.\n# If all clusters are occupied, returns `null`.\nfunc _find_largest_inoccupied_asteroid_cluster() -> AsteroidCluster:\n\tvar target_cluster: AsteroidCluster\n\n\tvar target_cluster_iron_amount := -INF\n\tfor cluster in asteroid_spawner.get_children():\n\t\tassert(cluster is AsteroidCluster)\n\t\tif cluster.is_occupied:\n\t\t\tcontinue\n\t\tif cluster.iron_amount > target_cluster_iron_amount:\n\t\t\ttarget_cluster = cluster\n\t\t\ttarget_cluster_iron_amount = cluster.iron_amount\n\tif target_cluster:\n\t\ttarget_cluster.is_occupied = true\n\treturn target_cluster\n\n# Spawn a new group of pirates upon getting an upgrade\nfunc _on_Events_upgrade_chosen(_choice) -> void:\n\tvar target_cluster := _find_largest_inoccupied_asteroid_cluster()\n\tif target_cluster:\n\t\tpirate_spawner.spawn_pirate_group(rng, 0, radius, target_cluster.global_position)\n\nfunc _on_AsteroidSpawner_cluster_depleted(iron_left: float) -> void:\n\tif iron_left < refresh_threshold_range:\n\t\tasteroid_spawner.spawn_asteroid_clusters(rng, iron_amount_balance_level, radius)\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "# One-shot particle emitter that recycles itself after use.\nextends GPUParticles2D\n\n@onready var timer := $Timer\nvar is_dying := false\n\n", "output": "func _ready() -> void:\n\tone_shot = true\n\temitting = true\n\nfunc _process(_delta: float) -> void:\n\tif not emitting and not is_dying:\n\t\tdie()\n\nfunc die() -> void:\n\tis_dying = true\n\ttimer.start(lifetime)\n\tawait timer.timeout\n\tqueue_free()\n"} {"instruction": "Erstelle eine Godot-Klasse 'CollisionFinder' die von RefCounted erbt mit folgenden Funktionen: _init, search", "input": "", "output": "## Find all collision shapes of a given mask within a specified search radius.\n##\n## The CollisionFinder is used to search for objects that contain a [CollisionObject2D]. In the\n## OpenRPG it serves as the cornerstone of the [Gameboard]/[Gamepiece] system, since objects\n## (gamepieces, terrain, etc.) are found dynamically by collision shape.\n##\n## [br][br]For example, to see if a given cell is occupied a CollisionFinder would be used to\n## [method search] for collision shapes at that cell's location.\n##\n## [br][br][b]Note:[/b] physics objects update on the physics 'tick' so changes in position often\n## need a single frame before they may be found by [method search].\nclass_name CollisionFinder\nextends RefCounted\n\n## Cache the search parameters to quickly perform multiple searches.\nvar query_parameters: PhysicsShapeQueryParameters2D\n\n# Cache the space state that will be queried.\nvar _space_state: PhysicsDirectSpaceState2D\n\nfunc _init(space_state: PhysicsDirectSpaceState2D, search_radius: float, collision_mask: int,\n\t\tfind_areas: = true) -> void:\n\t_space_state = space_state\n\n\tvar query_shape: = CircleShape2D.new()\n\tquery_shape.radius = search_radius\n\n\tquery_parameters = PhysicsShapeQueryParameters2D.new()\n\tquery_parameters.shape = query_shape\n\tquery_parameters.collision_mask = collision_mask\n\tquery_parameters.collide_with_areas = find_areas\n\n## Find all collision shapes intersecting the query shape at position (in global coordinates).\n##\n## Please see [method PhysicsDirectSpaceState2D.intersect_shape] for possible return values.\n## [br][br][b]Note:[/b] [code]position[/code] must be given in global coordinates.\nfunc search(position: Vector2) -> Array[Dictionary]:\n\t# To find collision shapes we'll query the PhysicsDirectSpaceState2D (usually from the main\n\t# viewport's current World2D). Any intersecting collision shape matching the provided collision\n\t# mask will be included in the results.\n\tquery_parameters.transform.origin = position\n\n\treturn _space_state.int"} {"instruction": "Vervollständige den GDScript-Code:", "input": "extends Control\n\nconst EXPOSE_DURATION := 2.0\nconst FADE_DURATION := 0.5\n\n@onready var container := $HBoxContainer/CenterContainer\n@onready var tween := create_tween()\n@onready var keyboard := container.get_node(\"AnyKey\")\n@onready var xbox := container.get_node(\"XboxA\")\n@onready var playstation := container.get_node(\"PlaystationX\")\n@onready var nintendo := container.get_node(\"NintendoB\")\n\n@onready var elements := [keyboard, xbox, playstation, nintendo]\n", "output": "\nfunc _ready() -> void:\n\tvar total_time := 0.0\n\tfor element in elements:\n\t\ttotal_time += _fade_in(element, total_time)\n\t\ttotal_time += _fade_out(element, total_time)\n\ttween.set_loops()\n\ttween.play()\n\nfunc _fade_in(target: Control, total_time: float) -> float:\n\ttween.tween_property(\n\t\ttarget,\n\t\t\"modulate\",\n\t\tColor.WHITE,\n\t\tFADE_DURATION\n\t).from(Color.TRANSPARENT).set_ease(Tween.EASE_OUT).set_trans(Tween.TRANS_LINEAR)\n\treturn FADE_DURATION\n\nfunc _fade_out(target: Control, total_time: float) -> float:\n\ttween.tween_property(\n\t\ttarget,\n\t\t\"modulate\",\n\t\tColor.TRANSPARENT,\n\t\tFADE_DURATION\n\t).from(Color.WHITE).set_ease(Tween.EASE_OUT).set_trans(Tween.TRANS_LINEAR)\n\treturn FADE_DURATION + EXPOSE_DURATION\n"} {"instruction": "Erstelle eine Godot-Klasse 'PianoKey' die von Control erbt mit folgenden Funktionen: setup, activate, deactivate", "input": "", "output": "class_name PianoKey\nextends Control\n\nvar pitch_scale: float\n\n@onready var key: ColorRect = $Key\n@onready var start_color: Color = key.color\n@onready var color_timer: Timer = $ColorTimer\n\nfunc setup(pitch_index: int) -> void:\n\tname = \"PianoKey\" + str(pitch_index)\n\tvar exponent := (pitch_index - 69.0) / 12.0\n\tpitch_scale = pow(2, exponent)\n\nfunc activate() -> void:\n\tkey.color = (Color.YELLOW + start_color) / 2\n\tvar audio := AudioStreamPlayer.new()\n\tadd_child(audio)\n\taudio.stream = preload(\"res://piano_keys/A440.wav\")\n\taudio.pitch_scale = pitch_scale\n\taudio.play()\n\tcolor_timer.start()\n\tawait get_tree().create_timer(8.0).timeout\n\taudio.queue_free()\n\nfunc deactivate() -> void:\n\tkey.color = start_color\n"} {"instruction": "Erstelle eine Godot-Klasse 'GSAICharacterBody2DAgent' die von GSAISpecializedAgent erbt mit folgenden Funktionen: _init, _apply_steering, _apply_sliding_steering, _apply_collide_steering, _apply_position_steering", "input": "", "output": "# A specialized steering agent that updates itself every frame so the user does\n# not have to using a CharacterBody2D\n# @category - Specialized agents\nclass_name GSAICharacterBody2DAgent\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 CharacterBody2D to keep track of\nvar body: CharacterBody2D: set = _set_body\n\n# The type of movement the body executes\nvar movement_type: int\n\nvar _last_position: Vector2\nvar _body_ref: WeakRef\n\nfunc _init(_body: CharacterBody2D, _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# 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\nfunc _apply_sliding_steering(accel: Vector3, delta: float) -> void:\n\tvar _body: CharacterBody2D = _body_ref.get_ref()\n\tif not _body:\n\t\treturn\n\n\tif not _body.is_inside_tree():\n\t\treturn\n\n\t_body.velocity = GSAIUtils.to_vector2(linear_velocity + accel * delta).limit_length(linear_speed_max)\n\tif apply_linear_drag:\n\t\t_body.velocity = _body.velocity.lerp(Vector2.ZERO, linear_drag_percentage)\n\n\t_body.move_and_slide()\n\n\tif calculate_velocities:\n\t\tlinear_velocity = GSAIUtils.to_vector3(_body.velocity)\n\nfunc _apply_collide_steering(accel: Vector3, delta: float) -> void:\n\tvar _body: CharacterBody2D = _body_ref.get_ref()\n\tif not _bo"} {"instruction": "Erstelle eine GDScript-Funktion namens 'report_success':", "input": "", "output": "func report_success() -> GdUnitArrayAssert:\n\t@warning_ignore(\"return_value_discarded\")\n\t_base.report_success()\n\treturn self\n\nfunc report_error(error: String) -> GdUnitArrayAssert:\n\t@warning_ignore(\"return_value_discarded\")\n\t_base.report_error(error)\n\treturn self\n\nfunc failure_message() -> String:\n\treturn _base.failure_message()\n\nfunc override_failure_message(message: String) -> GdUnitArrayAssert:\n\t@warning_ignore(\"return_value_discarded\")\n\t_base.override_failure_message(message)\n\treturn self\n\nfunc append_failure_message(message: String) -> GdUnitArrayAssert:\n\t@warning_ignore(\"return_value_discarded\")\n\t_base.append_failure_message(message)\n\treturn self\n\nfunc _validate_value_type(value: Variant) -> bool:\n\treturn value == null or GdArrayTools.is_array_type(value)\n\nfunc get_current_value() -> Variant:\n\treturn _current_value_provider.get_value()\n\nfunc max_length(left: Variant, right: Variant) -> int:\n\tvar ls := str(left).length()\n\tvar rs := str(right).length()\n\treturn rs if ls < rs else ls\n\n# gdlint: disable=function-name\nfunc _toPackedStringArray(value: Variant) -> PackedStringArray:\n\tif GdArrayTools.is_array_type(value):\n\t\t@warning_ignore(\"unsafe_cast\")\n\t\treturn PackedStringArray(value as Array)\n\treturn PackedStringArray([str(value)])\n\nfunc _array_equals_div(current: Variant, expected: Variant, case_sensitive: bool = false) -> Array:\n\tvar current_value := _toPackedStringArray(current)\n\tvar expected_value := _toPackedStringArray(expected)\n\tvar index_report := Array()\n\tfor index in current_value.size():\n\t\tvar c := current_value[index]\n\t\tif index < expected_value.size():\n\t\t\tvar e := expected_value[index]\n\t\t\tif not GdObjects.equals(c, e, case_sensitive):\n\t\t\t\tvar length := max_length(c, e)\n\t\t\t\tcurrent_value[index] = GdAssertMessages.format_invalid(c.lpad(length))\n\t\t\t\texpected_value[index] = e.lpad(length)\n\t\t\t\tindex_report.push_back({\"index\": index, \"current\": c, \"expected\": e}", "source": "extracted_function"} {"instruction": "Erstelle eine Godot-Klasse 'GdUnitArrayAssertImpl' die von GdUnitArrayAssert erbt mit folgenden Funktionen: _init, _notification, report_success, report_error, failure_message", "input": "", "output": "class_name GdUnitArrayAssertImpl\nextends GdUnitArrayAssert\n\nvar _base: GdUnitAssertImpl\nvar _current_value_provider: ValueProvider\nvar _type_check: bool\n\nfunc _init(current: Variant, type_check := true) -> void:\n\t_type_check = type_check\n\t_current_value_provider = DefaultValueProvider.new(current)\n\t_base = GdUnitAssertImpl.new(current)\n\t# save the actual assert instance on the current thread context\n\tGdUnitThreadManager.get_current_context().set_assert(self)\n\tif not _validate_value_type(current):\n\t\t@warning_ignore(\"return_value_discarded\")\n\t\treport_error(\"GdUnitArrayAssert inital error, unexpected type <%s>\" % GdObjects.typeof_as_string(current))\n\nfunc _notification(event: int) -> void:\n\tif event == NOTIFICATION_PREDELETE:\n\t\tif _base != null:\n\t\t\t_base.notification(event)\n\t\t\t_base = null\n\nfunc report_success() -> GdUnitArrayAssert:\n\t@warning_ignore(\"return_value_discarded\")\n\t_base.report_success()\n\treturn self\n\nfunc report_error(error: String) -> GdUnitArrayAssert:\n\t@warning_ignore(\"return_value_discarded\")\n\t_base.report_error(error)\n\treturn self\n\nfunc failure_message() -> String:\n\treturn _base.failure_message()\n\nfunc override_failure_message(message: String) -> GdUnitArrayAssert:\n\t@warning_ignore(\"return_value_discarded\")\n\t_base.override_failure_message(message)\n\treturn self\n\nfunc append_failure_message(message: String) -> GdUnitArrayAssert:\n\t@warning_ignore(\"return_value_discarded\")\n\t_base.append_failure_message(message)\n\treturn self\n\nfunc _validate_value_type(value: Variant) -> bool:\n\treturn value == null or GdArrayTools.is_array_type(value)\n\nfunc get_current_value() -> Variant:\n\treturn _current_value_provider.get_value()\n\nfunc max_length(left: Variant, right: Variant) -> int:\n\tvar ls := str(left).length()\n\tvar rs := str(right).length()\n\treturn rs if ls < rs else ls\n\n# gdlint: disable=function-name\nfunc _toPackedStringArray(value: Variant) -> PackedStringArray:\n\tif GdArrayTools.is_array_type(value):\n\t\t@warning_ignore(\"unsafe_cast\")\n\t\treturn PackedStrin"} {"instruction": "Vervollständige den GDScript-Code:", "input": "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\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\n\nfunc _process(_delta: float) -> void:", "output": "\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, note_delta)\n\t\telse:\n\t\t\t# Note is still hittable, so stop checking rest of the (later)\n\t\t\t# notes.\n\t\t\tbreak\n\nfunc _handle_keypress() -> void:\n\tvar note := _notes[0] as Note\n\tvar hit_delta := _get_note_delta(note)\n\tif hit_delta < -HIT_MARGIN_MISS:\n\t\t# Note is not hittable, do nothing.\n\t\tpass\n\telif -HIT_MARGIN_PERFECT <= hit_delta and hit_delta <= HIT_MARGIN_PERFECT:\n\t\t# Hit on time, perfect.\n\t\tnote.hit_perfect()\n\t\t_notes.remove_at(0)\n\t\t_hit_error_acc += hit_delta\n\t\t_hit_count += 1\n\t\t_play_stats.perfect_count += 1\n\t\t_play_stats.mean_hit_error = _hit_error_acc / _hit_count\n\t\tnote_hit.emit(note.beat, Enums.HitType.PERFECT, hit_delta)\n\telif -HIT_MARGIN_GOOD <= hit_delta and hit_delta <= HIT_MARGIN_GOOD:\n\t\t# Hit slightly off time, good."} {"instruction": "Vervollständige den GDScript-Code:", "input": "#*\n#* select_flanking_pos.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## Selects a position on the target's side and stores it on the\n## blackboard, returning [code]SUCCESS[/code]. [br]\n## Returns [code]FAILURE[/code] if the target is not valid.\n\nenum AgentSide {\n\tCLOSEST,\n\tFARTHEST,\n\tBACK,\n\tFRONT,\n}\n\n## Blackboard variable that holds current target (should be a Node2D instance).\n@export var target_var: StringName = &\"target\"", "output": "\n## Which agent's side should we flank?\n@export var flank_side: AgentSide = AgentSide.CLOSEST\n\n## Minimum range relative to the target.\n@export var range_min: int = 300\n\n## Maximum range relative to the target.\n@export var range_max: int = 400\n\n## Blackboard variable that will be used to store selected position.\n@export var position_var: StringName = &\"pos\"\n\n# Display a customized name (requires @tool).\nfunc _generate_name() -> String:\n\treturn \"SelectFlankingPos target: %s range: [%s, %s] side: %s ➜%s\" % [\n\t\tLimboUtility.decorate_var(target_var),\n\t\trange_min,\n\t\trange_max,\n\t\tAgentSide.keys()[flank_side],\n\t\tLimboUtility.decorate_var(position_var)]\n\n# Called each time this task is ticked (aka executed).\nfunc _tick(_delta: float) -> Status:\n\tvar target := blackboard.get_var(target_var) as Node2D\n\tif not is_instance_valid(target):\n\t\treturn FAILURE\n\n\tvar dir: float # 1.0 is right, -1.0 is left (relative to target)\n\tmatch flank_side:\n\t\tAgentSide.FARTHEST:\n\t\t\tdir = signf(target.global_position.x - agent.global_position.x)\n\t\tAgentSide.CLOSEST :\n\t\t\tdir = -signf(target.global_position.x - agent.global_position.x)\n\t\tAgentSide.BACK:\n\t\t\tdir = -target.get_facing()\n\t\tAgentSide.FRONT:\n\t\t\tdir = target.get_facing()\n\n\tvar flank_pos: Vector2\n\tvar offset := Vector2(dir * randf_range(range_min, range_max), 0.0)\n\tflank_pos = target.global_position + offset\n\tif not agent.is_good_position(flank_pos):\n\t\t# Choose the opposite side if the preferred side is not good (i.e., inside a collision shape).\n\t\tflank_pos = target.global_position - offset\n\tblackboard.set_var(position_var, flank_pos)\n\treturn SUCCESS\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "## An Assertion Tool to verify integer values\n@abstract class_name GdUnitIntAssert\nextends GdUnitAssert\n\n\n## Verifies that the current value is null.\n@abstract func is_null() -> GdUnitIntAssert\n\n\n## Verifies that the current value is not null.\n@abstract func is_not_null() -> GdUnitIntAssert\n\n\n## Verifies that the current value is equal to the given one.\n@abstract func is_equal(expected: Variant) -> GdUnitIntAssert\n\n\n## Verifies that the current value is not equal to expected one.\n@abstract func is_not_equal(expected: Variant) -> GdUnitIntAssert\n\n\n## Overrides the default failure message by given custom message.\n@abstract func override_failure_message(message: String) -> GdUnitIntAssert\n\n\n## Appends a custom message to the failure message.", "output": "@abstract func append_failure_message(message: String) -> GdUnitIntAssert\n\n## Verifies that the current value is less than the given one.\n@abstract func is_less(expected: int) -> GdUnitIntAssert\n\n## Verifies that the current value is less than or equal the given one.\n@abstract func is_less_equal(expected: int) -> GdUnitIntAssert\n\n## Verifies that the current value is greater than the given one.\n@abstract func is_greater(expected: int) -> GdUnitIntAssert\n\n## Verifies that the current value is greater than or equal the given one.\n@abstract func is_greater_equal(expected: int) -> GdUnitIntAssert\n\n## Verifies that the current value is even.\n@abstract func is_even() -> GdUnitIntAssert\n\n## Verifies that the current value is odd.\n@abstract func is_odd() -> GdUnitIntAssert\n\n## Verifies that the current value is negative.\n@abstract func is_negative() -> GdUnitIntAssert\n\n## Verifies that the current value is not negative.\n@abstract func is_not_negative() -> GdUnitIntAssert\n\n## Verifies that the current value is equal to zero.\n@abstract func is_zero() -> GdUnitIntAssert\n\n## Verifies that the current value is not equal to zero.\n@abstract func is_not_zero() -> GdUnitIntAssert\n\n## Verifies that the current value is in the given set of values.\n@abstract func is_in(expected: Array) -> GdUnitIntAssert\n\n## Verifies that the current value is not in the given set of values.\n@abstract func is_not_in(expected: Array) -> GdUnitIntAssert\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "@tool\nclass_name CombatTrigger extends Trigger\n\n@export var combat_arena: PackedScene\n\n\nfunc _execute() -> void:\n\t# Let other systems know that a combat has been triggered and then wait for its outcome.\n\tFieldEvents.combat_triggered.emit(combat_arena)\n\t\n\tvar did_player_win: bool = await CombatEvents.combat_finished\n\t\n\t# The combat ends with a covered screen, and so we fix that here.", "output": "\tTransition.clear.call_deferred(0.2)\n\tawait Transition.finished\n\n\t# We want to run post-combat events. In some cases, this may not involve much, such as playing a\n\t# game-over screen or removing an AI combat-starting gamepiece from the field.\n\t# In some cases, however, we'll want a dialogue to play or some creative event to occur if, for\n\t# example, the player lost a difficult but non-essential battle.\n\tif did_player_win:\n\t\tawait _run_victory_cutscene()\n\n\telse:\n\t\tawait _run_loss_cutscene()\n\n## The following method may be overwridden to allow for custom behaviour following a combat victory.\n## Examples include adding an item to the player's inventory, running a dialogue, removing an enemy\n## [Gamepiece], etc.\nfunc _run_victory_cutscene() -> void:\n\tawait get_tree().process_frame\n\n## The following method may be overwridden to allow for custom behaviour following a combat loss.\n## In most cases this may result in a gameover, but in others it may run a cutscene, change some\n## sort of event flag, etc.\nfunc _run_loss_cutscene() -> void:\n\tawait get_tree().process_frame\n"} {"instruction": "Erstelle eine Godot-Klasse 'GdUnitVectorAssert' die von GdUnitAssert erbt mit folgenden Funktionen: is_null, is_not_null, is_equal, is_not_equal, is_equal_approx", "input": "", "output": "## An Assertion Tool to verify Vector values\n@abstract class_name GdUnitVectorAssert\nextends GdUnitAssert\n\n## Verifies that the current value is null.\n@abstract func is_null() -> GdUnitVectorAssert\n\n## Verifies that the current value is not null.\n@abstract func is_not_null() -> GdUnitVectorAssert\n\n## Verifies that the current value is equal to the given one.\n@abstract func is_equal(expected: Variant) -> GdUnitVectorAssert\n\n## Verifies that the current value is not equal to expected one.\n@abstract func is_not_equal(expected: Variant) -> GdUnitVectorAssert\n\n## Verifies that the current and expected value are approximately equal.\n@abstract func is_equal_approx(expected: Variant, approx: Variant) -> GdUnitVectorAssert\n\n## Overrides the default failure message by given custom message.\n@abstract func override_failure_message(message: String) -> GdUnitVectorAssert\n\n## Appends a custom message to the failure message.\n@abstract func append_failure_message(message: String) -> GdUnitVectorAssert\n\n## Verifies that the current value is less than the given one.\n@abstract func is_less(expected: Variant) -> GdUnitVectorAssert\n\n## Verifies that the current value is less than or equal the given one.\n@abstract func is_less_equal(expected: Variant) -> GdUnitVectorAssert\n\n## Verifies that the current value is greater than the given one.\n@abstract func is_greater(expected: Variant) -> GdUnitVectorAssert\n\n## Verifies that the current value is greater than or equal the given one.\n@abstract func is_greater_equal(expected: Variant) -> GdUnitVectorAssert\n\n## Verifies that the current value is between the given boundaries (inclusive).\n@abstract func is_between(from: Variant, to: Variant) -> GdUnitVectorAssert\n\n## Verifies that the current value is not between the given boundaries (inclusive).\n@abstract func is_not_between(from: Variant, to: Variant) -> GdUnitVectorAssert\n"} {"instruction": "Erstelle eine GDScript-Funktion namens '_on_gamepiece_free':", "input": "", "output": "func _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 '_physics_process':", "input": "", "output": "func _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": "Vervollständige den GDScript-Code:", "input": "extends Node3D\n\n@export_enum(\"Left\", \"Right\") var hand : int = 0\n\n@export var fallback_mesh : Node3D\n\n# Called every frame. 'delta' is the elapsed time since the previous frame.\nfunc _process(delta):\n\tvar text = \"\"\n\n\tif hand == 0:\n\t\ttext += \"Left hand\\n\"\n\telse:\n\t\ttext += \"Right hand\\n\"\n\n\tvar controller_tracker : XRPositionalTracker = XRServer.get_tracker(&\"left_hand\" if hand == 0 else &\"right_hand\")\n\tif controller_tracker:\n\t\tvar profile = controller_tracker.profile.replace(\"/interaction_profiles/\", \"\").replace(\"/\", \" \")\n\t\ttext += \"\\nProfile: \" + profile + \"\\n\"\n\n\t\tvar pose : XRPose = controller_tracker.get_pose(&\"palm_pose\")\n\t\tif pose and pose.tracking_confidence != XRPose.XR_TRACKING_CONFIDENCE_NONE:", "output": "\t\t\ttext +=\" - Using palm pose\\n\"\n\t\telse:\n\t\t\tpose = controller_tracker.get_pose(&\"grip\")\n\t\t\tif pose:\n\t\t\t\ttext +=\" - Using grip pose\\n\"\n\n\t\tif pose:\n\t\t\tif pose.tracking_confidence == XRPose.XR_TRACKING_CONFIDENCE_NONE:\n\t\t\t\ttext += \"- No tracking data\\n\"\n\t\t\telif pose.tracking_confidence == XRPose.XR_TRACKING_CONFIDENCE_LOW:\n\t\t\t\ttext += \"- Low confidence tracking data\\n\"\n\t\t\telif pose.tracking_confidence == XRPose.XR_TRACKING_CONFIDENCE_HIGH:\n\t\t\t\ttext += \"- High confidence tracking data\\n\"\n\t\t\telse:\n\t\t\t\ttext += \"- Unknown tracking data %d \\n\" % [ pose.tracking_confidence ]\n\t\telse:\n\t\t\ttext += \"- No pose data\\n\"\n\telse:\n\t\ttext += \"\\nNo controller tracker found!\\n\"\n\n\tvar hand_tracker : XRHandTracker = XRServer.get_tracker(&\"/user/hand_tracker/left\" if hand == 0 else &\"/user/hand_tracker/right\")\n\tif hand_tracker:\n\t\ttext += \"\\nHand tracker found\\n\"\n\n\t\t# Report data source specified\n\t\tif hand_tracker.hand_tracking_source == XRHandTracker.HAND_TRACKING_SOURCE_UNKNOWN:\n\t\t\ttext += \"- Source: unknown\\n\"\n\t\telif hand_tracker.hand_tracking_source == XRHandTracker.HAND_TRACKING_SOURCE_UNOBSTRUCTED:\n\t\t\ttext += \"- Source: optical hand tracking\\n\"\n\t\telif hand_tracker.hand_tracking_source == XRHandTracker.HAND_TRACKING_SOURCE_CONTROLLER:\n\t\t\ttext += \"- Source: inferred from controller\\n\"\n\t\telif hand_tracker.hand_tracking_source == XRHandTracker.HAND_TRACKING_SOURCE_NOT_TRACKED:\n\t\t\ttext += \"- Source: no source\\n\"\n\t\telse:\n\t\t\ttext += \"- Source: %d\\n\" % [ hand_tracker.hand_tracking_source ]\n\n\t\t# If we're not tracking, show our fallback mesh on our controller tracking.\n\t\t# If we're also not controller tracking, we can't show anything.\n\t\t# Note: this is only a sphere in this example.\n\t\tif fallback_mesh:\n\t\t\tfallback_mesh.visible = not hand_tracker.has_tracking_data\n\telse:\n\t\ttext += \"\\nNo hand tracker found!\\n\"\n\n\t$Info.text = text\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "extends Camera3D\n\n## If true, we are in control of positioning.\n@export var enable_positioning: bool = true:\n\tset(value):\n\t\tif enable_positioning == value:\n\t\t\treturn\n\n\t\tenable_positioning = value\n\t\tif is_inside_tree():\n\t\t\t$Area3D/CollisionShape3D.disabled = not enable_positioning\n\t\t\tif enable_positioning:\n\t\t\t\t# We just turned this on? Reset this.", "output": "\t\t\t\tglobal_transform = last_transform\n\n## Our camera should be pointed at this node.\n@export var lookat_node: Node3D\n\n@onready var last_transform: Transform3D = global_transform\n@onready var display: MeshInstance3D = $CameraBody/DisplayContainer/Display\n\n# Called when the node enters the scene tree for the first time.\nfunc _ready():\n\tvar material: ShaderMaterial = display.material_override\n\tif material:\n\t\tmaterial.set_shader_parameter(&\"albedo_texture\", get_viewport().get_texture())\n\n# Called every frame. 'delta' is the elapsed time since the previous frame.\nfunc _process(_delta):\n\tif not enable_positioning:\n\t\treturn\n\n\t# Make sure we look in the right direction.\n\tif lookat_node:\n\t\tlook_at(lookat_node.global_position, Vector3.UP, false)\n\n\t# Remember this.\n\tlast_transform = global_transform\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "@tool\nextends EditorPlugin\n\nconst BeehaveEditorDebugger := preload(\"debug/debugger.gd\")\nvar editor_debugger: BeehaveEditorDebugger\nvar frames: RefCounted\nvar _custom_types: Array[StringName] = []\n\n\nfunc _init():\n\tname = \"BeehavePlugin\"\n\tadd_autoload_singleton(\"BeehaveGlobalMetrics\", \"metrics/beehave_global_metrics.gd\")\n\tadd_autoload_singleton(\"BeehaveGlobalDebugger\", \"debug/global_debugger.gd\")\n\t\n\t# Add project settings\n\tif not ProjectSettings.has_setting(\"beehave/debugger/start_detached\"):\n\t\tProjectSettings.set_setting(\"beehave/debugger/start_detached\", false)\n\t\tProjectSettings.set_initial_value(\"beehave/debugger/start_detached\", false)\n\t\tProjectSettings.add_property_info({\n\t\t\t\"name\": \"beehave/debugger/start_detached\",\n\t\t\t\"type\": TYPE_BOOL,", "output": "\t\t\t\"hint\": PROPERTY_HINT_NONE,\n\t\t\t\"hint_string\": \"If enabled, the debugger will start in a separate window\"\n\t\t})\n\t\tProjectSettings.save()\n\n\tprint(\"Beehave initialized!\")\n\nfunc _enter_tree() -> void:\n\teditor_debugger = BeehaveEditorDebugger.new()\n\tif Engine.get_version_info().minor >= 2:\n\t\tframes = preload(\"debug/new_frames.gd\").new()\n\telse:\n\t\tframes = preload(\"debug/old_frames.gd\").new()\n\tadd_debugger_plugin(editor_debugger)\n\t_register_custom_types()\n\nfunc _exit_tree() -> void:\n\t_unregister_custom_types()\n\tremove_debugger_plugin(editor_debugger)\n\nfunc _register_custom_types() -> void:\n\t# Some users report the script-class cache randomly missing BeehaveTree,\n\t# which makes the editor return a null instance. Register the type manually\n\t# so the node is still available even if the cache is broken.\n\tvar tree_script: Script = load(\"res://addons/beehave/nodes/beehave_tree.gd\")\n\tif tree_script == null:\n\t\tpush_warning(\"Beehave: failed to load BeehaveTree script; custom type not registered.\")\n\t\treturn\n\n\tvar tree_icon: Texture2D = load(\"res://addons/beehave/icons/tree.svg\")\n\tadd_custom_type(\"BeehaveTree\", \"Node\", tree_script, tree_icon)\n\t_custom_types.append(&\"BeehaveTree\")\n\nfunc _unregister_custom_types() -> void:\n\tfor type_name in _custom_types:\n\t\tremove_custom_type(type_name)\n\t_custom_types.clear()\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "@tool\n\n## A [Cutscene] that is triggered by the presence of the player and the player's input.\n##\n## An active Interaction may be run by the player walking up to it and 'interacting' with it,\n## usually via something as ubiquitous as the spacebar key. Common examples found in most RPGs are\n## NPC conversations, opening treasure chests, activating a save point, etc.\n## An edge case occurs when the player clicks on an interaction, though the player is far away. We\n## only want to report the top-most interaction as being clicked.\n##\n##[br][br]\n## Interactions handle player input directly and are activated according to the presence of the\n## player's interaction collision shape, which occupies the cell faced by the player's character.\n@icon(\"res://assets/editor/icons/Interaction.svg\")\nclass_name Interaction extends Cutscene\n\n## An active [code]Interaction[/code] may be run, whereas one that is inactive may only be run\n## directly through code via the [method Cutscene.run] method.\n@export var is_active: = true:\n\tset(value):\n\t\tis_active = value\n\t\t\n\t\tif not Engine.is_editor_hint():\n\t\t\t_update_input_state()\n\t\t\t\n\t\t\tif not is_inside_tree():\n\t\t\t\tawait ready\n\t\t\t\n\t\t\t# We use \"Visible Collision Shapes\" to debug positions on the gameboard, so we'll want \n\t\t\t# to change the state of child collision shapes.These could be either CollisionShape2Ds\n\t\t\t# or CollisionPolygon2Ds.\n\t\t\t# Note that we only want to disable the collision shapes of objects that are actually\n\t\t\t# connected to this Interaction.\n\t\t\tfor data in get_incoming_connections():\n\t\t\t\tvar callable: = data[\"callable\"] as Callable\n\t\t\t\tif callable == _on_area_entered :\n\t\t\t\t\tvar connected_area: = data[\"signal\"].get_object() as Area2D\n\t\t\t\t\tif connected_area:\n\t\t\t\t\t\tfor node in connected_area.find_children(\"*\", \"CollisionShape2D\"):\n\t\t\t\t\t\t\t(node as CollisionShape2D).disabled = !is_active\n\t\t\t\t\t\tfor node in connected_area.find_children(\"*\", \"CollisionPolygon2D\"):\n\t\t\t\t\t\t\t(node as CollisionPolygon2D).disabled = !is_active\n\n# Track overlapping areas. Determining whether or not to run an event is not as simple as the", "output": "# presence of overlapping areas, since factors such as gamestate and the existence of another\n# running events are relevant.\nvar _overlapping_areas: = []\n\n# A hidden Button control tells us when the player has clicked on the interaction. Note that only\n# the topmost button may be clicked.\n@onready var _button: Button = $Button\n\nfunc _ready():\n\tset_process_unhandled_input(false)\n\n\tif not Engine.is_editor_hint():\n\t\tFieldEvents.input_paused.connect(_on_input_paused)\n\n\t\t# The button does not stop all mouse/touch input, otherwise the user could not highlight\n\t\t# selectable cells. Instead, the GUI must prevent only clicks from propogating and should\n\t\t# forward the general interaction_selected event.\n\t\t_button.pressed.connect(\n\t\t\tfunc _on_button_pressed() -> void:\n\t\t\t\t_button.accept_event() # Stop the click event from being passed to _unhandled_input.\n\t\t\t\tFieldEvents.interaction_selected.emit(self)\n\t\t)\n\n# Ensure that something is connected to _on_area_entered and _on_area_exited, which the Interaction\n# requires. If nothing is connected, issue a configuration warning.\nfunc _get_configuration_warnings() -> PackedStringArray:\n\tvar warnings: PackedStringArray = []\n\tvar has_area_entered_bindings: = false\n\tvar has_area_exited_bindings: = false\n\n\tfor data in get_incoming_connections():\n\t\tvar callable: = data[\"callable\"] as Callable\n\t\tif callable == _on_area_entered :\n\t\t\thas_area_entered_bindings = true\n\t\telif callable == _on_area_exited:\n\t\t\thas_area_exited_bindings = true\n\n\tif not has_area_entered_bindings:\n\t\twarnings.append(\"This object does not have a CollisionObject2D's signals connected to \" +\n\t\t\t\"this Interactions's _on_area_entered method. The Interaction is not interactable!\")\n\tif not has_area_exited_bindings:\n\t\twarnings.append(\"This object does not have a CollisionObject2D's signals connected to \" +\n\t\t\t\"this Interactions's _on_area_exited method. The Interaction can never turn off!\")\n\treturn warnings\n\n# An Interaction only processes input when its childrens' collision shape(s) have collided with the\n# player's interaction collision shape."} {"instruction": "Vervollständige den GDScript-Code:", "input": "extends XRController3D\n\n# Check if we can use our palm pose or should fallback to our grip pose.\n\n", "output": "# Called every frame. 'delta' is the elapsed time since the previous frame.\nfunc _process(delta):\n\tvar controller_tracker : XRControllerTracker = XRServer.get_tracker(tracker)\n\tif controller_tracker:\n\t\tvar new_pose : String = \"palm_pose\"\n\t\tvar xr_pose : XRPose = controller_tracker.get_pose(new_pose)\n\t\tif not xr_pose or xr_pose.tracking_confidence == XRPose.XR_TRACKING_CONFIDENCE_NONE:\n\t\t\tnew_pose = \"grip\"\n\n\t\tif pose != new_pose:\n\t\t\tpose = new_pose\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "# Changes scenes after fading the screen on `any key` or on the A/B/cross\n# buttons on a gamepad.\nextends Control\n\nconst FADE_IN_TIME := 0.5\nconst FADE_OUT_TIME := 2.5\n\n@onready var screen_fader: TextureRect = $FadeLayer/ScreenFader", "output": "@onready var main_screen := $Background/MainScreen\n\n@onready var menu_sounds: MenuSoundPlayer = $MenuSoundPlayer\n\nfunc _ready() -> void:\n\tscreen_fader.fade_in()\n\nfunc _unhandled_input(event: InputEvent) -> void:\n\tif screen_fader.is_playing:\n\t\treturn\n\tif event is InputEventKey or event.is_action_pressed(\"thrust_forwards\"):\n\t\tmain_screen.animator.play_backwards(\"intro\")\n\t\tmenu_sounds.play_confirm()\n\t\tscreen_fader.fade_out()\n\t\tawait screen_fader.animation_finished\n\t\tget_tree().change_scene_to_file(\"res://main/game.tscn\")\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "extends Node2D\n\nconst VU_COUNT = 16\nconst FREQ_MAX = 11050.0\n\nconst WIDTH = 800\nconst HEIGHT = 250\nconst HEIGHT_SCALE = 8.0\nconst MIN_DB = 60\nconst ANIMATION_SPEED = 0.1\n\nvar spectrum: AudioEffectSpectrumAnalyzerInstance\nvar min_values: Array[float] = []\nvar max_values: Array[float] = []\n\nfunc _draw() -> void:\n\t@warning_ignore(\"integer_division\")\n\tvar w := WIDTH / VU_COUNT\n\tfor i in VU_COUNT:\n\t\tvar min_height = min_values[i]\n\t\tvar max_height = max_values[i]\n\t\tvar height = lerp(min_height, max_height, ANIMATION_SPEED)\n\n\t\tdraw_rect(\n\t\t\t\tRect2(w * i, HEIGHT - height, w - 2, height),\n\t\t\t\tColor.from_hsv(float(VU_COUNT * 0.6 + i * 0.5) / VU_COUNT, 0.5, 0.6)\n\t\t\t)", "output": "\t\tdraw_line(\n\t\t\t\tVector2(w * i, HEIGHT - height),\n\t\t\t\tVector2(w * i + w - 2, HEIGHT - height),\n\t\t\t\tColor.from_hsv(float(VU_COUNT * 0.6 + i * 0.5) / VU_COUNT, 0.5, 1.0),\n\t\t\t\t2.0,\n\t\t\t\ttrue\n\t\t\t)\n\n\t\t# Draw a reflection of the bars with lower opacity.\n\t\tdraw_rect(\n\t\t\t\tRect2(w * i, HEIGHT, w - 2, height),\n\t\t\t\tColor.from_hsv(float(VU_COUNT * 0.6 + i * 0.5) / VU_COUNT, 0.5, 0.6) * Color(1, 1, 1, 0.125)\n\t\t\t)\n\t\tdraw_line(\n\t\t\t\tVector2(w * i, HEIGHT + height),\n\t\t\t\tVector2(w * i + w - 2, HEIGHT + height),\n\t\t\t\tColor.from_hsv(float(VU_COUNT * 0.6 + i * 0.5) / VU_COUNT, 0.5, 1.0) * Color(1, 1, 1, 0.125),\n\t\t\t\t2.0,\n\t\t\t\ttrue\n\t\t\t)\n\nfunc _process(_delta: float) -> void:\n\tvar data: Array[float] = []\n\tvar prev_hz := 0.0\n\n\tfor i in range(1, VU_COUNT + 1):\n\t\tvar hz := i * FREQ_MAX / VU_COUNT\n\t\tvar magnitude := spectrum.get_magnitude_for_frequency_range(prev_hz, hz).length()\n\t\tvar energy := clampf((MIN_DB + linear_to_db(magnitude)) / MIN_DB, 0, 1)\n\t\tvar height := energy * HEIGHT * HEIGHT_SCALE\n\t\tdata.append(height)\n\t\tprev_hz = hz\n\n\tfor i in VU_COUNT:\n\t\tif data[i] > max_values[i]:\n\t\t\tmax_values[i] = data[i]\n\t\telse:\n\t\t\tmax_values[i] = lerpf(max_values[i], data[i], ANIMATION_SPEED)\n\n\t\tif data[i] <= 0.0:\n\t\t\tmin_values[i] = lerpf(min_values[i], 0.0, ANIMATION_SPEED)\n\n\t# Sound plays back continuously, so the graph needs to be updated every frame.\n\tqueue_redraw()\n\nfunc _ready() -> void:\n\tspectrum = AudioServer.get_bus_effect_instance(0, 0)\n\tmin_values.resize(VU_COUNT)"} {"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": "Vervollständige den GDScript-Code:", "input": "@tool\nclass_name Door extends AreaTransition\n\n# A locked door will block movement by placing a dummy gamepiece on the cell occupied by the door.\nconst GP_SCENE: = preload(\"res://src/field/gamepieces/gamepiece.tscn\")\n\n@export var is_locked: = false:\n\tset(value):\n\t\tif value != is_locked:\n\t\t\tis_locked = value\n\t\t\t\n\t\t\tif not is_inside_tree():\n\t\t\t\tawait ready\n\t\t\t\n\t\t\tif is_locked:\n\t\t\t\tif _dummy_gp == null:\n\t\t\t\t\t_dummy_gp = GP_SCENE.instantiate()\n\t\t\t\t\t_dummy_gp.name = \"CellBlocker\"\n\t\t\t\t\t_closed_door.add_child(_dummy_gp)\n\t\t\t\n\t\t\telse:", "output": "\t\t\t\topen()\n\t\t\t\tif _dummy_gp != null:\n\t\t\t\t\t_dummy_gp.queue_free()\n\t\t\t\t\t_dummy_gp = null\n\n# Keep a reference to the object used to block movement through a locked door.\n# Note that this gamepiece has no animation, movement, etc. It exists to occupy a board cell.\nvar _dummy_gp: Gamepiece = null\n\n@onready var _anim: = $AnimationPlayer as AnimationPlayer\n@onready var _closed_door: = $Area2D/ClosedDoor as Sprite2D\n\nfunc _ready() -> void:\n\tsuper._ready()\n\nfunc open() -> void:\n\t# Do not open the door if it is already open.\n\tif not _closed_door.visible:\n\t\treturn\n\n\telif is_locked:\n\t\t_anim.play(\"locked\")\n\n\telse:\n\t\t_anim.play(\"open\")\n\tawait _anim.animation_finished\n\nfunc _on_area_entered(area: Area2D) -> void:\n\t# Only open the door if it is closed.\n\tif _closed_door.visible:\n\t\t_anim.play(\"open\")\n\n\tawait super._on_area_entered(area)\n\nfunc _on_blackout() -> void:\n\tsuper._on_blackout()\n\n\t#TODO: this becomes redundant when world area loading is implemented.\n\t_anim.play(\"RESET\")\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": "Vervollständige den GDScript-Code:", "input": "extends Panel\n\nenum SyncSource {\n\tSYSTEM_CLOCK,\n\tSOUND_CLOCK,\n}\n\nconst BPM = 116\nconst BARS = 4\n\nconst COMPENSATE_FRAMES = 2\nconst COMPENSATE_HZ = 60.0\n\nvar playing: bool = false\nvar sync_source := SyncSource.SYSTEM_CLOCK\n\n# Used by system clock.\nvar time_begin: float", "output": "var time_delay: float\n\nfunc _process(_delta: float) -> void:\n\tif not playing or not $Player.playing:\n\t\treturn\n\n\tvar time := 0.0\n\tif sync_source == SyncSource.SYSTEM_CLOCK:\n\t\t# Obtain from ticks.\n\t\ttime = (Time.get_ticks_usec() - time_begin) / 1000000.0\n\t\t# Compensate.\n\t\ttime -= time_delay\n\telif sync_source == SyncSource.SOUND_CLOCK:\n\t\ttime = $Player.get_playback_position() + AudioServer.get_time_since_last_mix() - AudioServer.get_output_latency() + (1 / COMPENSATE_HZ) * COMPENSATE_FRAMES\n\n\tvar beat := int(time * BPM / 60.0)\n\tvar seconds := int(time)\n\tvar seconds_total := int($Player.stream.get_length())\n\t@warning_ignore(\"integer_division\")\n\t$Label.text = str(\"BEAT: \", beat % BARS + 1, \"/\", BARS, \" TIME: \", seconds / 60, \":\", str(seconds % 60).pad_zeros(2), \" / \", seconds_total / 60, \":\", str(seconds_total % 60).pad_zeros(2))\n\nfunc _on_PlaySystem_pressed() -> void:\n\tsync_source = SyncSource.SYSTEM_CLOCK\n\ttime_begin = Time.get_ticks_usec()\n\ttime_delay = AudioServer.get_time_to_next_mix() + AudioServer.get_output_latency()\n\tplaying = true\n\t$Player.play()\n\nfunc _on_PlaySound_pressed() -> void:\n\tsync_source = SyncSource.SOUND_CLOCK\n\tplaying = true\n\t$Player.play()\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "# Math and vector utility functions.\n# @Category - Utilities\nclass_name GSAIUtils\n\n# Returns the `vector` with its length capped to `limit`.\nstatic func clampedv3(vector: Vector3, limit: float) -> Vector3:\n\tvar length_squared := vector.length_squared()\n\tvar limit_squared := limit * limit\n\tif length_squared > limit_squared:\n\t\tvector *= sqrt(limit_squared / length_squared)\n\treturn vector\n", "output": "# Returns an angle in radians between the positive X axis and the `vector`.\n#\n# This assumes orientation for 3D agents that are upright and rotate\n# around the Y axis.\nstatic func vector3_to_angle(vector: Vector3) -> float:\n\treturn atan2(vector.x, vector.z)\n\n# Returns an angle in radians between the positive X axis and the `vector`.\nstatic func vector2_to_angle(vector: Vector2) -> float:\n\treturn atan2(vector.x, -vector.y)\n\n# Returns a directional vector from the given orientation angle.\n#\n# This assumes orientation for 2D agents or 3D agents that are upright and\n# rotate around the Y axis.\nstatic func angle_to_vector2(angle: float) -> Vector2:\n\treturn Vector2(sin(-angle), cos(angle))\n\n# Returns a vector2 with `vector`'s x and y components.\nstatic func to_vector2(vector: Vector3) -> Vector2:\n\treturn Vector2(vector.x, vector.y)\n\n# Returns a vector3 with `vector`'s x and y components and 0 in z.\nstatic func to_vector3(vector: Vector2) -> Vector3:\n\treturn Vector3(vector.x, vector.y, 0)\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "# Copyright (c) 2023 Patryk Kalinowski (patrykkalinowski.com)\n# SPDX-License-Identifier: MIT\n\n## Implementation of the 1€ filter (https://gery.casiez.net/1euro/).[br]\n## Modification of https://github.com/patrykkalinowski/godot-xr-kit/blob/master/addons/xr-kit/smooth-input-filter/scripts/one_euro_filter.gd\nclass_name OneEuroFilter\n\nvar min_cutoff: float\nvar beta: float\nvar d_cutoff: float\nvar x_filter: LowPassFilter\nvar dx_filter: LowPassFilter\n\nfunc _init(args: Variant) -> void:\n\tmin_cutoff = args.cutoff\n\tbeta = args.beta\n\td_cutoff = args.cutoff", "output": "\tx_filter = LowPassFilter.new()\n\tdx_filter = LowPassFilter.new()\n\nfunc alpha(rate: float, cutoff: float) -> float:\n\tvar tau: float = 1.0 / (2 * PI * cutoff)\n\tvar te: float = 1.0 / rate\n\n\treturn 1.0 / (1.0 + tau/te)\n\nfunc filter(value: float, delta: float) -> float:\n\tvar rate: float = 1.0 / delta\n\tvar dx: float = (value - x_filter.last_value) * rate\n\n\tvar edx: float = dx_filter.filter(dx, alpha(rate, d_cutoff))\n\tvar cutoff: float = min_cutoff + beta * abs(edx)\n\treturn x_filter.filter(value, alpha(rate, cutoff))\n\nclass LowPassFilter:\n\tvar last_value: float\n\n\tfunc _init() -> void:\n\t\tlast_value = 0\n\n\tfunc filter(value: float, alpha: float) -> float:\n\t\tvar result := alpha * value + (1 - alpha) * last_value\n\t\tlast_value = result\n\n\t\treturn result\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "extends RayCast2D\n\n@export var cast_speed := 7000.0\n@export var max_length := 1400\n@export var growth_time := 0.1\n\n@onready var casting_particles := $CastingParticles2D\n@onready var collision_particles := $CollisionParticles2D\n@onready var beam_particles := $BeamParticles2D\n@onready var fill := $FillLine2D\n@onready var tween : Tween\n@onready var line_width: float = fill.width\n\nvar is_casting := false: set = set_is_casting\n\n\nfunc _ready() -> void:\n\tset_physics_process(false)\n\tfill.points[1] = Vector2.ZERO\n\n\nfunc _physics_process(delta: float) -> void:\n\ttarget_position = (target_position + Vector2.RIGHT * cast_speed * delta).limit_length(max_length)\n\tcast_beam()\n", "output": "\nfunc set_is_casting(cast: bool) -> void:\n\tis_casting = cast\n\n\tif is_casting:\n\t\ttarget_position = Vector2.ZERO\n\t\tfill.points[1] = target_position\n\t\tappear()\n\telse:\n\t\tcollision_particles.emitting = false\n\t\tdisappear()\n\n\tset_physics_process(is_casting)\n\tbeam_particles.emitting = is_casting\n\tcasting_particles.emitting = is_casting\n\nfunc cast_beam() -> void:\n\tvar cast_point := target_position\n\n\t# Required, the raycast's collisions update one frame after moving otherwise, making the laser\n\t# overshoot the collision point.\n\tforce_raycast_update()\n\tif is_colliding():\n\t\tcast_point = to_local(get_collision_point())\n\t\tcollision_particles.process_material.direction = Vector3(\n\t\t\tget_collision_normal().x, get_collision_normal().y, 0\n\t\t)\n\n\tcollision_particles.emitting = is_colliding()\n\n\tfill.points[1] = cast_point\n\tcollision_particles.position = cast_point\n\tbeam_particles.position = cast_point * 0.5\n\tbeam_particles.process_material.emission_box_extents.x = cast_point.length() * 0.5\n\nfunc appear() -> void:\n\tif tween and tween.is_running():\n\t\ttween.kill()\n\ttween = create_tween()\n\ttween.tween_property(fill, \"width\", line_width, growth_time * 2).from(0.0)\n\ttween.play()\n\nfunc disappear() -> void:\n\tif tween and tween.is_running():\n\t\ttween.kill()\n\ttween = create_tween()\n\ttween.tween_property(fill, \"width\", 0, growth_time).from(fill.width)"} {"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 RigidBody2D\n# @category - Specialized agents\nclass_name GSAIRigidBody2DAgent\nextends GSAISpecializedAgent\n\n# The RigidBody2D to keep track of\nvar body: RigidBody2D: set = _set_body\n\nvar _last_position: Vector2\nvar _body_ref: WeakRef\n\n\nfunc _init(_body: RigidBody2D) -> void:\n\tif not _body.is_inside_tree():\n\t\tawait(_body).ready\n\tself.body = _body\n\n\t# warning-ignore:return_value_discarded\n\t_body.get_tree().physics_frame.connect(_on_SceneTree_frame)\n\n\n# Moves the agent's `body` by target `acceleration`.", "output": "# @tags - virtual\nfunc _apply_steering(acceleration: GSAITargetAcceleration, _delta: float) -> void:\n\tvar _body: RigidBody2D = _body_ref.get_ref()\n\tif not _body:\n\t\treturn\n\n\t_applied_steering = true\n\t_body.apply_central_impulse(GSAIUtils.to_vector2(acceleration.linear))\n\t_body.apply_torque_impulse(acceleration.angular)\n\tif calculate_velocities:\n\t\tlinear_velocity = GSAIUtils.to_vector3(_body.linear_velocity)\n\t\tangular_velocity = _body.angular_velocity\n\nfunc _set_body(value: RigidBody2D) -> void:\n\tbody = value\n\t_body_ref = weakref(value)\n\n\t_last_position = value.global_position\n\t_last_orientation = value.rotation\n\n\tposition = GSAIUtils.to_vector3(_last_position)\n\torientation = _last_orientation\n\nfunc _on_SceneTree_frame() -> void:\n\tvar _body: RigidBody2D = _body_ref.get_ref()\n\tif not _body:\n\t\treturn\n\n\tif not _body.is_inside_tree():\n\t\treturn\n\n\tvar current_position := _body.global_position\n\tvar current_orientation := _body.rotation\n\n\tposition = GSAIUtils.to_vector3(current_position)\n\torientation = current_orientation\n\n\tif calculate_velocities:\n\t\tif _applied_steering:\n\t\t\t_applied_steering = false\n\t\telse:\n\t\t\tlinear_velocity = GSAIUtils.to_vector3(_body.linear_velocity)\n\t\t\tangular_velocity = _body.angular_velocity\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "## An Assertion Tool to verify float values\n@abstract class_name GdUnitFloatAssert\nextends GdUnitAssert\n\n\n## Verifies that the current value is null.\n@abstract func is_null() -> GdUnitFloatAssert\n\n\n## Verifies that the current value is not null.\n@abstract func is_not_null() -> GdUnitFloatAssert\n\n\n## Verifies that the current value is equal to the given one.\n@abstract func is_equal(expected: Variant) -> GdUnitFloatAssert\n\n\n## Verifies that the current value is not equal to expected one.\n@abstract func is_not_equal(expected: Variant) -> GdUnitFloatAssert\n\n\n## Verifies that the current and expected value are approximately equal.\n@abstract func is_equal_approx(expected: float, approx: float) -> GdUnitFloatAssert\n\n", "output": "## Overrides the default failure message by given custom message.\n@abstract func override_failure_message(message: String) -> GdUnitFloatAssert\n\n## Appends a custom message to the failure message.\n@abstract func append_failure_message(message: String) -> GdUnitFloatAssert\n\n## Verifies that the current value is less than the given one.\n@abstract func is_less(expected: float) -> GdUnitFloatAssert\n\n## Verifies that the current value is less than or equal the given one.\n@abstract func is_less_equal(expected: float) -> GdUnitFloatAssert\n\n## Verifies that the current value is greater than the given one.\n@abstract func is_greater(expected: float) -> GdUnitFloatAssert\n\n## Verifies that the current value is greater than or equal the given one.\n@abstract func is_greater_equal(expected: float) -> GdUnitFloatAssert\n\n## Verifies that the current value is negative.\n@abstract func is_negative() -> GdUnitFloatAssert\n\n## Verifies that the current value is not negative.\n@abstract func is_not_negative() -> GdUnitFloatAssert\n\n## Verifies that the current value is equal to zero.\n@abstract func is_zero() -> GdUnitFloatAssert\n\n## Verifies that the current value is not equal to zero.\n@abstract func is_not_zero() -> GdUnitFloatAssert\n\n## Verifies that the current value is in the given set of values.\n@abstract func is_in(expected: Array) -> GdUnitFloatAssert\n\n## Verifies that the current value is not in the given set of values.\n@abstract func is_not_in(expected: Array) -> GdUnitFloatAssert\n\n## Verifies that the current value is between the given boundaries (inclusive).\n@abstract func is_between(from: float, to: float) -> GdUnitFloatAssert"} {"instruction": "Vervollständige den GDScript-Code:", "input": "extends XRNode3D\n\n## Detect which tracker we should use to position our hand, we prefer\n## hand tracking as this works in unison with our hand skeleton updates.\n\n## Hand for which to get our tracking data.\n@export_enum(\"Left\",\"Right\") var hand : int = 0\n\n# Called every frame. 'delta' is the elapsed time since the previous frame.\nfunc _process(delta):\n\tvar new_tracker : String\n\n\t# Check if our hand tracker is usable\n\tnew_tracker = \"/user/hand_tracker/left\" if hand == 0 \\", "output": "\t\telse \"/user/hand_tracker/right\"\n\tvar hand_tracker : XRHandTracker = XRServer.get_tracker(new_tracker)\n\tif hand_tracker and hand_tracker.has_tracking_data:\n\t\tif tracker != new_tracker:\n\t\t\tprint(\"Switching to left hand tracker\" if hand == 0 \\\n\t\t\t\telse \"Switching to right hand tracker\")\n\t\t\ttracker = new_tracker\n\t\t\tpose = \"default\"\n\n\t\treturn\n\n\t# Else fallback to our controller tracker\n\tnew_tracker = \"left_hand\" if hand == 0 else \"right_hand\"\n\tvar controller_tracker : XRControllerTracker = XRServer.get_tracker(new_tracker)\n\tif controller_tracker:\n\t\tif tracker != new_tracker:\n\t\t\tprint(\"Switching to left controller tracker\" if hand == 0 \\\n\t\t\t\telse \"Switching to right controller tracker\")\n\t\t\ttracker = new_tracker\n\n\t\tvar new_pose : String = \"palm_pose\"\n\t\tvar xr_pose : XRPose = controller_tracker.get_pose(new_pose)\n\t\tif not xr_pose or xr_pose.tracking_confidence == XRPose.XR_TRACKING_CONFIDENCE_NONE:\n\t\t\tnew_pose = \"grip\"\n\n\t\tif pose != new_pose:\n\t\t\tpose = new_pose\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "## An Assertion Tool to verify array values\n@abstract class_name GdUnitArrayAssert\nextends GdUnitAssert\n\n\n## Verifies that the current value is null.\n@abstract func is_null() -> GdUnitArrayAssert\n\n\n## Verifies that the current value is not null.\n@abstract func is_not_null() -> GdUnitArrayAssert\n\n\n## Verifies that the current Array is equal to the given one.\n@abstract func is_equal(...expected: Array) -> GdUnitArrayAssert\n\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\n## Verifies that the current Array is not equal to the given one.\n@abstract func is_not_equal(...expected: Array) -> GdUnitArrayAssert\n\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\n## Overrides the default failure message by given custom message.\n@abstract func override_failure_message(message: String) -> GdUnitArrayAssert\n\n\n## Appends a custom message to the failure message.\n@abstract func append_failure_message(message: String) -> GdUnitArrayAssert\n\n\n## Verifies that the current Array is empty, it has a size of 0.\n@abstract func is_empty() -> GdUnitArrayAssert\n\n", "output": "## 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 are compared by deep parameter comparision, for object reference compare you have to use [method contains_same]\n@abstract func contains(...expected: Array) -> GdUnitArrayAssert\n\n## Verifies that the current Array contains exactly only the given values and nothing else, in same order.[br]\n## The values are compared by deep parameter comparision, for object reference compare you have to use [method contains_same_exactly]\n@abstract func contains_exactly(...expected: Array) -> GdUnitArrayAssert\n\n## Verifies that the current Array contains exactly only the given values and nothing else, in any order.[br]\n## The values are compared by deep parameter comparision, for object reference compare you have to use [method contains_same_exactly_in_any_order]\n@abstract func contains_exactly_in_any_order(...expected: Array) -> GdUnitArrayAssert\n\n## Verifies that the current Array contains the given values, in any order.[br]\n## The values are compared by object reference, for deep parameter comparision use [method contains]\n@abstract func contains_same(...expected: Array) -> GdUnitArrayAssert\n\n## Verifies that the current Array contains exactly only the given values and nothing else, in same order.[br]\n## The values are compared by object reference, for deep parameter comparision use [method contains_exactly]\n@abstract func contains_same_exactly(...expected: Array) -> GdUnitArrayAssert\n\n## Verifies that the current Array contains exactly only the given values and nothing else, in any order.[br]\n## The values are compared by object reference, for deep parameter comparision use [method contains_exactly_in_any_order]\n@abstract func contains_same_exactly_in_any_order(...expected: Array) -> GdUnitArrayAssert\n\n## Verifies that the current Array do NOT contains the given values, in any order.[br]\n## The values are compared by deep parameter comparision, for object reference compare you have to use [method not_contains_same]"} {"instruction": "Vervollständige den GDScript-Code:", "input": "## An inventory item, tracking both it's UI representation and underlying data.\n## Will be replaced in future iterations of the OpenRPG project.\n## Please see UIInventory for additional information.\nclass_name UIInventoryItem extends TextureRect\n\nvar ID: = Inventory.ItemTypes.KEY\n\nvar count: = 0:", "output": "\tset = set_count\n\n@onready var _count_label: = $Count as Label\n\nfunc set_count(value: int) -> void:\n\tcount = max(value, 0)\n\tif count == 0:\n\t\tqueue_free()\n\n\telif count > 1:\n\t\t_count_label.show()\n\t\t_count_label.text = str(count)\n\n\telse:\n\t\t_count_label.hide()\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "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\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\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\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", "output": "# 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"} {"instruction": "Vervollständige den GDScript-Code:", "input": "# Helper global object that holds helpful mathematics functions that are not\n# part of Godot.\nclass_name MathUtils\nextends Node\n\n# Returns the radius of a circumcircle for a triangle.\n# The circumscribed circle or circumcircle of a polygon is a circle that passes\n# through all the vertices of the polygon.\n# Adapted from an algorithm by [mutoo](https://gist.github.com/mutoo/5617691)\nstatic func get_triangle_circumcircle_radius(vertices: PackedVector2Array) -> float:\n\tassert(vertices.size() == 3)", "output": "\n\tvar a := vertices[0]\n\tvar b := vertices[1]\n\tvar c := vertices[2]\n\n\tvar A := b.x - a.x\n\tvar B := b.y - a.y\n\tvar C := c.x - a.x\n\tvar D := c.y - a.y\n\tvar E := A * (a.x + b.x) + B * (a.y + b.y)\n\tvar F := C * (a.x + c.x) + D * (a.y + c.y)\n\tvar G := 2 * (A * (c.y - b.y) - B * (c.x - b.x))\n\tvar dx: float\n\tvar dy: float\n\n\tif abs(G) < 0.000001:\n\t\tdx = (max(a.x, max(b.x, c.x))) * 0.5\n\t\tdy = (max(a.y, max(b.y, c.y))) * 0.5\n\telse:\n\t\tdx = ((D * E - B * F) / G) - a.x\n\t\tdy = ((A * F - C * E) / G) - a.y\n\n\treturn sqrt(dx * dx + dy * dy)\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "# Handles the input that brings up the minimap or the quit menu.\nextends CanvasLayer\n\n@onready var screen_fader: TextureRect = $ScreenFader\n@onready var map: TextureRect = $MapDisplay\n@onready var upgrade_menu := $UpgradeUI\n@onready var quit_menu := $QuitMenu\n\n\nfunc _ready() -> void:\n\tEvents.player_died.connect(reset.bind(true))", "output": "\tEvents.quit_requested.connect(quit)\n\tEvents.upgrade_unlocked.connect(upgrade_menu.open)\n\tscreen_fader.fade_in()\n\nfunc _unhandled_input(event: InputEvent) -> void:\n\tif get_tree().paused:\n\t\treturn\n\n\tif event.is_action_pressed(\"ui_cancel\"):\n\t\tquit_menu.open()\n\tif event.is_action_pressed(\"toggle_map\") and not map.is_animating():\n\t\tmap.toggle()\n\nfunc quit() -> void:\n\tget_tree().quit()\n\nfunc reset(with_delay: bool) -> void:\n\tscreen_fader.fade_out(with_delay)\n\tawait screen_fader.animation_finished\n\tget_tree().change_scene_to_file(\"res://ui/main_menu.tscn\")\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "class_name PianoKey\nextends Control\n\nvar pitch_scale: float\n\n@onready var key: ColorRect = $Key\n@onready var start_color: Color = key.color\n@onready var color_timer: Timer = $ColorTimer\n\nfunc setup(pitch_index: int) -> void:", "output": "\tname = \"PianoKey\" + str(pitch_index)\n\tvar exponent := (pitch_index - 69.0) / 12.0\n\tpitch_scale = pow(2, exponent)\n\nfunc activate() -> void:\n\tkey.color = (Color.YELLOW + start_color) / 2\n\tvar audio := AudioStreamPlayer.new()\n\tadd_child(audio)\n\taudio.stream = preload(\"res://piano_keys/A440.wav\")\n\taudio.pitch_scale = pitch_scale\n\taudio.play()\n\tcolor_timer.start()\n\tawait get_tree().create_timer(8.0).timeout\n\taudio.queue_free()\n\nfunc deactivate() -> void:\n\tkey.color = start_color\n"} {"instruction": "Erstelle eine Godot-Klasse 'GSAIGroupBehavior' die von GSAISteeringBehavior erbt mit folgenden Funktionen: _init, _report_neighbor", "input": "", "output": "# Base type for group-based steering behaviors.\n# @category - Base types\nclass_name GSAIGroupBehavior\nextends GSAISteeringBehavior\n\n# Container to find neighbors of the agent and calculate group behavior.\nvar proximity: GSAIProximity\n\nvar _callback := Callable(self, \"_report_neighbor\")\n\nfunc _init(agent: GSAISteeringAgent, _proximity: GSAIProximity) -> void:\n\tsuper._init(agent)\n\tself.proximity = _proximity\n\n# Internal callback for the behavior to define whether or not a member is\n# relevant\n# @tags - virtual\nfunc _report_neighbor(_neighbor: GSAISteeringAgent) -> bool:\n\treturn false\n"} {"instruction": "Erstelle eine Godot-Klasse 'Hurtbox' die von Area2D erbt mit folgenden Funktionen: take_damage", "input": "", "output": "#*\n#* hurtbox.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#*\nclass_name Hurtbox\nextends Area2D\n## Area that registers damage.\n\n@export var health: Health\n\nvar last_attack_vector: Vector2\n\nfunc take_damage(amount: float, knockback: Vector2, source: Hitbox) -> void:\n\tlast_attack_vector = owner.global_position - source.owner.global_position\n\thealth.take_damage(amount, knockback)\n"} {"instruction": "Vervollständige den GDScript-Code:", "input": "#*\n#* hitbox.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#*\nclass_name Hitbox\nextends Area2D\n## Area that deals damage.", "output": "\n## Damage value to apply.\n@export var damage: float = 1.0\n\n## Push back the victim.\n@export var knockback_enabled: bool = false\n\n## Desired pushback speed.\n@export var knockback_strength: float = 500.0\n\nfunc _ready() -> void:\n\tarea_entered.connect(_area_entered)\n\nfunc _area_entered(hurtbox: Hurtbox) -> void:\n\tif hurtbox.owner == owner:\n\t\treturn\n\thurtbox.take_damage(damage, get_knockback(), self)\n\nfunc get_knockback() -> Vector2:\n\tvar knockback: Vector2\n\tif knockback_enabled:\n\t\tknockback = Vector2.RIGHT.rotated(global_rotation) * knockback_strength\n\treturn knockback\n"} {"instruction": "Erstelle eine GDScript-Funktion namens 'initialize':", "input": "", "output": "func initialize() -> void:\n\t_update_all()\n\n# Get the final value of a stat, with all modifiers applied to it.\nfunc 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"}