mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-31 03:52:31 +00:00
If you came here thinking this was some game feature then you are in the wrong place. Here is where I ramble about code. This adds /datum/element as a sort of sibling to components. Only one of each type gets instanced and they do not get tied directly to any particular thing like a component does. Basically they're a very lightweight component for doing simple functionality that doesn't have much state. Originally this concept came about as a kind of component that could be shared between many parents to reduce some resource costs. Doing this would allow us to componentize more behaviors that are a part of too many things to be viable to have a whole component for every single one. For example a component on every space turf would be entirely unviable. With elements it's much more reasonable. This implements a prety bare framework and a couple components are migrated to it. It's ready to be used but I fully expect I'm going to need to refine how it works for all the usecases we'll want it for. Also: this fixes the qdeleted signal. This signal isn't even possible because after qdel is done there's nothing to receive a signal anyway. I've changed it to a qdeling signal instead. I need it to work for some elements to know when to clean themselves up.
17 lines
472 B
Plaintext
17 lines
472 B
Plaintext
PROCESSING_SUBSYSTEM_DEF(dcs)
|
|
name = "Datum Component System"
|
|
flags = SS_NO_INIT
|
|
|
|
var/list/elements_by_type = list()
|
|
|
|
/datum/controller/subsystem/processing/dcs/Recover()
|
|
comp_lookup = SSdcs.comp_lookup
|
|
|
|
/datum/controller/subsystem/processing/dcs/proc/GetElement(eletype)
|
|
. = elements_by_type[eletype]
|
|
if(.)
|
|
return
|
|
if(!ispath(eletype, /datum/element))
|
|
CRASH("Attempted to instantiate [eletype] as a /datum/element")
|
|
. = elements_by_type[eletype] = new eletype
|