Caps the number of thrown object impact sounds at 20/tick (400/second). (#25646)

* Caps the number of thrown object impact sounds at 20/tick (400/second).

* Update code/controllers/subsystem/SSthrowing.dm

Co-authored-by: DGamerL <108773801+DGamerL@users.noreply.github.com>
Signed-off-by: Charlie Nolan <funnyman3595@gmail.com>

---------

Signed-off-by: Charlie Nolan <funnyman3595@gmail.com>
Co-authored-by: FunnyMan3595 (Charlie Nolan) <funnyman@google.com>
Co-authored-by: DGamerL <108773801+DGamerL@users.noreply.github.com>
This commit is contained in:
Charlie Nolan
2024-06-06 19:34:37 +00:00
committed by GitHub
co-authored by DGamerL FunnyMan3595
parent ae1cada835
commit 30f83f719a
2 changed files with 23 additions and 5 deletions
+18
View File
@@ -13,6 +13,15 @@ SUBSYSTEM_DEF(throwing)
var/list/currentrun
var/list/processing = list()
/// How many throw impact sounds have happened this tick.
var/impact_sounds = 0
/// How many throw impact sounds we allow per tick.
var/impact_sounds_cap = 20
/// How many sounds we've skipped due to hitting the per-tick cap.
var/skipped_sounds = 0
/// How many sounds there were last tick.
var/last_impact_sounds = 0
/datum/controller/subsystem/throwing/get_stat_details()
return "P:[length(processing)]"
@@ -25,6 +34,8 @@ SUBSYSTEM_DEF(throwing)
/datum/controller/subsystem/throwing/fire(resumed = 0)
if(!resumed)
src.currentrun = processing.Copy()
last_impact_sounds = impact_sounds
impact_sounds = 0
//cache for sanic speed (lists are references anyways)
var/list/currentrun = src.currentrun
@@ -46,6 +57,13 @@ SUBSYSTEM_DEF(throwing)
currentrun = null
/datum/controller/subsystem/throwing/proc/playsound_capped(atom/source, soundin, vol, vary, extrarange, falloff_exponent = SOUND_FALLOFF_EXPONENT, frequency, channel = 0, pressure_affected = TRUE, ignore_walls = TRUE, falloff_distance = SOUND_DEFAULT_FALLOFF_DISTANCE, use_reverb = TRUE)
if(impact_sounds < impact_sounds_cap)
impact_sounds++
playsound(source, soundin, vol, vary, extrarange, falloff_exponent, frequency, channel, pressure_affected, ignore_walls, falloff_distance, use_reverb)
else
skipped_sounds++
/datum/thrownthing
var/atom/movable/thrownthing
var/atom/target