Showers clean contamination and make sound (#31773)

* fucking showers

* cleanup
This commit is contained in:
Emmett Gaines
2017-10-19 04:28:21 -04:00
committed by CitadelStationBot
parent 02fcc06eb1
commit ee3d18fe58
9 changed files with 120 additions and 0 deletions
@@ -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)
@@ -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
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -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)
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+2
View File
@@ -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"