Audio: mood music, ambience, sound effects and creature voices (Kenney CC0 + synthesised); protocol 13
This commit is contained in:
@@ -17,6 +17,7 @@ var _noise := FastNoiseLite.new()
|
||||
var _lit := true
|
||||
var _roofed_cache := -1.0 ## -1 unknown, 0 open sky, 1 under a roof
|
||||
var _roof_timer := 0.0
|
||||
var _crackle: AudioStreamPlayer3D
|
||||
|
||||
func _build() -> void:
|
||||
add_to_group("station:campfire")
|
||||
@@ -38,6 +39,19 @@ func _build() -> void:
|
||||
[0.0, Color(1.0, 0.75, 0.35, 1.0)], [1.0, Color(1.0, 0.3, 0.05, 0.0)]]), true, 0.04, 0.15))
|
||||
for p in _fx:
|
||||
add_child(p)
|
||||
# The crackle, close to it (sfx.gd's buses; not on a headless server).
|
||||
if DisplayServer.get_name() != "headless":
|
||||
_crackle = AudioStreamPlayer3D.new()
|
||||
var st: Variant = load("res://assets/audio/ambience/fire.ogg")
|
||||
if st is AudioStreamOggVorbis:
|
||||
(st as AudioStreamOggVorbis).loop = true
|
||||
_crackle.stream = st
|
||||
_crackle.bus = "Ambience"
|
||||
_crackle.unit_size = 2.0
|
||||
_crackle.max_distance = 16.0
|
||||
_crackle.volume_db = -4.0
|
||||
_crackle.position = Vector3(0, 0.3, 0)
|
||||
add_child(_crackle)
|
||||
# TODO: smoke. Alpha-blended unshaded particles rendered as an opaque dark
|
||||
# ball whatever their ramp colour (additive flames are fine). Needs a small
|
||||
# particle shader.
|
||||
@@ -118,6 +132,12 @@ func _set_lit(on: bool) -> void:
|
||||
_light.visible = on
|
||||
for p in _fx:
|
||||
p.emitting = on
|
||||
if _crackle != null:
|
||||
_crackle.autoplay = on # (lit before it's in the tree: it starts when it's added)
|
||||
if on and not _crackle.playing and _crackle.is_inside_tree():
|
||||
_crackle.play(randf() * 5.0)
|
||||
elif not on:
|
||||
_crackle.stop()
|
||||
|
||||
func save_extra() -> Dictionary:
|
||||
return {"fuel": fuel}
|
||||
|
||||
Reference in New Issue
Block a user