mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-26 09:32:21 +00:00
* Improve the naming of the element argument hash index selector (#71319) So confusing name * Improve the naming of the element argument hash index selector * sr sync Co-authored-by: oranges <email@oranges.net.nz> Co-authored-by: tastyfish <crazychris32@gmail.com>
36 lines
1.2 KiB
Plaintext
36 lines
1.2 KiB
Plaintext
/**
|
|
* ## series element!
|
|
*
|
|
* bespoke element that assigns a series number to toys on examine, and shows their series name!
|
|
* used for mechas and rare collectable hats, should totally be used for way more ;)
|
|
*/
|
|
/datum/element/series
|
|
element_flags = ELEMENT_BESPOKE | ELEMENT_DETACH_ON_HOST_DESTROY // Detach for turfs
|
|
argument_hash_start_idx = 2
|
|
var/list/subtype_list
|
|
var/series_name
|
|
|
|
/datum/element/series/Attach(datum/target, subtype, series_name)
|
|
. = ..()
|
|
if(!isatom(target))
|
|
return ELEMENT_INCOMPATIBLE
|
|
if(!subtype)
|
|
stack_trace("series element without subtype given!")
|
|
return ELEMENT_INCOMPATIBLE
|
|
subtype_list = subtypesof(subtype)
|
|
src.series_name = series_name
|
|
var/atom/attached = target
|
|
RegisterSignal(attached, COMSIG_PARENT_EXAMINE, PROC_REF(on_examine))
|
|
|
|
/datum/element/series/Detach(datum/target)
|
|
. = ..()
|
|
UnregisterSignal(target, COMSIG_PARENT_EXAMINE)
|
|
|
|
///signal called examining
|
|
/datum/element/series/proc/on_examine(datum/target, mob/user, list/examine_list)
|
|
SIGNAL_HANDLER
|
|
|
|
var/series_number = subtype_list.Find(target.type)
|
|
examine_list += span_boldnotice("[target] is part of the \"[series_name]\" series!")
|
|
examine_list += span_notice("Collect them all: [series_number]/[length(subtype_list)].")
|