mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-01-13 02:52:03 +00:00
* 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>
317 lines
12 KiB
Plaintext
317 lines
12 KiB
Plaintext
/obj/machinery/computer/camera_advanced/shuttle_docker
|
|
name = "navigation computer"
|
|
desc = "Used to designate a precise transit location for a spacecraft."
|
|
icon_screen = "navigation"
|
|
icon_keyboard = "med_key"
|
|
jump_action = null
|
|
var/datum/action/innate/shuttledocker_rotate/rotate_action = new
|
|
var/datum/action/innate/shuttledocker_place/place_action = new
|
|
var/shuttleId = ""
|
|
var/shuttlePortId = ""
|
|
var/shuttlePortName = "custom location"
|
|
var/list/jumpto_ports = list() //list of ports to jump to
|
|
var/access_station = TRUE //can we park near X?
|
|
var/access_mining = TRUE
|
|
var/obj/docking_port/stationary/my_port //the custom docking port placed by this console
|
|
var/obj/docking_port/mobile/shuttle_port //the mobile docking port of the connected shuttle
|
|
var/view_range = 7
|
|
var/x_offset = 0
|
|
var/y_offset = 0
|
|
var/space_turfs_only = TRUE
|
|
var/see_hidden = FALSE
|
|
var/designate_time = 0
|
|
var/turf/designating_target_loc
|
|
|
|
/obj/machinery/computer/camera_advanced/shuttle_docker/Initialize(mapload)
|
|
. = ..()
|
|
GLOB.navigation_computers += src
|
|
if(access_station)
|
|
jumpto_ports += list("nav_z[level_name_to_num(MAIN_STATION)]" = 1)
|
|
if(access_mining && GLOB.configuration.ruins.enable_lavaland)
|
|
jumpto_ports += list("nav_z[level_name_to_num(MINING)]" = 1)
|
|
|
|
/obj/machinery/computer/camera_advanced/shuttle_docker/Destroy()
|
|
GLOB.navigation_computers -= src
|
|
return ..()
|
|
|
|
/obj/machinery/computer/camera_advanced/shuttle_docker/attack_hand(mob/user)
|
|
if(!shuttle_port && !SSshuttle.getShuttle(shuttleId))
|
|
to_chat(user,"<span class='warning'>Warning: Shuttle connection severed!</span>")
|
|
return
|
|
return ..()
|
|
|
|
/obj/machinery/computer/camera_advanced/shuttle_docker/GrantActions(mob/living/user)
|
|
if(length(jumpto_ports))
|
|
jump_action = new /datum/action/innate/camera_jump/shuttle_docker
|
|
..()
|
|
if(place_action)
|
|
place_action.target = user
|
|
place_action.Grant(user)
|
|
actions += place_action
|
|
|
|
/obj/machinery/computer/camera_advanced/shuttle_docker/CreateEye()
|
|
shuttle_port = SSshuttle.getShuttle(shuttleId)
|
|
if(QDELETED(shuttle_port))
|
|
shuttle_port = null
|
|
return
|
|
|
|
eyeobj = new /mob/camera/eye/shuttle_docker(get_turf(locate("landmark*Observer-Start")), name, src, current_user) // There should always be an observer start landmark
|
|
var/mob/camera/eye/shuttle_docker/the_eye = eyeobj
|
|
the_eye.setDir(shuttle_port.dir)
|
|
var/turf/origin = locate(shuttle_port.x + x_offset, shuttle_port.y + y_offset, shuttle_port.z)
|
|
for(var/V in shuttle_port.shuttle_areas)
|
|
var/area/A = V
|
|
for(var/turf/T in A)
|
|
if(T.z != origin.z)
|
|
continue
|
|
var/image/I = image('icons/effects/alphacolors.dmi', origin, "red")
|
|
var/x_off = T.x - origin.x
|
|
var/y_off = T.y - origin.y
|
|
I.loc = locate(origin.x + x_off, origin.y + y_off, origin.z) //we have to set this after creating the image because it might be null, and images created in nullspace are immutable.
|
|
I.layer = ABOVE_NORMAL_TURF_LAYER
|
|
I.plane = 0
|
|
I.mouse_opacity = MOUSE_OPACITY_TRANSPARENT
|
|
the_eye.placement_images[I] = list(x_off, y_off)
|
|
give_eye_control(current_user)
|
|
|
|
/obj/machinery/computer/camera_advanced/shuttle_docker/give_eye_control(mob/user)
|
|
..()
|
|
if(!QDELETED(user) && user.client)
|
|
var/mob/camera/eye/shuttle_docker/the_eye = eyeobj
|
|
var/list/to_add = list()
|
|
to_add += the_eye.placement_images
|
|
to_add += the_eye.placed_images
|
|
if(!see_hidden)
|
|
to_add += SSshuttle.hidden_shuttle_turf_images
|
|
|
|
user.client.images += to_add
|
|
user.client.SetView(view_range)
|
|
|
|
/obj/machinery/computer/camera_advanced/shuttle_docker/remove_eye_control(mob/living/user)
|
|
..()
|
|
if(!QDELETED(user) && user.client)
|
|
var/mob/camera/eye/shuttle_docker/the_eye = eyeobj
|
|
var/list/to_remove = list()
|
|
to_remove += the_eye.placement_images
|
|
to_remove += the_eye.placed_images
|
|
if(!see_hidden)
|
|
to_remove += SSshuttle.hidden_shuttle_turf_images
|
|
|
|
user.client.images -= to_remove
|
|
user.client.SetView(user.client.prefs.viewrange)
|
|
|
|
/obj/machinery/computer/camera_advanced/shuttle_docker/proc/placeLandingSpot()
|
|
if(designating_target_loc || !current_user)
|
|
return
|
|
|
|
var/mob/camera/eye/shuttle_docker/the_eye = eyeobj
|
|
var/landing_clear = check_landing_spot()
|
|
if(designate_time && (landing_clear != SHUTTLE_DOCKER_BLOCKED))
|
|
to_chat(current_user, "<span class='warning'>Targeting transit location, please wait [DisplayTimeText(designate_time)]...</span>")
|
|
designating_target_loc = the_eye.loc
|
|
var/wait_completed = do_after(current_user, designate_time, FALSE, designating_target_loc, TRUE, CALLBACK(src, PROC_REF(canDesignateTarget)))
|
|
designating_target_loc = null
|
|
if(!current_user)
|
|
return
|
|
if(!wait_completed)
|
|
to_chat(current_user, "<span class='warning'>Operation aborted.</span>")
|
|
return
|
|
landing_clear = check_landing_spot()
|
|
|
|
if(landing_clear != SHUTTLE_DOCKER_LANDING_CLEAR)
|
|
switch(landing_clear)
|
|
if(SHUTTLE_DOCKER_BLOCKED)
|
|
to_chat(current_user, "<span class='warning'>Invalid transit location</span>")
|
|
if(SHUTTLE_DOCKER_BLOCKED_BY_HIDDEN_PORT)
|
|
to_chat(current_user, "<span class='warning'>Unknown object detected in landing zone. Please designate another location.</span>")
|
|
return
|
|
|
|
if(!my_port)
|
|
my_port = new()
|
|
my_port.name = shuttlePortName
|
|
my_port.id = shuttlePortId
|
|
my_port.height = shuttle_port.height
|
|
my_port.width = shuttle_port.width
|
|
my_port.dheight = shuttle_port.dheight
|
|
my_port.dwidth = shuttle_port.dwidth
|
|
my_port.hidden = shuttle_port.hidden
|
|
my_port.register()
|
|
my_port.setDir(the_eye.dir)
|
|
my_port.forceMove(locate(eyeobj.x - x_offset, eyeobj.y - y_offset, eyeobj.z))
|
|
if(current_user.client)
|
|
current_user.client.images -= the_eye.placed_images
|
|
|
|
QDEL_LIST_CONTENTS(the_eye.placed_images)
|
|
|
|
for(var/V in the_eye.placement_images)
|
|
var/image/I = V
|
|
var/image/newI = image('icons/effects/alphacolors.dmi', the_eye.loc, "blue")
|
|
newI.loc = I.loc //It is highly unlikely that any landing spot including a null tile will get this far, but better safe than sorry.
|
|
newI.layer = ABOVE_OPEN_TURF_LAYER
|
|
newI.plane = 0
|
|
newI.mouse_opacity = 0
|
|
the_eye.placed_images += newI
|
|
|
|
if(current_user.client)
|
|
current_user.client.images += the_eye.placed_images
|
|
to_chat(current_user, "<span class='notice'>Transit location designated</span>")
|
|
return
|
|
|
|
/obj/machinery/computer/camera_advanced/shuttle_docker/proc/canDesignateTarget()
|
|
if(!designating_target_loc || !current_user || (eyeobj.loc != designating_target_loc) || (stat & (NOPOWER|BROKEN)))
|
|
return FALSE
|
|
return TRUE
|
|
|
|
/obj/machinery/computer/camera_advanced/shuttle_docker/proc/rotateLandingSpot()
|
|
var/mob/camera/eye/shuttle_docker/the_eye = eyeobj
|
|
var/list/image_cache = the_eye.placement_images
|
|
the_eye.setDir(turn(the_eye.dir, -90))
|
|
for(var/i in 1 to length(image_cache))
|
|
var/image/pic = image_cache[i]
|
|
var/list/coords = image_cache[pic]
|
|
var/Tmp = coords[1]
|
|
coords[1] = coords[2]
|
|
coords[2] = -Tmp
|
|
pic.loc = locate(the_eye.x + coords[1], the_eye.y + coords[2], the_eye.z)
|
|
var/Tmp = x_offset
|
|
x_offset = y_offset
|
|
y_offset = -Tmp
|
|
check_landing_spot()
|
|
|
|
/obj/machinery/computer/camera_advanced/shuttle_docker/proc/check_landing_spot()
|
|
var/mob/camera/eye/shuttle_docker/the_eye = eyeobj
|
|
var/turf/eyeturf = get_turf(the_eye)
|
|
if(!eyeturf)
|
|
return SHUTTLE_DOCKER_BLOCKED
|
|
|
|
. = SHUTTLE_DOCKER_LANDING_CLEAR
|
|
var/list/bounds = shuttle_port.return_coords(the_eye.x - x_offset, the_eye.y - y_offset, the_eye.dir)
|
|
var/list/overlappers = SSshuttle.get_dock_overlap(bounds[1], bounds[2], bounds[3], bounds[4], the_eye.z)
|
|
var/list/image_cache = the_eye.placement_images
|
|
for(var/i in 1 to length(image_cache))
|
|
var/image/I = image_cache[i]
|
|
var/list/coords = image_cache[I]
|
|
var/turf/T = locate(eyeturf.x + coords[1], eyeturf.y + coords[2], eyeturf.z)
|
|
I.loc = T
|
|
switch(checkLandingTurf(T, overlappers))
|
|
if(SHUTTLE_DOCKER_LANDING_CLEAR)
|
|
I.icon_state = "green"
|
|
if(SHUTTLE_DOCKER_BLOCKED_BY_HIDDEN_PORT)
|
|
I.icon_state = "green"
|
|
if(. == SHUTTLE_DOCKER_LANDING_CLEAR)
|
|
. = SHUTTLE_DOCKER_BLOCKED_BY_HIDDEN_PORT
|
|
else
|
|
I.icon_state = "red"
|
|
. = SHUTTLE_DOCKER_BLOCKED
|
|
|
|
/obj/machinery/computer/camera_advanced/shuttle_docker/proc/checkLandingTurf(turf/T, list/overlappers)
|
|
// Too close to the map edge is never allowed
|
|
if(!T || T.x <= 10 || T.y <= 10 || T.x >= world.maxx - 10 || T.y >= world.maxy - 10)
|
|
return SHUTTLE_DOCKER_BLOCKED
|
|
// If it's one of our shuttle areas assume it's ok to be there
|
|
if(shuttle_port.shuttle_areas[T.loc])
|
|
return SHUTTLE_DOCKER_LANDING_CLEAR
|
|
. = SHUTTLE_DOCKER_LANDING_CLEAR
|
|
// See if the turf is hidden from us
|
|
var/list/hidden_turf_info
|
|
if(!see_hidden)
|
|
hidden_turf_info = SSshuttle.hidden_shuttle_turfs[T]
|
|
if(hidden_turf_info)
|
|
. = SHUTTLE_DOCKER_BLOCKED_BY_HIDDEN_PORT
|
|
|
|
if(space_turfs_only)
|
|
var/turf_type = hidden_turf_info ? hidden_turf_info[2] : T.type
|
|
if(!ispath(turf_type, /turf/space))
|
|
return SHUTTLE_DOCKER_BLOCKED
|
|
|
|
if(istype(T.loc.type, /area/syndicate_depot))
|
|
return SHUTTLE_DOCKER_BLOCKED
|
|
|
|
// Checking for overlapping dock boundaries
|
|
for(var/i in 1 to length(overlappers))
|
|
var/obj/docking_port/port = overlappers[i]
|
|
if(port == my_port || locate(port) in jumpto_ports)
|
|
continue
|
|
var/port_hidden = !see_hidden && port.hidden
|
|
var/list/overlap = overlappers[port]
|
|
var/list/xs = overlap[1]
|
|
var/list/ys = overlap[2]
|
|
if(xs["[T.x]"] && ys["[T.y]"])
|
|
if(port_hidden)
|
|
. = SHUTTLE_DOCKER_BLOCKED_BY_HIDDEN_PORT
|
|
else
|
|
return SHUTTLE_DOCKER_BLOCKED
|
|
|
|
/obj/machinery/computer/camera_advanced/shuttle_docker/proc/update_hidden_docking_ports(list/remove_images, list/add_images)
|
|
if(!see_hidden && current_user && current_user.client)
|
|
current_user.client.images -= remove_images
|
|
current_user.client.images += add_images
|
|
|
|
/obj/machinery/computer/camera_advanced/shuttle_docker/proc/connect_to_shuttle(obj/docking_port/mobile/port, obj/docking_port/stationary/dock, idnum, override=FALSE)
|
|
if(port && (shuttleId == initial(shuttleId) || override))
|
|
shuttleId = port.id
|
|
shuttlePortId = "[port.id]_custom"
|
|
if(dock)
|
|
jumpto_ports[dock.id] = TRUE
|
|
|
|
/datum/action/innate/shuttledocker_rotate
|
|
name = "Rotate"
|
|
button_overlay_icon = 'icons/mob/actions/actions_mecha.dmi'
|
|
button_overlay_icon_state = "mech_cycle_equip_off"
|
|
|
|
/datum/action/innate/shuttledocker_rotate/Activate()
|
|
if(QDELETED(target) || !isliving(target))
|
|
return
|
|
var/mob/living/C = target
|
|
var/mob/camera/eye/remote_eye = C.remote_control
|
|
var/obj/machinery/computer/camera_advanced/shuttle_docker/origin = remote_eye.origin
|
|
origin.rotateLandingSpot()
|
|
|
|
/datum/action/innate/shuttledocker_place
|
|
name = "Place"
|
|
button_overlay_icon = 'icons/mob/actions/actions_mecha.dmi'
|
|
button_overlay_icon_state = "mech_zoom_off"
|
|
|
|
/datum/action/innate/shuttledocker_place/Activate()
|
|
if(QDELETED(target) || !isliving(target))
|
|
return
|
|
var/mob/living/C = target
|
|
var/mob/camera/eye/remote_eye = C.remote_control
|
|
var/obj/machinery/computer/camera_advanced/shuttle_docker/origin = remote_eye.origin
|
|
origin.placeLandingSpot(target)
|
|
|
|
/datum/action/innate/camera_jump/shuttle_docker
|
|
name = "Jump to Location"
|
|
button_overlay_icon_state = "camera_jump"
|
|
|
|
/datum/action/innate/camera_jump/shuttle_docker/Activate()
|
|
if(QDELETED(target) || !isliving(target))
|
|
return
|
|
var/mob/living/C = target
|
|
var/mob/camera/eye/remote_eye = C.remote_control
|
|
var/obj/machinery/computer/camera_advanced/shuttle_docker/console = remote_eye.origin
|
|
|
|
playsound(console, 'sound/machines/terminal_prompt_deny.ogg', 25, 0)
|
|
|
|
var/list/L = list()
|
|
for(var/V in SSshuttle.stationary)
|
|
if(!V)
|
|
continue
|
|
var/obj/docking_port/stationary/S = V
|
|
if(console.jumpto_ports[S.id])
|
|
L[S.name] = S
|
|
|
|
playsound(console, 'sound/machines/terminal_prompt.ogg', 25, 0)
|
|
var/selected = tgui_input_list(target, "Choose location to jump to", "Locations", L)
|
|
if(QDELETED(src) || QDELETED(target) || !isliving(target))
|
|
return
|
|
playsound(src, "terminal_type", 25, 0)
|
|
if(selected)
|
|
var/turf/T = get_turf(L[selected])
|
|
if(T)
|
|
playsound(console, 'sound/machines/terminal_prompt_confirm.ogg', 25, 0)
|
|
remote_eye.set_loc(T)
|
|
to_chat(target, "<span class='notice'>Jumped to [selected]</span>")
|
|
else
|
|
playsound(console, 'sound/machines/terminal_prompt_deny.ogg', 25, 0)
|