Files
Bubberstation/code/modules/mob/eye/camera/camera.dm
T
d8450b4933 Camera eyes have been lightly refactored (among other things...) (#87805)
## About The Pull Request

* A generic /mob/eye/camera type has been made, containing everything
needed to interface with a cameranet
* /mob/eye/ai_eye has been refactored into a generic /mob/eye/camera
instance
* Advanced cameras no longer inherit from AI eyes, splitting off
behaviour
* Camera code has been somewhat cleaned up
* Probably some more stuff I'm forgetting right now

## Big man Southport:

![image](https://github.com/user-attachments/assets/de6e6ff0-ca99-4636-bdec-5e0b2d6b8037)

## Changelog

🆑
code: made /proc/getviewsize() pure

refactor: mob/eye/ai_eye has been restructured, now inheriting from a
generic mob/eye/camera type
refactor: advanced cameras and their subtypes are now
mob/eye/camera/remote subtypes
code: the cameranet no longer expects the user to be an AI eye
code: remote camera eyes have had their initialization streamlined
code: remote cameras handle assigning and unassigning users by
themselves now
code: remote cameras now use weakrefs instead of hard referencing owners
and origins
code: also the sentient disease is_define was removed (we don't have
those anymore)
fix: AI eyes no longer assign real names to themselves, fixing their
orbit name
/🆑

---------

Co-authored-by: Ghom <42542238+Ghommie@users.noreply.github.com>
2024-11-21 12:55:38 +01:00

81 lines
2.1 KiB
Plaintext

/**
* Eye mob used to look around a [camera network][/datum/cameranet]. \
* As it moves, it makes requests to the network to update what the user can and cannot see.
*/
/mob/eye/camera
name = "Inactive Camera Eye"
icon = 'icons/mob/eyemob.dmi'
icon_state = "generic_camera"
invisibility = INVISIBILITY_OBSERVER
interaction_range = INFINITY
/// If TRUE, the eye will cover turfs hidden to the cameranet with static.
var/use_visibility = TRUE
/// List of [camera chunks][/datum/camerachunk] visible to this camera.
/// Please don't interface with this directly. Use the [cameranet][/datum/cameranet].
var/final/list/datum/camerachunk/visibleCameraChunks = list()
/// NxN Range of a single camera chunk.
var/static_visibility_range = 16
/mob/eye/camera/Initialize(mapload)
. = ..()
GLOB.camera_eyes += src
/mob/eye/camera/Destroy()
for(var/datum/camerachunk/chunk in visibleCameraChunks)
chunk.remove(src)
GLOB.camera_eyes -= src
return ..()
/**
* Getter proc for getting the current user's client.
*
* The base version of this proc returns null.
* Subtypes are expected to overload this proc and make it return something meaningful.
*/
/mob/eye/camera/proc/GetViewerClient()
RETURN_TYPE(/client)
SHOULD_BE_PURE(TRUE)
return null
/**
* Use this when setting the camera eye's location directly. \
* It will also attempt to update visible chunks.
*/
/mob/eye/camera/proc/setLoc(destination, force_update = FALSE)
SHOULD_NOT_SLEEP(TRUE)
SHOULD_CALL_PARENT(TRUE)
destination = get_turf(destination)
if(!force_update && (destination == get_turf(src)))
return
if(destination)
abstract_move(destination)
else
moveToNullspace()
if(use_visibility)
update_visibility()
update_parallax_contents()
/// Sends a visibility query to the cameranet.
/// Can be used as a signal handler.
/mob/eye/camera/proc/update_visibility()
SIGNAL_HANDLER
PROTECTED_PROC(TRUE)
SHOULD_CALL_PARENT(TRUE)
if(use_visibility)
GLOB.cameranet.visibility(src)
/mob/eye/camera/zMove(dir, turf/target, z_move_flags = NONE, recursions_left = 1, list/falling_movs)
. = ..()
if(.)
setLoc(loc, force_update = TRUE)
/mob/eye/camera/Move()
SHOULD_NOT_OVERRIDE(TRUE)
return