40 lines
930 B
GDScript
40 lines
930 B
GDScript
extends Area3D
|
|
class_name Interactable3D
|
|
|
|
@export var interactable = true
|
|
|
|
signal clicked
|
|
|
|
@export var hover_animation_player : AnimationPlayer
|
|
@export var audio_player : AudioStreamPlayer3D
|
|
|
|
func click():
|
|
if interactable:
|
|
clicked.emit()
|
|
|
|
func _ready():
|
|
if audio_player:
|
|
var default_volume := audio_player.volume_db
|
|
audio_player.volume_db += GameInfo.settings_data.sfx_volume
|
|
GameInfo.settings_data.sound_changed.connect(
|
|
func(settings : SettingsData):
|
|
audio_player.volume_db = default_volume + settings.sfx_volume
|
|
)
|
|
|
|
|
|
func play_audio():
|
|
if audio_player:
|
|
audio_player.play()
|
|
|
|
func stop_audio():
|
|
if audio_player:
|
|
audio_player.stop()
|
|
|
|
func _on_mouse_entered():
|
|
if hover_animation_player:
|
|
hover_animation_player.play("hover")
|
|
|
|
func _on_mouse_exited():
|
|
if hover_animation_player:
|
|
hover_animation_player.stop()
|