mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-22 12:41:09 +01:00
Co-authored-by: tralezab <spamqetuo2@gmail.com> Co-authored-by: Mothblocks <35135081+Jared-Fogle@users.noreply.github.com> Co-authored-by: Aleksej Komarov <stylemistake@gmail.com> Co-authored-by: Qustinnus <Floydje123@hotmail.com> Co-authored-by: coiax <yellowbounder@gmail.com> Co-authored-by: AnturK <AnturK@users.noreply.github.com> Co-authored-by: tralezab <spamqetuo2@gmail.com> Co-authored-by: Mothblocks <35135081+Jared-Fogle@users.noreply.github.com> Co-authored-by: Aleksej Komarov <stylemistake@gmail.com> Co-authored-by: Qustinnus <Floydje123@hotmail.com> Co-authored-by: coiax <yellowbounder@gmail.com>
This commit is contained in:
co-authored by
tralezab
Mothblocks
Aleksej Komarov
Qustinnus
coiax
AnturK
parent
8c3d2811c2
commit
3000d75ad5
@@ -0,0 +1,27 @@
|
||||
/**
|
||||
* Create /datum/component/aquarium_content with the preset path on the target right before being inserted into aquarium and deletes itself.
|
||||
* Used to save memory from aquarium properties on common objects/stacks that won't see aquarium in 99 out of 100 rounds.
|
||||
*/
|
||||
/datum/element/deferred_aquarium_content
|
||||
element_flags = ELEMENT_BESPOKE
|
||||
id_arg_index = 2
|
||||
var/aquarium_content_type
|
||||
|
||||
/datum/element/deferred_aquarium_content/Attach(datum/target, aquarium_content_type)
|
||||
. = ..()
|
||||
if(!ismovable(target))
|
||||
return ELEMENT_INCOMPATIBLE
|
||||
if(!aquarium_content_type)
|
||||
CRASH("Deferred aquarium content missing behaviour type.")
|
||||
src.aquarium_content_type = aquarium_content_type
|
||||
RegisterSignal(target, COMSIG_AQUARIUM_BEFORE_INSERT_CHECK, .proc/create_aquarium_component)
|
||||
|
||||
/datum/element/deferred_aquarium_content/Detach(datum/target)
|
||||
. = ..()
|
||||
UnregisterSignal(target, COMSIG_AQUARIUM_BEFORE_INSERT_CHECK)
|
||||
|
||||
/datum/element/deferred_aquarium_content/proc/create_aquarium_component(datum/source)
|
||||
SIGNAL_HANDLER
|
||||
|
||||
source.AddComponent(/datum/component/aquarium_content, aquarium_content_type)
|
||||
Detach(source)
|
||||
Reference in New Issue
Block a user