Skip to content

Commit

Permalink
bugfix: AI internal camera & entertainment monitor overlays working p…
Browse files Browse the repository at this point in the history
…roperly. (#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.
  • Loading branch information
Daeberdir authored Jun 19, 2024
1 parent 5c5a581 commit 7e50d64
Show file tree
Hide file tree
Showing 10 changed files with 49 additions and 52 deletions.
14 changes: 9 additions & 5 deletions code/game/machinery/camera/camera.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions code/game/machinery/camera/camera_assembly.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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" )
Expand Down
10 changes: 5 additions & 5 deletions code/game/machinery/camera/presets.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
6 changes: 2 additions & 4 deletions code/game/machinery/computer/camera.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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 ..()


Expand Down
5 changes: 1 addition & 4 deletions code/game/objects/items/devices/aicard.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
12 changes: 4 additions & 8 deletions code/modules/clothing/spacesuits/ert.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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, "<span class='notice'>User scanned as [camera.c_tag]. Camera activated.</span>")

/obj/item/clothing/head/helmet/space/hardsuit/ert/examine(mob/user)
Expand Down Expand Up @@ -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)

Expand All @@ -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, "<span class='notice'>User scanned as [camera.c_tag]. Camera activated.</span>")

/obj/item/clothing/head/helmet/space/ert_eva_amber/examine(mob/user)
Expand Down
4 changes: 1 addition & 3 deletions code/modules/mob/living/silicon/ai/ai.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 15 additions & 8 deletions code/modules/mob/living/silicon/ai/freelook/chunk.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
6 changes: 2 additions & 4 deletions code/modules/mob/living/silicon/robot/robot.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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

Expand Down
18 changes: 9 additions & 9 deletions code/modules/paperwork/photography.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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 ..()


Expand All @@ -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)


Expand All @@ -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"]."))
Expand Down

0 comments on commit 7e50d64

Please sign in to comment.