mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-07-14 08:34:16 +01:00
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:
@@ -8,6 +8,7 @@
|
||||
pockets.storage_slots = 2 //two slots
|
||||
pockets.max_w_class = WEIGHT_CLASS_SMALL //fit only pocket sized items
|
||||
pockets.max_combined_w_class = 4
|
||||
ADD_TRAIT(src, TRAIT_ADJACENCY_TRANSPARENT, ROUNDSTART_TRAIT)
|
||||
|
||||
/obj/item/clothing/suit/storage/Destroy()
|
||||
QDEL_NULL(pockets)
|
||||
@@ -25,15 +26,9 @@
|
||||
..()
|
||||
pockets?.update_viewers()
|
||||
|
||||
/obj/item/clothing/suit/storage/forceMove(atom/destination)
|
||||
/obj/item/clothing/suit/storage/Moved(atom/oldloc, dir, forced = FALSE)
|
||||
. = ..()
|
||||
if(ismob(destination.loc) || isnull(pockets))
|
||||
return
|
||||
|
||||
for(var/mob/player in pockets.mobs_viewing)
|
||||
if(player == destination)
|
||||
continue
|
||||
pockets.hide_from(player)
|
||||
pockets?.update_viewers()
|
||||
|
||||
/obj/item/clothing/suit/storage/AltClick(mob/user)
|
||||
if(ishuman(user) && Adjacent(user) && !user.incapacitated(FALSE, TRUE))
|
||||
@@ -43,6 +38,12 @@
|
||||
if(isobserver(user))
|
||||
pockets?.show_to(user)
|
||||
|
||||
/obj/item/clothing/suit/storage/attack_ghost(mob/user)
|
||||
if(isobserver(user))
|
||||
// Revenants don't get to play with the toys.
|
||||
pockets.show_to(user)
|
||||
return ..()
|
||||
|
||||
/obj/item/clothing/suit/storage/attackby(obj/item/W as obj, mob/user as mob, params)
|
||||
..()
|
||||
return pockets?.attackby(W, user, params)
|
||||
|
||||
@@ -6,6 +6,11 @@
|
||||
desc = "Somehow, it's in two places at once."
|
||||
max_combined_w_class = 60
|
||||
max_w_class = WEIGHT_CLASS_NORMAL
|
||||
var/obj/item/shared_storage/red
|
||||
var/obj/item/shared_storage/blue
|
||||
|
||||
/obj/item/storage/backpack/shared/Adjacent(atom/neighbor, recurse = 1)
|
||||
return red?.Adjacent(neighbor, recurse) || blue?.Adjacent(neighbor, recurse)
|
||||
|
||||
//External
|
||||
/obj/item/shared_storage
|
||||
@@ -17,6 +22,10 @@
|
||||
resistance_flags = INDESTRUCTIBLE
|
||||
var/obj/item/storage/backpack/shared/bag
|
||||
|
||||
/obj/item/shared_storage/Moved(atom/oldloc, dir, forced = FALSE)
|
||||
. = ..()
|
||||
bag?.update_viewers()
|
||||
|
||||
/obj/item/shared_storage/red
|
||||
name = "paradox bag"
|
||||
desc = "Somehow, it's in two places at once."
|
||||
@@ -29,19 +38,27 @@
|
||||
|
||||
bag = S
|
||||
blue.bag = S
|
||||
bag.red = src
|
||||
bag.blue = blue
|
||||
|
||||
/obj/item/shared_storage/Initialize()
|
||||
. = ..()
|
||||
ADD_TRAIT(src, TRAIT_ADJACENCY_TRANSPARENT, ROUNDSTART_TRAIT)
|
||||
|
||||
/obj/item/shared_storage/attackby(obj/item/W, mob/user, params)
|
||||
if(bag)
|
||||
bag.loc = user
|
||||
bag.attackby(W, user, params)
|
||||
bag?.attackby(W, user, params)
|
||||
|
||||
/obj/item/shared_storage/attack_ghost(mob/user)
|
||||
if(isobserver(user))
|
||||
// Revenants don't get to play with the toys.
|
||||
bag?.show_to(user)
|
||||
return ..()
|
||||
|
||||
/obj/item/shared_storage/attack_self(mob/living/carbon/user)
|
||||
if(!iscarbon(user))
|
||||
return
|
||||
if(src == user.l_hand || src == user.r_hand)
|
||||
if(bag)
|
||||
bag.loc = user
|
||||
bag.attack_hand(user)
|
||||
bag?.open(user)
|
||||
else
|
||||
..()
|
||||
|
||||
@@ -49,12 +66,17 @@
|
||||
if(!iscarbon(user))
|
||||
return
|
||||
if(loc == user && user.back && user.back == src)
|
||||
if(bag)
|
||||
bag.loc = user
|
||||
bag.attack_hand(user)
|
||||
bag?.open(user)
|
||||
else
|
||||
..()
|
||||
|
||||
/obj/item/shared_storage/AltClick(mob/user)
|
||||
if(ishuman(user) && Adjacent(user) && !user.incapacitated(FALSE, TRUE))
|
||||
bag?.open(user)
|
||||
add_fingerprint(user)
|
||||
else if(isobserver(user))
|
||||
bag?.show_to(user)
|
||||
|
||||
/obj/item/shared_storage/MouseDrop(atom/over_object)
|
||||
if(iscarbon(usr))
|
||||
var/mob/M = usr
|
||||
@@ -72,9 +94,8 @@
|
||||
if(!M.unEquip(src))
|
||||
return
|
||||
M.put_in_active_hand(src)
|
||||
else if(bag)
|
||||
bag.loc = usr
|
||||
bag.attack_hand(usr)
|
||||
else
|
||||
bag?.open(usr)
|
||||
|
||||
add_fingerprint(M)
|
||||
|
||||
|
||||
@@ -158,6 +158,7 @@
|
||||
for(var/obj/item/mod/module/module as anything in theme.inbuilt_modules)
|
||||
module = new module(src)
|
||||
install(module)
|
||||
ADD_TRAIT(src, TRAIT_ADJACENCY_TRANSPARENT, ROUNDSTART_TRAIT)
|
||||
|
||||
/obj/item/mod/control/Destroy()
|
||||
if(active)
|
||||
@@ -256,7 +257,7 @@
|
||||
/obj/item/mod/control/MouseDrop(atom/over_object)
|
||||
if(iscarbon(usr))
|
||||
var/mob/M = usr
|
||||
if(get_dist(usr, src) > 1) //1 as we want to access it if beside the user
|
||||
if(!Adjacent(usr, src))
|
||||
return
|
||||
|
||||
if(!over_object)
|
||||
@@ -277,9 +278,8 @@
|
||||
if(!M.unEquip(src, silent = TRUE))
|
||||
return
|
||||
M.put_in_active_hand(src)
|
||||
else if(bag)
|
||||
bag.forceMove(usr)
|
||||
bag.show_to(usr)
|
||||
else
|
||||
bag?.open(usr)
|
||||
|
||||
add_fingerprint(M)
|
||||
|
||||
@@ -400,7 +400,6 @@
|
||||
else if(istype(attacking_item, /obj/item/mod/skin_applier))
|
||||
return ..()
|
||||
else if(bag && istype(attacking_item))
|
||||
bag.forceMove(user)
|
||||
bag.attackby(attacking_item, user, params)
|
||||
|
||||
return ..()
|
||||
@@ -409,18 +408,22 @@
|
||||
if(!iscarbon(user))
|
||||
return
|
||||
if(loc == user && user.back && user.back == src)
|
||||
if(bag)
|
||||
bag.forceMove(user)
|
||||
bag.show_to(user)
|
||||
bag?.open(user)
|
||||
else
|
||||
..()
|
||||
|
||||
/obj/item/mod/control/AltClick(mob/user)
|
||||
if(ishuman(user) && Adjacent(user) && !user.incapacitated(FALSE, TRUE) && bag)
|
||||
bag.forceMove(user)
|
||||
bag.show_to(user)
|
||||
playsound(loc, "rustle", 50, TRUE, -5)
|
||||
if(ishuman(user) && Adjacent(user) && !user.incapacitated(FALSE, TRUE))
|
||||
bag?.open(user)
|
||||
add_fingerprint(user)
|
||||
else if(isobserver(user))
|
||||
bag?.show_to(user)
|
||||
|
||||
/obj/item/mod/control/attack_ghost(mob/user)
|
||||
if(isobserver(user))
|
||||
// Revenants don't get to play with the toys.
|
||||
bag?.show_to(user)
|
||||
return ..()
|
||||
|
||||
/obj/item/mod/control/proc/can_be_inserted(I, stop_messages)
|
||||
if(bag)
|
||||
@@ -774,3 +777,7 @@
|
||||
. = ..()
|
||||
for(var/obj/item/mod/module/module as anything in modules)
|
||||
module.extinguish_light(force)
|
||||
|
||||
/obj/item/mod/control/Moved(atom/oldloc, dir, forced = FALSE)
|
||||
. = ..()
|
||||
bag?.update_viewers()
|
||||
|
||||
@@ -16,6 +16,10 @@
|
||||
var/max_items = 7
|
||||
var/obj/item/storage/backpack/modstorage/bag
|
||||
|
||||
/obj/item/mod/module/storage/Initialize()
|
||||
. = ..()
|
||||
ADD_TRAIT(src, TRAIT_ADJACENCY_TRANSPARENT, ROUNDSTART_TRAIT)
|
||||
|
||||
/obj/item/mod/module/storage/serialize()
|
||||
var/list/data = ..()
|
||||
data["bag"] = bag.serialize()
|
||||
@@ -35,34 +39,24 @@
|
||||
bag.max_combined_w_class = max_combined_w_class
|
||||
bag.storage_slots = max_items
|
||||
bag.source = src
|
||||
bag.forceMove(src)
|
||||
|
||||
/obj/item/mod/module/storage/Destroy()
|
||||
QDEL_NULL(bag)
|
||||
return ..()
|
||||
|
||||
|
||||
/obj/item/mod/module/storage/on_install()
|
||||
mod.bag = bag
|
||||
bag.forceMove(mod)
|
||||
|
||||
/obj/item/mod/module/storage/on_uninstall(deleting = FALSE)
|
||||
if(!deleting)
|
||||
for(var/obj/I in bag.contents)
|
||||
I.forceMove(get_turf(loc))
|
||||
bag.forceMove(src)
|
||||
mod.bag = null
|
||||
return
|
||||
qdel(bag)
|
||||
UnregisterSignal(mod.chestplate, COMSIG_ITEM_PRE_UNEQUIP)
|
||||
|
||||
/obj/item/mod/module/storage/on_suit_deactivation(deleting)
|
||||
. = ..()
|
||||
bag.forceMove(src) //So the pinpointer doesnt lie.
|
||||
|
||||
/obj/item/mod/module/storage/on_unequip()
|
||||
. = ..()
|
||||
bag.forceMove(src)
|
||||
|
||||
/obj/item/mod/module/storage/large_capacity
|
||||
name = "MOD expanded storage module"
|
||||
desc = "Reverse engineered by Cybersun Industries from Donk Corporation designs, this system of hidden compartments \
|
||||
@@ -118,16 +112,6 @@
|
||||
STOP_PROCESSING(SSobj, src)
|
||||
return ..()
|
||||
|
||||
/obj/item/storage/backpack/modstorage/process()
|
||||
update_viewers()
|
||||
|
||||
/obj/item/storage/backpack/modstorage/update_viewers()
|
||||
for(var/_M in mobs_viewing)
|
||||
var/mob/M = _M
|
||||
if(!QDELETED(M) && M.s_active == src && (M in range(1, loc)) && (source.mod.loc == _M || (M in range(1, source.mod)))) //This ensures someone isn't taking it away from the mod unit
|
||||
continue
|
||||
hide_from(M)
|
||||
|
||||
|
||||
///Ion Jetpack - Lets the user fly freely through space using battery charge.
|
||||
/obj/item/mod/module/jetpack
|
||||
|
||||
Reference in New Issue
Block a user