This commit is contained in:
sharpoff
2026-01-14 13:01:37 +09:00
commit 49d7e22132
660 changed files with 41243 additions and 0 deletions

View File

@@ -0,0 +1,53 @@
@tool
@icon("res://addons/godot-xr-tools/editor/icons/audio.svg")
class_name XRToolsAreaAudio
extends AudioStreamPlayer3D
## XRTools Area Audio
##
## This node is attached as a child of a Area3D,
## since all the interactables are actualy Extensions of the Area3D,
## this node will work on those as well
## XRToolsAreaAudioType to associate with this Area Audio
@export var area_audio_type : XRToolsAreaAudioType
@onready var area : Area3D = get_parent()
# Add support for is_class on XRTools classes
func is_xr_class(xr_name: String) -> bool:
return xr_name == "XRToolsAreaAudio"
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
# Listen for enter
area.body_entered.connect(_on_body_entered)
# Listen for exit
area.body_exited.connect(_on_body_exited)
func _on_body_entered(_body):
if playing:
stop()
stream = area_audio_type.touch_sound
play()
func _on_body_exited(_body):
if playing:
stop()
# This method checks for configuration issues.
func _get_configuration_warnings() -> PackedStringArray:
var warnings := PackedStringArray()
if !area_audio_type:
warnings.append("Area audio type not specified")
# Return warnings
return warnings

View File

@@ -0,0 +1 @@
uid://bmqrm3opvrbgq

View File

@@ -0,0 +1,8 @@
[gd_scene load_steps=2 format=3 uid="uid://duqehif60vcjg"]
[ext_resource type="Script" uid="uid://bmqrm3opvrbgq" path="res://addons/godot-xr-tools/audio/area_audio.gd" id="1_q1jr0"]
[node name="AreaAudio" type="AudioStreamPlayer3D"]
unit_size = 3.0
max_distance = 100.0
script = ExtResource("1_q1jr0")

View File

@@ -0,0 +1,28 @@
@tool
@icon("res://addons/godot-xr-tools/editor/icons/audio.svg")
class_name XRToolsAreaAudioType
extends Resource
## XRTools Area Audio Type Resource
##
## This resource defines the audio stream to play when
## a objects enters it
## Surface name
@export var name : String = ""
## Optional audio stream to play when the player lands on this surface
@export var touch_sound : AudioStream
# This method checks for configuration issues.
func _get_configuration_warnings() -> PackedStringArray:
var warnings := PackedStringArray()
if name == "":
warnings.append("Area audio type must have a name")
# Return warnings
return warnings

View File

@@ -0,0 +1 @@
uid://bg0vquffh1cr4

View File

@@ -0,0 +1,79 @@
@tool
@icon("res://addons/godot-xr-tools/editor/icons/audio.svg")
class_name XRToolsPickableAudio
extends AudioStreamPlayer3D
## XRTools Pickable Audio
##
## This node is attached as a child of a Pickable,
## it plays audio for drop and hit based on velocity,
## along with a audio for when the object is being picked up.
## XRToolsPickableAudioType to associate with this pickable
@export var pickable_audio_type : XRToolsPickableAudioType
## delta throttle is 1/10 of delta
@onready var delta_throttle : float = 0.1
@onready var _pickable : XRToolsPickable = get_parent()
# Add support for is_class on XRTools classes
func is_xr_class(xr_name: String) -> bool:
return xr_name == "XRToolsPickableAudio"
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
# Listen for when this object enters a body
_pickable.body_entered.connect(_on_body_entered)
# Listen for when this object is picked up or dropped
_pickable.picked_up.connect(_on_picked_up)
_pickable.dropped.connect(_on_dropped)
func _physics_process(_delta):
if !_pickable.sleeping:
if _pickable.linear_velocity.length() > 5:
volume_db = 0
else:
volume_db -= _pickable.linear_velocity.length() * delta_throttle
# Called when this object is picked up
func _on_picked_up(_pickable) -> void:
volume_db = 0
if playing:
stop()
stream = pickable_audio_type.grab_sound
play()
# Called when this object is dropped
func _on_dropped(_pickable) -> void:
for body in _pickable.get_colliding_bodies():
if playing:
stop()
func _on_body_entered(_body):
if playing:
stop()
if _pickable.is_picked_up():
stream = pickable_audio_type.hit_sound
else:
stream = pickable_audio_type.drop_sound
play()
# This method checks for configuration issues.
func _get_configuration_warnings() -> PackedStringArray:
var warnings := PackedStringArray()
if !pickable_audio_type:
warnings.append("Pickable audio type not specified")
# Return warnings
return warnings

