Refactors component signals registration (#38798)

Datums know what signals are being listened for and components can now be registered to listen for signals on more than one object.
This commit is contained in:
Emmett Gaines
2018-07-04 17:56:39 -04:00
committed by vuonojenmustaturska
parent a088bde838
commit 34a3d2da4d
41 changed files with 203 additions and 202 deletions

View File

@@ -2,34 +2,5 @@ SUBSYSTEM_DEF(dcs)
name = "Datum Component System"
flags = SS_NO_INIT | SS_NO_FIRE
var/list/comp_lookup = list() // A signal:list(components) assoc list
/datum/controller/subsystem/dcs/proc/_SendGlobalSignal(sigtype, list/arguments)
. = NONE
for(var/i in comp_lookup[sigtype])
var/datum/component/comp = i
if(!comp.enabled)
continue
var/datum/callback/CB = comp.signal_procs[sigtype]
if(!CB)
continue // Should we error from this?
. |= CB.InvokeAsync(arglist(arguments))
/datum/controller/subsystem/dcs/proc/RegisterSignal(datum/component/comp, sigtype)
if(!comp_lookup[sigtype])
comp_lookup[sigtype] = list()
comp_lookup[sigtype][comp] = TRUE
/datum/controller/subsystem/dcs/proc/UnregisterSignal(datum/component/comp, list/sigtypes)
if(!length(sigtypes))
sigtypes = list(sigtypes)
for(var/sigtype in sigtypes)
switch(length(comp_lookup[sigtype]))
if(1)
comp_lookup -= sigtype
if(2 to INFINITY)
comp_lookup[sigtype] -= comp
/datum/controller/subsystem/dcs/Recover()
comp_lookup = SSdcs.comp_lookup