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:
chuga-git
2024-03-24 18:41:07 +00:00
committed by GitHub
co-authored by cybercapitalism
parent 25848b6988
commit 19c0b70171
18 changed files with 84 additions and 67 deletions
+21 -21
View File
@@ -243,50 +243,50 @@
/obj/item/proc/equip_to_best_slot(mob/M)
if(src != M.get_active_hand())
to_chat(M, "<span class='warning'>You are not holding anything to equip!</span>")
return 0
return FALSE
if(M.equip_to_appropriate_slot(src))
if(M.hand)
M.update_inv_l_hand()
else
M.update_inv_r_hand()
return 1
return TRUE
if(M.s_active && M.s_active.can_be_inserted(src, 1)) //if storage active insert there
M.s_active.handle_item_insertion(src)
return 1
if(M.s_active && M.s_active.can_be_inserted(src, TRUE)) //if storage active insert there
M.s_active.handle_item_insertion(src, M)
return TRUE
var/obj/item/storage/S = M.get_inactive_hand()
if(istype(S) && S.can_be_inserted(src, 1)) //see if we have box in other hand
S.handle_item_insertion(src)
return 1
if(istype(S) && S.can_be_inserted(src, M, TRUE)) //see if we have box in other hand
S.handle_item_insertion(src, M)
return TRUE
S = M.get_item_by_slot(SLOT_HUD_WEAR_ID)
if(istype(S) && S.can_be_inserted(src, 1)) //else we put in a wallet
S.handle_item_insertion(src)
return 1
if(istype(S) && S.can_be_inserted(src, TRUE)) //else we put in a wallet
S.handle_item_insertion(src, M)
return TRUE
S = M.get_item_by_slot(SLOT_HUD_BELT)
if(istype(S) && S.can_be_inserted(src, 1)) //else we put in belt
S.handle_item_insertion(src)
return 1
if(istype(S) && S.can_be_inserted(src, TRUE)) //else we put in belt
S.handle_item_insertion(src, M)
return TRUE
var/obj/item/O = M.get_item_by_slot(SLOT_HUD_BACK) //else we put in backpack
if(istype(O, /obj/item/storage))
S = O
if(S.can_be_inserted(src, 1))
S.handle_item_insertion(src)
if(S.can_be_inserted(src, TRUE))
S.handle_item_insertion(src, M)
playsound(loc, "rustle", 50, TRUE, -5)
return 1
return TRUE
if(ismodcontrol(O))
var/obj/item/mod/control/C = O
if(C.can_be_inserted(src, 1))
C.handle_item_insertion(src)
if(C.can_be_inserted(src, TRUE))
C.handle_item_insertion(src, M)
playsound(loc, "rustle", 50, TRUE, -5)
return 1
return TRUE
to_chat(M, "<span class='warning'>You are unable to equip that!</span>")
return 0
return FALSE
/mob/proc/get_all_slots()
return list(wear_mask, back, l_hand, r_hand)