Small storage refactor and examine change (#44109)

* Removes repeated line

* Description change for clothing items that can only store specific items

* Get all children of can_hold listed items.

* can_hold only needs the top most item, child items are dealt automatically

* cant_hold related change

* Text change

* Moves the item check to the line above, and removes the current.

* Same changes, but to belt/wallet code.

* Change to using signals instead

* Generic signal on datum/topic

* Cache typecache, and small signal change

* Small argument tweaks and remove unneeded lists

* Change to proc

* Change call can_holds/cant_holds to use new proc

* initial, and cleaned up display code

* Null check
This commit is contained in:
Akrilla
2019-05-30 14:20:29 -04:00
committed by Emmett Gaines
parent 471705d622
commit 2d32be1904
23 changed files with 132 additions and 98 deletions
@@ -9,7 +9,7 @@
/datum/component/storage/concrete/implant/Initialize()
. = ..()
cant_hold = typecacheof(list(/obj/item/disk/nuclear))
set_holdable(null, list(/obj/item/disk/nuclear))
/datum/component/storage/concrete/implant/InheritComponent(datum/component/storage/concrete/implant/I, original)
if(!istype(I))
@@ -43,24 +43,26 @@
/datum/component/storage/concrete/pockets/shoes/Initialize()
. = ..()
cant_hold = typecacheof(list(/obj/item/screwdriver/power)) //Must be specifically called out since normal screwdrivers can fit but not the wrench form of the drill
can_hold = typecacheof(list(
set_holdable(list(
/obj/item/kitchen/knife, /obj/item/switchblade, /obj/item/pen,
/obj/item/scalpel, /obj/item/reagent_containers/syringe, /obj/item/dnainjector,
/obj/item/reagent_containers/hypospray/medipen, /obj/item/reagent_containers/dropper,
/obj/item/implanter, /obj/item/screwdriver, /obj/item/weldingtool/mini,
/obj/item/firing_pin
))
),
list(/obj/item/screwdriver/power)
)
/datum/component/storage/concrete/pockets/shoes/clown/Initialize()
. = ..()
cant_hold = typecacheof(list(/obj/item/screwdriver/power)) //Must be specifically called out since normal screwdrivers can fit but not the wrench form of the drill
can_hold = typecacheof(list(
set_holdable(list(
/obj/item/kitchen/knife, /obj/item/switchblade, /obj/item/pen,
/obj/item/scalpel, /obj/item/reagent_containers/syringe, /obj/item/dnainjector,
/obj/item/reagent_containers/hypospray/medipen, /obj/item/reagent_containers/dropper,
/obj/item/implanter, /obj/item/screwdriver, /obj/item/weldingtool/mini,
/obj/item/firing_pin, /obj/item/bikehorn))
/obj/item/firing_pin, /obj/item/bikehorn),
list(/obj/item/screwdriver/power)
)
/datum/component/storage/concrete/pockets/pocketprotector
max_items = 3
@@ -70,12 +72,13 @@
/datum/component/storage/concrete/pockets/pocketprotector/Initialize()
original_parent = parent
. = ..()
can_hold = typecacheof(list( //Same items as a PDA
set_holdable(list( //Same items as a PDA
/obj/item/pen,
/obj/item/toy/crayon,
/obj/item/lipstick,
/obj/item/flashlight/pen,
/obj/item/clothing/mask/cigarette))
/obj/item/clothing/mask/cigarette)
)
/datum/component/storage/concrete/pockets/pocketprotector/real_location()
// if the component is reparented to a jumpsuit, the items still go in the protector
@@ -87,5 +90,5 @@
/datum/component/storage/concrete/pockets/small/helmet/Initialize()
. = ..()
can_hold = typecacheof(list(/obj/item/reagent_containers/glass/bottle,
set_holdable(list(/obj/item/reagent_containers/glass/bottle,
/obj/item/ammo_box/a762))
+32 -3
View File
@@ -14,9 +14,11 @@
dupe_mode = COMPONENT_DUPE_UNIQUE
var/datum/component/storage/concrete/master //If not null, all actions act on master and this is just an access point.
var/list/can_hold //if this is set, only things in this typecache will fit, if within the size limit.
var/list/cant_hold //if this is set, anything in this typecache will not be able to fit.
var/list/exception_hold //if set, these items will be the exception to the max size of object that can fit.
var/list/can_hold //if this is set, only items, and their children, will fit
var/list/cant_hold //if this is set, items, and their children, won't fit
var/list/exception_hold //if set, these items will be the exception to the max size of object that can fit.
var/can_hold_description
var/list/mob/is_using //lazy list of mobs looking at the contents of this storage.
@@ -82,6 +84,8 @@
RegisterSignal(parent, COMSIG_TRY_STORAGE_HIDE_ALL, .proc/close_all)
RegisterSignal(parent, COMSIG_TRY_STORAGE_RETURN_INVENTORY, .proc/signal_return_inv)
RegisterSignal(parent, COMSIG_TOPIC, .proc/topic_handle)
RegisterSignal(parent, COMSIG_PARENT_ATTACKBY, .proc/attackby)
RegisterSignal(parent, COMSIG_ATOM_ATTACK_HAND, .proc/on_attack_hand)
@@ -115,6 +119,24 @@
/datum/component/storage/PreTransfer()
update_actions()
/datum/component/storage/proc/set_holdable(can_hold_list, cant_hold_list)
can_hold_description = generate_hold_desc(can_hold_list)
if (can_hold_list != null)
can_hold = typecacheof(can_hold_list)
if (cant_hold_list != null)
cant_hold = typecacheof(cant_hold_list)
/datum/component/storage/proc/generate_hold_desc(can_hold_list)
var/list/desc = list()
for(var/valid_type in can_hold_list)
var/obj/item/valid_item = valid_type
desc += "\a [initial(valid_item.name)]"
return "\n\t<span class='notice'>[desc.Join("\n\t")]</span>"
/datum/component/storage/proc/update_actions()
QDEL_NULL(modeswitch_action)
if(!isitem(parent) || !allow_quick_gather)
@@ -502,6 +524,13 @@
interface |= return_inv(recursive)
return TRUE
/datum/component/storage/proc/topic_handle(datum/source, user, href_list)
if(href_list["show_valid_pocket_items"])
handle_show_valid_items(source, user)
/datum/component/storage/proc/handle_show_valid_items(datum/source, user)
to_chat(user, "<span class='notice'>[source] can hold: [can_hold_description]</span>")
/datum/component/storage/proc/mousedrop_onto(datum/source, atom/over_object, mob/M)
set waitfor = FALSE
. = COMPONENT_NO_MOUSEDROP