RegisterSignal() can now accept a list (#31098)
* RegisterSignal may now accept a list of signals * Update old calls to RegisterSignal()
This commit is contained in:
committed by
CitadelStationBot
parent
fceb289072
commit
08ecb0e322
@@ -94,7 +94,8 @@ Stands have a lot of procs which mimic mob procs. Rather than inserting hooks fo
|
||||
* Allows the component to react to ownership transfers
|
||||
1. `/datum/component/proc/_RemoveNoSignal()` (private, final)
|
||||
* Internal, clears the parent var and removes the component from the parents component list
|
||||
1. `/datum/component/proc/RegisterSignal(signal(string), proc_ref(type), override(boolean))` (protected, final) (Consider removing for performance gainz)
|
||||
1. `/datum/component/proc/RegisterSignal(signal(string/list of strings), proc_ref(type), override(boolean))` (protected, final) (Consider removing for performance gainz)
|
||||
* If signal is a list it will be as if RegisterSignal was called for each of the entries with the same following arguments
|
||||
* Makes a component listen for the specified `signal` on it's `parent` datum.
|
||||
* When that signal is recieved `proc_ref` will be called on the component, along with associated arguments
|
||||
* Example proc ref: `.proc/OnEvent`
|
||||
|
||||
@@ -95,7 +95,7 @@
|
||||
P.datum_components = null
|
||||
parent = null
|
||||
|
||||
/datum/component/proc/RegisterSignal(sig_type, proc_on_self, override = FALSE)
|
||||
/datum/component/proc/RegisterSignal(sig_type_or_types, proc_on_self, override = FALSE)
|
||||
if(QDELETED(src))
|
||||
return
|
||||
var/list/procs = signal_procs
|
||||
@@ -103,12 +103,14 @@
|
||||
procs = list()
|
||||
signal_procs = procs
|
||||
|
||||
if(!override)
|
||||
. = procs[sig_type]
|
||||
if(.)
|
||||
stack_trace("[sig_type] overridden. Use override = TRUE to suppress this warning")
|
||||
|
||||
procs[sig_type] = CALLBACK(src, proc_on_self)
|
||||
var/list/sig_types = islist(sig_type_or_types) ? sig_type_or_types : list(sig_type_or_types)
|
||||
for(var/sig_type in sig_types)
|
||||
if(!override)
|
||||
. = procs[sig_type]
|
||||
if(.)
|
||||
stack_trace("[sig_type] overridden. Use override = TRUE to suppress this warning")
|
||||
|
||||
procs[sig_type] = CALLBACK(src, proc_on_self)
|
||||
|
||||
/datum/component/proc/InheritComponent(datum/component/C, i_am_original)
|
||||
return
|
||||
|
||||
@@ -6,10 +6,7 @@
|
||||
/datum/component/slippery/Initialize(_intensity, _lube_flags = NONE)
|
||||
intensity = max(_intensity, 0)
|
||||
lube_flags = _lube_flags
|
||||
if(ismovableatom(parent))
|
||||
RegisterSignal(COMSIG_MOVABLE_CROSSED, .proc/Slip)
|
||||
else
|
||||
RegisterSignal(COMSIG_ATOM_ENTERED, .proc/Slip)
|
||||
RegisterSignal(list(COMSIG_MOVABLE_CROSSED, COMSIG_ATOM_ENTERED), .proc/Slip)
|
||||
|
||||
/datum/component/slippery/proc/Slip(atom/movable/AM)
|
||||
var/mob/victim = AM
|
||||
|
||||
@@ -24,22 +24,9 @@
|
||||
if(use_delay_override)
|
||||
use_delay = use_delay_override
|
||||
|
||||
if(istype(parent, /atom))
|
||||
RegisterSignal(COMSIG_ATOM_BLOB_ACT, .proc/play_squeak)
|
||||
RegisterSignal(COMSIG_ATOM_HULK_ATTACK, .proc/play_squeak)
|
||||
RegisterSignal(COMSIG_PARENT_ATTACKBY, .proc/play_squeak)
|
||||
if(istype(parent, /atom/movable))
|
||||
RegisterSignal(COMSIG_MOVABLE_CROSSED, .proc/play_squeak)
|
||||
RegisterSignal(COMSIG_MOVABLE_COLLIDE, .proc/play_squeak)
|
||||
RegisterSignal(COMSIG_MOVABLE_IMPACT, .proc/play_squeak)
|
||||
if(istype(parent, /obj/item))
|
||||
RegisterSignal(COMSIG_ITEM_ATTACK, .proc/play_squeak)
|
||||
RegisterSignal(COMSIG_ITEM_ATTACK_SELF, .proc/use_squeak)
|
||||
RegisterSignal(COMSIG_ITEM_ATTACK_OBJ, .proc/play_squeak)
|
||||
if(istype(parent, /obj/item/clothing/shoes))
|
||||
RegisterSignal(COMSIG_SHOES_STEP_ACTION, .proc/step_squeak)
|
||||
else
|
||||
RegisterSignal(COMSIG_ATOM_ENTERED, .proc/play_squeak)
|
||||
RegisterSignal(list(COMSIG_ATOM_ENTERED, COMSIG_ATOM_BLOB_ACT, COMSIG_ATOM_HULK_ATTACK, COMSIG_PARENT_ATTACKBY, COMSIG_MOVABLE_CROSSED, COMSIG_MOVABLE_COLLIDE, COMSIG_MOVABLE_IMPACT, COMSIG_ITEM_ATTACK, COMSIG_ITEM_ATTACK_OBJ, COMSIG_ITEM_ATTACK_OBJ), .proc/play_squeak)
|
||||
RegisterSignal(COMSIG_ITEM_ATTACK_SELF, .proc/use_squeak)
|
||||
RegisterSignal(COMSIG_SHOES_STEP_ACTION, .proc/step_squeak)
|
||||
|
||||
/datum/component/squeak/proc/play_squeak()
|
||||
if(prob(squeak_chance))
|
||||
|
||||
Reference in New Issue
Block a user