Updates AI UI handling to use the cameranet instead of the AI eye (#22745)

This PR tweaks an AI's can_use_remote_ui() proc to check for cameranet
visibility instead of distance to an AI's eye. This allows an AI to use
machines that aren't visible from the eye due to dense objects, but are
still visible from cameras. It also keeps the UI window open if the AI's
eye moves away, and closes the UI window if the viewing camera is
disabled or destroyed.

Fixes #22726
This commit is contained in:
Benjamin
2026-07-14 10:07:48 +00:00
committed by GitHub
parent 929cb9e6e0
commit 535a3f56e7
2 changed files with 65 additions and 21 deletions
+7 -21
View File
@@ -86,6 +86,11 @@
return UI_DISABLED
return ..()
/**
* Handles remote view for AIs.
* To open a UI, the AI needs to be able to see the source machine on cameras.
* If a camera is disabled while the AI is viewing a machine's UI, the UI closes.
*/
/mob/living/silicon/ai/proc/can_use_remote_ui(src_object)
if(src_object == src)
return TRUE
@@ -93,29 +98,10 @@
if(control_disabled || !istype(src_object, /atom))
return FALSE
var/atom/source = src_object
var/atom/interaction_source = eyeobj || src
var/turf/interaction_turf = get_turf(interaction_source)
var/turf/source_turf = get_turf(source)
if(!interaction_turf || !source_turf || interaction_turf.z != source_turf.z)
return FALSE
var/view_setting = world.view
if(client)
view_setting = client.view
var/list/clientviewlist = getviewsize(view_setting)
var/x_range = round((clientviewlist[1] - 1) / 2)
var/y_range = round((clientviewlist[2] - 1) / 2)
if(!IsInRange(source_turf.x, interaction_turf.x - x_range, interaction_turf.x + x_range))
return FALSE
if(!IsInRange(source_turf.y, interaction_turf.y - y_range, interaction_turf.y + y_range))
return FALSE
return can_see(interaction_source, source, max(x_range, y_range))
return GLOB.cameranet.is_visible(src_object)
/// Disable UIs if the object isn't installed in the borg AND the borg has a dead cell, or no cell.
/mob/living/silicon/robot/shared_ui_interaction(src_object)
// Disable UIs if the object isn't installed in the borg AND the borg has a dead cell, or no cell.
var/atom/device = src_object
if((istype(device) && device.loc != src) && (!cell || cell.charge <= 0))
return UI_DISABLED