mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-26 22:50:26 +01:00
Festival Sect is back in 2022! (#64731)
Adds the "Festival Sect" to chaplains, focusing on healing and religious acts through music.
This commit is contained in:
@@ -32,8 +32,8 @@
|
||||
/obj/item/instrument/piano_synth/headphones/ComponentInitialize()
|
||||
. = ..()
|
||||
AddElement(/datum/element/update_icon_updates_onmob)
|
||||
RegisterSignal(src, COMSIG_SONG_START, .proc/start_playing)
|
||||
RegisterSignal(src, COMSIG_SONG_END, .proc/stop_playing)
|
||||
RegisterSignal(src, COMSIG_INSTRUMENT_START, .proc/start_playing)
|
||||
RegisterSignal(src, COMSIG_INSTRUMENT_END, .proc/stop_playing)
|
||||
|
||||
/**
|
||||
* Called by a component signal when our song starts playing.
|
||||
@@ -120,15 +120,15 @@
|
||||
/obj/item/circuit_component/synth/register_shell(atom/movable/shell)
|
||||
. = ..()
|
||||
synth = shell
|
||||
RegisterSignal(synth, COMSIG_SONG_START, .proc/on_song_start)
|
||||
RegisterSignal(synth, COMSIG_SONG_END, .proc/on_song_end)
|
||||
RegisterSignal(synth, COMSIG_SONG_SHOULD_STOP_PLAYING, .proc/continue_if_autoplaying)
|
||||
RegisterSignal(synth, COMSIG_INSTRUMENT_START, .proc/on_song_start)
|
||||
RegisterSignal(synth, COMSIG_INSTRUMENT_END, .proc/on_song_end)
|
||||
RegisterSignal(synth, COMSIG_INSTRUMENT_SHOULD_STOP_PLAYING, .proc/continue_if_autoplaying)
|
||||
|
||||
/obj/item/circuit_component/synth/unregister_shell(atom/movable/shell)
|
||||
if(synth.song.music_player == src)
|
||||
synth.song.stop_playing()
|
||||
synth = null
|
||||
UnregisterSignal(synth, list(COMSIG_SONG_START, COMSIG_SONG_END, COMSIG_SONG_SHOULD_STOP_PLAYING))
|
||||
UnregisterSignal(synth, list(COMSIG_INSTRUMENT_START, COMSIG_INSTRUMENT_END, COMSIG_INSTRUMENT_SHOULD_STOP_PLAYING))
|
||||
return ..()
|
||||
|
||||
/obj/item/circuit_component/synth/proc/start_playing(datum/port/input/port)
|
||||
|
||||
@@ -126,7 +126,7 @@
|
||||
/datum/song/New(atom/parent, list/instrument_ids, new_range)
|
||||
SSinstruments.on_song_new(src)
|
||||
lines = list()
|
||||
tempo = sanitize_tempo(tempo)
|
||||
tempo = sanitize_tempo(tempo, TRUE)
|
||||
src.parent = parent
|
||||
if(instrument_ids)
|
||||
allowed_instrument_ids = islist(instrument_ids)? instrument_ids : list(instrument_ids)
|
||||
@@ -211,7 +211,8 @@
|
||||
//we can not afford to runtime, since we are going to be doing sound channel reservations and if we runtime it means we have a channel allocation leak.
|
||||
//wrap the rest of the stuff to ensure stop_playing() is called.
|
||||
do_hearcheck()
|
||||
SEND_SIGNAL(parent, COMSIG_SONG_START)
|
||||
SEND_SIGNAL(parent, COMSIG_INSTRUMENT_START, src)
|
||||
SEND_SIGNAL(user, COMSIG_ATOM_STARTING_INSTRUMENT, src)
|
||||
elapsed_delay = 0
|
||||
delay_by = 0
|
||||
current_chord = 1
|
||||
@@ -222,15 +223,18 @@
|
||||
|
||||
/**
|
||||
* Stops playing, terminating all sounds if in synthesized mode. Clears hearing_mobs.
|
||||
*
|
||||
* Arguments:
|
||||
* * finished: boolean, whether the song ended via reaching the end.
|
||||
*/
|
||||
/datum/song/proc/stop_playing()
|
||||
/datum/song/proc/stop_playing(finished = FALSE)
|
||||
if(!playing)
|
||||
return
|
||||
playing = FALSE
|
||||
if(!debug_mode)
|
||||
compiled_chords = null
|
||||
STOP_PROCESSING(SSinstruments, src)
|
||||
SEND_SIGNAL(parent, COMSIG_SONG_END)
|
||||
SEND_SIGNAL(parent, COMSIG_INSTRUMENT_END, finished)
|
||||
terminate_all_sounds(TRUE)
|
||||
hearing_mobs.len = 0
|
||||
music_player = null
|
||||
@@ -239,23 +243,27 @@
|
||||
* Processes our song.
|
||||
*/
|
||||
/datum/song/proc/process_song(wait)
|
||||
if(!length(compiled_chords) || should_stop_playing(music_player) == STOP_PLAYING)
|
||||
stop_playing()
|
||||
if(!length(compiled_chords))
|
||||
stop_playing(TRUE)
|
||||
return
|
||||
if(should_stop_playing(music_player) == STOP_PLAYING)
|
||||
stop_playing(FALSE)
|
||||
return
|
||||
var/list/chord = compiled_chords[current_chord]
|
||||
if(++elapsed_delay >= delay_by)
|
||||
play_chord(chord)
|
||||
elapsed_delay = 0
|
||||
delay_by = tempodiv_to_delay(chord[length(chord)])
|
||||
current_chord++
|
||||
if(current_chord > length(compiled_chords))
|
||||
if(repeat)
|
||||
repeat--
|
||||
current_chord = 1
|
||||
return
|
||||
else
|
||||
stop_playing()
|
||||
return
|
||||
if(++elapsed_delay < delay_by)
|
||||
return
|
||||
play_chord(chord)
|
||||
elapsed_delay = 0
|
||||
delay_by = tempodiv_to_delay(chord[length(chord)])
|
||||
current_chord++
|
||||
if(current_chord <= length(compiled_chords))
|
||||
return
|
||||
if(!repeat)
|
||||
stop_playing(TRUE)
|
||||
return
|
||||
repeat--
|
||||
current_chord = 1
|
||||
SEND_SIGNAL(parent, COMSIG_INSTRUMENT_REPEAT, TRUE)
|
||||
|
||||
/**
|
||||
* Converts a tempodiv to ticks to elapse before playing the next chord, taking into account our tempo.
|
||||
@@ -285,7 +293,7 @@
|
||||
/datum/song/proc/should_stop_playing(atom/player)
|
||||
if(QDELETED(player) || !using_instrument || !playing)
|
||||
return STOP_PLAYING
|
||||
return SEND_SIGNAL(parent, COMSIG_SONG_SHOULD_STOP_PLAYING, player)
|
||||
return SEND_SIGNAL(parent, COMSIG_INSTRUMENT_SHOULD_STOP_PLAYING, player)
|
||||
|
||||
/// Sets and sanitizes the repeats variable.
|
||||
/datum/song/proc/set_repeats(new_repeats_value)
|
||||
@@ -301,8 +309,10 @@
|
||||
/**
|
||||
* Sanitizes tempo to a value that makes sense and fits the current world.tick_lag.
|
||||
*/
|
||||
/datum/song/proc/sanitize_tempo(new_tempo)
|
||||
/datum/song/proc/sanitize_tempo(new_tempo, initializing = FALSE)
|
||||
new_tempo = abs(new_tempo)
|
||||
if(!initializing) // not only is it not helpful while initializing but it will runtime really hard since nothing is set up
|
||||
SEND_SIGNAL(parent, COMSIG_INSTRUMENT_TEMPO_CHANGE, src)
|
||||
return clamp(round(new_tempo, world.tick_lag), world.tick_lag, 5 SECONDS)
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user