Tsu's Brand Spanking New Storage: or, How I Learned To Pass Github Copilot As My Own Code (#67478)

Currently, storage works as a subtype of /datum/component, utilizing GetComponent() and signals to operate. While this is a pretty good idea in theory, the execution was pretty trash, and we end up with alot of GetComponent() snowflake code (something that shouldn't even need to be used frankly), and a heaping load of scattered procs that lead into one another, and procs that don't get utilized properly.

Instead, this PR adds atom_storage and proc/create_storage(. . .) to every atom, allowing for the possibility of storage on quite frankly anything. Not only does this entirely remove the need for signals, but it heavily squashes down the number of needed procs in total (removing snowflake signal procs that just lead to one another), reducing overall proc overhead and improving performance.
This commit is contained in:
magatsuchi
2022-07-08 20:13:18 -05:00
committed by GitHub
parent 944eb14541
commit 7d0f393f5d
133 changed files with 2056 additions and 2358 deletions
+1 -1
View File
@@ -63,7 +63,7 @@ GLOBAL_LIST_EMPTY(total_extraction_beacons)
to_chat(user, span_notice("You attach the pack to [A] and activate it."))
if(loc == user && istype(user.back, /obj/item/storage/backpack))
var/obj/item/storage/backpack/B = user.back
SEND_SIGNAL(B, COMSIG_TRY_STORAGE_INSERT, src, user, FALSE, FALSE)
B.atom_storage?.attempt_insert(B, src, user)
uses_left--
if(uses_left <= 0)
user.transferItemToLoc(src, A, TRUE)
+8 -10
View File
@@ -449,20 +449,18 @@
/obj/item/shared_storage/red/Initialize(mapload)
. = ..()
var/datum/component/storage/STR = AddComponent(/datum/component/storage/concrete)
STR.max_w_class = WEIGHT_CLASS_NORMAL
STR.max_combined_w_class = 15
STR.max_items = 21
new /obj/item/shared_storage/blue(drop_location(), STR)
create_storage(max_total_storage = 15, max_slots = 21)
new /obj/item/shared_storage/blue(drop_location(), src)
/obj/item/shared_storage/blue/Initialize(mapload, datum/component/storage/concrete/master)
/obj/item/shared_storage/blue/Initialize(mapload, atom/master)
. = ..()
if(!istype(master))
return INITIALIZE_HINT_QDEL
var/datum/component/storage/STR = AddComponent(/datum/component/storage, master)
STR.max_w_class = WEIGHT_CLASS_NORMAL
STR.max_combined_w_class = 15
STR.max_items = 21
create_storage(max_total_storage = 15, max_slots = 21)
atom_storage.set_real_location(master)
//Book of Babel
+3 -5
View File
@@ -14,11 +14,9 @@
. = ..()
if(prob(20))
icon_state = "moneybagalt"
var/datum/component/storage/STR = GetComponent(/datum/component/storage)
STR.max_w_class = WEIGHT_CLASS_NORMAL
STR.max_items = 40
STR.max_combined_w_class = 40
STR.set_holdable(list(/obj/item/coin, /obj/item/stack/spacecash, /obj/item/holochip))
atom_storage.max_slots = 40
atom_storage.max_specific_storage = 40
atom_storage.set_holdable(list(/obj/item/coin, /obj/item/stack/spacecash, /obj/item/holochip))
/obj/item/storage/bag/money/vault/PopulateContents()
new /obj/item/coin/silver(src)
+2 -2
View File
@@ -12,8 +12,8 @@
/obj/structure/ore_box/attackby(obj/item/W, mob/user, params)
if (istype(W, /obj/item/stack/ore))
user.transferItemToLoc(W, src)
else if(SEND_SIGNAL(W, COMSIG_CONTAINS_STORAGE))
SEND_SIGNAL(W, COMSIG_TRY_STORAGE_TAKE_TYPE, /obj/item/stack/ore, src)
else if(W.atom_storage)
W.atom_storage.remove_type(/obj/item/stack/ore, src)
to_chat(user, span_notice("You empty the ore in [W] into \the [src]."))
else
return ..()