diff --git a/code/_globalvars/lists/typecache.dm b/code/_globalvars/lists/typecache.dm index 1ec3de0bc5..d380816bbf 100644 --- a/code/_globalvars/lists/typecache.dm +++ b/code/_globalvars/lists/typecache.dm @@ -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] diff --git a/code/game/objects/items/dice.dm b/code/game/objects/items/dice.dm index bbc493672f..53b0860def 100644 --- a/code/game/objects/items/dice.dm +++ b/code/game/objects/items/dice.dm @@ -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)