Cleans up the storage accessory attackby path and prevents double insertion of items into storage accessories.

This commit is contained in:
MistakeNot4892
2022-11-08 12:55:20 +11:00
parent 3584065199
commit 86a8fb4378
11 changed files with 73 additions and 78 deletions
+6 -6
View File
@@ -261,18 +261,18 @@
R.activate_module(src)
R.hud_used.update_robot_modules_display()
/obj/item/attackby(obj/item/W as obj, mob/user as mob)
/obj/item/attackby(obj/item/W, mob/user)
. = ..()
if(istype(W, /obj/item/storage))
if(!. && istype(W, /obj/item/storage))
var/obj/item/storage/S = W
if(S.use_to_pickup)
if(S.collection_mode) //Mode is set to collect all items
if(isturf(src.loc))
S.gather_all(src.loc, user)
else if(S.can_be_inserted(src))
S.handle_item_insertion(src)
return
return TRUE
if(S.can_be_inserted(src))
S.handle_item_insertion(src)
return TRUE
/obj/item/proc/talk_into(mob/M as mob, text)
return
+3 -4
View File
@@ -51,13 +51,12 @@
use(1, user)
// Generic use
/obj/item/attackby(obj/item/W as obj, mob/user as mob)
/obj/item/attackby(obj/item/W, mob/user)
if(istype(W, /obj/item/kit))
var/obj/item/kit/K = W
K.customize(src, user)
return
..()
return TRUE
return ..()
/// Ponchos specifically, but other accessories may eventually need this.
/// Consequence of snowflake-y teshari code.
@@ -242,7 +242,8 @@
// Modified handle_item_insertion. Would prefer not to, but...
/obj/item/storage/bag/sheetsnatcher/handle_item_insertion(obj/item/W as obj, prevent_warning = 0)
var/obj/item/stack/material/S = W
if(!istype(S)) return 0
if(!istype(S))
return FALSE
var/amount
var/inserted = 0
@@ -276,7 +277,7 @@
if(usr.s_active)
usr.s_active.show_to(usr)
update_icon()
return 1
return TRUE
// Sets up numbered display to show the stack size of each stored mineral
// NOTE: numbered display is turned off currently because it's broken
@@ -353,7 +353,8 @@
//The stop_warning parameter will stop the insertion message from being displayed. It is intended for cases where you are inserting multiple items at once,
//such as when picking up all the items on a tile with one click.
/obj/item/storage/proc/handle_item_insertion(obj/item/W as obj, prevent_warning = 0)
if(!istype(W)) return 0
if(!istype(W))
return FALSE
if(usr)
usr.remove_from_mob(W,target = src) //If given a target, handles forceMove()
@@ -382,7 +383,7 @@
W.on_enter_storage(src)
update_icon()
return 1
return TRUE
//Call this proc to handle the removal of an item from the storage item. The item will be moved to the atom sent as new_target
/obj/item/storage/proc/remove_from_storage(obj/item/W as obj, atom/new_location)
@@ -420,10 +421,14 @@
//This proc is called when you want to place an item into the storage item.
/obj/item/storage/attackby(obj/item/W as obj, mob/user as mob, silent)
..()
. = ..()
if(.)
return
//Robots can't interact with storage items.
if(isrobot(user))
return //Robots can't interact with storage items.
return FALSE
if(istype(W, /obj/item/lightreplacer))
var/obj/item/lightreplacer/LP = W
@@ -439,10 +444,10 @@
if(amt_inserted)
if (!silent)
to_chat(user, "You inserted [amt_inserted] light\s into \the [LP.name]. You have [LP.uses] light\s remaining.")
return
return TRUE
if(!can_be_inserted(W))
return
return FALSE
if(istype(W, /obj/item/tray))
var/obj/item/tray/T = W
@@ -450,14 +455,14 @@
if(prob(85))
if (!silent)
to_chat(user, "<span class='warning'>The tray won't fit in [src].</span>")
return
else
W.forceMove(get_turf(user))
if ((user.client && user.s_active != src))
user.client.screen -= W
W.dropped(user)
if (!silent)
to_chat(user, "<span class='warning'>God damn it!</span>")
return TRUE
W.forceMove(get_turf(user))
if ((user.client && user.s_active != src))
user.client.screen -= W
W.dropped(user)
if (!silent)
to_chat(user, "<span class='warning'>God damn it!</span>")
return TRUE
W.add_fingerprint(user)
return handle_item_insertion(W, silent)
@@ -56,11 +56,10 @@
/obj/item/storage/wallet/handle_item_insertion(obj/item/W as obj, prevent_warning = 0)
. = ..(W, prevent_warning)
if(.)
if(!front_id && istype(W, /obj/item/card/id))
front_id = W
name = "[name] ([front_id])"
update_icon()
if(. && !front_id && istype(W, /obj/item/card/id))
front_id = W
name = "[name] ([front_id])"
update_icon()
/obj/item/storage/wallet/update_icon()
cut_overlays()