Merge pull request #15181 from Citadel-Station-13/typecaches

no more powergaming dice bags
This commit is contained in:
Lin
2021-09-20 23:59:53 -05:00
committed by GitHub
2 changed files with 18 additions and 0 deletions

View File

@@ -12,3 +12,16 @@ GLOBAL_LIST_INIT(typecache_stack, typecacheof(/obj/item/stack))
GLOBAL_LIST_INIT(typecache_machine_or_structure, typecacheof(list(/obj/machinery, /obj/structure)))
GLOBAL_LIST_INIT(freezing_objects, typecacheof(list(/obj/structure/closet/crate/freezer, /obj/structure/closet/secure_closet/freezer, /obj/structure/bodycontainer, /obj/item/autosurgeon, /obj/machinery/smartfridge/organ))) //list of all cold objects, that freeze organs when inside
GLOBAL_LIST_EMPTY(typecaches)
/**
* Makes a typecache of a single typecache
*
* Obviously in BYOND we don't have the efficiency around here to have proper enforcement so
* If you use this you better know what you're doing. The list you get back is globally cached and if it's modified, you might break multiple things.
*/
/proc/single_path_typecache_immutable(path)
if(!GLOB.typecaches[path])
GLOB.typecaches[path] = typecacheof(path)
return GLOB.typecaches[path]

View File

@@ -17,6 +17,11 @@
/obj/item/dice/d100
)
/obj/item/storage/dice/ComponentInitialize()
. = ..()
var/datum/component/storage/STR = GetComponent(/datum/component/storage)
STR.can_hold = single_path_typecache_immutable(/obj/item/dice)
/obj/item/storage/dice/PopulateContents()
new /obj/item/dice/d4(src)
new /obj/item/dice/d6(src)