Global Sounds system
This commit is contained in:
parent
5677971bf0
commit
ba3306c04c
15 changed files with 232 additions and 1 deletions
18
autoloads/global_sounds.gd
Normal file
18
autoloads/global_sounds.gd
Normal 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()
|
1
autoloads/global_sounds.gd.uid
Normal file
1
autoloads/global_sounds.gd.uid
Normal file
|
@ -0,0 +1 @@
|
|||
uid://c1yco1xiqppw
|
23
autoloads/global_sounds.tscn
Normal file
23
autoloads/global_sounds.tscn
Normal 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"
|
Loading…
Add table
Add a link
Reference in a new issue