From c13c0f84fb5cc882fb4990ab5056bcbdf903f8f8 Mon Sep 17 00:00:00 2001 From: Lohikar Date: Fri, 22 Sep 2017 04:45:43 -0600 Subject: [PATCH] Add get_listeners_by_type (#3483) --- code/controllers/subsystems/global_listener.dm | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/code/controllers/subsystems/global_listener.dm b/code/controllers/subsystems/global_listener.dm index e3d57dadc50..4914c6bdfc7 100644 --- a/code/controllers/subsystems/global_listener.dm +++ b/code/controllers/subsystems/global_listener.dm @@ -25,3 +25,16 @@ var/datum/controller/subsystem/listener/SSlistener if (!LAZYLEN(listeners[L.channel])) listeners -= L.channel + +/proc/get_listeners_by_type(id, type) + if (!type) + CRASH("Cannot get listeners of type null.") + + . = list() + var/listener/L + var/datum/D + for (var/thing in GET_LISTENERS(id)) + L = thing + D = L.target + if (istype(D, type) && !QDELETED(D)) + . += D