diff --git a/code/modules/mob/living/silicon/ai/freelook/cameranet.dm b/code/modules/mob/living/silicon/ai/freelook/cameranet.dm index abf76999951..dc4fccfe837 100644 --- a/code/modules/mob/living/silicon/ai/freelook/cameranet.dm +++ b/code/modules/mob/living/silicon/ai/freelook/cameranet.dm @@ -67,16 +67,18 @@ GLOBAL_DATUM_INIT(cameranet, /datum/cameranet, new) for(var/mob/camera/ai_eye/eye as anything in moved_eyes) var/list/visibleChunks = list() + ///Get the eye's turf in case it's located in an object like a mecha + var/turf/eye_turf = get_turf(eye) if(eye.loc) var/static_range = eye.static_visibility_range - var/x1 = max(1, eye.x - static_range) - var/y1 = max(1, eye.y - static_range) - var/x2 = min(world.maxx, eye.x + static_range) - var/y2 = min(world.maxy, eye.y + static_range) + var/x1 = max(1, eye_turf.x - static_range) + var/y1 = max(1, eye_turf.y - static_range) + var/x2 = min(world.maxx, eye_turf.x + static_range) + var/y2 = min(world.maxy, eye_turf.y + static_range) for(var/x = x1; x <= x2; x += CHUNK_SIZE) for(var/y = y1; y <= y2; y += CHUNK_SIZE) - visibleChunks |= getCameraChunk(x, y, eye.z) + visibleChunks |= getCameraChunk(x, y, eye_turf.z) var/list/remove = eye.visibleCameraChunks - visibleChunks var/list/add = visibleChunks - eye.visibleCameraChunks diff --git a/code/modules/mob/living/silicon/ai/freelook/eye.dm b/code/modules/mob/living/silicon/ai/freelook/eye.dm index 8f20e3c79b4..8336d2eddb2 100644 --- a/code/modules/mob/living/silicon/ai/freelook/eye.dm +++ b/code/modules/mob/living/silicon/ai/freelook/eye.dm @@ -83,6 +83,12 @@ var/turf/upperright = locate(min(world.maxx, lowerleft.x + (view[1] - 1)), min(world.maxy, lowerleft.y + (view[2] - 1)), lowerleft.z) return block(lowerleft, upperright) +/// Used in cases when the eye is located in a movable object (i.e. mecha) +/mob/camera/ai_eye/proc/update_visibility() + SIGNAL_HANDLER + if(use_static) + ai.camera_visibility(src) + // Use this when setting the aiEye's location. // It will also stream the chunk that the new loc is in. diff --git a/code/modules/vehicles/mecha/mecha_ai_interaction.dm b/code/modules/vehicles/mecha/mecha_ai_interaction.dm index abe62a57755..1b1d88e2e87 100644 --- a/code/modules/vehicles/mecha/mecha_ai_interaction.dm +++ b/code/modules/vehicles/mecha/mecha_ai_interaction.dm @@ -98,7 +98,8 @@ AI.ai_restore_power() mecha_flags |= SILICON_PILOT moved_inside(AI) - AI.cancel_camera() + AI.eyeobj?.forceMove(src) + AI.eyeobj?.RegisterSignal(src, COMSIG_MOVABLE_MOVED, /mob/camera/ai_eye/proc/update_visibility) AI.controlled_equipment = src AI.remote_control = src to_chat(AI, AI.can_dominate_mechs ? span_greenannounce("Takeover of [name] complete! You are now loaded onto the onboard computer. Do not attempt to leave the station sector!") :\ diff --git a/code/modules/vehicles/mecha/mecha_mob_interaction.dm b/code/modules/vehicles/mecha/mecha_mob_interaction.dm index 28762ffbc24..b07d565a775 100644 --- a/code/modules/vehicles/mecha/mecha_mob_interaction.dm +++ b/code/modules/vehicles/mecha/mecha_mob_interaction.dm @@ -112,6 +112,9 @@ mob_container = brain.container else if(isAI(M)) var/mob/living/silicon/ai/AI = M + //stop listening to this signal, as the static update is now handled by the eyeobj's setLoc + AI.eyeobj?.UnregisterSignal(src, COMSIG_MOVABLE_MOVED) + AI.eyeobj?.forceMove(newloc) //kick the eye out as well if(forced)//This should only happen if there are multiple AIs in a round, and at least one is Malf. AI.gib() //If one Malf decides to steal a mech from another AI (even other Malfs!), they are destroyed, as they have nowhere to go when replaced. AI = null