83 lines
1.9 KiB
GDScript3
83 lines
1.9 KiB
GDScript3
|
|
@tool
|
||
|
|
class_name MixedAudioHelper extends AudioStreamPlayer
|
||
|
|
|
||
|
|
enum TriggerPoint {
|
||
|
|
IMMEDIATE,
|
||
|
|
INTRO_END,
|
||
|
|
LOOP_IN,
|
||
|
|
LOOP_OUT,
|
||
|
|
OUTRO
|
||
|
|
}
|
||
|
|
|
||
|
|
#FIXME: I should consider adding a neutral scene to the ids enum for each room. Maybe we can work something out based on the currently selected room here, but as it stands now it is impossible to select the main theme other than intentionally selecting something unintended.
|
||
|
|
@export var play_next: Scenes.id:
|
||
|
|
set(next):
|
||
|
|
if next == 0:
|
||
|
|
play_next = 0
|
||
|
|
return
|
||
|
|
play_next = next
|
||
|
|
|
||
|
|
func get_playback_id_from_scene(scene: int) -> int:
|
||
|
|
match scene:
|
||
|
|
Scenes.id.ADULT_DND: return 1
|
||
|
|
Scenes.id.ADULD_VOLUNTARY: return 2
|
||
|
|
Scenes.id.ADULD_CHRISTMAS: return 3
|
||
|
|
Scenes.id.ADULT_EATING: return 4
|
||
|
|
Scenes.id.ADULT_UNI: return 5
|
||
|
|
Scenes.id.ADULT_THERAPY: return 6
|
||
|
|
Scenes.id.ADULT_BURNOUT: return 7
|
||
|
|
_: return 0
|
||
|
|
|
||
|
|
@export var actually_playing: bool = false:
|
||
|
|
set(play):
|
||
|
|
actually_playing = play
|
||
|
|
if actually_playing:
|
||
|
|
self.play()
|
||
|
|
else:
|
||
|
|
stop()
|
||
|
|
@export var actual_stream: MixedAudioStream
|
||
|
|
|
||
|
|
var _playback: AudioStreamPlaybackPolyphonic
|
||
|
|
var main_stream_id: int = -1:
|
||
|
|
set(stream_id):
|
||
|
|
main_stream_id = stream_id
|
||
|
|
if main_stream_id == -1:
|
||
|
|
stop()
|
||
|
|
else:
|
||
|
|
main_stream_playback_id = _playback.play_stream(actual_stream.get_stream_by_id(main_stream_id))
|
||
|
|
var main_stream_playback_id:int = -1
|
||
|
|
var transition_stream_id: int
|
||
|
|
var transition_stream_playback_id:int = -1
|
||
|
|
var next_stream_id: int
|
||
|
|
var next_stream_playback_id:int = -1
|
||
|
|
|
||
|
|
|
||
|
|
func _ready() -> void:
|
||
|
|
stream = AudioStreamPolyphonic.new()
|
||
|
|
|
||
|
|
func play(from_position: float = 0.0):
|
||
|
|
print("got called")
|
||
|
|
super.play(from_position)
|
||
|
|
self._play(from_position)
|
||
|
|
|
||
|
|
func queue_trigger(stream_id: int, point: TriggerPoint, trigger: Callable):
|
||
|
|
pass
|
||
|
|
|
||
|
|
func loop_back():
|
||
|
|
pass
|
||
|
|
|
||
|
|
func transition_trigger():
|
||
|
|
pass
|
||
|
|
|
||
|
|
func transition_start():
|
||
|
|
pass
|
||
|
|
|
||
|
|
func transition_end():
|
||
|
|
#make new
|
||
|
|
pass
|
||
|
|
|
||
|
|
func _play(from_position: float = 0.0):
|
||
|
|
_playback = get_stream_playback()
|
||
|
|
|
||
|
|
main_stream_id = get_playback_id_from_scene(play_next)
|