diff --git a/code/game/objects/structures/displaycase.dm b/code/game/objects/structures/displaycase.dm
index b4eb488adf0..af964f5e2e4 100644
--- a/code/game/objects/structures/displaycase.dm
+++ b/code/game/objects/structures/displaycase.dm
@@ -10,7 +10,8 @@
max_integrity = 200
integrity_failure = 0.25
var/obj/item/showpiece = null
- var/obj/item/showpiece_type = null //This allows for showpieces that can only hold items if they're the same istype as this.
+ //var/obj/item/showpiece_type = null //This allows for showpieces that can only hold items if they're the same istype as this.
+ var/list/compatible_items_typecache
var/alert = TRUE
var/open = FALSE
var/openable = TRUE
@@ -133,14 +134,14 @@
to_chat(user, "You [open ? "close":"open"] [src].")
toggle_lock(user)
else if(open && !showpiece)
- if(!istype(W, showpiece_type) && showpiece_type)
+ if(compatible_items_typecache && !is_type_in_typecache(W, compatible_items_typecache))
to_chat(user, "This doesn't belong in this kind of display.")
return TRUE
if(user.transferItemToLoc(W, src))
showpiece = W
to_chat(user, "You put [W] on display.")
update_icon()
- else if(istype(W, /obj/item/stack/sheet/glass) && broken && glass_fix)
+ else if(glass_fix && broken && istype(W, /obj/item/stack/sheet/glass))
var/obj/item/stack/sheet/glass/G = W
if(G.get_amount() < 2)
to_chat(user, "You need two glass sheets to fix the case!")
@@ -250,12 +251,22 @@
/obj/structure/displaycase/captain
start_showpiece_type = /obj/item/gun/energy/laser/captain
req_access = list(ACCESS_CENT_SPECOPS) //this was intentional, presumably to make it slightly harder for caps to grab their gun roundstart
+ var/static/list/captain_typecache = typecacheof(/obj/item/gun/energy/laser/captain)
+
+/obj/structure/displaycase/captain/Initialize()
+ . = ..()
+ compatible_items_typecache = captain_typecache
/obj/structure/displaycase/labcage
name = "lab cage"
desc = "A glass lab container for storing interesting creatures."
start_showpiece_type = /obj/item/clothing/mask/facehugger/lamarr
req_access = list(ACCESS_RD)
+ var/static/list/rd_typecache = typecacheof(/obj/item/clothing/mask/facehugger)
+
+/obj/structure/displaycase/labcage/Initialize()
+ . = ..()
+ compatible_items_typecache = rd_typecache
/obj/structure/displaycase/noalert
alert = FALSE
@@ -268,9 +279,11 @@
var/is_locked = TRUE
integrity_failure = 0
openable = FALSE
+ var/static/list/trophy_typecache = typecacheof(/obj/item)
/obj/structure/displaycase/trophy/Initialize()
. = ..()
+ compatible_items_typecache = trophy_typecache
GLOB.trophy_cases += src
/obj/structure/displaycase/trophy/Destroy()
@@ -371,12 +384,17 @@
density = FALSE
max_integrity = 100
req_access = list(ACCESS_KITCHEN)
- showpiece_type = /obj/item/reagent_containers/food
+ var/static/list/kitchen_typecache = typecacheof(/obj/item/reagent_containers/food)
+ //showpiece_type = /obj/item/reagent_containers/food
alert = FALSE //No, we're not calling the fire department because someone stole your cookie.
glass_fix = FALSE //Fixable with tools instead.
var/sale_price = 20
var/datum/bank_account/payments_acc = null
+/obj/structure/displaycase/forsale/Initialize()
+ . = ..()
+ compatible_items_typecache = kitchen_typecache
+
/obj/structure/displaycase/forsale/update_icon() //remind me to fix my shitcode later
var/icon/I
if(open)
@@ -395,13 +413,13 @@
return
/obj/structure/displaycase/forsale/attackby(obj/item/I, mob/living/user, params)
- if(istype(I, /obj/item/card/id))
+ if(isidcard(I))
//Card Registration
var/obj/item/card/id/potential_acc = I
if(!potential_acc.registered_account)
to_chat(user, "This ID card has no account registered!")
return
- if(payments_acc != potential_acc.registered_account && payments_acc)
+ if(payments_acc && payments_acc != potential_acc.registered_account)
to_chat(user, "This Vend-a-tray is already registered!")
return
if(!payments_acc && potential_acc.registered_account)
@@ -410,41 +428,42 @@
to_chat(user, "Vend-a-tray registered. Use your ID on grab intent to change the sale price, or disarm intent to open the tray.")
return
//Buying the contained item with the ID.
- if(user.a_intent == INTENT_HELP)
- if(!showpiece)
- to_chat(user, "There's nothing for sale.")
- return 1
- if(broken)
- to_chat(user, "[src] appears to be broken.")
- return 1
- var/confirm = alert(user, "Purchase [showpiece] for [sale_price]?", "Purchase?", "Confirm", "Cancel")
- if(confirm == "Cancel")
- return 1
- var/datum/bank_account/account = potential_acc.registered_account
- if(!account.has_money(sale_price))
- to_chat(user, "You do not possess the funds to purchase this.")
- return 1
- else
- account.adjust_money(-sale_price)
- if(payments_acc)
- payments_acc.adjust_money(sale_price)
- user.put_in_hands(showpiece)
- to_chat(user, "You purchase [showpiece] for [sale_price] credits.")
- playsound(src, 'sound/effects/cashregister.ogg', 40, TRUE)
- icon = 'icons/obj/stationobjs.dmi'
- flick("laserbox_vend", src)
- showpiece = null
- update_icon()
- return 1
- //Setting the object's price.
- if(user.a_intent == INTENT_GRAB)
- var/new_price_input = input(user,"Set the sale price for this vend-a-tray.","new price",0) as num|null
- if(isnull(new_price_input) || !user.canUseTopic(src, BE_CLOSE, FALSE, NO_TK))
- return
- new_price_input = CLAMP(round(new_price_input, 1), 10, 1000)
- sale_price = new_price_input
- to_chat(user, "The cost is now set to [sale_price].")
- return 1
+ switch(user.a_intent)
+ if(INTENT_HELP)
+ if(!showpiece)
+ to_chat(user, "There's nothing for sale.")
+ return TRUE
+ if(broken)
+ to_chat(user, "[src] appears to be broken.")
+ return TRUE
+ var/confirm = alert(user, "Purchase [showpiece] for [sale_price]?", "Purchase?", "Confirm", "Cancel")
+ if(confirm == "Cancel")
+ return TRUE
+ var/datum/bank_account/account = potential_acc.registered_account
+ if(!account.has_money(sale_price))
+ to_chat(user, "You do not possess the funds to purchase this.")
+ return TRUE
+ else
+ account.adjust_money(-sale_price)
+ if(payments_acc)
+ payments_acc.adjust_money(sale_price)
+ user.put_in_hands(showpiece)
+ to_chat(user, "You purchase [showpiece] for [sale_price] credits.")
+ playsound(src, 'sound/effects/cashregister.ogg', 40, TRUE)
+ icon = 'icons/obj/stationobjs.dmi'
+ flick("laserbox_vend", src)
+ showpiece = null
+ update_icon()
+ return TRUE
+ //Setting the object's price.
+ if(INTENT_GRAB)
+ var/new_price_input = input(user,"Set the sale price for this vend-a-tray.","new price",0) as num|null
+ if(isnull(new_price_input) || !user.canUseTopic(src, BE_CLOSE, FALSE, NO_TK))
+ return
+ new_price_input = CLAMP(round(new_price_input, 1), 10, 1000)
+ sale_price = new_price_input
+ to_chat(user, "The cost is now set to [sale_price].")
+ return TRUE
if(I.tool_behaviour == TOOL_WRENCH && open && user.a_intent == INTENT_HELP )
if(anchored)
to_chat(user, "You start unsecuring [src]...")
@@ -463,7 +482,7 @@
to_chat(user, "[src] must be open to move it.")
return
if(istype(I, /obj/item/pda))
- return 1
+ return TRUE
. = ..()
/obj/structure/displaycase/forsale/multitool_act(mob/living/user, obj/item/I)