Merge pull request #3772 from Citadel-Station-13/upstream-merge-32298

[MIRROR] Signal redirection component
This commit is contained in:
LetterJay
2017-11-03 00:15:56 -05:00
committed by GitHub
3 changed files with 15 additions and 3 deletions

View File

@@ -109,7 +109,7 @@
P.datum_components = null
parent = null
/datum/component/proc/RegisterSignal(sig_type_or_types, proc_on_self, override = FALSE)
/datum/component/proc/RegisterSignal(sig_type_or_types, proc_or_callback, override = FALSE)
if(QDELETED(src))
return
var/list/procs = signal_procs
@@ -123,8 +123,10 @@
. = procs[sig_type]
if(.)
stack_trace("[sig_type] overridden. Use override = TRUE to suppress this warning")
procs[sig_type] = CALLBACK(src, proc_on_self)
if(!istype(proc_or_callback, /datum/callback)) //if it wasnt a callback before, it is now
proc_or_callback = CALLBACK(src, proc_or_callback)
procs[sig_type] = proc_or_callback
/datum/component/proc/InheritComponent(datum/component/C, i_am_original)
return

View File

@@ -0,0 +1,9 @@
/datum/component/redirect
dupe_mode = COMPONENT_DUPE_ALLOWED
/datum/component/redirect/Initialize(list/signals, _callback)
//It's not our job to verify the right signals are registered here, just do it.
if(!signals || !signals.len || !_callback)
. = COMPONENT_INCOMPATIBLE
CRASH("A redirection component was initialized with incorrect args.")
RegisterSignal(signals, _callback)