2022-12-27 20:06:15 -07:00
|
|
|
extends AudioStreamPlayer
|
|
|
|
|
2022-12-28 16:53:17 -07:00
|
|
|
export var base_volume: float = -15.0
|
2022-12-27 20:06:15 -07:00
|
|
|
export var base_pitch: float = 1.0
|
2022-12-28 16:53:17 -07:00
|
|
|
export var submerged_volume: float = 5.0
|
2022-12-27 20:06:15 -07:00
|
|
|
export var submerged_pitch: float = 0.75
|
2022-12-28 16:53:17 -07:00
|
|
|
export var pit_volume: float = 2
|
2022-12-27 20:06:15 -07:00
|
|
|
export var pit_pitch: float = 0.25
|
|
|
|
|
|
|
|
func _ready():
|
|
|
|
var _ignore = GlobalEventBus.connect("player_entered_meat_sink", self, "enter_water")
|
|
|
|
_ignore = GlobalEventBus.connect("player_exited_meat_sink", self, "exit_water")
|
|
|
|
volume_db = base_volume
|
|
|
|
|
|
|
|
var water = 0
|
|
|
|
|
|
|
|
func enter_water():
|
|
|
|
water += 1
|
|
|
|
|
|
|
|
func exit_water():
|
|
|
|
water -= 1
|
|
|
|
|
|
|
|
func _process(delta):
|
|
|
|
var target_volume = base_volume
|
|
|
|
var target_pitch = base_pitch
|
|
|
|
if water:
|
|
|
|
target_volume = submerged_volume
|
|
|
|
target_pitch = submerged_pitch
|
|
|
|
if Util.player.camera_position().y <= -18:
|
|
|
|
target_volume = pit_volume
|
|
|
|
target_pitch = pit_pitch
|
|
|
|
volume_db = Util.clamped_lerp(volume_db, target_volume, delta*5, 0.01)
|
|
|
|
pitch_scale = Util.clamped_lerp(pitch_scale, target_pitch, delta*5, 0.01)
|
|
|
|
|