mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-01-23 23:54:45 +00:00
## About The Pull Request [Improves the documentation of DCS lists, removes old list of callback docs that no longer apply](c3821d9f5f) [Adds a second signal register to decal rotating, adds a trait to objects under a tile. STOP DIRECTLY READING HIDDEN LISTS I SWEAR TO GOD](6b3f97a76a) [Removes direct reads of the timer list, they were redundant mostly](14fcd9f8a6) [Please stop directly reading/modifying the traits list to ensure your dna rot follows the brain](ec0e5237ec) [Marks internal datum lists as well internal with _](57c6577ff6) [57c6577](57c6577ff6) Does the same to _clear_signal_refs() in hopes of keeping people from touching it ## Why It's Good For The Game They pissed me off. Users should not be touching these lists, especially in ways that make assumptions about their structure and are thus prone to breaking if that ever changes. Most of these are close to zero cost changes, using a wrapper to solve the problem, or just yeeting it Two aren't, Decals with a direction have gained a second signal register on init, and things that sit underfloor (cables/pipes) now get a trait when inserted there. This should have a minimal impact on memory/init time, bugging @Mothblocks about it just in case
61 lines
1.7 KiB
Plaintext
61 lines
1.7 KiB
Plaintext
PROCESSING_SUBSYSTEM_DEF(dcs)
|
|
name = "Datum Component System"
|
|
flags = SS_NO_INIT
|
|
wait = 1 SECONDS
|
|
|
|
var/list/elements_by_type = list()
|
|
|
|
/datum/controller/subsystem/processing/dcs/Recover()
|
|
_comp_lookup = SSdcs._comp_lookup
|
|
|
|
/datum/controller/subsystem/processing/dcs/proc/GetElement(list/arguments)
|
|
var/datum/element/eletype = arguments[1]
|
|
var/element_id = eletype
|
|
|
|
if(!ispath(eletype, /datum/element))
|
|
CRASH("Attempted to instantiate [eletype] as a /datum/element")
|
|
|
|
if(initial(eletype.element_flags) & ELEMENT_BESPOKE)
|
|
element_id = GetIdFromArguments(arguments)
|
|
|
|
. = elements_by_type[element_id]
|
|
if(.)
|
|
return
|
|
. = elements_by_type[element_id] = new eletype
|
|
|
|
/****
|
|
* Generates an id for bespoke elements when given the argument list
|
|
* Generating the id here is a bit complex because we need to support named arguments
|
|
* Named arguments can appear in any order and we need them to appear after ordered arguments
|
|
* We assume that no one will pass in a named argument with a value of null
|
|
**/
|
|
/datum/controller/subsystem/processing/dcs/proc/GetIdFromArguments(list/arguments)
|
|
var/datum/element/eletype = arguments[1]
|
|
var/list/fullid = list("[eletype]")
|
|
var/list/named_arguments = list()
|
|
|
|
for(var/i in initial(eletype.argument_hash_start_idx) to length(arguments))
|
|
var/key = arguments[i]
|
|
|
|
if(istext(key))
|
|
var/value = arguments[key]
|
|
if (isnull(value))
|
|
fullid += key
|
|
else
|
|
if (!istext(value) && !isnum(value))
|
|
value = REF(value)
|
|
named_arguments[key] = value
|
|
|
|
continue
|
|
|
|
if (isnum(key))
|
|
fullid += "[key]"
|
|
else
|
|
fullid += REF(key)
|
|
|
|
if(length(named_arguments))
|
|
named_arguments = sortTim(named_arguments, GLOBAL_PROC_REF(cmp_text_asc))
|
|
fullid += named_arguments
|
|
|
|
return list2params(fullid)
|