Merge pull request #1337 from yogstation13/upstream-merge-38537

[MIRROR] Removes status_effect_listener
This commit is contained in:
Ling
2018-06-18 12:05:55 +02:00
committed by GitHub
6 changed files with 5 additions and 64 deletions

View File

@@ -3,7 +3,6 @@
var/dupe_mode = COMPONENT_DUPE_HIGHLANDER
var/dupe_type
var/list/signal_procs
var/report_signal_origin = FALSE
var/datum/parent
/datum/component/New(datum/P, ...)
@@ -131,8 +130,6 @@
var/datum/callback/CB = C.signal_procs[sigtype]
if(!CB)
return NONE
if(initial(C.report_signal_origin))
arguments = list(sigtype) + arguments
return CB.InvokeAsync(arglist(arguments))
. = NONE
for(var/I in target)
@@ -142,10 +139,7 @@
var/datum/callback/CB = C.signal_procs[sigtype]
if(!CB)
continue
if(initial(C.report_signal_origin))
. |= CB.InvokeAsync(arglist(list(sigtype) + arguments))
else
. |= CB.InvokeAsync(arglist(arguments))
. |= CB.InvokeAsync(arglist(arguments))
/datum/proc/GetComponent(c_type)
var/list/dc = datum_components

View File

@@ -1,38 +0,0 @@
/datum/component/status_effect_listener
dupe_mode = COMPONENT_DUPE_UNIQUE
report_signal_origin = TRUE
var/list/effect_signals = list()
/datum/component/status_effect_listener/proc/RegisterEffectSignal(datum/status_effect/se, sig_type_or_types, proc_or_callback)
var/list/sig_types = islist(sig_type_or_types) ? sig_type_or_types : list(sig_type_or_types)
RegisterSignal(sig_type_or_types, .proc/signal, override = TRUE)
for(var/type in sig_types)
var/list/callbacks = effect_signals[type]
if(!callbacks)
callbacks = list()
effect_signals[type] = callbacks
if(!istype(proc_or_callback, /datum/callback)) //if it wasnt a callback before, it is now
proc_or_callback = CALLBACK(se, proc_or_callback)
effect_signals[type] += proc_or_callback
/datum/component/status_effect_listener/proc/ClearSignalRegister(datum/status_effect/se)
for(var/type in effect_signals)
for(var/datum/callback/cb in effect_signals[type])
if(cb.object == se)
effect_signals[type] -= cb
QDEL_NULL(cb)
if(effect_signals[type].len <= 0)
QDEL_LIST(effect_signals[type])
effect_signals[type] = null
effect_signals -= type
if(effect_signals.len <= 0)
QDEL_LIST(effect_signals)
qdel(src)
/datum/component/status_effect_listener/proc/signal(sigtype, ...)
var/list/arguments = args.Copy(2)
if(effect_signals[sigtype])
for(var/datum/callback/CB in effect_signals[sigtype])
if(!CB)
continue
. |= CB.InvokeAsync(arglist(arguments))

View File

@@ -5,6 +5,7 @@
alert_type = /obj/screen/alert/status_effect/freon
var/icon/cube
var/can_melt = TRUE
var/datum/weakref/redirect_component
/obj/screen/alert/status_effect/freon
name = "Frozen Solid"
@@ -12,7 +13,7 @@
icon_state = "frozen"
/datum/status_effect/freon/on_apply()
RegisterEffectSignal(COMSIG_LIVING_RESIST, .proc/owner_resist)
redirect_component = WEAKREF(owner.AddComponent(/datum/component/redirect, list(COMSIG_LIVING_RESIST), CALLBACK(src, .proc/owner_resist)))
if(!owner.stat)
to_chat(owner, "<span class='userdanger'>You become frozen in a cube!</span>")
cube = icon('icons/effects/freeze.dmi', "ice_cube")
@@ -39,6 +40,8 @@
owner.cut_overlay(cube)
owner.adjust_bodytemperature(100)
owner.update_canmove()
qdel(redirect_component.resolve())
redirect_component = null
/datum/status_effect/freon/watcher
duration = 8

View File

@@ -13,20 +13,9 @@
var/alert_type = /obj/screen/alert/status_effect //the alert thrown by the status effect, contains name and description
var/obj/screen/alert/status_effect/linked_alert = null //the alert itself, if it exists
var/listening = FALSE //Whether or not the status effect listens to mob interaction, using the status_effect_listener. Don't touch!
/datum/status_effect/New(list/arguments)
on_creation(arglist(arguments))
/datum/status_effect/proc/RegisterEffectSignal(sig_type_or_types, proc_or_callback)
if(!owner)
CRASH("[src] attempted to apply a status effect listener before it had an owner.")
GET_COMPONENT_FROM(listener, /datum/component/status_effect_listener, owner)
if(!listener)
listener = owner.AddComponent(/datum/component/status_effect_listener)
listener.RegisterEffectSignal(src,sig_type_or_types, proc_or_callback)
listening = TRUE
/datum/status_effect/proc/on_creation(mob/living/new_owner, ...)
if(new_owner)
owner = new_owner
@@ -51,10 +40,6 @@
owner.clear_alert(id)
LAZYREMOVE(owner.status_effects, src)
on_remove()
if(listening)
GET_COMPONENT_FROM(listener, /datum/component/status_effect_listener, owner)
if(listener)
listener.ClearSignalRegister(src)
owner = null
return ..()
@@ -71,7 +56,6 @@
/datum/status_effect/proc/on_apply() //Called whenever the buff is applied; returning FALSE will cause it to autoremove itself.
return TRUE
/datum/status_effect/proc/tick() //Called every tick.
/datum/status_effect/proc/receiveSignal(var/sigtype) //Called when a listener recieves a signal, if the effect is listening.
/datum/status_effect/proc/on_remove() //Called whenever the buff expires or is removed; do note that at the point this is called, it is out of the owner's status_effects but owner is not yet null
/datum/status_effect/proc/be_replaced() //Called instead of on_remove when a status effect is replaced by itself or when a status effect with on_remove_on_mob_delete = FALSE has its mob deleted
owner.clear_alert(id)

View File

@@ -341,7 +341,6 @@
#include "code\datums\components\spooky.dm"
#include "code\datums\components\squeek.dm"
#include "code\datums\components\stationloving.dm"
#include "code\datums\components\status_effect_listener.dm"
#include "code\datums\components\swarming.dm"
#include "code\datums\components\thermite.dm"
#include "code\datums\components\wearertargeting.dm"

View File

@@ -344,7 +344,6 @@
#include "code\datums\components\spooky.dm"
#include "code\datums\components\squeek.dm"
#include "code\datums\components\stationloving.dm"
#include "code\datums\components\status_effect_listener.dm"
#include "code\datums\components\swarming.dm"
#include "code\datums\components\thermite.dm"
#include "code\datums\components\wearertargeting.dm"