Significantly reduce volume of disposals machinery when processing a ton of items (#21700)

* Reduce volume of recycler when consuming a ton of items

* Quiets up the rest of disposals machinery

* Defines, not magic numbers

* Apply suggestions from code review

Co-authored-by: Ryan <80364400+Sirryan2002@users.noreply.github.com>

---------

Co-authored-by: Ryan <80364400+Sirryan2002@users.noreply.github.com>
This commit is contained in:
Luc
2023-07-23 23:32:35 +01:00
committed by GitHub
co-authored by Ryan
parent df3b44e6ab
commit 83229034da
3 changed files with 36 additions and 8 deletions
+7 -1
View File
@@ -1,4 +1,5 @@
#define SAFETY_COOLDOWN 100
#define SOUND_COOLDOWN (0.5 SECONDS)
/obj/machinery/recycler
name = "recycler"
@@ -19,6 +20,8 @@
var/item_recycle_sound = 'sound/machines/recycler.ogg'
/// For admin fun, var edit always_gib to TRUE (1)
var/always_gib = FALSE
/// The last time we played a consumption sound.
var/last_consumption_sound
/obj/machinery/recycler/Initialize(mapload)
. = ..()
@@ -137,8 +140,9 @@
playsound(loc, 'sound/machines/buzz-sigh.ogg', 50, 0)
AM.forceMove(loc)
if(items_recycled && sound)
if(items_recycled && sound && (last_consumption_sound + SOUND_COOLDOWN) < world.time)
playsound(loc, item_recycle_sound, 100, 0)
last_consumption_sound = world.time
/obj/machinery/recycler/proc/recycle_item(obj/item/I)
I.forceMove(loc)
@@ -243,3 +247,5 @@
/obj/item/paper/recycler
name = "paper - 'garbage duty instructions'"
info = "<h2>New Assignment</h2> You have been assigned to collect garbage from trash bins, located around the station. The crewmembers will put their trash into it and you will collect the said trash.<br><br>There is a recycling machine near your closet, inside maintenance; use it to recycle the trash for a small chance to get useful minerals. Then deliver these minerals to cargo or engineering. You are our last hope for a clean station, do not screw this up!"
#undef SOUND_COOLDOWN
+26 -6
View File
@@ -6,6 +6,8 @@
// Can hold items and human size things, no other draggables
// Toilets are a type of disposal bin for small objects only and work on magic. By magic, I mean torque rotation
#define SEND_PRESSURE 0.05*ONE_ATMOSPHERE
/// How frequently disposals can make sounds, to prevent huge sound stacking
#define DISPOSAL_SOUND_COOLDOWN (0.1 SECONDS)
/obj/machinery/disposal
name = "disposal unit"
@@ -464,7 +466,7 @@
H.tomail = 1
sleep(10)
if(last_sound < world.time + 1)
if(last_sound + DISPOSAL_SOUND_COOLDOWN < world.time)
playsound(src, 'sound/machines/disposalflush.ogg', 50, 0, 0)
last_sound = world.time
sleep(5) // wait for animation to finish
@@ -499,7 +501,10 @@
/obj/machinery/disposal/proc/expel(obj/structure/disposalholder/H)
var/turf/target
playsound(src, 'sound/machines/hiss.ogg', 50, 0, 0)
if(last_sound + DISPOSAL_SOUND_COOLDOWN < world.time)
playsound(src, 'sound/machines/hiss.ogg', 50, 0, FALSE)
last_sound = world.time
if(H) // Somehow, someone managed to flush a window which broke mid-transit and caused the disposal to go in an infinite loop trying to expel null, hopefully this fixes it
for(var/atom/movable/AM in H)
target = get_offset_target_turf(src.loc, rand(5)-rand(5), rand(5)-rand(5))
@@ -733,6 +738,8 @@
plane = FLOOR_PLANE
layer = DISPOSAL_PIPE_LAYER // slightly lower than wires and other pipes
base_icon_state // initial icon state on map
/// The last time a sound was played from this
var/last_sound
// new pipe, set the icon_state as on map
/obj/structure/disposalpipe/Initialize(mapload)
@@ -841,7 +848,10 @@
else // otherwise limit to 10 tiles
target = get_ranged_target_turf(T, direction, 10)
playsound(src, 'sound/machines/hiss.ogg', 50, 0, 0)
if(last_sound + DISPOSAL_SOUND_COOLDOWN < world.time)
playsound(src, 'sound/machines/hiss.ogg', 50, 0, FALSE)
last_sound = world.time
if(H)
for(var/atom/movable/AM in H)
AM.forceMove(T)
@@ -856,7 +866,9 @@
else // no specified direction, so throw in random direction
playsound(src, 'sound/machines/hiss.ogg', 50, 0, 0)
if(last_sound + DISPOSAL_SOUND_COOLDOWN < world.time)
playsound(src, 'sound/machines/hiss.ogg', 50, 0, FALSE)
last_sound = world.time
if(H)
for(var/atom/movable/AM in H)
target = get_offset_target_turf(T, rand(5)-rand(5), rand(5)-rand(5))
@@ -1378,6 +1390,8 @@
var/turf/target // this will be where the output objects are 'thrown' to.
var/obj/structure/disposalpipe/trunk/linkedtrunk
var/mode = FALSE // Is the maintenance panel open? Different than normal disposal's mode
/// The last time a sound was played
var/last_sound
/obj/structure/disposaloutlet/Initialize(mapload)
. = ..()
@@ -1401,9 +1415,15 @@
/obj/structure/disposaloutlet/proc/expel(animation = TRUE)
if(animation)
flick("outlet-open", src)
playsound(src, 'sound/machines/warning-buzzer.ogg', 50, 0, 0)
var/play_sound = FALSE
if(last_sound + DISPOSAL_SOUND_COOLDOWN < world.time)
play_sound = TRUE
last_sound = world.time
if(play_sound)
playsound(src, 'sound/machines/warning-buzzer.ogg', 50, 0, FALSE)
sleep(20) //wait until correct animation frame
playsound(src, 'sound/machines/hiss.ogg', 50, 0, 0)
if(play_sound)
playsound(src, 'sound/machines/hiss.ogg', 50, 0, FALSE)
for(var/atom/movable/AM in contents)
AM.forceMove(loc)
AM.pipe_eject(dir)
+3 -1
View File
@@ -317,7 +317,9 @@
H.destinationTag = 1
sleep(10)
playsound(src, 'sound/machines/disposalflush.ogg', 50, 0, 0)
if(last_sound + DISPOSAL_SOUND_COOLDOWN < world.time)
playsound(src, 'sound/machines/disposalflush.ogg', 50, 0, FALSE)
last_sound = world.time
sleep(5) // wait for animation to finish
H.init(src) // copy the contents of disposer to holder