mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-07-20 19:44:09 +01:00
Slightly refactors storage item insertion (#24429)
* everything is on fire * silent trait check * how did it even become CRLF * minor formatting * fix icon updating and adds silent insertion to global trait list * adds the new parameter to documentation - whoops! * pain * contra review * contra review again, reduces amount of checks for user in the loops --------- Co-authored-by: cybercapitalism <98280110+cybercapitalism@users.noreply.github.com>
This commit is contained in:
@@ -454,7 +454,7 @@
|
||||
|
||||
// The following three procs handle refusing access to contents if the duffel is zipped
|
||||
|
||||
/obj/item/storage/backpack/duffel/handle_item_insertion(obj/item/I, prevent_warning, bypass_zip = FALSE)
|
||||
/obj/item/storage/backpack/duffel/handle_item_insertion(obj/item/I, mob/user, prevent_warning, bypass_zip = FALSE)
|
||||
if(bypass_zip)
|
||||
return ..()
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@
|
||||
. = ..()
|
||||
update_weight()
|
||||
|
||||
/obj/item/storage/bag/trash/handle_item_insertion(obj/item/I, prevent_warning)
|
||||
/obj/item/storage/bag/trash/handle_item_insertion(obj/item/I, mob/user, prevent_warning)
|
||||
. = ..()
|
||||
update_weight()
|
||||
|
||||
@@ -273,7 +273,7 @@
|
||||
|
||||
|
||||
// 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)
|
||||
/obj/item/storage/bag/sheetsnatcher/handle_item_insertion(obj/item/W as obj, mob/user, prevent_warning = FALSE)
|
||||
var/obj/item/stack/sheet/S = W
|
||||
if(!istype(S)) return 0
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
belt_image.color = I.color
|
||||
. += belt_image
|
||||
|
||||
/obj/item/storage/belt/handle_item_insertion(obj/item/I, prevent_warning)
|
||||
/obj/item/storage/belt/handle_item_insertion(obj/item/I, mob/user, prevent_warning)
|
||||
. = ..()
|
||||
update_weight()
|
||||
|
||||
@@ -754,7 +754,7 @@
|
||||
else
|
||||
to_chat(user, "<span class='warning'>[src] is empty!</span>")
|
||||
|
||||
/obj/item/storage/belt/rapier/handle_item_insertion(obj/item/W, prevent_warning)
|
||||
/obj/item/storage/belt/rapier/handle_item_insertion(obj/item/W, mob/user, prevent_warning)
|
||||
if(!..())
|
||||
return
|
||||
playsound(src, 'sound/weapons/blade_sheath.ogg', 20)
|
||||
|
||||
@@ -423,20 +423,21 @@
|
||||
* This doesn't perform any checks of whether an item can be inserted. That's done by [/obj/item/storage/proc/can_be_inserted]
|
||||
* Arguments:
|
||||
* * obj/item/I - The item to be inserted
|
||||
* * mob/user - The mob performing the insertion
|
||||
* * prevent_warning - Stop the insertion message being displayed. Intended for cases when you are inserting multiple items at once.
|
||||
*/
|
||||
/obj/item/storage/proc/handle_item_insertion(obj/item/I, prevent_warning = FALSE)
|
||||
/obj/item/storage/proc/handle_item_insertion(obj/item/I, mob/user, prevent_warning = FALSE)
|
||||
if(!istype(I))
|
||||
return FALSE
|
||||
if(usr)
|
||||
if(!Adjacent(usr) && !isnewplayer(usr))
|
||||
if(user)
|
||||
if(!Adjacent(user) && !isnewplayer(user))
|
||||
return FALSE
|
||||
if(!usr.unEquip(I, silent = TRUE))
|
||||
if(!user.unEquip(I, silent = TRUE))
|
||||
return FALSE
|
||||
usr.update_icons() //update our overlays
|
||||
user.update_icons() //update our overlays
|
||||
if(QDELING(I))
|
||||
return FALSE
|
||||
if(silent)
|
||||
if(silent || HAS_TRAIT(I, TRAIT_SILENT_INSERTION))
|
||||
prevent_warning = TRUE
|
||||
I.forceMove(src)
|
||||
if(QDELING(I))
|
||||
@@ -447,25 +448,34 @@
|
||||
var/mob/M = _M
|
||||
if((M.s_active == src) && M.client)
|
||||
M.client.screen += I
|
||||
if(user)
|
||||
if(user.client && user.s_active != src)
|
||||
user.client.screen -= I
|
||||
I.dropped(user, TRUE)
|
||||
add_fingerprint(user)
|
||||
|
||||
if(usr)
|
||||
if(usr.client && usr.s_active != src)
|
||||
usr.client.screen -= I
|
||||
I.dropped(usr, TRUE)
|
||||
add_fingerprint(usr)
|
||||
if(!prevent_warning)
|
||||
// all mobs with clients attached, sans the item's user
|
||||
var/viewer_list = GLOB.player_list - user
|
||||
|
||||
if(!prevent_warning && !istype(I, /obj/item/gun/energy/kinetic_accelerator/crossbow))
|
||||
for(var/mob/M in viewers(usr, null))
|
||||
if(M == usr)
|
||||
to_chat(usr, "<span class='notice'>You put [I] into [src].</span>")
|
||||
else if(M in range(1)) //If someone is standing close enough, they can tell what it is...
|
||||
M.show_message("<span class='notice'>[usr] puts [I] into [src].</span>")
|
||||
else if(I && I.w_class >= WEIGHT_CLASS_NORMAL) //Otherwise they can only see large or normal items from a distance...
|
||||
M.show_message("<span class='notice'>[usr] puts [I] into [src].</span>")
|
||||
// the item's user will always get a notification
|
||||
to_chat(user, "<span class='notice'>You put [I] into [src].</span>")
|
||||
|
||||
// if the item less than normal sized, only people within 1 tile get the message, otherwise, everybody in view gets it
|
||||
if(I.w_class < WEIGHT_CLASS_NORMAL)
|
||||
for(var/mob/M in viewer_list)
|
||||
if(in_range(M, user))
|
||||
M.show_message("<span class='notice'>[user] puts [I] into [src].</span>")
|
||||
else
|
||||
// restrict player list to include only those in view
|
||||
viewer_list = viewer_list & viewers(world.view, user)
|
||||
for(var/mob/M in viewer_list)
|
||||
M.show_message("<span class='notice'>[user] puts [I] into [src].</span>")
|
||||
|
||||
orient2hud(user)
|
||||
if(user.s_active)
|
||||
user.s_active.show_to(user)
|
||||
|
||||
orient2hud(usr)
|
||||
if(usr.s_active)
|
||||
usr.s_active.show_to(usr)
|
||||
I.mouse_opacity = MOUSE_OPACITY_OPAQUE //So you can click on the area around the item to equip it, instead of having to pixel hunt
|
||||
I.in_inventory = TRUE
|
||||
update_icon()
|
||||
@@ -545,7 +555,7 @@
|
||||
return TRUE
|
||||
return FALSE
|
||||
|
||||
handle_item_insertion(I)
|
||||
handle_item_insertion(I, user)
|
||||
|
||||
/obj/item/storage/attack_hand(mob/user)
|
||||
if(ishuman(user))
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
if(. && istype(I, /obj/item/card/id))
|
||||
refresh_ID()
|
||||
|
||||
/obj/item/storage/wallet/handle_item_insertion(obj/item/I, prevent_warning = FALSE)
|
||||
/obj/item/storage/wallet/handle_item_insertion(obj/item/I, mob/user, prevent_warning = FALSE)
|
||||
. = ..()
|
||||
if(. && istype(I, /obj/item/card/id))
|
||||
refresh_ID()
|
||||
|
||||
@@ -928,7 +928,7 @@
|
||||
var/obj/item/storage/bag/trash/bag = jani_vehicle?.mybag || jani_cart?.mybag
|
||||
var/obj/trashed_into
|
||||
if(bag?.can_be_inserted(garbage, TRUE))
|
||||
bag.handle_item_insertion(garbage, TRUE)
|
||||
bag.handle_item_insertion(garbage, user, TRUE)
|
||||
trashed_into = bag
|
||||
else if(target_bin)
|
||||
move_into_storage(user, target_bin, garbage)
|
||||
|
||||
Reference in New Issue
Block a user