diff --git a/code/_onclick/click.dm b/code/_onclick/click.dm index 5f0e7c9b22..58eabbdbcf 100644 --- a/code/_onclick/click.dm +++ b/code/_onclick/click.dm @@ -200,7 +200,7 @@ if (!target.loc) continue - if(!(SEND_SIGNAL(target.loc, COMSIG_ATOM_CANREACH, next) & COMPONENT_BLOCK_REACH)) + if(!(SEND_SIGNAL(target.loc, COMSIG_ATOM_CANREACH, next) & COMPONENT_BLOCK_REACH) && target.loc.canReachInto(src, ultimate_target, next, view_only, tool)) next += target.loc checking = next @@ -215,6 +215,10 @@ /mob/living/DirectAccess(atom/target) return ..() + GetAllContents() +//This is called reach into but it's called on the deepest things first so uh, make sure to account for that! +/atom/proc/canReachInto(atom/user, atom/target, list/next, view_only, obj/item/tool) + return TRUE + /atom/proc/AllowClick() return FALSE diff --git a/code/datums/components/storage/storage.dm b/code/datums/components/storage/storage.dm index ee9cff19c7..9f6ca0ffbb 100644 --- a/code/datums/components/storage/storage.dm +++ b/code/datums/components/storage/storage.dm @@ -96,6 +96,7 @@ RegisterSignal(parent, COMSIG_ITEM_PICKUP, .proc/signal_on_pickup) RegisterSignal(parent, COMSIG_MOVABLE_POST_THROW, .proc/close_all) + RegisterSignal(parent, COMSIG_MOVABLE_MOVED, .proc/check_views) RegisterSignal(parent, COMSIG_CLICK_ALT, .proc/on_alt_click) RegisterSignal(parent, COMSIG_MOUSEDROP_ONTO, .proc/mousedrop_onto) @@ -386,6 +387,11 @@ close(M) . = TRUE //returns TRUE if any mobs actually got a close(M) call +/datum/component/storage/proc/check_views() + for(var/mob/M in can_see_contents()) + if(!isobserver(M) && !M.CanReach(src, view_only = TRUE)) + close(M) + /datum/component/storage/proc/emp_act(datum/source, severity) if(emp_shielded) return diff --git a/code/game/objects/structures/crates_lockers/closets.dm b/code/game/objects/structures/crates_lockers/closets.dm index 8b0d410a72..172120861b 100644 --- a/code/game/objects/structures/crates_lockers/closets.dm +++ b/code/game/objects/structures/crates_lockers/closets.dm @@ -614,3 +614,6 @@ user.resting = FALSE togglelock(user) T1.visible_message("[user] dives into [src]!") + +/obj/structure/closet/canReachInto(atom/user, atom/target, list/next, view_only, obj/item/tool) + return ..() && opened diff --git a/code/modules/mob/inventory.dm b/code/modules/mob/inventory.dm index 760fb7a29f..e77a91332e 100644 --- a/code/modules/mob/inventory.dm +++ b/code/modules/mob/inventory.dm @@ -468,3 +468,6 @@ bodyparts += BP hand_bodyparts[i] = BP ..() //Don't redraw hands until we have organs for them + +/mob/canReachInto(atom/user, atom/target, list/next, view_only, obj/item/tool) + return ..() && (user == src)