feat(audio): add built-in sound effects (bell, coin, chime, etc.), inspector sound presets, and preview player
checkpoint / checkpoint (push) Failing after 6m3s
checkpoint / checkpoint (push) Failing after 6m3s
This commit is contained in:
@@ -396,6 +396,7 @@ func _act_give_item(action: Dictionary, player: Node) -> void:
|
||||
_show_give_feedback(item_id, count)
|
||||
if item_id.to_lower() in ["buffalo_chips", "chips", "credits"]:
|
||||
_deposit_to_wallet(count)
|
||||
_act_play_sound({"sound_id": "coin"}, player)
|
||||
|
||||
|
||||
func _show_give_feedback(item_id: String, count: int) -> void:
|
||||
@@ -441,19 +442,26 @@ func _deposit_to_wallet(count: int) -> void:
|
||||
|
||||
|
||||
|
||||
## Trusted, code-defined mapping from sound_id -> resource path. Rule data
|
||||
## supplies only the key; this table (not the data) decides what actually
|
||||
## plays.
|
||||
const _TRUSTED_SOUND_TABLE: Dictionary = {
|
||||
"bell": "res://assets/audio/bell.wav",
|
||||
"coin": "res://assets/audio/coin.wav",
|
||||
"click": "res://assets/audio/click.wav",
|
||||
"chime": "res://assets/audio/chime.wav",
|
||||
"fanfare": "res://assets/audio/fanfare.wav",
|
||||
"door_open": "res://assets/audio/door_open.wav",
|
||||
}
|
||||
|
||||
|
||||
func _act_play_sound(action: Dictionary, _player: Node) -> void:
|
||||
# No real audio asset catalog exists in this repo yet. The verb still
|
||||
# runs through a real, trusted playback path -- attempting to resolve
|
||||
# and play a stream when one is registered -- so it's not a no-op
|
||||
# pretending to be a verb; it's just that today's trusted sound table
|
||||
# is empty. `sound_id` is only ever used as a key into that trusted,
|
||||
# code-defined table below, never as a path handed to load() directly.
|
||||
var sound_id: String = action.get("sound_id", "")
|
||||
var sound_id: String = str(action.get("sound_id", "")).to_lower().strip_edges().trim_suffix(".wav")
|
||||
var stream_path: String = _TRUSTED_SOUND_TABLE.get(sound_id, "")
|
||||
if not stream_path.is_empty() and ResourceLoader.exists(stream_path):
|
||||
var stream: Resource = load(stream_path)
|
||||
if stream is AudioStream:
|
||||
var player_node := AudioStreamPlayer3D.new()
|
||||
var player_node := AudioStreamPlayer.new()
|
||||
player_node.stream = stream
|
||||
add_child(player_node)
|
||||
player_node.finished.connect(player_node.queue_free)
|
||||
@@ -461,12 +469,6 @@ func _act_play_sound(action: Dictionary, _player: Node) -> void:
|
||||
verb_executed.emit("play_sound", action)
|
||||
|
||||
|
||||
## Trusted, code-defined mapping from sound_id -> resource path. Rule data
|
||||
## supplies only the key; this table (not the data) decides what actually
|
||||
## plays. Empty for now -- no sound assets exist in this repo yet.
|
||||
const _TRUSTED_SOUND_TABLE: Dictionary = {}
|
||||
|
||||
|
||||
func _act_move(action: Dictionary, player: Node) -> void:
|
||||
var target_node := _resolve_target(action.get("target", "self"), player)
|
||||
if target_node == null:
|
||||
|
||||
Reference in New Issue
Block a user