diff --git a/code/datums/looping_sounds/looping_sound.dm b/code/datums/looping_sounds/looping_sound.dm new file mode 100644 index 0000000000..2374da67b4 --- /dev/null +++ b/code/datums/looping_sounds/looping_sound.dm @@ -0,0 +1,89 @@ +/* + list/atom/output_atoms + + mid_sounds (list or soundfile) Since this can be either a list or a single soundfile you can have random sounds. May contain further lists but must contain a soundfile at the end. + mid_length (num) The length to wait between playing mid_sounds + + start_sound (soundfile) Played before starting the mid_sounds loop + start_length (num) How long to wait before starting the main loop after playing start_sound + + end_sound (soundfile) The sound played after the main loop has concluded + + chance (num) Chance per loop to play a mid_sound + volume (num) Sound output volume + muted (bool) Private. Used to stop the sound loop. + max_loops (num) The max amount of loops to run for. +*/ +/datum/looping_sound + var/list/atom/output_atoms + var/mid_sounds + var/mid_length + var/start_sound + var/start_length + var/end_sound + var/chance + var/volume + var/muted = TRUE + var/max_loops + +/datum/looping_sound/New(list/_output_atoms, start_immediately=FALSE) + if(!mid_sounds) + WARNING("A looping sound datum was created without sounds to play.") + return + + if(_output_atoms) + output_atoms = _output_atoms + else + output_atoms = list() + + if(start_immediately) + start() + +/datum/looping_sound/Destroy() + stop() + output_atoms = null + return ..() + +/datum/looping_sound/proc/start() + if(!muted) + return + muted = FALSE + on_start() + +/datum/looping_sound/proc/stop() + if(muted) + return + muted = TRUE + +/datum/looping_sound/proc/sound_loop(looped=0) + if(muted || (max_loops && looped > max_loops)) + on_stop(looped) + return + if(!chance || prob(chance)) + play(get_sound(looped)) + addtimer(CALLBACK(src, .proc/sound_loop, ++looped), mid_length) + +/datum/looping_sound/proc/play(soundfile) + var/list/atoms_cache = output_atoms + for(var/i in 1 to atoms_cache.len) + var/atom/thing = atoms_cache[i] + playsound(thing, soundfile, volume) + +/datum/looping_sound/proc/get_sound(looped, _mid_sounds) + if(!_mid_sounds) + . = mid_sounds + else + . = _mid_sounds + while(!isfile(.) && !isnull(.)) + . = pickweight(.) + +/datum/looping_sound/proc/on_start() + var/start_wait = 0 + if(start_sound) + play(start_sound) + start_wait = start_length + addtimer(CALLBACK(src, .proc/sound_loop), start_wait) + +/datum/looping_sound/proc/on_stop(looped) + if(end_sound) + play(end_sound) \ No newline at end of file diff --git a/code/datums/looping_sounds/machinery_sounds.dm b/code/datums/looping_sounds/machinery_sounds.dm new file mode 100644 index 0000000000..88b2b06878 --- /dev/null +++ b/code/datums/looping_sounds/machinery_sounds.dm @@ -0,0 +1,9 @@ +/datum/looping_sound/showering + start_sound = 'sound/machines/shower/shower_start.ogg' + start_length = 2 + mid_sounds = list('sound/machines/shower/shower_mid1.ogg'=1,'sound/machines/shower/shower_mid2.ogg'=1,'sound/machines/shower/shower_mid3.ogg'=1) + mid_length = 10 + end_sound = 'sound/machines/shower/shower_end.ogg' + volume = 25 + +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// \ No newline at end of file diff --git a/code/game/objects/structures/watercloset.dm b/code/game/objects/structures/watercloset.dm index 18d8b8f7f0..e22d75f9aa 100644 --- a/code/game/objects/structures/watercloset.dm +++ b/code/game/objects/structures/watercloset.dm @@ -199,7 +199,15 @@ var/obj/effect/mist/mymist = null var/ismist = 0 //needs a var so we can make it linger~ var/watertemp = "normal" //freezing, normal, or boiling + var/datum/looping_sound/showering/soundloop +/obj/machinery/shower/Initialize() + . = ..() + soundloop = new(list(src), FALSE) + +/obj/machinery/shower/Destroy() + QDEL_NULL(soundloop) + return ..() /obj/effect/mist name = "mist" @@ -215,6 +223,7 @@ update_icon() add_fingerprint(M) if(on) + soundloop.start() wash_turf() for(var/atom/movable/G in loc) if(isliving(G)) @@ -223,6 +232,7 @@ else if(isobj(G)) // Skip the light objects wash_obj(G) else + soundloop.stop() if(isopenturf(loc)) var/turf/open/tile = loc tile.MakeSlippery(min_wet_time = 5, wet_time_to_add = 1) @@ -368,6 +378,15 @@ else L.clean_blood() +/obj/machinery/shower/proc/contamination_cleanse(atom/movable/thing) + var/datum/component/radioactive/healthy_green_glow = thing.GetComponent(/datum/component/radioactive) + if(!healthy_green_glow || QDELETED(healthy_green_glow)) + return + var/strength = healthy_green_glow.strength + if(strength <= RAD_BACKGROUND_RADIATION) + qdel(healthy_green_glow) + return + healthy_green_glow.strength = max(strength-1, 0) /obj/machinery/shower/process() if(on) @@ -377,6 +396,7 @@ wash_mob(AM) else if(isobj(AM)) wash_obj(AM) + contamination_cleanse(AM) /obj/machinery/shower/deconstruct(disassembled = TRUE) new /obj/item/stack/sheet/metal (loc, 3) diff --git a/sound/machines/shower/shower_end.ogg b/sound/machines/shower/shower_end.ogg new file mode 100644 index 0000000000..80b93af39e Binary files /dev/null and b/sound/machines/shower/shower_end.ogg differ diff --git a/sound/machines/shower/shower_mid1.ogg b/sound/machines/shower/shower_mid1.ogg new file mode 100644 index 0000000000..e1ae5a0c45 Binary files /dev/null and b/sound/machines/shower/shower_mid1.ogg differ diff --git a/sound/machines/shower/shower_mid2.ogg b/sound/machines/shower/shower_mid2.ogg new file mode 100644 index 0000000000..4a54acd352 Binary files /dev/null and b/sound/machines/shower/shower_mid2.ogg differ diff --git a/sound/machines/shower/shower_mid3.ogg b/sound/machines/shower/shower_mid3.ogg new file mode 100644 index 0000000000..8b4776a9b9 Binary files /dev/null and b/sound/machines/shower/shower_mid3.ogg differ diff --git a/sound/machines/shower/shower_start.ogg b/sound/machines/shower/shower_start.ogg new file mode 100644 index 0000000000..e5529f401b Binary files /dev/null and b/sound/machines/shower/shower_start.ogg differ diff --git a/tgstation.dme b/tgstation.dme index 903f4878c8..f551309a54 100755 --- a/tgstation.dme +++ b/tgstation.dme @@ -376,6 +376,8 @@ #include "code\datums\helper_datums\icon_snapshot.dm" #include "code\datums\helper_datums\teleport.dm" #include "code\datums\helper_datums\topic_input.dm" +#include "code\datums\looping_sounds\looping_sound.dm" +#include "code\datums\looping_sounds\machinery_sounds.dm" #include "code\datums\martial\boxing.dm" #include "code\datums\martial\cqc.dm" #include "code\datums\martial\krav_maga.dm"