mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-11 02:34:00 +00:00
Fixes #2302
This commit is contained in:
@@ -14,138 +14,140 @@
|
|||||||
var/cache_id = 0
|
var/cache_id = 0
|
||||||
circuit = /obj/item/weapon/circuitboard/security
|
circuit = /obj/item/weapon/circuitboard/security
|
||||||
|
|
||||||
New()
|
/obj/machinery/computer/security/New()
|
||||||
if(!network)
|
if(!network)
|
||||||
network = station_networks.Copy()
|
network = station_networks.Copy()
|
||||||
..()
|
..()
|
||||||
if(network.len)
|
if(network.len)
|
||||||
current_network = network[1]
|
current_network = network[1]
|
||||||
|
|
||||||
attack_ai(var/mob/user as mob)
|
/obj/machinery/computer/security/attack_ai(var/mob/user as mob)
|
||||||
return attack_hand(user)
|
return attack_hand(user)
|
||||||
|
|
||||||
check_eye(var/mob/user as mob)
|
/obj/machinery/computer/security/check_eye(var/mob/user as mob)
|
||||||
if (user.stat || ((get_dist(user, src) > 1 || !( user.canmove ) || user.blinded) && !istype(user, /mob/living/silicon))) //user can't see - not sure why canmove is here.
|
if (user.stat || ((get_dist(user, src) > 1 || !( user.canmove ) || user.blinded) && !istype(user, /mob/living/silicon))) //user can't see - not sure why canmove is here.
|
||||||
return -1
|
return -1
|
||||||
if(!current_camera)
|
if(!current_camera)
|
||||||
return 0
|
return 0
|
||||||
var/viewflag = current_camera.check_eye(user)
|
var/viewflag = current_camera.check_eye(user)
|
||||||
if ( viewflag < 0 ) //camera doesn't work
|
if ( viewflag < 0 ) //camera doesn't work
|
||||||
reset_current()
|
reset_current()
|
||||||
return viewflag
|
return viewflag
|
||||||
|
|
||||||
ui_interact(mob/user, ui_key = "main", datum/nanoui/ui = null, force_open = 1)
|
/obj/machinery/computer/security/ui_interact(mob/user, ui_key = "main", datum/nanoui/ui = null, force_open = 1)
|
||||||
if(src.z > 6) return
|
if(src.z > 6) return
|
||||||
if(stat & (NOPOWER|BROKEN)) return
|
if(stat & (NOPOWER|BROKEN)) return
|
||||||
if(user.stat) return
|
if(user.stat) return
|
||||||
|
|
||||||
var/data[0]
|
var/data[0]
|
||||||
|
|
||||||
data["current_camera"] = current_camera ? current_camera.nano_structure() : null
|
data["current_camera"] = current_camera ? current_camera.nano_structure() : null
|
||||||
data["current_network"] = current_network
|
data["current_network"] = current_network
|
||||||
data["networks"] = network ? network : list()
|
data["networks"] = network ? network : list()
|
||||||
if(current_network)
|
if(current_network)
|
||||||
data["cameras"] = camera_repository.cameras_in_network(current_network)
|
data["cameras"] = camera_repository.cameras_in_network(current_network)
|
||||||
|
if(current_camera)
|
||||||
|
switch_to_camera(user, current_camera)
|
||||||
|
|
||||||
ui = nanomanager.try_update_ui(user, src, ui_key, ui, data, force_open)
|
ui = nanomanager.try_update_ui(user, src, ui_key, ui, data, force_open)
|
||||||
if (!ui)
|
if (!ui)
|
||||||
ui = new(user, src, ui_key, "sec_camera.tmpl", "Camera Console", 900, 800)
|
ui = new(user, src, ui_key, "sec_camera.tmpl", "Camera Console", 900, 800)
|
||||||
|
|
||||||
// adding a template with the key "mapContent" enables the map ui functionality
|
// adding a template with the key "mapContent" enables the map ui functionality
|
||||||
ui.add_template("mapContent", "sec_camera_map_content.tmpl")
|
ui.add_template("mapContent", "sec_camera_map_content.tmpl")
|
||||||
// adding a template with the key "mapHeader" replaces the map header content
|
// adding a template with the key "mapHeader" replaces the map header content
|
||||||
ui.add_template("mapHeader", "sec_camera_map_header.tmpl")
|
ui.add_template("mapHeader", "sec_camera_map_header.tmpl")
|
||||||
|
|
||||||
ui.set_initial_data(data)
|
ui.set_initial_data(data)
|
||||||
ui.open()
|
ui.open()
|
||||||
|
|
||||||
Topic(href, href_list)
|
/obj/machinery/computer/security/Topic(href, href_list)
|
||||||
if(..())
|
if(..())
|
||||||
return 1
|
return 1
|
||||||
if(href_list["switch_camera"])
|
if(href_list["switch_camera"])
|
||||||
if(src.z>6 || stat&(NOPOWER|BROKEN)) return
|
if(src.z>6 || stat&(NOPOWER|BROKEN)) return
|
||||||
if(usr.stat || ((get_dist(usr, src) > 1 || !( usr.canmove ) || usr.blinded) && !istype(usr, /mob/living/silicon))) return
|
if(usr.stat || ((get_dist(usr, src) > 1 || !( usr.canmove ) || usr.blinded) && !istype(usr, /mob/living/silicon))) return
|
||||||
var/obj/machinery/camera/C = locate(href_list["switch_camera"]) in cameranet.cameras
|
var/obj/machinery/camera/C = locate(href_list["switch_camera"]) in cameranet.cameras
|
||||||
if(!C)
|
if(!C)
|
||||||
return
|
return
|
||||||
if(!(current_network in C.network))
|
if(!(current_network in C.network))
|
||||||
return
|
|
||||||
|
|
||||||
switch_to_camera(usr, C)
|
|
||||||
return 1
|
|
||||||
else if(href_list["switch_network"])
|
|
||||||
if(src.z>6 || stat&(NOPOWER|BROKEN)) return
|
|
||||||
if(usr.stat || ((get_dist(usr, src) > 1 || !( usr.canmove ) || usr.blinded) && !istype(usr, /mob/living/silicon))) return
|
|
||||||
if(href_list["switch_network"] in network)
|
|
||||||
current_network = href_list["switch_network"]
|
|
||||||
return 1
|
|
||||||
else if(href_list["reset"])
|
|
||||||
if(src.z>6 || stat&(NOPOWER|BROKEN)) return
|
|
||||||
if(usr.stat || ((get_dist(usr, src) > 1 || !( usr.canmove ) || usr.blinded) && !istype(usr, /mob/living/silicon))) return
|
|
||||||
reset_current()
|
|
||||||
usr.reset_view(current_camera)
|
|
||||||
return 1
|
|
||||||
else
|
|
||||||
. = ..()
|
|
||||||
|
|
||||||
attack_hand(var/mob/user as mob)
|
|
||||||
if (src.z > 6)
|
|
||||||
user << "<span class='danger'>Unable to establish a connection:</span> You're too far away from the station!"
|
|
||||||
return
|
return
|
||||||
if(stat & (NOPOWER|BROKEN)) return
|
|
||||||
|
|
||||||
if(!isAI(user))
|
switch_to_camera(usr, C)
|
||||||
user.set_machine(src)
|
return 1
|
||||||
ui_interact(user)
|
else if(href_list["switch_network"])
|
||||||
|
if(src.z>6 || stat&(NOPOWER|BROKEN)) return
|
||||||
|
if(usr.stat || ((get_dist(usr, src) > 1 || !( usr.canmove ) || usr.blinded) && !istype(usr, /mob/living/silicon))) return
|
||||||
|
if(href_list["switch_network"] in network)
|
||||||
|
current_network = href_list["switch_network"]
|
||||||
|
return 1
|
||||||
|
else if(href_list["reset"])
|
||||||
|
if(src.z>6 || stat&(NOPOWER|BROKEN)) return
|
||||||
|
if(usr.stat || ((get_dist(usr, src) > 1 || !( usr.canmove ) || usr.blinded) && !istype(usr, /mob/living/silicon))) return
|
||||||
|
reset_current()
|
||||||
|
usr.reset_view(current_camera)
|
||||||
|
return 1
|
||||||
|
else
|
||||||
|
. = ..()
|
||||||
|
|
||||||
proc/switch_to_camera(var/mob/user, var/obj/machinery/camera/C)
|
/obj/machinery/computer/security/attack_hand(var/mob/user as mob)
|
||||||
//don't need to check if the camera works for AI because the AI jumps to the camera location and doesn't actually look through cameras.
|
if (src.z > 6)
|
||||||
if(isAI(user))
|
user << "<span class='danger'>Unable to establish a connection:</span> You're too far away from the station!"
|
||||||
var/mob/living/silicon/ai/A = user
|
return
|
||||||
// Only allow non-carded AIs to view because the interaction with the eye gets all wonky otherwise.
|
if(stat & (NOPOWER|BROKEN)) return
|
||||||
if(!A.is_in_chassis())
|
|
||||||
return 0
|
|
||||||
|
|
||||||
A.eyeobj.setLoc(get_turf(C))
|
if(!isAI(user))
|
||||||
A.client.eye = A.eyeobj
|
user.set_machine(src)
|
||||||
return 1
|
ui_interact(user)
|
||||||
|
|
||||||
if (!C.can_use() || user.stat || (get_dist(user, src) > 1 || user.machine != src || user.blinded || !( user.canmove ) && !istype(user, /mob/living/silicon)))
|
/obj/machinery/computer/security/proc/switch_to_camera(var/mob/user, var/obj/machinery/camera/C)
|
||||||
|
//don't need to check if the camera works for AI because the AI jumps to the camera location and doesn't actually look through cameras.
|
||||||
|
if(isAI(user))
|
||||||
|
var/mob/living/silicon/ai/A = user
|
||||||
|
// Only allow non-carded AIs to view because the interaction with the eye gets all wonky otherwise.
|
||||||
|
if(!A.is_in_chassis())
|
||||||
return 0
|
return 0
|
||||||
set_current(C)
|
|
||||||
user.reset_view(current_camera)
|
A.eyeobj.setLoc(get_turf(C))
|
||||||
check_eye(user)
|
A.client.eye = A.eyeobj
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
if (!C.can_use() || user.stat || (get_dist(user, src) > 1 || user.machine != src || user.blinded || !( user.canmove ) && !istype(user, /mob/living/silicon)))
|
||||||
|
return 0
|
||||||
|
set_current(C)
|
||||||
|
user.reset_view(current_camera)
|
||||||
|
check_eye(user)
|
||||||
|
return 1
|
||||||
|
|
||||||
//Camera control: moving.
|
//Camera control: moving.
|
||||||
proc/jump_on_click(var/mob/user,var/A)
|
/obj/machinery/computer/security/proc/jump_on_click(var/mob/user,var/A)
|
||||||
if(user.machine != src)
|
if(user.machine != src)
|
||||||
return
|
return
|
||||||
var/obj/machinery/camera/jump_to
|
var/obj/machinery/camera/jump_to
|
||||||
if(istype(A,/obj/machinery/camera))
|
if(istype(A,/obj/machinery/camera))
|
||||||
jump_to = A
|
jump_to = A
|
||||||
else if(ismob(A))
|
else if(ismob(A))
|
||||||
if(ishuman(A))
|
if(ishuman(A))
|
||||||
jump_to = locate() in A:head
|
jump_to = locate() in A:head
|
||||||
else if(isrobot(A))
|
else if(isrobot(A))
|
||||||
jump_to = A:camera
|
jump_to = A:camera
|
||||||
else if(isobj(A))
|
else if(isobj(A))
|
||||||
jump_to = locate() in A
|
jump_to = locate() in A
|
||||||
else if(isturf(A))
|
else if(isturf(A))
|
||||||
var/best_dist = INFINITY
|
var/best_dist = INFINITY
|
||||||
for(var/obj/machinery/camera/camera in get_area(A))
|
for(var/obj/machinery/camera/camera in get_area(A))
|
||||||
if(!camera.can_use())
|
if(!camera.can_use())
|
||||||
continue
|
continue
|
||||||
if(!can_access_camera(camera))
|
if(!can_access_camera(camera))
|
||||||
continue
|
continue
|
||||||
var/dist = get_dist(camera,A)
|
var/dist = get_dist(camera,A)
|
||||||
if(dist < best_dist)
|
if(dist < best_dist)
|
||||||
best_dist = dist
|
best_dist = dist
|
||||||
jump_to = camera
|
jump_to = camera
|
||||||
if(isnull(jump_to))
|
if(isnull(jump_to))
|
||||||
return
|
return
|
||||||
if(can_access_camera(jump_to))
|
if(can_access_camera(jump_to))
|
||||||
switch_to_camera(user,jump_to)
|
switch_to_camera(user,jump_to)
|
||||||
|
|
||||||
/obj/machinery/computer/security/process()
|
/obj/machinery/computer/security/process()
|
||||||
if(cache_id != camera_repository.camera_cache_id)
|
if(cache_id != camera_repository.camera_cache_id)
|
||||||
|
|||||||
Reference in New Issue
Block a user