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 19:20:29 +01:00
committed by Emmett Gaines
parent 471705d622
commit 2d32be1904
23 changed files with 132 additions and 98 deletions
+1 -1
View File
@@ -507,7 +507,7 @@
. = ..()
GET_COMPONENT(STR, /datum/component/storage)
STR.max_items = 7
STR.can_hold = typecacheof(list(/obj/item/toy/crayon))
STR.set_holdable(list(/obj/item/toy/crayon))
/obj/item/storage/crayons/PopulateContents()
new /obj/item/toy/crayon/red(src)
+1 -1
View File
@@ -326,7 +326,7 @@
STR.max_items = 20
STR.max_combined_w_class = 40
STR.display_numerical_stacking = TRUE
STR.can_hold = typecacheof(list(
STR.set_holdable(list(
/obj/item/throwing_star/magspear
))
+1 -1
View File
@@ -305,7 +305,7 @@
. = ..()
GET_COMPONENT(STR, /datum/component/storage)
STR.max_combined_w_class = 15
STR.cant_hold = typecacheof(list(/obj/item/storage/backpack/satchel/flat)) //muh recursive backpacks
STR.set_holdable(null, list(/obj/item/storage/backpack/satchel/flat)) //muh recursive backpacks)
/obj/item/storage/backpack/satchel/flat/hide(intact)
if(intact)
+7 -9
View File
@@ -48,7 +48,7 @@
STR.max_w_class = WEIGHT_CLASS_SMALL
STR.max_combined_w_class = 30
STR.max_items = 30
STR.cant_hold = typecacheof(list(/obj/item/disk/nuclear))
STR.set_holdable(null, list(/obj/item/disk/nuclear))
/obj/item/storage/bag/trash/suicide_act(mob/user)
user.visible_message("<span class='suicide'>[user] puts [src] over [user.p_their()] head and starts chomping at the insides! Disgusting!</span>")
@@ -110,7 +110,7 @@
. = ..()
GET_COMPONENT(STR, /datum/component/storage/concrete/stack)
STR.allow_quick_empty = TRUE
STR.can_hold = typecacheof(list(/obj/item/stack/ore))
STR.set_holdable(list(/obj/item/stack/ore))
STR.max_w_class = WEIGHT_CLASS_HUGE
STR.max_combined_stack_amount = 50
@@ -191,8 +191,7 @@
STR.max_w_class = WEIGHT_CLASS_NORMAL
STR.max_combined_w_class = 100
STR.max_items = 100
STR.can_hold = typecacheof(list(/obj/item/reagent_containers/food/snacks/grown, /obj/item/seeds, /obj/item/grown, /obj/item/reagent_containers/honeycomb))
STR.set_holdable(list(/obj/item/reagent_containers/food/snacks/grown, /obj/item/seeds, /obj/item/grown, /obj/item/reagent_containers/honeycomb))
////////
/obj/item/storage/bag/plants/portaseeder
@@ -229,8 +228,7 @@
. = ..()
GET_COMPONENT(STR, /datum/component/storage/concrete/stack)
STR.allow_quick_empty = TRUE
STR.can_hold = typecacheof(list(/obj/item/stack/sheet))
STR.cant_hold = typecacheof(list(/obj/item/stack/sheet/mineral/sandstone, /obj/item/stack/sheet/mineral/wood))
STR.set_holdable(list(/obj/item/stack/sheet), list(/obj/item/stack/sheet/mineral/sandstone, /obj/item/stack/sheet/mineral/wood))
STR.max_combined_stack_amount = 300
// -----------------------------
@@ -266,7 +264,7 @@
STR.max_combined_w_class = 21
STR.max_items = 7
STR.display_numerical_stacking = FALSE
STR.can_hold = typecacheof(list(/obj/item/book, /obj/item/storage/book, /obj/item/spellbook))
STR.set_holdable(list(/obj/item/book, /obj/item/storage/book, /obj/item/spellbook))
/*
* Trays - Agouri
@@ -344,7 +342,7 @@
STR.max_combined_w_class = 200
STR.max_items = 50
STR.insert_preposition = "in"
STR.can_hold = typecacheof(list(/obj/item/reagent_containers/pill, /obj/item/reagent_containers/glass/beaker, /obj/item/reagent_containers/glass/bottle, /obj/item/reagent_containers/medspray, /obj/item/reagent_containers/syringe, /obj/item/reagent_containers/dropper))
STR.set_holdable(list(/obj/item/reagent_containers/pill, /obj/item/reagent_containers/glass/beaker, /obj/item/reagent_containers/glass/bottle, /obj/item/reagent_containers/medspray, /obj/item/reagent_containers/syringe, /obj/item/reagent_containers/dropper))
/*
* Biowaste bag (mostly for xenobiologists)
@@ -364,4 +362,4 @@
STR.max_combined_w_class = 200
STR.max_items = 25
STR.insert_preposition = "in"
STR.can_hold = typecacheof(list(/obj/item/slime_extract, /obj/item/reagent_containers/syringe, /obj/item/reagent_containers/dropper, /obj/item/reagent_containers/glass/beaker, /obj/item/reagent_containers/glass/bottle, /obj/item/reagent_containers/blood, /obj/item/reagent_containers/hypospray/medipen, /obj/item/reagent_containers/food/snacks/deadmouse, /obj/item/reagent_containers/food/snacks/monkeycube))
STR.set_holdable(list(/obj/item/slime_extract, /obj/item/reagent_containers/syringe, /obj/item/reagent_containers/dropper, /obj/item/reagent_containers/glass/beaker, /obj/item/reagent_containers/glass/bottle, /obj/item/reagent_containers/blood, /obj/item/reagent_containers/hypospray/medipen, /obj/item/reagent_containers/food/snacks/deadmouse, /obj/item/reagent_containers/food/snacks/monkeycube))
+14 -15
View File
@@ -43,7 +43,7 @@
/obj/item/storage/belt/utility/ComponentInitialize()
. = ..()
GET_COMPONENT(STR, /datum/component/storage)
var/static/list/can_hold = typecacheof(list(
STR.set_holdable(list(
/obj/item/crowbar,
/obj/item/screwdriver,
/obj/item/weldingtool,
@@ -64,7 +64,6 @@
/obj/item/assembly/signaler,
/obj/item/lightreplacer
))
STR.can_hold = can_hold
/obj/item/storage/belt/utility/chief
name = "\improper Chief Engineer's toolbelt" //"the Chief Engineer's toolbelt", because "Chief Engineer's toolbelt" is not a proper noun
@@ -129,7 +128,7 @@
. = ..()
GET_COMPONENT(STR, /datum/component/storage)
STR.max_w_class = WEIGHT_CLASS_BULKY
STR.can_hold = typecacheof(list(
STR.set_holdable(list(
/obj/item/healthanalyzer,
/obj/item/dnainjector,
/obj/item/reagent_containers/dropper,
@@ -190,7 +189,7 @@
GET_COMPONENT(STR, /datum/component/storage)
STR.max_items = 5
STR.max_w_class = WEIGHT_CLASS_NORMAL
STR.can_hold = typecacheof(list(
STR.set_holdable(list(
/obj/item/melee/baton,
/obj/item/melee/classic_baton,
/obj/item/grenade,
@@ -244,7 +243,7 @@
STR.max_items = 6
STR.max_w_class = WEIGHT_CLASS_BULKY
STR.max_combined_w_class = 20
STR.can_hold = typecacheof(list(
STR.set_holdable(list(
/obj/item/crowbar,
/obj/item/screwdriver,
/obj/item/weldingtool,
@@ -312,7 +311,7 @@
. = ..()
GET_COMPONENT(STR, /datum/component/storage)
STR.max_items = 6
STR.can_hold = typecacheof(list(
STR.set_holdable(list(
/obj/item/soulstone
))
@@ -335,9 +334,9 @@
. = ..()
GET_COMPONENT(STR, /datum/component/storage)
STR.max_items = 1
STR.can_hold = list(
STR.set_holdable(list(
/obj/item/clothing/mask/luchador
)
))
/obj/item/storage/belt/military
name = "chest rig"
@@ -364,7 +363,7 @@
GET_COMPONENT(STR, /datum/component/storage)
STR.max_items = 6
STR.max_w_class = WEIGHT_CLASS_SMALL
STR.can_hold = typecacheof(list(
STR.set_holdable(list(
/obj/item/reagent_containers/food/snacks,
/obj/item/reagent_containers/food/drinks
))
@@ -444,7 +443,7 @@
STR.display_numerical_stacking = TRUE
STR.max_combined_w_class = 60
STR.max_w_class = WEIGHT_CLASS_BULKY
STR.can_hold = typecacheof(list(
STR.set_holdable(list(
/obj/item/grenade,
/obj/item/screwdriver,
/obj/item/lighter,
@@ -479,7 +478,7 @@
. = ..()
GET_COMPONENT(STR, /datum/component/storage)
STR.max_items = 6
STR.can_hold = typecacheof(list(
STR.set_holdable(list(
/obj/item/gun/magic/wand
))
@@ -506,7 +505,7 @@
GET_COMPONENT(STR, /datum/component/storage)
STR.max_items = 6
STR.max_w_class = WEIGHT_CLASS_BULKY // Set to this so the light replacer can fit.
STR.can_hold = typecacheof(list(
STR.set_holdable(list(
/obj/item/grenade/chem_grenade,
/obj/item/lightreplacer,
/obj/item/flashlight,
@@ -538,7 +537,7 @@
GET_COMPONENT(STR, /datum/component/storage)
STR.max_items = 18
STR.display_numerical_stacking = TRUE
STR.can_hold = typecacheof(list(
STR.set_holdable(list(
/obj/item/ammo_casing/shotgun
))
@@ -554,7 +553,7 @@
GET_COMPONENT(STR, /datum/component/storage)
STR.max_items = 3
STR.max_w_class = WEIGHT_CLASS_NORMAL
STR.can_hold = typecacheof(list(
STR.set_holdable(list(
/obj/item/gun/ballistic/automatic/pistol,
/obj/item/gun/ballistic/revolver,
/obj/item/ammo_box,
@@ -654,7 +653,7 @@
STR.max_items = 1
STR.rustle_sound = FALSE
STR.max_w_class = WEIGHT_CLASS_BULKY
STR.can_hold = typecacheof(list(
STR.set_holdable(list(
/obj/item/melee/sabre
))
+6 -6
View File
@@ -402,7 +402,7 @@
/obj/item/storage/box/donkpockets/ComponentInitialize()
. = ..()
GET_COMPONENT(STR, /datum/component/storage)
STR.can_hold = typecacheof(list(/obj/item/reagent_containers/food/snacks/donkpocket))
STR.set_holdable(list(/obj/item/reagent_containers/food/snacks/donkpocket))
/obj/item/storage/box/donkpockets/PopulateContents()
for(var/i in 1 to 6)
@@ -419,7 +419,7 @@
. = ..()
GET_COMPONENT(STR, /datum/component/storage)
STR.max_items = 7
STR.can_hold = typecacheof(list(/obj/item/reagent_containers/food/snacks/monkeycube))
STR.set_holdable(list(/obj/item/reagent_containers/food/snacks/monkeycube))
/obj/item/storage/box/monkeycubes/PopulateContents()
for(var/i in 1 to 5)
@@ -439,7 +439,7 @@
. = ..()
GET_COMPONENT(STR, /datum/component/storage)
STR.max_items = 3
STR.can_hold = typecacheof(list(/obj/item/reagent_containers/food/snacks/monkeycube))
STR.set_holdable(list(/obj/item/reagent_containers/food/snacks/monkeycube))
/obj/item/storage/box/gorillacubes/PopulateContents()
for(var/i in 1 to 3)
@@ -591,7 +591,7 @@
/obj/item/storage/box/snappops/ComponentInitialize()
. = ..()
GET_COMPONENT(STR, /datum/component/storage)
STR.can_hold = typecacheof(list(/obj/item/toy/snappop))
STR.set_holdable(list(/obj/item/toy/snappop))
STR.max_items = 8
/obj/item/storage/box/snappops/PopulateContents()
@@ -610,7 +610,7 @@
. = ..()
GET_COMPONENT(STR, /datum/component/storage)
STR.max_items = 10
STR.can_hold = typecacheof(list(/obj/item/match))
STR.set_holdable(list(/obj/item/match))
/obj/item/storage/box/matches/PopulateContents()
SEND_SIGNAL(src, COMSIG_TRY_STORAGE_FILL_TYPE, /obj/item/match)
@@ -633,7 +633,7 @@
. = ..()
GET_COMPONENT(STR, /datum/component/storage)
STR.max_items = 21
STR.can_hold = typecacheof(list(/obj/item/light/tube, /obj/item/light/bulb))
STR.set_holdable(list(/obj/item/light/tube, /obj/item/light/bulb))
STR.max_combined_w_class = 21
STR.click_gather = FALSE //temp workaround to re-enable filling the light replacer with the box
+6 -6
View File
@@ -74,7 +74,7 @@
. = ..()
GET_COMPONENT(STR, /datum/component/storage)
STR.max_items = 6
STR.can_hold = typecacheof(list(/obj/item/reagent_containers/food/snacks/donut))
STR.set_holdable(list(/obj/item/reagent_containers/food/snacks/donut))
/*
* Egg Box
@@ -95,7 +95,7 @@
. = ..()
GET_COMPONENT(STR, /datum/component/storage)
STR.max_items = 12
STR.can_hold = typecacheof(list(/obj/item/reagent_containers/food/snacks/egg))
STR.set_holdable(list(/obj/item/reagent_containers/food/snacks/egg))
/*
* Candle Box
@@ -140,7 +140,7 @@
. = ..()
GET_COMPONENT(STR, /datum/component/storage)
STR.max_items = 6
STR.can_hold = typecacheof(list(/obj/item/clothing/mask/cigarette, /obj/item/lighter))
STR.set_holdable(list(/obj/item/clothing/mask/cigarette, /obj/item/lighter))
/obj/item/storage/fancy/cigarettes/examine(mob/user)
..()
@@ -278,7 +278,7 @@
. = ..()
GET_COMPONENT(STR, /datum/component/storage)
STR.max_items = 10
STR.can_hold = typecacheof(list(/obj/item/rollingpaper))
STR.set_holdable(list(/obj/item/rollingpaper))
/obj/item/storage/fancy/rollingpapers/update_icon()
cut_overlays()
@@ -302,7 +302,7 @@
. = ..()
GET_COMPONENT(STR, /datum/component/storage)
STR.max_items = 5
STR.can_hold = typecacheof(list(/obj/item/clothing/mask/cigarette/cigar))
STR.set_holdable(list(/obj/item/clothing/mask/cigarette/cigar))
/obj/item/storage/fancy/cigarettes/cigars/update_icon()
cut_overlays()
@@ -349,4 +349,4 @@
. = ..()
GET_COMPONENT(STR, /datum/component/storage)
STR.max_items = 8
STR.can_hold = typecacheof(list(/obj/item/reagent_containers/food/snacks/tinychocolate))
STR.set_holdable(list(/obj/item/reagent_containers/food/snacks/tinychocolate))
+1 -1
View File
@@ -219,7 +219,7 @@
GET_COMPONENT(STR, /datum/component/storage)
STR.allow_quick_gather = TRUE
STR.click_gather = TRUE
STR.can_hold = typecacheof(list(/obj/item/reagent_containers/pill, /obj/item/dice))
STR.set_holdable(list(/obj/item/reagent_containers/pill, /obj/item/dice))
/obj/item/storage/pill_bottle/suicide_act(mob/user)
user.visible_message("<span class='suicide'>[user] is trying to get the cap off [src]! It looks like [user.p_theyre()] trying to commit suicide!</span>")
+1 -1
View File
@@ -103,7 +103,7 @@
STR.max_w_class = WEIGHT_CLASS_SMALL
STR.max_items = 10
STR.max_combined_w_class = 20
STR.can_hold = typecacheof(list(/obj/item/clothing/accessory/medal))
STR.set_holdable(list(/obj/item/clothing/accessory/medal))
/obj/item/storage/lockbox/medal/examine(mob/user)
..()
+1 -1
View File
@@ -171,7 +171,7 @@
/obj/item/storage/secure/safe/ComponentInitialize()
. = ..()
GET_COMPONENT(STR, /datum/component/storage)
STR.cant_hold = typecacheof(list(/obj/item/storage/secure/briefcase))
STR.set_holdable(null, list(/obj/item/storage/secure/briefcase))
STR.max_w_class = 8 //??
/obj/item/storage/secure/safe/PopulateContents()
+15 -15
View File
@@ -10,8 +10,8 @@
new /obj/item/encryptionkey/syndicate(src) // 2 tc
new /obj/item/storage/box/syndie_kit/space(src) //4 tc
new /obj/item/grenade/syndieminibomb/concussion/frag(src) // ~2 tc each?
new /obj/item/grenade/syndieminibomb/concussion/frag(src)
new /obj/item/grenade/syndieminibomb/concussion/frag(src)
if("bloodyspai") // 27 tc now this is more right
new /obj/item/clothing/under/chameleon(src) // 2 tc since it's not the full set
new /obj/item/clothing/mask/chameleon(src) // Goes with above
@@ -33,7 +33,7 @@
new /obj/item/chameleon(src)
new /obj/item/soap/syndie(src)
new /obj/item/clothing/glasses/thermal/syndi(src)
if("guns") // 28 tc now
new /obj/item/gun/ballistic/revolver(src)
new /obj/item/ammo_box/a357(src)
@@ -109,7 +109,7 @@
new /obj/item/grenade/plastic/c4 (src) // 1 tc
new /obj/item/grenade/plastic/c4 (src) // 1 tc
new /obj/item/card/emag(src) // 6 tc
/obj/item/storage/box/syndicate/bundle_B/PopulateContents()
switch (pickweight(list( "bond" = 2, "ninja" = 1, "darklord" = 1, "white_whale_holy_grail" = 2, "mad_scientist" = 2, "bee" = 2, "mr_freeze" = 2)))
if("bond") // 29 tc
@@ -120,7 +120,7 @@
new /obj/item/clothing/under/chameleon(src)
new /obj/item/card/id/syndicate(src)
new /obj/item/reagent_containers/syringe/stimulants(src)
if("ninja") // 33 tc worth
new /obj/item/katana(src) // Unique , hard to tell how much tc this is worth. 8 tc?
new /obj/item/implanter/adrenalin(src) // 8 tc
@@ -128,8 +128,8 @@
new /obj/item/throwing_star(src) // ~5 tc for all 6
new /obj/item/storage/belt/chameleon(src) // Unique but worth at least 2 tc
new /obj/item/card/id/syndicate(src) // 2 tc
new /obj/item/chameleon(src) // 7 tc
new /obj/item/chameleon(src) // 7 tc
if("darklord") //20 tc + tk + summon item close enough for now
new /obj/item/twohanded/dualsaber(src)
new /obj/item/dnainjector/telemut/darkbundle(src)
@@ -137,14 +137,14 @@
new /obj/item/card/id/syndicate(src)
new /obj/item/clothing/shoes/chameleon/noslip(src) //because slipping while being a dark lord sucks
new /obj/item/book/granter/spell/summonitem(src)
if("white_whale_holy_grail") //Unique items that don't appear anywhere else
new /obj/item/pneumatic_cannon/speargun(src)
new /obj/item/storage/backpack/magspear_quiver(src)
new /obj/item/clothing/suit/space/hardsuit/carp(src)
new /obj/item/clothing/mask/gas/carp(src)
new /obj/item/grenade/spawnergrenade/spesscarp(src)
if("mad_scientist") // ~26 tc
new /obj/item/clothing/suit/toggle/labcoat/mad(src) // 0 tc
new /obj/item/clothing/shoes/jackboots(src) // 0 tc
@@ -157,7 +157,7 @@
new /obj/item/assembly/signaler(src) // 0 tc
new /obj/item/assembly/signaler(src) // 0 tc
new /obj/item/storage/toolbox/syndicate(src) // 1 tc
if("bee") // ~25 tc
new /obj/item/paper/fluff/bee_objectives(src) // 0 tc (motivation)
new /obj/item/clothing/suit/hooded/bee_costume(src) // 0 tc
@@ -165,7 +165,7 @@
new /obj/item/storage/belt/fannypack/yellow(src) // 0 tc
new /obj/item/storage/box/syndie_kit/bee_grenades(src) // 15 tc
new /obj/item/reagent_containers/glass/bottle/beesease(src) // 10 tc?
if("mr_freeze")
new /obj/item/clothing/glasses/cold(src)
new /obj/item/clothing/gloves/color/black(src)
@@ -179,7 +179,7 @@
new /obj/item/dnainjector/geladikinesis(src)
new /obj/item/dnainjector/cryokinesis(src)
new /obj/item/gun/energy/temperature/security(src)
/obj/item/storage/box/syndie_kit
name = "box"
desc = "A sleek, sturdy box."
@@ -257,17 +257,17 @@
. = ..()
GET_COMPONENT(STR, /datum/component/storage)
STR.max_w_class = WEIGHT_CLASS_NORMAL
STR.can_hold = typecacheof(list(/obj/item/clothing/suit/space/syndicate, /obj/item/clothing/head/helmet/space/syndicate))
STR.set_holdable(list(/obj/item/clothing/suit/space/syndicate, /obj/item/clothing/head/helmet/space/syndicate))
/obj/item/storage/box/syndie_kit/space/PopulateContents()
if(prob(50))
new /obj/item/clothing/suit/space/syndicate/black/red(src) // Black and red is so in right now
new /obj/item/clothing/head/helmet/space/syndicate/black/red(src)
else
new /obj/item/clothing/head/helmet/space/syndicate(src)
new /obj/item/clothing/suit/space/syndicate(src)
/obj/item/storage/box/syndie_kit/emp
name = "EMP kit"
+3 -3
View File
@@ -13,8 +13,7 @@
. = ..()
GET_COMPONENT(STR, /datum/component/storage)
STR.max_items = 4
STR.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
STR.can_hold = typecacheof(list(
STR.set_holdable(list(
/obj/item/stack/spacecash,
/obj/item/holochip,
/obj/item/card,
@@ -36,7 +35,8 @@
/obj/item/reagent_containers/dropper,
/obj/item/reagent_containers/syringe,
/obj/item/screwdriver,
/obj/item/stamp))
/obj/item/stamp),
list(/obj/item/screwdriver/power))
/obj/item/storage/wallet/Exited(atom/movable/AM)
. = ..()