From 89fd8c6454ca8669929db78177d49e2c999487bf Mon Sep 17 00:00:00 2001 From: warriorstar-orion Date: Wed, 18 Sep 2024 12:56:33 -0400 Subject: [PATCH] refactor: ore bag pickup (#26699) --- .../game/turfs/simulated/floor/asteroid_floors.dm | 15 ++++++++++----- code/modules/mining/ores_coins.dm | 3 ++- code/modules/mining/satchel_ore_boxdm.dm | 1 - 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/code/game/turfs/simulated/floor/asteroid_floors.dm b/code/game/turfs/simulated/floor/asteroid_floors.dm index d4f98500c549..44021a067a0d 100644 --- a/code/game/turfs/simulated/floor/asteroid_floors.dm +++ b/code/game/turfs/simulated/floor/asteroid_floors.dm @@ -58,6 +58,15 @@ if(1) getDug() +/turf/simulated/floor/plating/asteroid/proc/attempt_ore_pickup(obj/item/storage/bag/ore/S, mob/user) + if(!istype(S)) + return + + if(S.pickup_all_on_tile) + for(var/obj/item/stack/ore/O in contents) + O.attackby(S, user) + return + /turf/simulated/floor/plating/asteroid/attackby(obj/item/I, mob/user, params) //note that this proc does not call ..() if(!I|| !user) @@ -82,11 +91,7 @@ return TRUE else if(istype(I, /obj/item/storage/bag/ore)) - var/obj/item/storage/bag/ore/S = I - if(S.pickup_all_on_tile) - for(var/obj/item/stack/ore/O in contents) - O.attackby(I, user) - return + attempt_ore_pickup(I, user) else if(istype(I, /obj/item/stack/tile)) var/obj/item/stack/tile/Z = I diff --git a/code/modules/mining/ores_coins.dm b/code/modules/mining/ores_coins.dm index fd4b2a3885ea..f4f0ed7cae9b 100644 --- a/code/modules/mining/ores_coins.dm +++ b/code/modules/mining/ores_coins.dm @@ -51,7 +51,8 @@ OB = thing break if(OB && istype(F, /turf/simulated/floor/plating/asteroid)) - F.attackby(OB, AM) + var/turf/simulated/floor/plating/asteroid/FA = F + FA.attempt_ore_pickup(OB, AM) // Then, if the user is dragging an ore box, empty the satchel // into the box. var/mob/living/L = AM diff --git a/code/modules/mining/satchel_ore_boxdm.dm b/code/modules/mining/satchel_ore_boxdm.dm index 92ed05e83c2a..3ff5be8c1a18 100644 --- a/code/modules/mining/satchel_ore_boxdm.dm +++ b/code/modules/mining/satchel_ore_boxdm.dm @@ -19,7 +19,6 @@ S.hide_from(usr) for(var/obj/item/stack/ore/O in S.contents) S.remove_from_storage(O, src) //This will move the item to this item's contents - CHECK_TICK to_chat(user, "You empty the satchel into the box.") else return ..()