Files
Paradise/code/modules/paperwork/silicon_photography.dm
T
93ed0f096d Refactors AI / camera eyes and slows holopad holograms to walk speed (#25078)
* Refactor/deduplicate camera eye code

Camera Eyes previously had duplicated logic across several files. This
change uncooks the spaghetti. Additionally, half-baked support for TG's
multicam feature has been removed, as it was not functional or in use.

* lets ff now

* Camera Eye refactor fixes and finishing touches

This change completes a refactor of AI eyes, which were previously used
by xenobio consoles, syndicate and abductor camera consoles, shuttle
docking computers, holograms, and, of course, the AI. Duplicated logic
has been extracted to an abstract base mob, /mob/camera/eye, from which
new types for each of the above now derive.

Functionality is largely the same, with only a few minor cosmetic
differences (i.e. camera eyes are now appropriately named given their
type and user), as well as a quality-of-life enhancement for holograms,
slowing their movement speed to base run speed to prevent users from
accidentally zooming out of calls.

* Camera eye refactor: Fix AI acceleration toggle

The acceleration toggle was broken in the camera eye refactor, as
previously the boolean was stored on the AI rather than its eye. This
change fixes that.

* Camera eye refactor: Fix syndicate cam visibility

With the camera eye refactor, the syndicate advanced camera consoles
lost the ability to view maintenance tunnels and other areas without
active cameras, seeing static in their place instead (as all other
cameras do). This change reinstates the original behavior.

* Camera eye refactor: Convert spaces to tabs

* Camera eye refactor: Fix CRLF

* Apply suggestions from code review

General minor code quality improvements suggested by GDNgit

Co-authored-by: GDN <96800819+GDNgit@users.noreply.github.com>

* Apply suggestions from code review

Rename parameter names to avoid src accesses, remove an ambiguous and
unused mob_define and holopad range variable from a previous WIP, change
the for loop in /mob/camera/eye/relaymove to a for-to loop, and change
the chat message warning, sent when an AI Eye is created on an AI that
already has one, to a stack trace

* Adds toggle to AI commands for fast holograms

* Refactor ripped Hologram Eye relaymove

Previously, the relaymove proc for hologram eyes was redundant and
nearly impossible to read. It has been separated out into a few
different named procs, and has had its use of `spawn` removed.

* Remove unnecessary src access

* Fix bug involving shuttle placement outlines

The camera eye refactor that this commit is a part of introduced a bug
that prevented shuttle placement outlines from showing up on first use
of the shuttle console. This change fixes that bug.

* Unrevert some changes from #26306 lost in merge

* Remove erroneous free xray vision on advanced cams

* Autodoc camera acceleration vars

* Remove redundant null var initialization per code review

Co-authored-by: Drsmail <60036448+Drsmail@users.noreply.github.com>
Signed-off-by: asciodev <81930475+asciodev@users.noreply.github.com>

* Changed variables to camel_case, autodocs, cleanup

Changed a number of camera eye-related variables to camel_case style,
added appropriate autodoc comments, as per code review. Also removed an
unused cameranet function, modified the call signature of a cameranet
function to be more semantic, and changed a qdel-on-initialize in camera
eyes to return INITIALIZE_HINT_QDEL instead.

Co-authored-by: Luc <89928798+lewcc@users.noreply.github.com>

* Remove stray qdel(src) per code review

Co-authored-by: Luc <89928798+lewcc@users.noreply.github.com>
Signed-off-by: asciodev <81930475+asciodev@users.noreply.github.com>

---------

Signed-off-by: asciodev <81930475+asciodev@users.noreply.github.com>
Co-authored-by: GDN <96800819+GDNgit@users.noreply.github.com>
Co-authored-by: Drsmail <60036448+Drsmail@users.noreply.github.com>
Co-authored-by: Luc <89928798+lewcc@users.noreply.github.com>
2025-01-17 18:22:43 +00:00

178 lines
5.0 KiB
Plaintext

/**************
* AI-specific *
**************/
/datum/picture
var/name = "image"
var/list/fields = list()
/obj/item/camera/siliconcam
var/in_camera_mode = 0
var/photos_taken = 0
var/list/aipictures = list()
flashing_light = FALSE
actions_types = list()
/// camera AI can take pictures with
/obj/item/camera/siliconcam/ai_camera
name = "AI photo camera"
/// camera cyborgs can take pictures with
/obj/item/camera/siliconcam/robot_camera
name = "Cyborg photo camera"
/// currently doesn't offer the verbs, thus cannot be used
/obj/item/camera/siliconcam/drone_camera
name = "Drone photo camera"
/obj/item/camera/siliconcam/proc/injectaialbum(datum/picture/P, sufix = "") //stores image information to a list similar to that of the datacore
photos_taken++
P.fields["name"] = "Image [photos_taken][sufix]"
aipictures += P
/obj/item/camera/siliconcam/proc/injectmasteralbum(datum/picture/P) //stores image information to a list similar to that of the datacore
var/mob/living/silicon/robot/C = src.loc
if(C.connected_ai)
var/mob/A = P.fields["author"]
C.connected_ai.aiCamera.injectaialbum(P, " (taken by [A.name])")
to_chat(C.connected_ai, "<span class='unconscious'>Image recorded and saved by [name]</span>")
to_chat(usr, "<span class='unconscious'>Image recorded and saved to remote database</span>")//feedback to the Cyborg player that the picture was taken
else
injectaialbum(P)
to_chat(usr, "<span class='unconscious'>Image recorded</span>")
/obj/item/camera/siliconcam/proc/selectpicture(obj/item/camera/siliconcam/cam)
if(!cam)
cam = getsource()
var/list/nametemp = list()
var/find
if(length(cam.aipictures) == 0)
to_chat(usr, "<span class='userdanger'>No images saved</span>")
return
for(var/datum/picture/t in cam.aipictures)
nametemp += t.fields["name"]
find = tgui_input_list(usr, "Select image (numbered in order taken)", "Pick Image", nametemp)
for(var/datum/picture/q in cam.aipictures)
if(q.fields["name"] == find)
return q
/obj/item/camera/siliconcam/proc/viewpictures()
var/datum/picture/selection = selectpicture()
if(!selection)
return
var/obj/item/photo/P = new /obj/item/photo()
P.construct(selection)
P.show(usr)
if(P.desc)
to_chat(usr, P.desc, MESSAGE_TYPE_INFO)
// TG uses a special garbage collector.. qdel(P)
qdel(P) //so 10 thousand pictures items are not left in memory should an AI take them and then view them all.
/obj/item/camera/siliconcam/proc/deletepicture(obj/item/camera/siliconcam/cam)
var/datum/picture/selection = selectpicture(cam)
if(!selection)
return
cam.aipictures -= selection
to_chat(usr, "<span class='unconscious'>Image deleted</span>")
/obj/item/camera/siliconcam/ai_camera/can_capture_turf(turf/T, mob/user)
var/mob/living/silicon/ai = user
return ai.TurfAdjacent(T)
/obj/item/camera/siliconcam/proc/toggle_camera_mode()
if(in_camera_mode)
camera_mode_off()
else
camera_mode_on()
/obj/item/camera/siliconcam/proc/camera_mode_off()
src.in_camera_mode = 0
to_chat(usr, "<B>Camera Mode deactivated</B>")
/obj/item/camera/siliconcam/proc/camera_mode_on()
src.in_camera_mode = 1
to_chat(usr, "<B>Camera Mode activated</B>")
/obj/item/camera/siliconcam/ai_camera/printpicture(mob/user, datum/picture/P)
injectaialbum(P)
to_chat(usr, "<span class='unconscious'>Image recorded</span>")
/obj/item/camera/siliconcam/robot_camera/printpicture(mob/user, datum/picture/P)
injectmasteralbum(P)
/obj/item/camera/siliconcam/ai_camera/verb/take_image()
set category = "AI Commands"
set name = "Take Image"
set desc = "Takes an image"
toggle_camera_mode()
/obj/item/camera/siliconcam/ai_camera/verb/change_lens()
set category = "AI Commands"
set name = "Set Photo Focus"
set desc = "Changes the lens size of your photo camera"
change_size()
/obj/item/camera/siliconcam/ai_camera/verb/view_images()
set category = "AI Commands"
set name = "View Images"
set desc = "View images"
viewpictures()
/obj/item/camera/siliconcam/ai_camera/verb/delete_images()
set category = "AI Commands"
set name = "Delete Image"
set desc = "Delete image"
deletepicture(src)
/obj/item/camera/siliconcam/robot_camera/verb/take_image()
set category ="Robot Commands"
set name = "Take Image"
set desc = "Takes an image"
toggle_camera_mode()
/obj/item/camera/siliconcam/robot_camera/verb/change_lens()
set category = "Robot Commands"
set name = "Set Photo Focus"
set desc = "Changes the lens size of your photo camera"
change_size()
/obj/item/camera/siliconcam/robot_camera/verb/view_images()
set category ="Robot Commands"
set name = "View Images"
set desc = "View images"
viewpictures()
/obj/item/camera/siliconcam/robot_camera/verb/delete_images()
set category = "Robot Commands"
set name = "Delete Image"
set desc = "Delete a local image"
// Explicitly only allow deletion from the local camera
deletepicture(src)
/obj/item/camera/siliconcam/proc/getsource()
if(is_ai(loc))
return src
var/mob/living/silicon/robot/C = loc
var/obj/item/camera/siliconcam/Cinfo
if(C.connected_ai)
Cinfo = C.connected_ai.aiCamera
else
Cinfo = src
return Cinfo