From 7e50d640dc726ab2eb56cfd524a209e1d69908ad Mon Sep 17 00:00:00 2001 From: Daeberdir <115735095+Daeberdir@users.noreply.github.com> Date: Wed, 19 Jun 2024 14:43:53 +0300 Subject: [PATCH] bugfix: AI internal camera & entertainment monitor overlays working properly. (#5203) * Done. * Now we can do things. * Cahem. * Global videocams list. Cute list for fast access to the videocams. Not so useful for now, but still. --- code/game/machinery/camera/camera.dm | 14 +++++++---- code/game/machinery/camera/camera_assembly.dm | 3 +-- code/game/machinery/camera/presets.dm | 10 ++++---- code/game/machinery/computer/camera.dm | 6 ++--- code/game/objects/items/devices/aicard.dm | 5 +--- code/modules/clothing/spacesuits/ert.dm | 12 ++++------ code/modules/mob/living/silicon/ai/ai.dm | 4 +--- .../mob/living/silicon/ai/freelook/chunk.dm | 23 ++++++++++++------- .../modules/mob/living/silicon/robot/robot.dm | 6 ++--- code/modules/paperwork/photography.dm | 18 +++++++-------- 10 files changed, 49 insertions(+), 52 deletions(-) diff --git a/code/game/machinery/camera/camera.dm b/code/game/machinery/camera/camera.dm index a4113e249fb..3a1bc3cb884 100644 --- a/code/game/machinery/camera/camera.dm +++ b/code/game/machinery/camera/camera.dm @@ -35,7 +35,7 @@ var/in_use_lights = 0 // TO BE IMPLEMENTED var/toggle_sound = 'sound/items/wirecutter.ogg' -/obj/machinery/camera/Initialize(mapload, list/networks, obj/item/camera_assembly/input_assembly) +/obj/machinery/camera/Initialize(mapload, list/network, c_tag, obj/item/camera_assembly/input_assembly) . = ..() wires = new(src) if(input_assembly) @@ -45,12 +45,16 @@ assembly.state = 4 assembly.set_anchored(TRUE) assembly.update_icon(UPDATE_ICON_STATE) + if(network) + src.network = network + if(c_tag) + src.c_tag = c_tag + GLOB.cameranet.cameras += src for(var/obj/item/upgrade as anything in assembly.upgrades) upgrade.camera_upgrade(src) - if(networks) - network = networks - var/list/tempnetwork = difflist(network, GLOB.restricted_camera_networks) + + var/list/tempnetwork = difflist(src.network, GLOB.restricted_camera_networks) if(tempnetwork.len) GLOB.cameranet.addCamera(src) else @@ -444,7 +448,7 @@ /obj/machinery/camera/portable //Cameras which are placed inside of things, such as helmets. var/turf/prev_turf -/obj/machinery/camera/portable/Initialize(mapload) +/obj/machinery/camera/portable/Initialize(mapload, list/network, c_tag, obj/item/camera_assembly/input_assembly) . = ..() assembly.state = 0 //These cameras are portable, and so shall be in the portable state if removed. assembly.set_anchored(FALSE) diff --git a/code/game/machinery/camera/camera_assembly.dm b/code/game/machinery/camera/camera_assembly.dm index 1624281fc8d..adb6fd2bc26 100644 --- a/code/game/machinery/camera/camera_assembly.dm +++ b/code/game/machinery/camera/camera_assembly.dm @@ -90,10 +90,9 @@ var/temptag = "[sanitize(camera_area.name)] ([rand(1, 999)])" input = strip_html(input(usr, "How would you like to name the camera?", "Set Camera Name", temptag)) state = ASSEMBLY_BUILT - var/obj/machinery/camera/C = new(loc, uniquelist(tempnetwork), src) + var/obj/machinery/camera/C = new(loc, uniquelist(tempnetwork), input, src) loc = C C.auto_turn() - C.c_tag = input for(var/i = 5; i >= 0; i -= 1) var/direct = input(user, "Direction?", "Assembling Camera", null) in list("LEAVE IT", "NORTH", "EAST", "SOUTH", "WEST" ) diff --git a/code/game/machinery/camera/presets.dm b/code/game/machinery/camera/presets.dm index 6aa4a19b42c..212769c4116 100644 --- a/code/game/machinery/camera/presets.dm +++ b/code/game/machinery/camera/presets.dm @@ -2,27 +2,27 @@ // EMP -/obj/machinery/camera/emp_proof/Initialize(mapload, list/networks, obj/item/camera_assembly/input_assembly) +/obj/machinery/camera/emp_proof/Initialize(mapload, list/network, c_tag, obj/item/camera_assembly/input_assembly) var/obj/item/camera_assembly/new_assembly = new(src) new_assembly.upgrades.Add(new /obj/item/stack/sheet/mineral/plasma(new_assembly)) . = ..(input_assembly = new_assembly) // X-RAY -/obj/machinery/camera/xray/Initialize(mapload, list/networks, obj/item/camera_assembly/input_assembly) +/obj/machinery/camera/xray/Initialize(mapload, list/network, c_tag, obj/item/camera_assembly/input_assembly) var/obj/item/camera_assembly/new_assembly = new(src) new_assembly.upgrades.Add(new /obj/item/analyzer(new_assembly)) . = ..(input_assembly = new_assembly) // MOTION -/obj/machinery/camera/motion/Initialize(mapload, list/networks, obj/item/camera_assembly/input_assembly) +/obj/machinery/camera/motion/Initialize(mapload, list/network, c_tag, obj/item/camera_assembly/input_assembly) var/obj/item/camera_assembly/new_assembly = new(src) new_assembly.upgrades.Add(new /obj/item/assembly/prox_sensor(new_assembly)) . = ..(input_assembly = new_assembly) // ALL UPGRADES -/obj/machinery/camera/all/Initialize(mapload, list/networks, obj/item/camera_assembly/input_assembly) +/obj/machinery/camera/all/Initialize(mapload, list/network, c_tag, obj/item/camera_assembly/input_assembly) var/obj/item/camera_assembly/new_assembly = new(src) new_assembly.upgrades.Add(new /obj/item/stack/sheet/mineral/plasma(new_assembly), new /obj/item/assembly/prox_sensor(new_assembly), new /obj/item/analyzer(new_assembly)) . = ..(input_assembly = new_assembly) @@ -32,7 +32,7 @@ var/number = 0 //camera number in area //This camera type automatically sets it's name to whatever the area that it's in is called. -/obj/machinery/camera/autoname/Initialize(mapload) +/obj/machinery/camera/autoname/Initialize(mapload, list/network, c_tag, obj/item/camera_assembly/input_assembly) . = ..() number = 1 var/area/A = get_area(src) diff --git a/code/game/machinery/computer/camera.dm b/code/game/machinery/computer/camera.dm index fa96d333bc0..a57aae63bb5 100644 --- a/code/game/machinery/computer/camera.dm +++ b/code/game/machinery/computer/camera.dm @@ -232,14 +232,12 @@ network = list("news") layer = 4 //becouse of plasma glass with layer = 3 circuit = /obj/item/circuitboard/camera/telescreen/entertainment - /// Icon utilised when feeds_on is true + /// Icon utilised when `GLOB.active_video_cameras` list have anything inside. var/icon_screen_on = "entertainment" - /// Used to detect how many video cameras are active - var/feeds_on = 0 /obj/machinery/computer/security/telescreen/entertainment/update_overlays() - icon_screen = feeds_on ? icon_screen_on : initial(icon_screen) + icon_screen = length(GLOB.active_video_cameras) ? icon_screen_on : initial(icon_screen) return ..() diff --git a/code/game/objects/items/devices/aicard.dm b/code/game/objects/items/devices/aicard.dm index 0b562c75987..4bbfa388c19 100644 --- a/code/game/objects/items/devices/aicard.dm +++ b/code/game/objects/items/devices/aicard.dm @@ -153,7 +153,4 @@ var/mob/living/silicon/ai/AI = locate() in src if(!AI) return - AI.builtInCamera = new /obj/machinery/camera/portable(AI) - AI.builtInCamera.c_tag = AI.name - AI.builtInCamera.network = list("SS13") - + AI.builtInCamera = new(AI, list("SS13"), AI.name) diff --git a/code/modules/clothing/spacesuits/ert.dm b/code/modules/clothing/spacesuits/ert.dm index 4a000c8c4f2..d21b931871a 100644 --- a/code/modules/clothing/spacesuits/ert.dm +++ b/code/modules/clothing/spacesuits/ert.dm @@ -7,7 +7,7 @@ item_color = "ert_commander" armor = list(melee = 45, bullet = 40, laser = 40, energy = 40, bomb = 25, bio = 100, rad = 100, fire = 100, acid = 80) resistance_flags = FIRE_PROOF - var/obj/machinery/camera/camera + var/obj/machinery/camera/portable/camera var/has_camera = TRUE strip_delay = 130 @@ -33,10 +33,8 @@ /obj/item/clothing/head/helmet/space/hardsuit/ert/proc/register_camera(mob/wearer) if(camera || !has_camera) return - camera = new /obj/machinery/camera(src) - camera.network = list("ERT") + camera = new(src, list("ERT"), wearer.name) GLOB.cameranet.removeCamera(camera) - camera.c_tag = wearer.name to_chat(wearer, "User scanned as [camera.c_tag]. Camera activated.") /obj/item/clothing/head/helmet/space/hardsuit/ert/examine(mob/user) @@ -372,7 +370,7 @@ flags_inv = HIDEMASK|HIDEHEADSETS|HIDEGLASSES armor = list(melee = 20, bullet = 20, laser = 20, energy = 15, bomb = 10, bio = 100, rad = 20, fire = 50, acid = 65) flash_protect = 0 - var/obj/machinery/camera/camera + var/obj/machinery/camera/portable/camera var/has_camera = TRUE species_restricted = list("exclude", SPECIES_WRYN, "lesser form", SPECIES_VOX) @@ -392,10 +390,8 @@ /obj/item/clothing/head/helmet/space/ert_eva_amber/proc/register_camera(mob/wearer) if(camera || !has_camera) return - camera = new /obj/machinery/camera(src) - camera.network = list("ERT") + camera = new(src, list("ERT"), wearer.name) GLOB.cameranet.removeCamera(camera) - camera.c_tag = wearer.name to_chat(wearer, "User scanned as [camera.c_tag]. Camera activated.") /obj/item/clothing/head/helmet/space/ert_eva_amber/examine(mob/user) diff --git a/code/modules/mob/living/silicon/ai/ai.dm b/code/modules/mob/living/silicon/ai/ai.dm index 98c2e243f5e..cec27079764 100644 --- a/code/modules/mob/living/silicon/ai/ai.dm +++ b/code/modules/mob/living/silicon/ai/ai.dm @@ -204,9 +204,7 @@ GLOBAL_LIST_INIT(ai_verbs_default, list( create_eye() - builtInCamera = new /obj/machinery/camera/portable(src) - builtInCamera.c_tag = name - builtInCamera.network = list("SS13") + builtInCamera = new(src, list("SS13"), name) GLOB.ai_list += src GLOB.shuttle_caller_list += src diff --git a/code/modules/mob/living/silicon/ai/freelook/chunk.dm b/code/modules/mob/living/silicon/ai/freelook/chunk.dm index 2ed6dd7d122..aa41d5677ef 100644 --- a/code/modules/mob/living/silicon/ai/freelook/chunk.dm +++ b/code/modules/mob/living/silicon/ai/freelook/chunk.dm @@ -135,14 +135,21 @@ for(var/z_level in lower_z to upper_z) var/list/local_cameras = list() - for(var/obj/machinery/camera/camera in urange(CHUNK_SIZE, locate(x + (CHUNK_SIZE / 2), y + (CHUNK_SIZE / 2), z_level))) - if(camera.can_use()) - local_cameras += camera - - for(var/mob/living/silicon/robot/sillycone in urange(CHUNK_SIZE, locate(x + (CHUNK_SIZE / 2), y + (CHUNK_SIZE / 2), z_level))) - if(sillycone.camera?.can_use()) - local_cameras += sillycone.camera - + for(var/maybe_camera in urange(CHUNK_SIZE, locate(x + (CHUNK_SIZE / 2), y + (CHUNK_SIZE / 2), z_level))) + if(istype(maybe_camera, /obj/machinery/camera)) + var/obj/machinery/camera/definetly_camera = maybe_camera + if(definetly_camera.can_use()) + local_cameras += definetly_camera + + else if(isrobot(maybe_camera)) + var/mob/living/silicon/robot/iron_cameraman = maybe_camera + if(iron_cameraman.camera?.can_use()) + local_cameras += iron_cameraman.camera + + else if(isAI(maybe_camera)) + var/mob/living/silicon/ai/TV_camera = maybe_camera + if(TV_camera.builtInCamera?.can_use()) + local_cameras += TV_camera.builtInCamera cameras["[z_level]"] = local_cameras var/image/mirror_from = GLOB.cameranet.obscured_images[GET_Z_PLANE_OFFSET(z_level) + 1] diff --git a/code/modules/mob/living/silicon/robot/robot.dm b/code/modules/mob/living/silicon/robot/robot.dm index 3c400330696..5db233afeae 100644 --- a/code/modules/mob/living/silicon/robot/robot.dm +++ b/code/modules/mob/living/silicon/robot/robot.dm @@ -42,7 +42,7 @@ GLOBAL_LIST_INIT(robot_verbs_default, list( var/obj/item/radio/borg/radio = null var/mob/living/silicon/ai/connected_ai = null var/obj/item/stock_parts/cell/cell = null - var/obj/machinery/camera/camera = null + var/obj/machinery/camera/portable/camera = null // Components are basically robot organs. var/list/components = list() @@ -156,9 +156,7 @@ GLOBAL_LIST_INIT(robot_verbs_default, list( faction += "syndicate" if(has_camera && !camera && !syndie) - camera = new /obj/machinery/camera(src) - camera.c_tag = real_name - camera.network = list("SS13","Robots") + camera = new(src, list("SS13", "Robots"), real_name) if(wires.is_cut(WIRE_BORG_CAMERA)) // 5 = BORG CAMERA camera.status = 0 diff --git a/code/modules/paperwork/photography.dm b/code/modules/paperwork/photography.dm index 9c3c5893336..1284a23eec3 100644 --- a/code/modules/paperwork/photography.dm +++ b/code/modules/paperwork/photography.dm @@ -565,6 +565,7 @@ GLOBAL_LIST_INIT(SpookyGhosts, list("ghost","shade","shade2","ghost-narsie","hor *video camera * ***************/ #define CAMERA_STATE_COOLDOWN 2 SECONDS +GLOBAL_LIST_EMPTY(active_video_cameras) /obj/item/videocam name = "video camera" @@ -577,13 +578,13 @@ GLOBAL_LIST_INIT(SpookyGhosts, list("ghost","shade","shade2","ghost-narsie","hor materials = list(MAT_METAL=2000) var/on = FALSE var/video_cooldown = 0 - var/obj/machinery/camera/camera + var/obj/machinery/camera/portable/camera var/canhear_range = 7 /obj/item/videocam/Destroy() if(on) - update_feeds() + camera_state() return ..() @@ -592,11 +593,12 @@ GLOBAL_LIST_INIT(SpookyGhosts, list("ghost","shade","shade2","ghost-narsie","hor /obj/item/videocam/proc/update_feeds() + if(on) + GLOB.active_video_cameras |= src + else + GLOB.active_video_cameras -= src + for(var/obj/machinery/computer/security/telescreen/entertainment/TV in GLOB.machines) - if(on) - TV.feeds_on++ - else - TV.feeds_on-- TV.update_icon(UPDATE_OVERLAYS) @@ -605,9 +607,7 @@ GLOBAL_LIST_INIT(SpookyGhosts, list("ghost","shade","shade2","ghost-narsie","hor camera.c_tag = null QDEL_NULL(camera) else - camera = new /obj/machinery/camera(src) - camera.network = list("news") - camera.c_tag = user.name + camera = new(src, list("news"), user.name) on = !on update_icon(UPDATE_ICON_STATE) visible_message(span_notice("The video camera has been turned [on ? "on" : "off"]."))