instruction stringlengths 34 212 | input stringlengths 0 7.8k | output stringlengths 70 3.97k | source stringclasses 1
value |
|---|---|---|---|
Vervollständige den GDScript-Code: | @tool
extends Node3D
@export_range(0, 1, 0.1) var fade := 0.0:
set(value):
fade = value
if is_inside_tree():
_update_fade() |
var material: ShaderMaterial
func _update_fade() -> void:
if fade == 0.0:
$MeshInstance3D.visible = false
else:
if material:
material.set_shader_parameter(&"albedo", Color(0.0, 0.0, 0.0, fade))
$MeshInstance3D.visible = true
func _ready() -> void:
material = $MeshInstance3D.material_override
_update_fad... | null |
Vervollständige den GDScript-Code: | extends GdUnitFloatAssert
var _base: GdUnitAssertImpl
func _init(current :Variant) -> void:
_base = GdUnitAssertImpl.new(current)
# save the actual assert instance on the current thread context
GdUnitThreadManager.get_current_context().set_assert(self)
if not GdUnitAssertions.validate_value_type(current, TYPE_FL... | func is_null() -> GdUnitFloatAssert:
@warning_ignore("return_value_discarded")
_base.is_null()
return self
func is_not_null() -> GdUnitFloatAssert:
@warning_ignore("return_value_discarded")
_base.is_not_null()
return self
func is_equal(expected: Variant) -> GdUnitFloatAssert:
@warning_ignore("return_value_disc... | null |
Vervollständige den GDScript-Code: | class_name GdAssertMessages
extends Resource
const WARN_COLOR = "#EFF883"
const ERROR_COLOR = "#CD5C5C"
const VALUE_COLOR = "#1E90FF"
const SUB_COLOR := Color(1, 0, 0, .15)
const ADD_COLOR := Color(0, 1, 0, .15)
# Dictionary of control characters and their readable representations
const CONTROL_CHARS = {
"\n": "<... | static func test_suite_skipped(hint :String, skip_count :int) -> String:
return """
%s
Skipped %s tests
Reason: %s
""".dedent().trim_prefix("\n")\
% [_error("The Entire test-suite is skipped!"), _colored_value(skip_count), _colored_value(hint)]
static func test_skipped(hint :String) -> String:
return "... | null |
Vervollständige den GDScript-Code: | extends Node3D
signal session_started
signal focus_lost
signal focus_gained
signal pose_recentered
## Set the highest refresh rate we wish to enable.
## We'll find the closest matching one.
@export var maximum_refresh_rate: int = 90
var xr_interface: OpenXRInterface
var xr_is_focused: bool = false
## Get our OpenX... | xr_interface.session_visible.connect(_on_openxr_visible_state)
xr_interface.session_focussed.connect(_on_openxr_focused_state)
xr_interface.session_stopping.connect(_on_openxr_stopping)
xr_interface.pose_recentered.connect(_on_openxr_pose_recentered)
else:
# We couldn't start OpenXR.
print("OpenXR not inst... | null |
Vervollständige den GDScript-Code: | ## A utility class converting between Godot angles (+'ve x axis is 0 rads) and cardinal points.
class_name Directions
extends RefCounted
## The cardinal points, in clockwise order starting from North.
enum Points { NORTH, EAST, SOUTH, WEST }
## The direction corresponding to a cardinal point as a [Vector2i] value. NO... | Directions.Points.EAST: Vector2i.RIGHT,
Directions.Points.SOUTH: Vector2i.DOWN,
Directions.Points.WEST: Vector2i.LEFT,
}
## Convert an angle, such as from [method Vector2.angle], to a [constant Points].
static func angle_to_direction(angle: float) -> Points:
if angle <= -PI / 4.0 and angle > -3.0 * PI / 4.0:
ret... | null |
Erstelle eine GDScript-Funktion namens '_ready': | func _ready() -> void:
await owner.ready
_parent = get_parent() as State
func unhandled_input(_event: InputEvent) -> void:
pass
func physics_process(_delta: float) -> void:
pass
func enter(_msg: Dictionary = {} | extracted_function | |
Erstelle eine GDScript-Funktion namens 'cell_to_pixel': | func cell_to_pixel(cell_coordinates: Vector2i) -> Vector2:
return Vector2(cell_coordinates * properties.cell_size) + properties.half_cell_size
## Convert pixel coordinates to cell coordinates.
func pixel_to_cell(pixel_coordinates: Vector2) -> Vector2i:
@warning_ignore("integer_division")
return Vector2i(
floori(p... | extracted_function | |
Vervollständige den GDScript-Code: | extends Node3D
signal session_started
signal focus_lost
signal focus_gained
signal pose_recentered
## Set the highest refresh rate we wish to enable.
## We'll find the closest matching one.
@export var maximum_refresh_rate: int = 90
var xr_interface: OpenXRInterface
var xr_is_focused: bool = false
## Get our OpenX... | xr_interface.session_visible.connect(_on_openxr_visible_state)
xr_interface.session_focussed.connect(_on_openxr_focused_state)
xr_interface.session_stopping.connect(_on_openxr_stopping)
xr_interface.pose_recentered.connect(_on_openxr_pose_recentered)
else:
# We couldn't start OpenXR.
print("OpenXR not inst... | null |
Vervollständige den GDScript-Code: | extends Node3D
signal session_started
signal focus_lost
signal focus_gained
signal pose_recentered
## Set the highest refresh rate we wish to enable.
## We'll find the closest matching one.
@export var maximum_refresh_rate: int = 90
var xr_interface: OpenXRInterface
var xr_is_focused: bool = false
## Get our OpenX... | xr_interface.session_visible.connect(_on_openxr_visible_state)
xr_interface.session_focussed.connect(_on_openxr_focused_state)
xr_interface.session_stopping.connect(_on_openxr_stopping)
xr_interface.pose_recentered.connect(_on_openxr_pose_recentered)
else:
# We couldn't start OpenXR.
print("OpenXR not inst... | null |
Erstelle eine Godot-Klasse 'XRPointer' die von RayCast3D erbt mit folgenden Funktionen: _process | class_name XRPointer
extends RayCast3D
var pointing_at: Node3D
var colliding_at: Vector3 = Vector3()
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(_delta):
$Laser.visible = enabled
var col_with: Node3D
var col_at: Vector3 = Vector3()
if enabled:
if is_colliding():
... | null | |
Vervollständige den GDScript-Code: | # Virtual base class for stats (health, speed...) that support upgrades.
#
# You must call `initialize()` to initialize the stats' values. This ensures that they are in sync
# with the values modified in Godot's inspector.
#
# Each stat should be a floating point value, and we recommend to make them private properties,... | # Get the final value of a stat, with all modifiers applied to it.
func get_stat(stat_name := "") -> float:
assert(stat_name in _stats_list)
return _cache[stat_name]
# Adds a modifier to the stat corresponding to `stat_name` and returns the new modifier's id.
func add_modifier(stat_name: String, modifier: float) -> ... | null |
Erstelle eine GDScript-Funktion namens '_init': | func _init(current: Variant, type_check := true) -> void:
_type_check = type_check
_current_value_provider = DefaultValueProvider.new(current)
_base = GdUnitAssertImpl.new(current)
# save the actual assert instance on the current thread context
GdUnitThreadManager.get_current_context().set_assert(self)
if not _va... | extracted_function | |
Vervollständige den GDScript-Code: | extends Button
func _ready() -> void:
pressed.connect(_toggle_fullscreen)
| # Set scaling properties and base resolution
get_window().mode = Window.MODE_FULLSCREEN
get_window().content_scale_aspect = Window.CONTENT_SCALE_ASPECT_KEEP
get_window().content_scale_mode = Window.CONTENT_SCALE_MODE_CANVAS_ITEMS
get_window().content_scale_size = Vector2i(1920,1080)
func _toggle_fullscreen() -> v... | null |
Erstelle eine Godot-Klasse 'Fuzzers' die von Resource erbt mit folgenden Funktionen: rand_str, boolean, rangei, rangef, rangev2 | ## Factory class providing convenient static methods to create various fuzzer instances.[br]
##
## Fuzzers is a utility class that simplifies the creation of different fuzzer types
## for testing purposes. It provides static factory methods that create pre-configured
## fuzzers with sensible defaults, making it easier ... | null | |
Vervollständige den GDScript-Code: | ## An Assertion Tool to verify boolean values
@abstract class_name GdUnitBoolAssert
extends GdUnitAssert
## Verifies that the current value is null.
@abstract func is_null() -> GdUnitBoolAssert
## Verifies that the current value is not null.
@abstract func is_not_null() -> GdUnitBoolAssert
|
## Verifies that the current value is equal to the given one.
@abstract func is_equal(expected: Variant) -> GdUnitBoolAssert
## Verifies that the current value is not equal to the given one.
@abstract func is_not_equal(expected: Variant) -> GdUnitBoolAssert
## Overrides the default failure message by given custom me... | null |
Erstelle eine GDScript-Funktion namens 'pixel_to_cell': | func pixel_to_cell(pixel_coordinates: Vector2) -> Vector2i:
@warning_ignore("integer_division")
return Vector2i(
floori(pixel_coordinates.x / properties.cell_size.x),
floori(pixel_coordinates.y / properties.cell_size.y)
)
func get_cell_under_node(node: Node2D) -> Vector2i:
return pixel_to_cell(node.global_posi... | extracted_function | |
Erstelle eine Godot-Klasse 'GSAIArrive' die von GSAISteeringBehavior erbt mit folgenden Funktionen: _init, _arrive, _calculate_steering | # Calculates acceleration to take an agent to its target's location. The
# calculation attempts to arrive with zero remaining velocity.
# @category - Individual behaviors
class_name GSAIArrive
extends GSAISteeringBehavior
# Target agent to arrive to.
var target: GSAIAgentLocation
# Distance from the target for the age... | null | |
Vervollständige den GDScript-Code: | class_name MusicPlayer extends Node
@onready var _anim: = $AnimationPlayer as AnimationPlayer
@onready var _track: = $AudioStreamPlayer as AudioStreamPlayer
func play(new_stream: AudioStream, time_in: = 0.0, time_out: = 0.0) -> void:
if new_stream == _track.stream:
return
if is_playing():
if is_equal_approx(... |
_track.stop()
_track.stream = new_stream
if is_equal_approx(time_in, 0.0):
time_in = 0.005
_track.volume_db = -50.0
_track.play()
_anim.speed_scale = 1.0/time_in
_anim.play("fade_in")
await _anim.animation_finished
_anim.speed_scale = 1.0
func stop(time_out: = 0.0) -> void:
if is_equal_approx(time_out... | null |
Erstelle eine GDScript-Funktion namens '_notification': | func _notification(event: int) -> void:
if event == NOTIFICATION_PREDELETE:
if _base != null:
_base.notification(event)
_base = null
func report_success() -> GdUnitArrayAssert:
@warning_ignore("return_value_discarded")
_base.report_success()
return self
func report_error(error: String) -> GdUnitArrayAsser... | extracted_function | |
Erstelle eine GDScript-Funktion namens 'get_stat': | func get_stat(stat_name := "") -> float:
assert(stat_name in _stats_list)
return _cache[stat_name]
# Adds a modifier to the stat corresponding to `stat_name` and returns the new modifier's id.
func add_modifier(stat_name: String, modifier: float) -> int:
assert(stat_name in _stats_list)
_modifiers[stat_name].appen... | extracted_function | |
Vervollständige den GDScript-Code: | # Determines any agent that is in the specified list as being neighbors with the owner agent if
# they lie within the specified radius.
# @category - Proximities
class_name GSAIRadiusProximity
extends GSAIProximity
# The radius around the owning agent to find neighbors in
var radius := 0.0
var _last_frame := 0
var _s... | # Returns a number of neighbors based on a `callback` function.
#
# `_find_neighbors` calls `callback` for each agent in the `agents` array that lie within
# the radius around the owning agent and adds one to the count if its `callback` returns true.
# @tags - virtual
func _find_neighbors(callback: Callable) -> int:
v... | null |
Vervollständige den GDScript-Code: | @tool
extends ActionLeaf
@export var modulate_color:Color = Color.WHITE
@export var interpolation_time:float = 3.0
var current_color
var tween
func tick(actor: Node, _blackboard: Blackboard) -> int: |
if current_color != modulate_color and actor.modulate != modulate_color:
if tween != null:
tween.stop()
current_color = modulate_color
tween = create_tween()\
.set_ease(Tween.EASE_IN_OUT)\
.set_trans(Tween.TRANS_CUBIC)
tween.tween_property(actor, "modulate", current_color, interpolation_time)\
.finis... | null |
Erstelle eine Godot-Klasse 'PianoKey' die von Control erbt mit folgenden Funktionen: setup, activate, deactivate | class_name PianoKey
extends Control
var pitch_scale: float
@onready var key: ColorRect = $Key
@onready var start_color: Color = key.color
@onready var color_timer: Timer = $ColorTimer
func setup(pitch_index: int) -> void:
name = "PianoKey" + str(pitch_index)
var exponent := (pitch_index - 69.0) / 12.0
pitch_scale... | null | |
Erstelle eine GDScript-Funktion namens 'pixel_to_cell': | func pixel_to_cell(pixel_coordinates: Vector2) -> Vector2i:
@warning_ignore("integer_division")
return Vector2i(
floori(pixel_coordinates.x / properties.cell_size.x),
floori(pixel_coordinates.y / properties.cell_size.y)
)
func get_cell_under_node(node: Node2D) -> Vector2i:
return pixel_to_cell(node.global_posi... | null | |
Erstelle eine GDScript-Funktion namens '_ready': | func _ready() -> void:
await owner.ready
state.enter()
func _unhandled_input(event: InputEvent) -> void:
state.unhandled_input(event)
func _physics_process(delta: float) -> void:
state.physics_process(delta)
func transition_to(target_state_path: String, msg: Dictionary = {} | null | |
Erstelle eine Godot-Klasse 'GSAICharacterBody3DAgent' die von GSAISpecializedAgent erbt mit folgenden Funktionen: _init, _apply_steering, _apply_sliding_steering, _apply_collide_steering, _apply_position_steering | # A specialized steering agent that updates itself every frame so the user does
# not have to using a CharacterBody3D
# @category - Specialized agents
class_name GSAICharacterBody3DAgent
extends GSAISpecializedAgent
# SLIDE uses `move_and_slide`
# COLLIDE uses `move_and_collide`
# POSITION changes the global_position ... | null | |
Erstelle eine Godot-Klasse 'StateMachine' die von Node erbt mit folgenden Funktionen: _init, _ready, _unhandled_input, _physics_process, transition_to | # Generic State Machine. Initializes states and delegates engine callbacks
# (_physics_process, _unhandled_input) to the active state.
extends Node
class_name StateMachine
@export var initial_state := NodePath()
@onready var state: State = get_node(initial_state): set = set_state
@onready var _state_name := state.nam... | null | |
Erstelle eine GDScript-Funktion namens '_physics_process': | func _physics_process(delta: float) -> void:
if not _is_playing:
return
# To have the best of both the audio-based time and system-based time, we
# apply a smoothing filter (1€ filter) on the delta between the two values,
# then add it to the system-based time. This allows us to have a stable
# value that is al... | extracted_function | |
Vervollständige den GDScript-Code: | @tool
## A Gamepiece is a scene that moves about and is snapped to the gameboard.
##
## Gamepieces, like other scenes in Godot, are expected to be composed from other nodes (i.e. an AI
## [GamepieceController], a collision shape, or a [Sprite2D], for example). Gamepieces themselves
## are 'dumb' objects that do nothin... | ## In the event that the gamepiece is moving along a path, direction is updated automatically as
## long as the gamepiece continues to move.
var direction: = Directions.Points.SOUTH:
set(value):
if value != direction:
direction = value
if not is_inside_tree():
await ready
animation.direction = directi... | null |
Erstelle eine Godot-Klasse 'CombatTrigger' die von Trigger erbt mit folgenden Funktionen: _execute, _run_victory_cutscene, _run_loss_cutscene | @tool
class_name CombatTrigger extends Trigger
@export var combat_arena: PackedScene
func _execute() -> void:
# Let other systems know that a combat has been triggered and then wait for its outcome.
FieldEvents.combat_triggered.emit(combat_arena)
var did_player_win: bool = await CombatEvents.combat_finished
# T... | null | |
Vervollständige den GDScript-Code: | @tool
extends CombatTrigger
| # If the player has defeated this 'roaming encounter', remove the encounter.
func _run_victory_cutscene() -> void:
queue_free()
# If the player has lost to this 'roaming encounter', play the game-over screen.
func _run_loss_cutscene() -> void:
await get_tree().process_frame
| null |
Vervollständige den GDScript-Code: | # Determines any agent that is in the specified list as being neighbors with the
# owner agent, regardless of distance.
# @category - Proximities
class_name GSAIInfiniteProximity
extends GSAIProximity
func _init(agent: GSAISteeringAgent, agents: Array) -> void:
super._init(agent, agents) |
# Returns a number of neighbors based on a `callback` function.
#
# `_find_neighbors` calls `callback` for each agent in the `agents` array and
# adds one to the count if its `callback` returns true.
# @tags - virtual
func _find_neighbors(callback: Callable) -> int:
var neighbor_count := 0
var agent_count := agents.... | null |
Vervollständige den GDScript-Code: | #*
#* showcase.gd
#* =============================================================================
#* Copyright 2024 Serhii Snitsaruk
#*
#* Use of this source code is governed by an MIT-style
#* license that can be found in the LICENSE file or at
#* https://opensource.org/licenses/MIT.
#* ==============================... | begin_tutorial.text = "End Tutorial"
navigation_hint.text = "Navigate ➤"
scene_title.text = "Tutorial"
_on_agent_selection_id_pressed(0)
else:
_populate_agent_files("res://demo/agents/")
begin_tutorial.text = "Begin Tutorial"
navigation_hint.text = "Select Agent ➤"
scene_title.text = "Showcase"
_on_a... | null |
Erstelle eine GDScript-Funktion namens 'keys': | func keys() -> Array[String]:
var keys: Array[String]
keys.assign(_data.keys().duplicate())
return keys
func set_value(key: Variant, value: Variant, blackboard_name: String = DEFAULT) -> void:
if not _data.has(blackboard_name):
_data[blackboard_name] = {} | null | |
Erstelle eine GDScript-Funktion namens 'set_current_report_path': | func set_current_report_path() -> void:
# scan for latest report directory
var iteration := GdUnitFileAccess.find_last_path_index(
_report_root_path, GdUnitConstants.REPORT_DIR_PREFIX
)
_current_report_path = "%s/%s%d" % [_report_root_path, GdUnitConstants.REPORT_DIR_PREFIX, iteration]
func set_report_directory(... | null | |
Erstelle eine GDScript-Funktion namens '_physics_process': | func _physics_process(delta: float) -> void:
if not _is_playing:
return
# To have the best of both the audio-based time and system-based time, we
# apply a smoothing filter (1€ filter) on the delta between the two values,
# then add it to the system-based time. This allows us to have a stable
# value that is al... | extracted_function | |
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 | @tool
## Applied to any gamepiece to allow player control.
##
## The controller responds to player input to handle movement and interaction.
class_name PlayerController extends GamepieceController
const GROUP: = "_PLAYER_CONTROLLER_GROUP"
# Keep track of a targeted interaction. Used to face & interact with the object... | null | |
Erstelle eine GDScript-Funktion namens 'initialize': | func initialize() -> void:
_update_all()
# Get the final value of a stat, with all modifiers applied to it.
func get_stat(stat_name := "") -> float:
assert(stat_name in _stats_list)
return _cache[stat_name]
# Adds a modifier to the stat corresponding to `stat_name` and returns the new modifier's id.
func add_modif... | null | |
Vervollständige den GDScript-Code: | ## Random action node that changes its state over time.
##
## Action node that returns a random status, depending on the action
## [member weights]. Changes its status every [member reset_duration_msec]
## milliseconds.
@tool
class_name RandomAction extends ActionLeaf
## How often this action changes its return statu... | var last_step = 0
var action = 0
## Array of 3 floats signifying the weights of SUCCESS, FAILURE and RUNNING
## statuses respectively.
var weights = [3., 3., 1.]
func _get_random_action():
var sum = 0.
for w in weights:
sum += w
var rnd = randf_range(0, sum)
for i in weights.size():
if rnd <= weights[i]:
r... | null |
Erstelle eine GDScript-Funktion namens '_process': | func _process(_delta: float) -> void:
if not _is_playing:
return
# Handle a web bug where AudioServer.get_time_since_last_mix() occasionally
# returns unsigned 64-bit integer max value. This is likely due to minor
# timing issues between the main/audio threads, thus causing an underflow
# in the engine code.
v... | extracted_function | |
Vervollständige den GDScript-Code: | extends Sprite2D
func _ready() -> void:
Player.player_path_set.connect( | func(gamepiece: Gamepiece, destination_cell: Vector2i) -> void:
if not gamepiece.arrived.is_connected(_on_gp_arrived):
gamepiece.arrived.connect(_on_gp_arrived, CONNECT_ONE_SHOT)
position = Gameboard.cell_to_pixel(destination_cell)
#show()
)
func _on_gp_arrived() -> void:
hide()
| null |
Erstelle eine GDScript-Funktion namens 'add': | func add(behavior: GSAISteeringBehavior, weight: float) -> void:
behavior.agent = agent
_behaviors.append({behavior = behavior, weight = weight} | extracted_function | |
Vervollständige den GDScript-Code: | class_name CollisionHands3D
extends AnimatableBody3D
func _ready():
# Make sure these are set correctly.
top_level = true | sync_to_physics = false
process_physics_priority = -90
func _physics_process(_delta):
# Follow our parent node around.
var dest_transform = get_parent().global_transform
# We just apply rotation for this example.
global_basis = dest_transform.basis
# Attempt to move to where our tracked hand is.
move_and_col... | null |
Erstelle eine Godot-Klasse 'GSAIRadiusProximity' die von GSAIProximity erbt mit folgenden Funktionen: _init, _find_neighbors | # Determines any agent that is in the specified list as being neighbors with the owner agent if
# they lie within the specified radius.
# @category - Proximities
class_name GSAIRadiusProximity
extends GSAIProximity
# The radius around the owning agent to find neighbors in
var radius := 0.0
var _last_frame := 0
var _s... | null | |
Vervollständige den GDScript-Code: | extends Control
@export var controller: XRController3D
@onready var trigger_input_node: HSlider = $VBoxContainer/TriggerInput/HSlider
@onready var trigger_click_node: CheckBox = $VBoxContainer/TriggerInput/CheckBox
@onready var on_threshold_node: Label = $VBoxContainer/Thresholds/OnThreshold
@onready var off_threshol... |
var off_trigger_threshold: float = 1.0
var on_trigger_threshold: float = 0.0
func _process(_delta: float) -> void:
if controller:
var trigger_input = controller.get_float(&"trigger")
trigger_input_node.value = trigger_input
var trigger_click = controller.is_button_pressed(&"trigger_click")
trigger_click_nod... | null |
Erstelle eine Godot-Klasse 'GSAIAvoidCollisions' die von GSAIGroupBehavior erbt mit folgenden Funktionen: _init, _calculate_steering, _report_neighbor | # Steers the agent to avoid obstacles in its path. Approximates obstacles as
# spheres.
# @category - Group behaviors
class_name GSAIAvoidCollisions
extends GSAIGroupBehavior
var _first_neighbor: GSAISteeringAgent
var _shortest_time: float
var _first_minimum_separation: float
var _first_distance: float
var _first_rela... | null | |
Vervollständige den GDScript-Code: | extends Node3D
var webxr_interface: WebXRInterface
var vr_supported: bool = false
@onready var left_controller = $XROrigin3D/LeftController
func _ready() -> void:
$CanvasLayer/EnterVRButton.pressed.connect(_on_enter_vr_button_pressed)
webxr_interface = XRServer.find_interface("WebXR")
if webxr_interface:
# W... | OS.alert("Your browser doesn't support VR")
return
# We want an immersive VR session, as opposed to AR ("immersive-ar") or a
# simple 3DoF viewer ("viewer").
webxr_interface.session_mode = "immersive-vr"
# "bounded-floor" is room scale, "local-floor" is a standing or sitting
# experience (it puts you 1.6m abo... | null |
Vervollständige den GDScript-Code: | extends Camera3D
## This script allows us to place a camera in the world that provides
## a spectator view where we see what the player sees.
## The positioning is smoothed to create a steadycam type of effect.
## Specify the XRCamera3D node we're replicating the view for.
@export var xr_camera : XRCamera3D
## Remov... | var first_frame : bool = true
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
if current and xr_camera:
# Note, we apply our smoothing in the local space of our XROrigin3D node.
# This way we don't apply smoothing when game logic moves the XROrigin3D node.
# We ... | null |
Vervollständige den GDScript-Code: | #*
#* face_target.gd
#* =============================================================================
#* Copyright (c) 2023-present Serhii Snitsaruk and the LimboAI contributors.
#*
#* Use of this source code is governed by an MIT-style
#* license that can be found in the LICENSE file or at
#* https://opensource.org/li... | extends BTAction
## Flips the agent to face the target, returning [code]SUCCESS[/code]. [br]
## Returns [code]FAILURE[/code] if [member target_var] is not a valid [Node2D] instance.
## Blackboard variable that stores our target (expecting Node2D).
@export var target_var: StringName = &"target"
# Display a customized ... | null |
Erstelle eine GDScript-Funktion namens 'has_value': | func has_value(key: Variant, blackboard_name: String = DEFAULT) -> bool:
return (
_data.has(blackboard_name)
and _data[blackboard_name].has(key)
and _data[blackboard_name][key] != null
)
func erase_value(key: Variant, blackboard_name: String = DEFAULT) -> void:
if _data.has(blackboard_name):
_data[blackboar... | extracted_function | |
Vervollständige den GDScript-Code: | ## Base interface of all GdUnit asserts
@abstract class_name GdUnitAssert
extends RefCounted
## Verifies that the current value is null.
@abstract func is_null() -> GdUnitAssert
## Verifies that the current value is not null.
@abstract func is_not_null() -> GdUnitAssert
## Verifies that the current value is equal... |
## Verifies that the current value is not equal to expected one.
@abstract func is_not_equal(expected: Variant) -> GdUnitAssert
## Overrides the default failure message by given custom message.[br]
## This function allows you to replace the automatically generated failure message with a more specific
## or user-frien... | null |
Vervollständige den GDScript-Code: | extends XRController3D
# Check if we can use our palm pose or should fallback to our grip pose.
| # Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
var controller_tracker : XRControllerTracker = XRServer.get_tracker(tracker)
if controller_tracker:
var new_pose : String = "palm_pose"
var xr_pose : XRPose = controller_tracker.get_pose(new_pose)
if not xr_pose or... | null |
Vervollständige den GDScript-Code: | extends Node3D
signal session_started
signal focus_lost
signal focus_gained
signal pose_recentered
## Set the highest refresh rate we wish to enable.
## We'll find the closest matching one.
@export var maximum_refresh_rate: int = 90
var xr_interface: OpenXRInterface
var xr_is_focused: bool = false
## Get our OpenX... | xr_interface.session_visible.connect(_on_openxr_visible_state)
xr_interface.session_focussed.connect(_on_openxr_focused_state)
xr_interface.session_stopping.connect(_on_openxr_stopping)
xr_interface.pose_recentered.connect(_on_openxr_pose_recentered)
else:
# We couldn't start OpenXR.
print("OpenXR not inst... | null |
Vervollständige den GDScript-Code: | class_name NoteManager
extends Node2D
signal play_stats_updated(play_stats: PlayStats)
signal note_hit(beat: float, hit_type: Enums.HitType, hit_error: float)
signal song_finished(play_stats: PlayStats)
const NOTE_SCENE = preload("res://objects/note/note.tscn")
const HIT_MARGIN_PERFECT = 0.050
const HIT_MARGIN_GOOD =... | if _notes.is_empty():
return
var curr_beat := _get_curr_beat()
for i in range(_notes.size()):
_notes[i].update_beat(curr_beat)
_miss_old_notes()
if Input.is_action_just_pressed(&"main_key"):
_handle_keypress()
if _notes.is_empty():
_finish_song()
func _miss_old_notes() -> void:
while not _notes.is_e... | null |
Vervollständige den GDScript-Code: | @tool
extends BTAction
## Selects a random position nearby within the specified range and stores it on the blackboard. [br]
## Returns [code]SUCCESS[/code].
## Minimum distance to the desired position.
@export var range_min: float = 300.0
## Maximum distance to the desired position.
@export var range_max: float = 500... | ## Blackboard variable that will be used to store the desired position.
@export var position_var: StringName = &"pos"
# Display a customized name (requires @tool).
func _generate_name() -> String:
return "SelectRandomNearbyPos range: [%s, %s] ➜%s" % [
range_min, range_max,
LimboUtility.decorate_var(position_var... | null |
Erstelle eine GDScript-Funktion namens '_init': | func _init():
name = "BeehavePlugin"
add_autoload_singleton("BeehaveGlobalMetrics", "metrics/beehave_global_metrics.gd")
add_autoload_singleton("BeehaveGlobalDebugger", "debug/global_debugger.gd")
# Add project settings
if not ProjectSettings.has_setting("beehave/debugger/start_detached"):
ProjectSettings.set_s... | null | |
Vervollständige den GDScript-Code: | extends Node2D
var main_viewport: Viewport
var vr_render_size: Vector2 = Vector2()
var window_size: Vector2 = Vector2()
var hmd_view_material: ShaderMaterial
@onready var hmd_view: ColorRect = $HMDView
@onready var ui_spectator_view: OptionButton = $UI/SpectatorView
@onready var ui_track_camera: CheckBox = $UI/TrackC... | ui_spectator_view.set("popup/item_2/disabled", true)
ui_spectator_view.set("popup/item_3/disabled", true)
# Get our hmd view material.
hmd_view_material = hmd_view.material
# Get a signal when our window size changes
get_tree().get_root().size_changed.connect(_on_size_changed)
# Call at least once to initia... | null |
Erstelle eine GDScript-Funktion namens 'get_stat': | func get_stat(stat_name := "") -> float:
assert(stat_name in _stats_list)
return _cache[stat_name]
# Adds a modifier to the stat corresponding to `stat_name` and returns the new modifier's id.
func add_modifier(stat_name: String, modifier: float) -> int:
assert(stat_name in _stats_list)
_modifiers[stat_name].appen... | null | |
Vervollständige den GDScript-Code: | extends Control
# A standard piano with 88 keys has keys from 21 to 108.
# To get a different set of keys, modify these numbers.
# A maximally extended 108-key piano goes from 12 to 119.
# A 76-key piano goes from 23 to 98, 61-key from 36 to 96,
# 49-key from 36 to 84, 37-key from 41 to 77, and 25-key
# from 48 to 72.... |
func _input(input_event: InputEvent) -> void:
if input_event is not InputEventMIDI:
return
var midi_event: InputEventMIDI = input_event
if midi_event.pitch < START_KEY or midi_event.pitch > END_KEY:
# The given pitch isn't on the on-screen keyboard, so return.
return
_print_midi_info(midi_event)
var key: ... | null |
Erstelle eine GDScript-Funktion namens '_on_gamepiece_free': | func _on_gamepiece_free(_gp: Gamepiece, coord: Vector2i) -> void:
var cell_id: = Gameboard.cell_to_index(coord)
if has_point(cell_id):
set_point_disabled(cell_id, false)
)
## Returns true if the coordinate is found in the Pathfinder.
func has_cell(coord: Vector2i) -> bool:
return has_point(Gameboard.cell_t... | null | |
Erstelle eine Godot-Klasse 'Comparator' die von Resource erbt mit folgenden Funktionen: | class_name Comparator
extends Resource
enum {
EQUAL,
LESS_THAN,
LESS_EQUAL,
GREATER_THAN,
GREATER_EQUAL,
BETWEEN_EQUAL,
NOT_BETWEEN_EQUAL,
}
| null | |
Erstelle eine GDScript-Funktion namens '_physics_process': | func _physics_process(delta: float) -> void:
if not _is_playing:
return
# To have the best of both the audio-based time and system-based time, we
# apply a smoothing filter (1€ filter) on the delta between the two values,
# then add it to the system-based time. This allows us to have a stable
# value that is al... | null | |
Vervollständige den GDScript-Code: | # A base class for a specialized steering agent that updates itself every frame
# so the user does not have to. All other specialized agents derive from this.
# @category - Specialized agents
# @tags - abstract
class_name GSAISpecializedAgent
extends GSAISteeringAgent
# If `true`, calculates linear and angular velocit... | # Does not apply to `RigidBody` and `RigidBody2D` nodes.
var apply_linear_drag := true
# If `true`, interpolates the current angular velocity towards 0 by the
# `angular_drag_percentage` value.
# Does not apply to `RigidBody` and `RigidBody2D` nodes.
var apply_angular_drag := true
# The percentage between the current... | null |
Erstelle eine Godot-Klasse 'GSAIInfiniteProximity' die von GSAIProximity erbt mit folgenden Funktionen: _init, _find_neighbors | # Determines any agent that is in the specified list as being neighbors with the
# owner agent, regardless of distance.
# @category - Proximities
class_name GSAIInfiniteProximity
extends GSAIProximity
func _init(agent: GSAISteeringAgent, agents: Array) -> void:
super._init(agent, agents)
# Returns a number of neighb... | null | |
Vervollständige den GDScript-Code: | extends Node3D
var webxr_interface: WebXRInterface
var vr_supported: bool = false
@onready var left_controller = $XROrigin3D/LeftController
func _ready() -> void:
$CanvasLayer/EnterVRButton.pressed.connect(_on_enter_vr_button_pressed)
webxr_interface = XRServer.find_interface("WebXR")
if webxr_interface:
# W... | OS.alert("Your browser doesn't support VR")
return
# We want an immersive VR session, as opposed to AR ("immersive-ar") or a
# simple 3DoF viewer ("viewer").
webxr_interface.session_mode = "immersive-vr"
# "bounded-floor" is room scale, "local-floor" is a standing or sitting
# experience (it puts you 1.6m abo... | null |
Erstelle eine GDScript-Funktion namens '_process': | func _process(_delta: float) -> void:
if not _is_playing:
return
# Handle a web bug where AudioServer.get_time_since_last_mix() occasionally
# returns unsigned 64-bit integer max value. This is likely due to minor
# timing issues between the main/audio threads, thus causing an underflow
# in the engine code.
v... | null | |
Vervollständige den GDScript-Code: | ## The visual representation of a [Battler].
##
## Battler animations respond visually to a closed set of stimiuli, such as receiving a hit or
## moving to a position. These animations often represent a single character or a class of enemies
## and are added as children to a given Battler.
##
## [br][br]Note: BattlerA... |
@onready var _anim: = $Pivot/AnimationPlayer as AnimationPlayer
func _ready() -> void:
_anim.animation_finished.connect(
func _on_animation_player_finished(anim_name: String) -> void:
animation_finished.emit(anim_name)
)
_rest_position = position
## Setup the BattlerAnim object to respond to gameplay signal... | null |
Erstelle eine GDScript-Funktion namens 'cell_to_pixel': | func cell_to_pixel(cell_coordinates: Vector2i) -> Vector2:
return Vector2(cell_coordinates * properties.cell_size) + properties.half_cell_size
## Convert pixel coordinates to cell coordinates.
func pixel_to_cell(pixel_coordinates: Vector2) -> Vector2i:
@warning_ignore("integer_division")
return Vector2i(
floori(p... | null | |
Erstelle eine GDScript-Funktion namens '_process': | func _process(_delta: float) -> bool:
# check if reports exists
if not reports_available():
prints("no reports found")
return true
# only process if godot logging is enabled
if not GdUnitSettings.is_log_enabled():
write_report(NO_LOG_MESSAGE, "")
return true
# parse possible custom report path,
var cmd_... | null | |
Vervollständige den GDScript-Code: | extends ColorRect
@onready var parent: PianoKey = get_parent() |
# Yes, this script exists just for this one method.
func _gui_input(input_event: InputEvent) -> void:
if input_event is InputEventMouseButton and input_event.pressed:
parent.activate()
| null |
Vervollständige den GDScript-Code: | extends Panel
enum SyncSource {
SYSTEM_CLOCK,
SOUND_CLOCK,
}
const BPM = 116
const BARS = 4
const COMPENSATE_FRAMES = 2
const COMPENSATE_HZ = 60.0
var playing: bool = false
var sync_source := SyncSource.SYSTEM_CLOCK
# Used by system clock.
var time_begin: float | var time_delay: float
func _process(_delta: float) -> void:
if not playing or not $Player.playing:
return
var time := 0.0
if sync_source == SyncSource.SYSTEM_CLOCK:
# Obtain from ticks.
time = (Time.get_ticks_usec() - time_begin) / 1000000.0
# Compensate.
time -= time_delay
elif sync_source == SyncSourc... | null |
Vervollständige den GDScript-Code: | @tool
extends BeehaveTree
@export_range(1, 100) var randomize_node_count: int = 20
@export var randomize_tree: bool = false:
set(v):
if !v:
return
randomize_tree = false
_randomize_tree()
class TNode extends RefCounted:
var children = []
var long_name_suffix = "LooooooooongNameSuffix"
func get_name_s... | return long_name_suffix
return ""
var tree_root: TNode
var tree_nodes = []
func _get_random_node():
return tree_nodes[randi_range(0, tree_nodes.size() - 1)]
func _make_random_tree():
# One node (the root) is already created
tree_root = TNode.new()
tree_nodes = [tree_root]
for i in randomize_node_count - 1:
... | null |
Vervollständige den GDScript-Code: | ## Find all collision shapes of a given mask within a specified search radius.
##
## The CollisionFinder is used to search for objects that contain a [CollisionObject2D]. In the
## OpenRPG it serves as the cornerstone of the [Gameboard]/[Gamepiece] system, since objects
## (gamepieces, terrain, etc.) are found dynami... | var query_parameters: PhysicsShapeQueryParameters2D
# Cache the space state that will be queried.
var _space_state: PhysicsDirectSpaceState2D
func _init(space_state: PhysicsDirectSpaceState2D, search_radius: float, collision_mask: int,
find_areas: = true) -> void:
_space_state = space_state
var query_shape: = Ci... | null |
Erstelle eine GDScript-Funktion namens '_init': | func _init(agent: GSAISteeringAgent) -> void:
super._init(agent)
# Appends a behavior to the internal array along with its `weight`.
func add(behavior: GSAISteeringBehavior, weight: float) -> void:
behavior.agent = agent
_behaviors.append({behavior = behavior, weight = weight} | extracted_function | |
Vervollständige den GDScript-Code: | extends Node
var thread
var mutex
var semaphore
var exit_thread = false
var time_max = 100 # Milliseconds.
var queue = []
var pending = {}
func _lock(_caller):
mutex.lock()
func _unlock(_caller):
mutex.unlock()
func _post(_caller):
semaphore.post()
func _wait(_caller):
semaphore.wait()
func queue_resour... | queue.erase(pending[path])
pending.erase(path)
_unlock("cancel_resource")
func get_progress(path):
_lock("get_progress")
var ret = -1
if path in pending:
if pending[path] is ResourceInteractiveLoader:
ret = float(pending[path].get_stage()) / float(pending[path].get_stage_count())
else:
ret = 1.0
_u... | null |
Vervollständige den GDScript-Code: | extends Node
signal scroll_speed_changed(speed: float)
@export var use_filtered_playback: bool = true
| @export var enable_metronome: bool = false
@export var input_latency_ms: int = 20
@export var scroll_speed: float = 400:
set(value):
if scroll_speed != value:
scroll_speed = value
scroll_speed_changed.emit(value)
@export var show_offsets: bool = false
@export var selected_chart: ChartData.Chart = ChartData.C... | null |
Erstelle eine Godot-Klasse 'GSAIPriority' die von GSAISteeringBehavior erbt mit folgenden Funktionen: _init, add, get_behavior_at, _calculate_steering | # Container for multiple behaviors that returns the result of the first child
# behavior with non-zero acceleration.
# @category - Combination behaviors
class_name GSAIPriority
extends GSAISteeringBehavior
var _behaviors := []
# The index of the last behavior the container prioritized.
var last_selected_index: int
# ... | null | |
Vervollständige den GDScript-Code: | @abstract class_name GdUnitFileAssert
extends GdUnitAssert
## Verifies that the current value is null.
@abstract func is_null() -> GdUnitFileAssert
## Verifies that the current value is not null.
@abstract func is_not_null() -> GdUnitFileAssert
## Verifies that the current value is equal to the given one. | @abstract func is_equal(expected: Variant) -> GdUnitFileAssert
## Verifies that the current value is not equal to expected one.
@abstract func is_not_equal(expected: Variant) -> GdUnitFileAssert
## Overrides the default failure message by given custom message.
@abstract func override_failure_message(message: String) ... | null |
Erstelle eine GDScript-Funktion namens '_init': | func _init(agent: GSAISteeringAgent) -> void:
super._init(agent)
# Appends a behavior to the internal array along with its `weight`.
func add(behavior: GSAISteeringBehavior, weight: float) -> void:
behavior.agent = agent
_behaviors.append({behavior = behavior, weight = weight} | null | |
Vervollständige den GDScript-Code: | extends Control
var effect: AudioEffect
var recording: AudioStreamWAV
var stereo: bool = true
var mix_rate := 44100 # This is the default mix rate on recordings.
var format := AudioStreamWAV.FORMAT_16_BITS # This is the default format on recordings.
func _ready() -> void:
var idx := AudioServer.get_bus_index(&"R... |
func _on_play_button_pressed() -> void:
print_rich("\n[b]Playing recording:[/b] %s" % recording)
print_rich("[b]Format:[/b] %s" % ("8-bit uncompressed" if recording.format == 0 else "16-bit uncompressed" if recording.format == 1 else "IMA ADPCM compressed"))
print_rich("[b]Mix rate:[/b] %s Hz" % recording.mix_rate)... | null |
Vervollständige den GDScript-Code: | ## An Assertion Tool to verify Vector values
@abstract class_name GdUnitVectorAssert
extends GdUnitAssert
## Verifies that the current value is null.
@abstract func is_null() -> GdUnitVectorAssert
## Verifies that the current value is not null.
@abstract func is_not_null() -> GdUnitVectorAssert
## Verifies that t... | @abstract func is_not_equal(expected: Variant) -> GdUnitVectorAssert
## Verifies that the current and expected value are approximately equal.
@abstract func is_equal_approx(expected: Variant, approx: Variant) -> GdUnitVectorAssert
## Overrides the default failure message by given custom message.
@abstract func overri... | null |
Vervollständige den GDScript-Code: | @tool
## Encapsulates [Gamepiece] animation as an optional component.
##
## Allows playing animations that automatically adapt to the parent
## [Gamepiece]'s direction by calling [method play]. Transitions between
## animations are handled automatically, including changes to direction.
## [br][br][b]Note:[/b] This is u... | set = set_direction
@onready var _anim: = $AnimationPlayer as AnimationPlayer
## Change the currently playing animation to a new value, if it exists.
##
## Animations may be added with or without a directional suffix (i.e. _n for
## north/up). Directional animations will be preferred with direction-less
## animation... | null |
Vervollständige den GDScript-Code: | extends OpenXRCompositionLayerEquirect
const NO_INTERSECTION = Vector2(-1.0, -1.0)
@export var controller : XRController3D
@export var button_action : String = "select"
var was_pressed : bool = false
var was_intersect : Vector2 = NO_INTERSECTION
# Pass input events on to viewport.
func _input(event):
if not layer... | var pos : Vector2 = intersect * Vector2(layer_viewport.size)
return Vector2i(pos)
else:
return Vector2i(-1, -1)
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(_delta):
if not controller:
return
if not layer_viewport:
return
var controller_t : Transform3D = cont... | null |
Erstelle eine Godot-Klasse 'GamepieceAnimation' die von Marker2D erbt mit folgenden Funktionen: play, set_direction, _swap_animation | @tool
## Encapsulates [Gamepiece] animation as an optional component.
##
## Allows playing animations that automatically adapt to the parent
## [Gamepiece]'s direction by calling [method play]. Transitions between
## animations are handled automatically, including changes to direction.
## [br][br][b]Note:[/b] This is u... | null | |
Vervollständige den GDScript-Code: | @tool
class_name AreaTransition extends Trigger
@export var arrival_coordinates: Vector2:
set(value):
arrival_coordinates = value
if Engine.is_editor_hint():
if not is_inside_tree():
await ready
var target = $Destination as Sprite2D
target.position = arrival_coordinates - position
#TODO: th... | if not Engine.is_editor_hint():
$Destination.queue_free()
# Area transitions are given several opportunities to "do something" at various stages, such as
# before the camera fades away, after it has faded, and immediately after it re-appears in the new
# area.
# This could include all manner of shenanigans, such as... | null |
Erstelle eine GDScript-Funktion namens 'get_value': | func get_value(
key: Variant, default_value: Variant = null, blackboard_name: String = DEFAULT
) -> Variant:
if has_value(key, blackboard_name):
return _data[blackboard_name].get(key, default_value)
return default_value
func has_value(key: Variant, blackboard_name: String = DEFAULT) -> bool:
return (
_data.has... | extracted_function | |
Erstelle eine GDScript-Funktion namens 'format_dict': | func format_dict(value :Variant) -> String:
if not value is Dictionary:
return str(value)
var dict_value: Dictionary = value
if dict_value.is_empty():
return "{ } | extracted_function | |
Vervollständige den GDScript-Code: | extends Node3D
## The position of this node will be updated if a camera tracker is available.
@export var tracked_camera : Node3D:
set(value):
tracked_camera = value
if tracked_camera:
%CameraRemoteTransform3D.remote_path = tracked_camera.get_path()
else:
%CameraRemoteTransform3D.remote_path = NodePath()
... |
# Enable the pointer on the last controller we pressed a button on.
func _enable_pointer():
$XROrigin3D/LeftHandAim/XRPointer.enabled = left_or_right == 0
$XROrigin3D/RightHandAim/XRPointer.enabled = left_or_right == 1
# Called when the node enters the scene tree for the first time.
func _ready():
_enable_pointer(... | null |
Erstelle eine GDScript-Funktion namens 'add': | func add(behavior: GSAISteeringBehavior, weight: float) -> void:
behavior.agent = agent
_behaviors.append({behavior = behavior, weight = weight} | null | |
Vervollständige den GDScript-Code: | # Creates, maintains, and organizes spawned special effects or projectiles;
# objects that should be untied from their spawners' lifespan when freed.
extends Node
@onready var _effects := $Effects
@onready var _projectiles := $Projectiles
@onready var _distortions: SubViewport
|
func register_effect(effect: Node) -> void:
_effects.add_child(effect)
func register_projectile(projectile: Node) -> void:
_projectiles.add_child(projectile)
func register_distortion_effect(effect: Node2D) -> void:
if is_instance_valid(_distortions):
_distortions.add_child(effect)
func register_distortion_pare... | null |
Vervollständige den GDScript-Code: | extends Node3D
@onready var viewport: Viewport = get_viewport()
@onready var environment: Environment = $WorldEnvironment.environment
@onready var fade_message : FadeMessage3D = $XROrigin3D/FadeMessage3D
var passthrough_enabled: bool = false
## Switch to AR (passthrough)
func switch_to_ar() -> bool:
var xr_interfac... | fade_message.text = "Passthrough is not supported on this device"
return false
viewport.transparent_bg = true
environment.background_mode = Environment.BG_COLOR
environment.background_color = Color(0.0, 0.0, 0.0, 0.0)
return true
## Switch to VR (exit passthrough)
func switch_to_vr() -> bool:
var xr_interfac... | null |
Vervollständige den GDScript-Code: | # Calculates an angular acceleration to match an agent's orientation to that of
# its target. Attempts to make the agent arrive with zero remaining angular
# velocity.
# @category - Individual behaviors
class_name GSAIMatchOrientation
extends GSAISteeringBehavior
# The target orientation for the behavior to try and ma... | var use_z: bool
func _init(agent: GSAISteeringAgent, _target: GSAIAgentLocation, _use_z := false) -> void:
super._init(agent)
self.use_z = _use_z
self.target = _target
func _match_orientation(acceleration: GSAITargetAcceleration, desired_orientation: float) -> void:
var rotation := wrapf(desired_orientation - age... | null |
Vervollständige den GDScript-Code: | # Presents a confirmation screen whether the player really intends on leaving
# the game back to the main menu or not.
extends MarginContainer
@onready var yes_button := $VBoxContainer/HBoxContainer/YesButton
@onready var no_button := $VBoxContainer/HBoxContainer/NoButton
@onready var menu_sounds: MenuSoundPlayer = $M... | if event.is_action_pressed("ui_cancel"):
close()
get_viewport().set_input_as_handled()
func open() -> void:
get_tree().paused = true
menu_sounds.play_open()
show()
no_button.grab_focus()
set_process_input(true)
func close() -> void:
menu_sounds.play_close()
get_tree().paused = false
set_process_input(fal... | null |
Vervollständige den GDScript-Code: | ## An autoload that provides easy access to the player's state, including both Combat and Field
## details.
## Reference to the player's party, inventory, and currently active character are found here.
## Additionally, game-wide player based signals are emitted from here.
extends Node
## Emitted whenever the player's ... | signal gamepiece_changed
## Emitted when the player sets a movement path for their focused gamepiece.
## The destination is the last cell in the path.
@warning_ignore("unused_signal")
signal player_path_set(gamepiece: Gamepiece, destination_cell: Vector2i)
## The gamepeice that the player is currently controlling. Th... | null |
Vervollständige den GDScript-Code: | # Represents a path made up of Vector3 waypoints, split into segments path
# follow behaviors can use.
# @category - Base types
class_name GSAIPath
extends RefCounted
# If `false`, the path loops.
var is_open: bool
# Total length of the path.
var length: float
var _segments: Array
var _nearest_point_on_segment: Vect... | length += segment.length
segment.cumulative_length = length
_segments.append(segment)
# Returns the distance from `agent_current_position` to the next waypoint.
func calculate_distance(agent_current_position: Vector3) -> float:
if _segments.size() == 0:
return 0.0
var smallest_distance_squared: float = INF
... | null |
Erstelle eine GDScript-Funktion namens '_process': | func _process(_delta: float) -> bool:
# check if reports exists
if not reports_available():
prints("no reports found")
return true
# only process if godot logging is enabled
if not GdUnitSettings.is_log_enabled():
write_report(NO_LOG_MESSAGE, "")
return true
# parse possible custom report path,
var cmd_... | extracted_function | |
Vervollständige den GDScript-Code: | extends Node2D
const Simple := preload("res://demo/agents/01_agent_melee_simple.tscn")
const Charger := preload("res://demo/agents/02_agent_charger.tscn")
const Imp := preload("res://demo/agents/03_agent_imp.tscn")
const Skirmisher := preload("res://demo/agents/04_agent_skirmisher.tscn")
const Ranged := preload("res:/... | @onready var gong: StaticBody2D = $Gong
@onready var player: CharacterBody2D = $Player
@onready var spawn_points: Node2D = $SpawnPoints
@onready var hp_bar: TextureProgressBar = %HPBar
@onready var round_counter: Label = %RoundCounter
func _ready() -> void:
hp_bar.max_value = player.get_health().max_health
player.ge... | null |
Vervollständige den GDScript-Code: | extends Node3D
@export_enum("Left", "Right") var hand : int = 0
@export var fallback_mesh : Node3D
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
var text = ""
if hand == 0:
text += "Left hand\n"
else:
text += "Right hand\n"
var controller_tracker : XRPosi... | text +=" - Using palm pose\n"
else:
pose = controller_tracker.get_pose(&"grip")
if pose:
text +=" - Using grip pose\n"
if pose:
if pose.tracking_confidence == XRPose.XR_TRACKING_CONFIDENCE_NONE:
text += "- No tracking data\n"
elif pose.tracking_confidence == XRPose.XR_TRACKING_CONFIDENCE_LOW... | null |
Vervollständige den GDScript-Code: | @tool
# An interaction that opens and closes an animated chest and adds an item to the player's inventory.
# The item is only added the first time the player opens the chest.
extends Interaction
@export var anim: AnimationPlayer
@export var popup: InteractionPopup
var item_type: Inventory.ItemTypes
var amount: = 1
v... | var _item_received: = false:
set(value):
_item_received = value
if _item_received:
popup.hide_and_free()
# Open or close the chest, depending on whether it is closed or open.
# If this is the first time opening it, apply the items inside to the player's inventory.
func _execute() -> void:
if _is_open:
anim.... | null |
Vervollständige den GDScript-Code: | extends AudioStreamPlayer
@export var conductor: Conductor
var _playing: bool = false
var _last_beat: float = -17 # 16 beat count-in
var _cached_latency: float = AudioServer.get_output_latency()
|
func _process(_delta: float) -> void:
if not _playing:
return
# Note that this implementation is flawed since every tick is rounded to the
# next mix window (~11ms at the default 44100 Hz mix rate) due to Godot's
# audio mix buffer. Precise audio scheduling is requested in
# https://github.com/godotengine/godo... | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.