[MIRROR] Fixing client eye (#11812)

Co-authored-by: Will <7099514+Willburd@users.noreply.github.com>
Co-authored-by: Cameron Lennox <killer65311@gmail.com>
This commit is contained in:
CHOMPStation2StaffMirrorBot
2025-10-12 22:44:25 -04:00
committed by GitHub
co-authored by Will Cameron Lennox
parent b9db7ed21f
commit 7d57273375
95 changed files with 762 additions and 710 deletions
+67 -17
View File
@@ -244,19 +244,69 @@
/mob/proc/restrained()
return
/mob/proc/reset_view(atom/A)
if (client)
if (istype(A, /atom/movable))
client.perspective = EYE_PERSPECTIVE
client.eye = A
else
if (isturf(loc))
client.eye = client.mob
client.perspective = MOB_PERSPECTIVE
else
/**
* Reset the attached clients perspective (viewpoint)
*
* reset_perspective() set eye to common default : mob on turf, loc otherwise. If the client mob is inside an object with REMOTEVIEW_ON_ENTER, it will restart that object's remote view.
* reset_perspective(thing) set the eye to the thing (if it's equal to current default reset to mob perspective). This ignores REMOTEVIEW_ON_ENTER, and forces focus to the mob.
*/
/mob/proc/reset_perspective(atom/new_eye)
SHOULD_CALL_PARENT(TRUE)
if(!client)
return
if(new_eye)
if(ismovable(new_eye))
//Set the new eye unless it's us
if(new_eye != src)
client.perspective = EYE_PERSPECTIVE
client.eye = loc
client.set_eye(new_eye)
else
client.set_eye(client.mob)
client.perspective = MOB_PERSPECTIVE
else if(isturf(new_eye))
//Set to the turf unless it's our current turf
if(new_eye != loc)
client.perspective = EYE_PERSPECTIVE
client.set_eye(new_eye)
else
client.set_eye(client.mob)
client.perspective = MOB_PERSPECTIVE
else
return TRUE //no setting eye to stupid things like areas or whatever
else
//If we return focus to our own mob, but we are still inside something with an inherent remote view. Restart it.
if(restore_remote_views())
return TRUE
//Reset to common defaults: mob if on turf, otherwise current loc
if(isturf(loc))
client.set_eye(client.mob)
client.perspective = MOB_PERSPECTIVE
else
client.perspective = EYE_PERSPECTIVE
client.set_eye(loc)
/// Signal sent after the eye has been successfully updated, with the client existing.
SEND_SIGNAL(src, COMSIG_MOB_RESET_PERSPECTIVE)
return TRUE
/// Reapplies remote views based on object type and flags. Returns true if the view was assigned.
/mob/proc/restore_remote_views()
if(!loc) // Nullspace during respawn
return FALSE
if(isturf(loc)) // Cannot be remote if it was a turf, also obj and turf flags overlap so stepping into space triggers remoteview endlessly.
return FALSE
// Check if we actually need to drop our current remote view component, as this is expensive to do, and leads to more difficult to understand error prone logic
var/datum/component/remote_view/remote_comp = GetComponent(/datum/component/remote_view)
if(remote_comp?.looking_at_target_already(loc))
return FALSE
if(isitem(loc) || isbelly(loc)) // Requires more careful handling than structures because they are held by mobs
AddComponent(/datum/component/remote_view/mob_holding_item, loc)
return TRUE
if(loc.flags & REMOTEVIEW_ON_ENTER) // Handle atoms that begin a remote view upon entering them.
AddComponent(/datum/component/remote_view, loc)
return TRUE
return FALSE
/mob/proc/ret_grab(list/L, flag)
return
@@ -509,17 +559,17 @@
var/mob/mob_eye = targets[eye_name]
if(client && mob_eye)
client.eye = mob_eye
if (is_admin)
client.adminobs = 1
if(mob_eye == client.mob || client.eye == client.mob)
client.adminobs = 0
AddComponent(/datum/component/remote_view, focused_on = mob_eye)
if(is_admin)
client.adminobs = TRUE
if(mob_eye == client.mob || !is_remote_viewing())
client.adminobs = FALSE
/mob/verb/cancel_camera()
set name = "Cancel Camera View"
set category = "OOC.Game"
unset_machine()
reset_view(null)
reset_perspective()
/mob/Topic(href, href_list)
if(href_list["mach_close"])