Made storage nesting better, improved consistency between storage types. (#24699)

* Made storage nesting better, improved consistency between storage types.

* Out, er, space.

* Null safety is good.

* Apply suggestions from code review

Co-authored-by: Burzah <116982774+Burzah@users.noreply.github.com>

---------

Co-authored-by: Burzah <116982774+Burzah@users.noreply.github.com>
This commit is contained in:
Charlie Nolan
2024-04-10 18:59:43 +00:00
committed by GitHub
co-authored by Burzah
parent 94c93c2537
commit fe74786905
9 changed files with 104 additions and 65 deletions
@@ -23,14 +23,14 @@
)
/obj/item/storage/backpack/attackby(obj/item/W as obj, mob/user as mob, params)
if(in_range(user, src))
playsound(src.loc, "rustle", 50, 1, -5)
if(Adjacent(user))
playsound(src.loc, "rustle", 50, TRUE, -5)
return ..()
/obj/item/storage/backpack/examine(mob/user)
var/space_used = 0
. = ..()
if(in_range(user, src))
if(Adjacent(user))
for(var/obj/item/I in contents)
space_used += I.w_class
if(!space_used)
@@ -73,6 +73,8 @@
closer.plane = ABOVE_HUD_PLANE
orient2hud()
ADD_TRAIT(src, TRAIT_ADJACENCY_TRANSPARENT, ROUNDSTART_TRAIT)
/obj/item/storage/Destroy()
for(var/obj/O in contents)
O.mouse_opacity = initial(O.mouse_opacity)
@@ -232,9 +234,15 @@
/obj/item/storage/proc/update_viewers()
for(var/_M in mobs_viewing)
var/mob/M = _M
if(!QDELETED(M) && M.s_active == src && (M in range(1, loc)))
if(!QDELETED(M) && M.s_active == src && Adjacent(M))
continue
hide_from(M)
for(var/obj/item/storage/child in src)
child.update_viewers()
/obj/item/storage/Moved(atom/oldloc, dir, forced = FALSE)
. = ..()
update_viewers()
/obj/item/storage/proc/open(mob/user)
if(use_sound && isliving(user))