From be93f20599538e3582e8622088f08c769a91bdc3 Mon Sep 17 00:00:00 2001 From: spookerton Date: Mon, 14 Nov 2022 11:35:26 +0000 Subject: [PATCH] storage gets LateInitializeName LateInitializeName allows storage items to set their name flexibly after normal initialization is completed, allowing it to be based on holder, contents, location, etc. Also hoisted storage/internal/Destroy to its rightful place. --- .../objects/items/weapons/storage/internal.dm | 22 ++++++++++++------- .../objects/items/weapons/storage/storage.dm | 10 +++++++++ 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/code/game/objects/items/weapons/storage/internal.dm b/code/game/objects/items/weapons/storage/internal.dm index 4e37c50928..3d84dd9475 100644 --- a/code/game/objects/items/weapons/storage/internal.dm +++ b/code/game/objects/items/weapons/storage/internal.dm @@ -4,18 +4,24 @@ preserve_item = 1 var/atom/movable/master_atom -/obj/item/storage/internal/Initialize() - . = ..() - master_atom = loc - if(!istype(master_atom)) - return INITIALIZE_HINT_QDEL - loc = master_atom - name = master_atom.name - verbs -= /obj/item/verb/verb_pickup //make sure this is never picked up. /obj/item/storage/internal/Destroy() master_atom = null + return ..() + + +/obj/item/storage/internal/Initialize() . = ..() + master_atom = loc + if (!istype(master_atom)) + return INITIALIZE_HINT_QDEL + loc = master_atom + verbs -= /obj/item/verb/verb_pickup + + +/obj/item/storage/internal/LateInitializeName() + name = master_atom.name + /obj/item/storage/internal/attack_hand() return //make sure this is never picked up diff --git a/code/game/objects/items/weapons/storage/storage.dm b/code/game/objects/items/weapons/storage/storage.dm index d06eb6a109..74526d373f 100644 --- a/code/game/objects/items/weapons/storage/storage.dm +++ b/code/game/objects/items/weapons/storage/storage.dm @@ -96,6 +96,11 @@ new newtype (src) starts_with = null calibrate_size() + return INITIALIZE_HINT_LATELOAD + + +/obj/item/storage/LateInitialize() + LateInitializeName() /obj/item/storage/MouseDrop(obj/over_object as obj) @@ -666,6 +671,11 @@ max_w_class = max(I.w_class, max_w_class) max_storage_space += I.get_storage_cost() + +/obj/item/storage/proc/LateInitializeName() + return + + /* * Trinket Box - READDING SOON */