Canreach refactor (#93165)

## About The Pull Request
ports https://github.com/DaedalusDock/daedalusdock/pull/1144
ports https://github.com/DaedalusDock/daedalusdock/pull/1147

full credit to @Kapu1178 for the juice

instead of `reacher.CanReach(target)` we now do
`target.CanBeReachedBy(reacher)`, this allows us to give special
behavior to atoms which we want to reach, which is exactly what I need
for a feature I'm working on.
## Why It's Good For The Game
allows us to be more flexible with reachability
## Changelog
🆑
refactor: refactored how reaching items works, report any oddities with
being unable to reach something you should be able to!
/🆑
This commit is contained in:
die
2025-10-07 20:28:59 +02:00
committed by GitHub
parent c82cb1734d
commit 0204ab8fdd
69 changed files with 190 additions and 162 deletions
+1 -1
View File
@@ -92,7 +92,7 @@ LINEN BINS
return ITEM_INTERACT_SUCCESS
/obj/item/bedsheet/attack_self(mob/living/user)
if(!user.CanReach(src)) //No telekinetic grabbing.
if(!IsReachableBy(user)) //No telekinetic grabbing.
return
if(user.body_position != LYING_DOWN)
return
+3 -1
View File
@@ -174,13 +174,15 @@ GLOBAL_LIST_INIT(mystery_fishing, list(
/obj/structure/mystery_box/proc/generate_valid_types()
valid_types = get_sane_item_types(selectable_base_type)
/obj/structure/mystery_box/IsContainedAtomAccessible(atom/contained, atom/movable/user)
return TRUE
/// The box has been activated, play the sound and spawn the prop item
/obj/structure/mystery_box/proc/activate(mob/living/user)
box_state = MYSTERY_BOX_CHOOSING
update_icon_state()
presented_item = new(src)
presented_item.vis_flags = VIS_INHERIT_PLANE
presented_item.flags_1 |= IS_ONTOP_1
vis_contents += presented_item
presented_item.start_animation(src)
current_sound_channel = SSsounds.reserve_sound_channel(src)
+4 -4
View File
@@ -1145,7 +1145,7 @@
tool.play_tool_sound(src, 50)
balloon_alert(user, "mask detached")
UnregisterSignal(breath_mask, list(COMSIG_MOVABLE_MOVED, COMSIG_ITEM_DROPPED))
if (user.CanReach(breath_mask))
if (breath_mask.IsReachableBy(user))
user.put_in_hands(breath_mask)
breath_mask = null
update_appearance()
@@ -1160,7 +1160,7 @@
air_tank.forceMove(drop_location())
tool.play_tool_sound(src, 50)
balloon_alert(user, "tank detached")
if (user.CanReach(air_tank))
if (air_tank.IsReachableBy(user))
user.put_in_hands(air_tank)
if (patient?.external && patient.external == air_tank)
patient.close_externals()
@@ -1192,7 +1192,7 @@
. += span_notice("There's a port for a breathing mask tube on its side.")
/obj/structure/table/optable/proc/detach_mask(mob/living/user)
if (!istype(user) || !user.CanReach(src) || !user.can_interact_with(src))
if (!istype(user) || !IsReachableBy(user) || !user.can_interact_with(src))
return FALSE
if (!breath_mask)
@@ -1208,7 +1208,7 @@
return TRUE
/obj/structure/table/optable/mouse_drop_dragged(atom/over, mob/living/user, src_location, over_location, params)
if (over != patient || !istype(user) || !user.CanReach(src) || !user.can_interact_with(src))
if (over != patient || !istype(user) || !IsReachableBy(user) || !user.can_interact_with(src))
return
if (!air_tank)
@@ -165,7 +165,7 @@
grabbed_mob.adjustBruteLoss(5)
return
if(cistern_open && !cover_open && user.CanReach(src))
if(cistern_open && !cover_open && IsReachableBy(user))
if(!LAZYLEN(cistern_items))
to_chat(user, span_notice("The cistern is empty."))
return