View File

@@ -0,0 +1 @@
uid://cl6ayr6145cwi

View File

@@ -0,0 +1,9 @@
[gd_scene load_steps=2 format=3 uid="uid://bikkxsbo8x7sd"]
[ext_resource type="Script" uid="uid://cl6ayr6145cwi" path="res://addons/godot-xr-tools/audio/pickable_audio.gd" id="1_cfg1k"]
[node name="PickableAudio" type="AudioStreamPlayer3D"]
unit_size = 3.0
max_db = 1.0
max_distance = 100.0
script = ExtResource("1_cfg1k")

View File

@@ -0,0 +1,34 @@
@tool
@icon("res://addons/godot-xr-tools/editor/icons/audio.svg")
class_name XRToolsPickableAudioType
extends Resource
## XRTools Pickable Audio Type Resource
##
## This resource defines the audio streams to play when
## the pickable is being picked up/ dropped/ hit something while being held
## Surface name
@export var name : String = ""
## Optional audio stream to play when the player picks up the pickable
@export var grab_sound : AudioStream
## Optional audio stream to play when the player drops the pickable
@export var drop_sound : AudioStream
## Optional audio stream to play when the item is beign held by the player
@export var hit_sound : AudioStream
# This method checks for configuration issues.
func _get_configuration_warnings() -> PackedStringArray:
var warnings := PackedStringArray()
if name == "":
warnings.append("Pickable audio type must have a name")
# Return warnings
return warnings

View File

@@ -0,0 +1 @@
uid://dcdtk842mf1h5

View File

@@ -0,0 +1,32 @@
@tool
@icon("res://addons/godot-xr-tools/editor/icons/foot.svg")
class_name XRToolsSurfaceAudio
extends Node
## XRTools Surface Audio Node
##
## This node is attached as a child of a StaticObject to give it a surface
## audio type. This will cause the XRToolsMovementFootStep to play the correct
## foot-step sounds when walking on the object.
## XRToolsSurfaceAudioType to associate with this surface
@export var surface_audio_type : XRToolsSurfaceAudioType
# Add support for is_class on XRTools classes
func is_xr_class(xr_name: String) -> bool:
return xr_name == "XRToolsSurfaceAudio"
# This method checks for configuration issues.
func _get_configuration_warnings() -> PackedStringArray:
var warnings := PackedStringArray()
# Verify the camera
if !surface_audio_type:
warnings.append("Surface audio type not specified")
# Return warnings
return warnings

View File

@@ -0,0 +1 @@
uid://mc4dmfy38nqa

View File

@@ -0,0 +1,6 @@
[gd_scene load_steps=2 format=3 uid="uid://c8jtmtuihfujs"]
[ext_resource type="Script" uid="uid://mc4dmfy38nqa" path="res://addons/godot-xr-tools/audio/surface_audio.gd" id="1"]
[node name="SurfaceAudio" type="Node"]
script = ExtResource("1")

View File

@@ -0,0 +1,41 @@
@tool
@icon("res://addons/godot-xr-tools/editor/icons/body.svg")
class_name XRToolsSurfaceAudioType
extends Resource
## XRTools Surface Type Resource
##
## This resource defines a type of surface, and the audio streams to play when
## the user steps on it
## Surface name
@export var name : String = ""
## Optional audio stream to play when the player jumps on this surface
@export var jump_sound : AudioStream
## Optional audio stream to play when the player lands on this surface
@export var hit_sound : AudioStream
## Audio streams to play when the player walks on this surface
@export var walk_sounds :Array[AudioStream] = []
## Walking sound minimum pitch (to randomize steps)
@export_range(0.5, 1.0) var walk_pitch_minimum : float = 0.8
## Walking sound maximum pitch (to randomize steps)
@export_range(1.0, 2.0) var walk_pitch_maximum : float = 1.2
# This method checks for configuration issues.
func _get_configuration_warnings() -> PackedStringArray:
var warnings := PackedStringArray()
# Verify the camera
if name == "":
warnings.append("Surface audio type must have a name")
# Return warnings
return warnings

View File

@@ -0,0 +1 @@
uid://bsk5funnj0084