Global Sounds system

This commit is contained in:
Haze Weathers 2025-03-08 16:32:47 -05:00
parent 5677971bf0
commit ba3306c04c
15 changed files with 232 additions and 1 deletions

View file

@ -0,0 +1,18 @@
@tool
extends Node
@export_tool_button("Update Sounds") var _update_sounds_action = _update_sounds
@export var sounds: Dictionary[StringName, AudioStreamPlayer]
func play_sound(id: StringName) -> void:
var sound := sounds.get(id) as AudioStreamPlayer
sound.play()
func _update_sounds() -> void:
sounds.clear()
for node in get_children():
if node is AudioStreamPlayer:
sounds[node.name] = node
notify_property_list_changed()

View file

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

View file

@ -0,0 +1,23 @@
[gd_scene load_steps=4 format=3 uid="uid://cof2sm0drv2i"]
[ext_resource type="Script" uid="uid://c1yco1xiqppw" path="res://autoloads/global_sounds.gd" id="1_22s5s"]
[ext_resource type="AudioStream" uid="uid://sci5aqar0oyx" path="res://assets/audio/bgs/amb_sog.wav" id="2_3njyb"]
[ext_resource type="AudioStream" uid="uid://flc817bekeh6" path="res://assets/audio/sfx/level_win.ogg" id="3_pqonv"]
[node name="GlobalSounds" type="Node" node_paths=PackedStringArray("sounds")]
script = ExtResource("1_22s5s")
sounds = {
&"SoggyAmbience": NodePath("SoggyAmbience"),
&"WinSound": NodePath("WinSound")
}
[node name="SoggyAmbience" type="AudioStreamPlayer" parent="."]
stream = ExtResource("2_3njyb")
volume_db = -10.0
autoplay = true
bus = &"Background Sound"
[node name="WinSound" type="AudioStreamPlayer" parent="."]
stream = ExtResource("3_pqonv")
volume_db = -6.558
bus = &"Sound Effects"