diff --git a/code/datums/components/README.md b/code/datums/components/README.md index 93a846035f..04dc21f33e 100644 --- a/code/datums/components/README.md +++ b/code/datums/components/README.md @@ -62,7 +62,7 @@ Stands have a lot of procs which mimic mob procs. Rather than inserting hooks fo * Returns the component that was created. Or the old component in a dupe situation where `COMPONENT_DUPE_UNIQUE` was set 1. `/datum/proc/LoadComponent(component_type(type), ...) -> datum/component` (public, final) * Equivalent to calling `GetComponent(component_type)` where, if the result would be `null`, returns `AddComponent(component_type, ...)` instead -1. `/datum/proc/ComponentActivated(datum/component/C)` (abstract) +1. `/datum/proc/ComponentActivated(datum/component/C)` (abstract, async) * Called on a component's `parent` after a signal recieved causes it to activate. `src` is the parameter * Will only be called if a component's callback returns `TRUE` 1. `/datum/proc/TakeComponent(datum/component/C)` (public, final) @@ -87,7 +87,7 @@ Stands have a lot of procs which mimic mob procs. Rather than inserting hooks fo * Called on a component when a component of the same type was added to the same parent * See `/datum/component/var/dupe_mode` * `C`'s type will always be the same of the called component -1. `/datum/component/proc/AfterComponentActivated()` (abstract) +1. `/datum/component/proc/AfterComponentActivated()` (abstract, async) * Called on a component that was activated after it's `parent`'s `ComponentActivated()` is called 1. `/datum/component/proc/OnTransfer(datum/new_parent)` (abstract, no-sleep) * Called before the new `parent` is assigned in `TakeComponent()`, after the remove signal, before the added signal @@ -101,8 +101,5 @@ Stands have a lot of procs which mimic mob procs. Rather than inserting hooks fo * If a previous registration is overwritten by the call, a runtime occurs. Setting `override` to TRUE prevents this * These callbacks run asyncronously * Returning `TRUE` from these callbacks will trigger a `TRUE` return from the `SendSignal()` that initiated it -1. `/datum/component/proc/ReceiveSignal(signal, ...)` (virtual) - * Called when a component recieves any signal and is enabled - * Default implementation looks if the signal is registered and runs the appropriate proc ### See/Define signals and their arguments in __DEFINES\components.dm diff --git a/code/datums/components/component.dm b/code/datums/components/_component.dm similarity index 88% rename from code/datums/components/component.dm rename to code/datums/components/_component.dm index 6b902a6ac6..667ffa7b82 100644 --- a/code/datums/components/component.dm +++ b/code/datums/components/_component.dm @@ -110,15 +110,6 @@ procs[sig_type] = CALLBACK(src, proc_on_self) -/datum/component/proc/ReceiveSignal(sigtype, ...) - var/list/sps = signal_procs - var/datum/callback/CB = LAZYACCESS(sps, sigtype) - if(!CB) - return FALSE - var/list/arguments = args.Copy() - arguments.Cut(1, 2) - return CB.InvokeAsync(arglist(arguments)) - /datum/component/proc/InheritComponent(datum/component/C, i_am_original) return @@ -126,6 +117,7 @@ return /datum/component/proc/AfterComponentActivated() + set waitfor = FALSE return /datum/component/proc/_GetInverseTypeList(current_type) @@ -136,26 +128,40 @@ /datum/proc/SendSignal(sigtype, ...) var/list/comps = datum_components - . = FALSE if(!comps) - return + return FALSE + var/list/arguments = args.Copy() + arguments.Cut(1, 2) var/target = comps[/datum/component] if(!islist(target)) var/datum/component/C = target - if(C.enabled && C.ReceiveSignal(arglist(args))) + if(!C.enabled) + return FALSE + var/list/sps = C.signal_procs + var/datum/callback/CB = LAZYACCESS(sps, sigtype) + if(!CB) + return FALSE + . = CB.InvokeAsync(arglist(arguments)) + if(.) ComponentActivated(C) C.AfterComponentActivated() - return TRUE else + . = FALSE for(var/I in target) var/datum/component/C = I if(!C.enabled) + continue + var/list/sps = C.signal_procs + var/datum/callback/CB = LAZYACCESS(sps, sigtype) + if(!CB) continue - if(C.ReceiveSignal(arglist(args))) + if(CB.InvokeAsync(arglist(arguments))) ComponentActivated(C) + C.AfterComponentActivated() . = TRUE /datum/proc/ComponentActivated(datum/component/C) + set waitfor = FALSE return /datum/proc/GetComponent(c_type) diff --git a/tgstation.dme b/tgstation.dme index 0710f192df..0d142f7973 100755 --- a/tgstation.dme +++ b/tgstation.dme @@ -283,8 +283,8 @@ #include "code\datums\antagonists\datum_traitor.dm" #include "code\datums\antagonists\devil.dm" #include "code\datums\antagonists\ninja.dm" +#include "code\datums\components\_component.dm" #include "code\datums\components\archaeology.dm" -#include "code\datums\components\component.dm" #include "code\datums\components\material_container.dm" #include "code\datums\components\slippery.dm" #include "code\datums\components\squeek.dm"