From 5c87c3001acc57a26d4ce3d7718376af0e6c3e53 Mon Sep 17 00:00:00 2001 From: jack-fractal Date: Sat, 7 Dec 2013 16:34:24 -0500 Subject: [PATCH] modifying visibility interface of ai to use generic visibility_interface --- baystation12.dme | 6 + code/datums/visibility_networks/dictionary.dm | 2 +- code/defines/obj/weapon.dm | 2 +- .../gamemodes/malfunction/Malf_Modules.dm | 4 +- code/game/machinery/camera/camera.dm | 2 +- code/game/machinery/camera/tracking.dm | 2 +- code/game/machinery/computer/camera.dm | 2 +- code/modules/admin/verbs/mapping.dm | 4 +- code/modules/mob/living/silicon/ai/ai.dm | 6 +- .../living/silicon/ai/freelook/cameranet.dm | 160 ++------------- .../mob/living/silicon/ai/freelook/chunk.dm | 185 ++---------------- .../mob/living/silicon/ai/freelook/eye.dm | 9 +- .../mob/living/silicon/ai/freelook/read_me.dm | 2 +- .../silicon/ai/freelook/update_triggers.dm | 87 +------- .../ai/freelook/visibility_interface.dm | 10 + code/modules/mob/mob_defines.dm | 1 + 16 files changed, 75 insertions(+), 409 deletions(-) create mode 100644 code/modules/mob/living/silicon/ai/freelook/visibility_interface.dm diff --git a/baystation12.dme b/baystation12.dme index bfa7dff4dd6..7b14970feee 100644 --- a/baystation12.dme +++ b/baystation12.dme @@ -156,6 +156,11 @@ #include "code\datums\spells\trigger.dm" #include "code\datums\spells\turf_teleport.dm" #include "code\datums\spells\wizard.dm" +#include "code\datums\visibility_networks\chunk.dm" +#include "code\datums\visibility_networks\dictionary.dm" +#include "code\datums\visibility_networks\update_triggers.dm" +#include "code\datums\visibility_networks\visibility_interface.dm" +#include "code\datums\visibility_networks\visibility_network.dm" #include "code\defines\obj.dm" #include "code\defines\obj\hydro.dm" #include "code\defines\obj\weapon.dm" @@ -958,6 +963,7 @@ #include "code\modules\mob\living\silicon\ai\freelook\eye.dm" #include "code\modules\mob\living\silicon\ai\freelook\read_me.dm" #include "code\modules\mob\living\silicon\ai\freelook\update_triggers.dm" +#include "code\modules\mob\living\silicon\ai\freelook\visibility_interface.dm" #include "code\modules\mob\living\silicon\decoy\death.dm" #include "code\modules\mob\living\silicon\decoy\decoy.dm" #include "code\modules\mob\living\silicon\decoy\life.dm" diff --git a/code/datums/visibility_networks/dictionary.dm b/code/datums/visibility_networks/dictionary.dm index 3dcb1bc427f..2ca6843cd80 100644 --- a/code/datums/visibility_networks/dictionary.dm +++ b/code/datums/visibility_networks/dictionary.dm @@ -1,4 +1,4 @@ -var/datum/visibility_network/cameras/cameraNetwork = new() +var/datum/visibility_network/cameras/cameranet = new() var/datum/visibility_network/cult/cultNetwork = new() var/datum/visibility_network/list/visibility_networks = list("ALL_CAMERAS"=cameraNetwork, "CULT" = cultNetwork) diff --git a/code/defines/obj/weapon.dm b/code/defines/obj/weapon.dm index b84388f5838..e798f26c600 100644 --- a/code/defines/obj/weapon.dm +++ b/code/defines/obj/weapon.dm @@ -422,7 +422,7 @@ /obj/item/weapon/camera_bug/attack_self(mob/usr as mob) var/list/cameras = new/list() - for (var/obj/machinery/camera/C in cameranet.cameras) + for (var/obj/machinery/camera/C in cameranet.viewpoints) if (C.bugged && C.status) cameras.Add(C) if (length(cameras) == 0) diff --git a/code/game/gamemodes/malfunction/Malf_Modules.dm b/code/game/gamemodes/malfunction/Malf_Modules.dm index 104fbf1cdb7..81559bcfe35 100644 --- a/code/game/gamemodes/malfunction/Malf_Modules.dm +++ b/code/game/gamemodes/malfunction/Malf_Modules.dm @@ -122,7 +122,7 @@ rcd light flash thingy on matter drain mod_pick_name = "recam" uses = 10 -/client/proc/reactivate_camera(obj/machinery/camera/C as obj in cameranet.cameras) +/client/proc/reactivate_camera(obj/machinery/camera/C as obj in cameranet.viewpoints) set name = "Reactivate Camera" set category = "Malfunction" if (istype (C, /obj/machinery/camera)) @@ -143,7 +143,7 @@ rcd light flash thingy on matter drain mod_pick_name = "upgradecam" uses = 10 -/client/proc/upgrade_camera(obj/machinery/camera/C as obj in cameranet.cameras) +/client/proc/upgrade_camera(obj/machinery/camera/C as obj in cameranet.viewpoints) set name = "Upgrade Camera" set category = "Malfunction" if(istype(C)) diff --git a/code/game/machinery/camera/camera.dm b/code/game/machinery/camera/camera.dm index daea3219d6e..ddaa2829325 100644 --- a/code/game/machinery/camera/camera.dm +++ b/code/game/machinery/camera/camera.dm @@ -39,7 +39,7 @@ assembly = new(src) assembly.state = 4 /* // Use this to look for cameras that have the same c_tag. - for(var/obj/machinery/camera/C in cameranet.cameras) + for(var/obj/machinery/camera/C in cameranet.viewpoints) var/list/tempnetwork = C.network&src.network if(C != src && C.c_tag == src.c_tag && tempnetwork.len) world.log << "[src.c_tag] [src.x] [src.y] [src.z] conflicts with [C.c_tag] [C.x] [C.y] [C.z]" diff --git a/code/game/machinery/camera/tracking.dm b/code/game/machinery/camera/tracking.dm index e088103fabd..56a3a0bab34 100644 --- a/code/game/machinery/camera/tracking.dm +++ b/code/game/machinery/camera/tracking.dm @@ -4,7 +4,7 @@ return var/list/L = list() - for (var/obj/machinery/camera/C in cameranet.cameras) + for (var/obj/machinery/camera/C in cameranet.viewpoints) L.Add(C) camera_sort(L) diff --git a/code/game/machinery/computer/camera.dm b/code/game/machinery/computer/camera.dm index 05d0ccea8d6..8b50e6e54a4 100644 --- a/code/game/machinery/computer/camera.dm +++ b/code/game/machinery/computer/camera.dm @@ -36,7 +36,7 @@ user.set_machine(src) var/list/L = list() - for (var/obj/machinery/camera/C in cameranet.cameras) + for (var/obj/machinery/camera/C in cameranet.viewpoints) L.Add(C) camera_sort(L) diff --git a/code/modules/admin/verbs/mapping.dm b/code/modules/admin/verbs/mapping.dm index 76f1b420461..80f3f6a62d7 100644 --- a/code/modules/admin/verbs/mapping.dm +++ b/code/modules/admin/verbs/mapping.dm @@ -58,7 +58,7 @@ var/intercom_range_display_status = 0 del(C) if(camera_range_display_status) - for(var/obj/machinery/camera/C in cameranet.cameras) + for(var/obj/machinery/camera/C in cameranet.viewpoints) new/obj/effect/debugging/camera_range(C.loc) feedback_add_details("admin_verb","mCRD") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc! @@ -74,7 +74,7 @@ var/intercom_range_display_status = 0 var/list/obj/machinery/camera/CL = list() - for(var/obj/machinery/camera/C in cameranet.cameras) + for(var/obj/machinery/camera/C in cameranet.viewpoints) CL += C var/output = {"CAMERA ANNOMALITIES REPORT
diff --git a/code/modules/mob/living/silicon/ai/ai.dm b/code/modules/mob/living/silicon/ai/ai.dm index 42c4b0745b2..7632585775d 100644 --- a/code/modules/mob/living/silicon/ai/ai.dm +++ b/code/modules/mob/living/silicon/ai/ai.dm @@ -318,7 +318,7 @@ var/list/ai_list = list() unset_machine() src << browse(null, t1) if (href_list["switchcamera"]) - switchCamera(locate(href_list["switchcamera"])) in cameranet.cameras + switchCamera(locate(href_list["switchcamera"])) in cameranet.viewpoints if (href_list["showalerts"]) ai_alerts() //Carn: holopad requests @@ -548,7 +548,7 @@ var/list/ai_list = list() var/mob/living/silicon/ai/U = usr - for (var/obj/machinery/camera/C in cameranet.cameras) + for (var/obj/machinery/camera/C in cameranet.viewpoints) if(!C.can_use()) continue @@ -566,7 +566,7 @@ var/list/ai_list = list() if(isnull(network)) network = old_network // If nothing is selected else - for(var/obj/machinery/camera/C in cameranet.cameras) + for(var/obj/machinery/camera/C in cameranet.viewpoints) if(!C.can_use()) continue if(network in C.network) diff --git a/code/modules/mob/living/silicon/ai/freelook/cameranet.dm b/code/modules/mob/living/silicon/ai/freelook/cameranet.dm index 7d52fbd7a24..d857856b7fd 100644 --- a/code/modules/mob/living/silicon/ai/freelook/cameranet.dm +++ b/code/modules/mob/living/silicon/ai/freelook/cameranet.dm @@ -1,148 +1,14 @@ -// CAMERA NET -// -// The datum containing all the chunks. +/datum/visibility_network/cameras + ChunkType = /datum/visibility_chunk/camera -var/datum/cameranet/cameranet = new() - -/datum/cameranet - // The cameras on the map, no matter if they work or not. Updated in obj/machinery/camera.dm by New() and Del(). - var/list/cameras = list() - // The chunks of the map, mapping the areas that the cameras can see. - var/list/chunks = list() - var/ready = 0 - -// Checks if a chunk has been Generated in x, y, z. -/datum/cameranet/proc/chunkGenerated(x, y, z) - x &= ~0xf - y &= ~0xf - var/key = "[x],[y],[z]" - return (chunks[key]) - -// Returns the chunk in the x, y, z. -// If there is no chunk, it creates a new chunk and returns that. -/datum/cameranet/proc/getCameraChunk(x, y, z) - x &= ~0xf - y &= ~0xf - var/key = "[x],[y],[z]" - if(!chunks[key]) - chunks[key] = new /datum/camerachunk(null, x, y, z) - - return chunks[key] - -// Updates what the aiEye can see. It is recommended you use this when the aiEye moves or it's location is set. - -/datum/cameranet/proc/visibility(mob/aiEye/ai) - // 0xf = 15 - var/x1 = max(0, ai.x - 16) & ~0xf - var/y1 = max(0, ai.y - 16) & ~0xf - var/x2 = min(world.maxx, ai.x + 16) & ~0xf - var/y2 = min(world.maxy, ai.y + 16) & ~0xf - - var/list/visibleChunks = list() - - for(var/x = x1; x <= x2; x += 16) - for(var/y = y1; y <= y2; y += 16) - visibleChunks += getCameraChunk(x, y, ai.z) - - var/list/remove = ai.visibleCameraChunks - visibleChunks - var/list/add = visibleChunks - ai.visibleCameraChunks - - for(var/chunk in remove) - var/datum/camerachunk/c = chunk - c.remove(ai) - - for(var/chunk in add) - var/datum/camerachunk/c = chunk - c.add(ai) - -// Updates the chunks that the turf is located in. Use this when obstacles are destroyed or when doors open. - -/datum/cameranet/proc/updateVisibility(atom/A, var/opacity_check = 1) - - if(!ticker || (opacity_check && !A.opacity)) - return - majorChunkChange(A, 2) - -/datum/cameranet/proc/updateChunk(x, y, z) - // 0xf = 15 - if(!chunkGenerated(x, y, z)) - return - var/datum/camerachunk/chunk = getCameraChunk(x, y, z) - chunk.hasChanged() - -// Removes a camera from a chunk. - -/datum/cameranet/proc/removeCamera(obj/machinery/camera/c) - if(c.can_use()) - majorChunkChange(c, 0) - -// Add a camera to a chunk. - -/datum/cameranet/proc/addCamera(obj/machinery/camera/c) - if(c.can_use()) - majorChunkChange(c, 1) - -// Used for Cyborg cameras. Since portable cameras can be in ANY chunk. - -/datum/cameranet/proc/updatePortableCamera(obj/machinery/camera/c) - if(c.can_use()) - majorChunkChange(c, 1) - //else - // majorChunkChange(c, 0) - -// Never access this proc directly!!!! -// This will update the chunk and all the surrounding chunks. -// It will also add the atom to the cameras list if you set the choice to 1. -// Setting the choice to 0 will remove the camera from the chunks. -// If you want to update the chunks around an object, without adding/removing a camera, use choice 2. - -/datum/cameranet/proc/majorChunkChange(atom/c, var/choice) - // 0xf = 15 - if(!c) - return - - var/turf/T = get_turf(c) - if(T) - var/x1 = max(0, T.x - 8) & ~0xf - var/y1 = max(0, T.y - 8) & ~0xf - var/x2 = min(world.maxx, T.x + 8) & ~0xf - var/y2 = min(world.maxy, T.y + 8) & ~0xf - - //world << "X1: [x1] - Y1: [y1] - X2: [x2] - Y2: [y2]" - - for(var/x = x1; x <= x2; x += 16) - for(var/y = y1; y <= y2; y += 16) - if(chunkGenerated(x, y, T.z)) - var/datum/camerachunk/chunk = getCameraChunk(x, y, T.z) - if(choice == 0) - // Remove the camera. - chunk.cameras -= c - else if(choice == 1) - // You can't have the same camera in the list twice. - chunk.cameras |= c - chunk.hasChanged() - -// Will check if a mob is on a viewable turf. Returns 1 if it is, otherwise returns 0. - -/datum/cameranet/proc/checkCameraVis(mob/living/target as mob) - - // 0xf = 15 - var/turf/position = get_turf(target) - var/datum/camerachunk/chunk = getCameraChunk(position.x, position.y, position.z) - if(chunk) - if(chunk.changed) - chunk.hasChanged(1) // Update now, no matter if it's visible or not. - if(chunk.visibleTurfs[position]) - return 1 - return 0 - - -// Debug verb for VVing the chunk that the turf is in. -/* -/turf/verb/view_chunk() - set src in world - - if(cameranet.chunkGenerated(x, y, z)) - var/datum/camerachunk/chunk = cameranet.getCameraChunk(x, y, z) - usr.client.debug_variables(chunk) -*/ \ No newline at end of file +/datum/visibility_network/cameras/getViewpointFromMob(var/mob/currentMob) + var/mob/living/silicon/robot/currentRobot=currentMob + if(currentRobot) + return currentRobot.camera + return FALSE + +/datum/visibility_network/cameras/validViewpoint(var/viewpoint) + var/obj/machinery/camera/c = viewpoint + if (!c) + return FALSE + return c.can_use() \ No newline at end of file diff --git a/code/modules/mob/living/silicon/ai/freelook/chunk.dm b/code/modules/mob/living/silicon/ai/freelook/chunk.dm index 33dbfd09665..89c88c1aaff 100644 --- a/code/modules/mob/living/silicon/ai/freelook/chunk.dm +++ b/code/modules/mob/living/silicon/ai/freelook/chunk.dm @@ -1,168 +1,23 @@ -#define UPDATE_BUFFER 25 // 2.5 seconds - -// CAMERA CHUNK -// -// A 16x16 grid of the map with a list of turfs that can be seen, are visible and are dimmed. -// Allows the AI Eye to stream these chunks and know what it can and cannot see. - -/datum/camerachunk - var/list/obscuredTurfs = list() - var/list/visibleTurfs = list() - var/list/obscured = list() - var/list/cameras = list() - var/list/turfs = list() - var/list/seenby = list() - var/visible = 0 - var/changed = 0 - var/updating = 0 - var/x = 0 - var/y = 0 - var/z = 0 - -// Add an AI eye to the chunk, then update if changed. - -/datum/camerachunk/proc/add(mob/aiEye/ai) - if(!ai.ai) - return - ai.visibleCameraChunks += src - if(ai.ai.client) - ai.ai.client.images += obscured - visible++ - seenby += ai - if(changed && !updating) - update() - -// Remove an AI eye from the chunk, then update if changed. - -/datum/camerachunk/proc/remove(mob/aiEye/ai) - if(!ai.ai) - return - ai.visibleCameraChunks -= src - if(ai.ai.client) - ai.ai.client.images -= obscured - seenby -= ai - if(visible > 0) - visible-- - -// Called when a chunk has changed. I.E: A wall was deleted. - -/datum/camerachunk/proc/visibilityChanged(turf/loc) - if(!visibleTurfs[loc]) - return - hasChanged() - -// Updates the chunk, makes sure that it doesn't update too much. If the chunk isn't being watched it will -// instead be flagged to update the next time an AI Eye moves near it. - -/datum/camerachunk/proc/hasChanged(var/update_now = 0) - if(visible || update_now) - if(!updating) - updating = 1 - spawn(UPDATE_BUFFER) // Batch large changes, such as many doors opening or closing at once - update() - updating = 0 - else - changed = 1 - -// The actual updating. It gathers the visible turfs from cameras and puts them into the appropiate lists. - -/datum/camerachunk/proc/update() - - set background = 1 - - var/list/newVisibleTurfs = list() - - for(var/camera in cameras) - var/obj/machinery/camera/c = camera - - if(!c) - continue - - if(!c.can_use()) - continue - - var/turf/point = locate(src.x + 8, src.y + 8, src.z) - if(get_dist(point, c) > 24) - continue - - for(var/turf/t in c.can_see()) - newVisibleTurfs[t] = t - - // Removes turf that isn't in turfs. - newVisibleTurfs &= turfs - - var/list/visAdded = newVisibleTurfs - visibleTurfs - var/list/visRemoved = visibleTurfs - newVisibleTurfs - - visibleTurfs = newVisibleTurfs - obscuredTurfs = turfs - newVisibleTurfs - - for(var/turf in visAdded) - var/turf/t = turf - if(t.obscured) - obscured -= t.obscured - for(var/eye in seenby) - var/mob/aiEye/m = eye - if(!m || !m.ai) - continue - if(m.ai.client) - m.ai.client.images -= t.obscured - - for(var/turf in visRemoved) - var/turf/t = turf - if(obscuredTurfs[t]) - if(!t.obscured) - t.obscured = image('icons/effects/cameravis.dmi', t, "black", 15) - - obscured += t.obscured - for(var/eye in seenby) - var/mob/aiEye/m = eye - if(!m || !m.ai) - seenby -= m - continue - if(m.ai.client) - m.ai.client.images += t.obscured - -// Create a new camera chunk, since the chunks are made as they are needed. - -/datum/camerachunk/New(loc, x, y, z) - - // 0xf = 15 - x &= ~0xf - y &= ~0xf - - src.x = x - src.y = y - src.z = z +/datum/visibility_chunk/camera +/datum/visibility_chunk/camera/validViewpoint(var/viewpoint) + var/obj/machinery/camera/c = viewpoint + if(!c) + return FALSE + if(!c.can_use()) + return FALSE + var/turf/point = locate(src.x + 8, src.y + 8, src.z) + if(get_dist(point, c) > 24) + return FALSE + return TRUE + + +/datum/visibility_chunk/camera/getVisibleTurfsForViewpoint(var/viewpoint) + var/obj/machinery/camera/c = viewpoint + return c.can_see() + + +/datum/visibility_chunk/camera/findNearbyViewpoints() for(var/obj/machinery/camera/c in range(16, locate(x + 8, y + 8, z))) if(c.can_use()) - cameras += c - - for(var/turf/t in range(10, locate(x + 8, y + 8, z))) - if(t.x >= x && t.y >= y && t.x < x + 16 && t.y < y + 16) - turfs[t] = t - - for(var/camera in cameras) - var/obj/machinery/camera/c = camera - if(!c) - continue - - if(!c.can_use()) - continue - - for(var/turf/t in c.can_see()) - visibleTurfs[t] = t - - // Removes turf that isn't in turfs. - visibleTurfs &= turfs - - obscuredTurfs = turfs - visibleTurfs - - for(var/turf in obscuredTurfs) - var/turf/t = turf - if(!t.obscured) - t.obscured = image('icons/effects/cameravis.dmi', t, "black", 15) - obscured += t.obscured - -#undef UPDATE_BUFFER \ No newline at end of file + viewpoints += c \ No newline at end of file diff --git a/code/modules/mob/living/silicon/ai/freelook/eye.dm b/code/modules/mob/living/silicon/ai/freelook/eye.dm index c82fbb7c76d..351b9b60fa1 100644 --- a/code/modules/mob/living/silicon/ai/freelook/eye.dm +++ b/code/modules/mob/living/silicon/ai/freelook/eye.dm @@ -6,13 +6,16 @@ /mob/aiEye name = "Inactive AI Eye" icon = 'icons/obj/status_display.dmi' // For AI friend secret shh :o - var/list/visibleCameraChunks = list() var/mob/living/silicon/ai/ai = null density = 0 status_flags = GODMODE // You can't damage it. mouse_opacity = 0 see_in_dark = 7 +/mob/aiEye/New() + ..() + visibility_interface = new /datum/visibility_interface/ai_eye(src) + // Movement code. Returns 0 to stop air movement from moving it. /mob/aiEye/Move() return 0 @@ -37,7 +40,6 @@ // It will also stream the chunk that the new loc is in. /mob/aiEye/proc/setLoc(var/T) - if(ai) if(!isturf(ai.loc)) return @@ -136,7 +138,8 @@ if(client && client.eye) client.eye = src - for(var/datum/camerachunk/c in eyeobj.visibleCameraChunks) + + for(var/datum/visibility_chunk/camera/c in eyeobj.visibility_interface.visible_chunks) c.remove(eyeobj) /mob/living/silicon/ai/verb/toggle_acceleration() diff --git a/code/modules/mob/living/silicon/ai/freelook/read_me.dm b/code/modules/mob/living/silicon/ai/freelook/read_me.dm index 53e68ff1377..aa3d99bdba0 100644 --- a/code/modules/mob/living/silicon/ai/freelook/read_me.dm +++ b/code/modules/mob/living/silicon/ai/freelook/read_me.dm @@ -43,7 +43,7 @@ WHERE IS EVERYTHING? - cameranet.dm = Everything about the cameranet datum. + cameraNetwork.dm = Everything about the cameraNetwork datum. chunk.dm = Everything about the chunk datum. eye.dm = Everything about the AI and the AIEye. updating.dm = Everything about triggers that will update chunks. diff --git a/code/modules/mob/living/silicon/ai/freelook/update_triggers.dm b/code/modules/mob/living/silicon/ai/freelook/update_triggers.dm index c1f63313727..5a1f9c6e9b6 100644 --- a/code/modules/mob/living/silicon/ai/freelook/update_triggers.dm +++ b/code/modules/mob/living/silicon/ai/freelook/update_triggers.dm @@ -1,80 +1,5 @@ #define BORG_CAMERA_BUFFER 30 -//UPDATE TRIGGERS, when the chunk (and the surrounding chunks) should update. - -// TURFS - -/turf - var/image/obscured - -/turf/proc/visibilityChanged() - if(ticker) - cameranet.updateVisibility(src) - -/turf/simulated/Del() - visibilityChanged() - ..() - -/turf/simulated/New() - ..() - visibilityChanged() - - - -// STRUCTURES - -/obj/structure/Del() - if(ticker) - cameranet.updateVisibility(src) - ..() - -/obj/structure/New() - ..() - if(ticker) - cameranet.updateVisibility(src) - -// EFFECTS - -/obj/effect/Del() - if(ticker) - cameranet.updateVisibility(src) - ..() - -/obj/effect/New() - ..() - if(ticker) - cameranet.updateVisibility(src) - - -// DOORS - -// Simply updates the visibility of the area when it opens/closes/destroyed. -/obj/machinery/door/update_nearby_tiles(need_rebuild) - . = ..(need_rebuild) - // Glass door glass = 1 - // don't check then? - if(!glass && cameranet) - cameranet.updateVisibility(src, 0) - - -// ROBOT MOVEMENT - -// Update the portable camera everytime the Robot moves. -// This might be laggy, comment it out if there are problems. -/mob/living/silicon/robot/var/updating = 0 - -/mob/living/silicon/robot/Move() - var/oldLoc = src.loc - . = ..() - if(.) - if(src.camera && src.camera.network.len) - if(!updating) - updating = 1 - spawn(BORG_CAMERA_BUFFER) - if(oldLoc != src.loc) - cameranet.updatePortableCamera(src.camera) - updating = 0 - // CAMERA // An addition to deactivate which removes/adds the camera from the chunk list based on if it works or not. @@ -82,23 +7,23 @@ /obj/machinery/camera/deactivate(user as mob, var/choice = 1) ..(user, choice) if(src.can_use()) - cameranet.addCamera(src) + cameranet.addViewpoint(src) else src.SetLuminosity(0) - cameranet.removeCamera(src) + cameranet.removeViewpoint(src) /obj/machinery/camera/New() ..() - cameranet.cameras += src //Camera must be added to global list of all cameras no matter what... + cameranet.viewpoints += src //Camera must be added to global list of all cameras no matter what... var/list/open_networks = difflist(network,RESTRICTED_CAMERA_NETWORKS) //...but if all of camera's networks are restricted, it only works for specific camera consoles. if(open_networks.len) //If there is at least one open network, chunk is available for AI usage. - cameranet.addCamera(src) + cameranet.addViewpoint(src) /obj/machinery/camera/Del() - cameranet.cameras -= src + cameranet.viewpoints -= src var/list/open_networks = difflist(network,RESTRICTED_CAMERA_NETWORKS) if(open_networks.len) - cameranet.removeCamera(src) + cameranet.removeViewpoint(src) ..() #undef BORG_CAMERA_BUFFER \ No newline at end of file diff --git a/code/modules/mob/living/silicon/ai/freelook/visibility_interface.dm b/code/modules/mob/living/silicon/ai/freelook/visibility_interface.dm new file mode 100644 index 00000000000..b55598c6090 --- /dev/null +++ b/code/modules/mob/living/silicon/ai/freelook/visibility_interface.dm @@ -0,0 +1,10 @@ +/datum/visibility_interface/ai_eye + chunk_type = /datum/visibility_chunk/camera + +/datum/visibility_interface/ai_eye/getClient() + var/mob/aiEye/eye = controller + if (!eye) + return FALSE + if (!eye.ai) + return FALSE + return eye.ai.client diff --git a/code/modules/mob/mob_defines.dm b/code/modules/mob/mob_defines.dm index 85992e55fa7..c5ae21773b0 100644 --- a/code/modules/mob/mob_defines.dm +++ b/code/modules/mob/mob_defines.dm @@ -204,6 +204,7 @@ var/obj/control_object //Used by admins to possess objects. All mobs should have this var + var/datum/visibility_interface/visibility_interface = null // used by the visibility system to provide an interface for the visibility networks //Whether or not mobs can understand other mobtypes. These stay in /mob so that ghosts can hear everything. var/universal_speak = 0 // Set to 1 to enable the mob to speak to everyone -- TLE