mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-07-18 10:33:30 +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:
@@ -271,6 +271,10 @@ Remember to update _globalvars/traits.dm if you're adding/removing/renaming trai
|
||||
///An organ that was inserted into a dead mob, that has not been revived yet
|
||||
#define TRAIT_ORGAN_INSERTED_WHILE_DEAD "organ_inserted_while_dead"
|
||||
|
||||
///An /obj that should not increase the "depth" of the search for adjacency,
|
||||
///e.g. a storage container or a modsuit.
|
||||
#define TRAIT_ADJACENCY_TRANSPARENT "adjacency_transparent"
|
||||
|
||||
//
|
||||
// common trait sources
|
||||
#define TRAIT_GENERIC "generic"
|
||||
@@ -370,6 +374,6 @@ Remember to update _globalvars/traits.dm if you're adding/removing/renaming trai
|
||||
// turf trait sources
|
||||
#define FLOOR_EFFECT_TRAIT "floor_effect_trait"
|
||||
|
||||
//***** TURF TRAITS *****//
|
||||
//***** EFFECT TRAITS *****//
|
||||
// Causes the effect to go through a teleporter instead of being deleted by it.
|
||||
#define TRAIT_EFFECT_CAN_TELEPORT "trait_effect_can_teleport"
|
||||
|
||||
@@ -100,6 +100,10 @@ GLOBAL_LIST_INIT(traits_by_type, list(
|
||||
"TRAIT_NEVER_MISSES_DISPOSALS" = TRAIT_NEVER_MISSES_DISPOSALS
|
||||
),
|
||||
|
||||
/obj = list(
|
||||
"TRAIT_ADJACENCY_TRANSPARENT" = TRAIT_ADJACENCY_TRANSPARENT,
|
||||
),
|
||||
|
||||
/obj/item = list(
|
||||
"TRAIT_SHOW_WIRE_INFO" = TRAIT_SHOW_WIRE_INFO,
|
||||
"TRAIT_SUPERMATTER_IMMUNE" = TRAIT_SUPERMATTER_IMMUNE,
|
||||
@@ -111,9 +115,11 @@ GLOBAL_LIST_INIT(traits_by_type, list(
|
||||
"TRAIT_NO_THROWN_MESSAGE" = TRAIT_NO_THROWN_MESSAGE,
|
||||
"TRAIT_SILENT_INSERTION" = TRAIT_SILENT_INSERTION
|
||||
),
|
||||
|
||||
/turf = list(
|
||||
"bluespace_speed_trait" = TRAIT_BLUESPACE_SPEED
|
||||
),
|
||||
|
||||
/obj/effect = list(
|
||||
"TRAIT_EFFECT_CAN_TELEPORT" = TRAIT_EFFECT_CAN_TELEPORT
|
||||
)
|
||||
|
||||
@@ -64,20 +64,28 @@
|
||||
This is not used in stock /tg/station currently.
|
||||
*/
|
||||
/atom/movable/Adjacent(atom/neighbor)
|
||||
if(neighbor == loc) return 1
|
||||
if(!isturf(loc)) return 0
|
||||
if(neighbor == loc)
|
||||
return TRUE
|
||||
if(!isturf(loc))
|
||||
return FALSE
|
||||
for(var/turf/T in locs)
|
||||
if(isnull(T)) continue
|
||||
if(T.Adjacent(neighbor,src)) return 1
|
||||
return 0
|
||||
if(T.Adjacent(neighbor, src)) return TRUE
|
||||
return FALSE
|
||||
|
||||
// This is necessary for storage items not on your person.
|
||||
/obj/item/Adjacent(atom/neighbor, recurse = 1)
|
||||
if(neighbor == loc) return 1
|
||||
if(neighbor == loc)
|
||||
return TRUE
|
||||
if(!istype(neighbor))
|
||||
return ..()
|
||||
if(HAS_TRAIT(loc, TRAIT_ADJACENCY_TRANSPARENT))
|
||||
// Transparent parent, don't decrease recurse.
|
||||
return loc.Adjacent(neighbor, recurse)
|
||||
if(isitem(loc) || isstructure(loc) || isvehicle(loc))
|
||||
if(recurse > 0)
|
||||
return loc.Adjacent(neighbor,recurse - 1)
|
||||
return 0
|
||||
return loc.Adjacent(neighbor, recurse - 1)
|
||||
return FALSE
|
||||
return ..()
|
||||
|
||||
/*
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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