Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Camera Autoname change #5456

Merged
merged 3 commits into from
Jan 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions code/game/machinery/camera/camera.dm
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@
/// If this camera should have innate EMP-proofing
var/emp_proof = FALSE

///Autonaming
var/autoname = FALSE
var/autonumber = 0 //camera number in area

GLOBAL_LIST_EMPTY_TYPED(all_cameras, /obj/structure/machinery/camera)
/obj/structure/machinery/camera/Initialize(mapload, ...)
. = ..()
Expand All @@ -60,6 +64,24 @@ GLOBAL_LIST_EMPTY_TYPED(all_cameras, /obj/structure/machinery/camera)
set_pixel_location()
update_icon()

//This camera automatically sets it's name to whatever the area that it's in is called.
if(autoname)
autonumber = 1
var/area/my_area = get_area(src)
if(my_area)
for(var/obj/structure/machinery/camera/autoname/current_camera in GLOB.machines)
if(current_camera == src)
continue
var/area/current_camera_area = get_area(current_camera)
if(current_camera_area.type != my_area.type)
continue

if(!current_camera.autonumber)
continue

autonumber = max(autonumber, current_camera.autonumber + 1)
c_tag = "[my_area.name] #[autonumber]"

/obj/structure/machinery/camera/Destroy()
GLOB.all_cameras -= src
. = ..()
Expand Down
16 changes: 1 addition & 15 deletions code/game/machinery/camera/presets.dm
Original file line number Diff line number Diff line change
Expand Up @@ -70,21 +70,7 @@
// AUTONAME

/obj/structure/machinery/camera/autoname
var/number = 0 //camera number in area

//This camera type automatically sets it's name to whatever the area that it's in is called.
/obj/structure/machinery/camera/autoname/Initialize(mapload, ...)
. = ..()
number = 1
var/area/A = get_area(src)
if(A)
for(var/obj/structure/machinery/camera/autoname/C in GLOB.machines)
if(C == src) continue
var/area/CA = get_area(C)
if(CA.type == A.type)
if(C.number)
number = max(number, C.number+1)
c_tag = "[A.name] #[number]"
autoname = TRUE

//cameras installed inside the dropships, accessible via both cockpit monitor and Almayer camera computers
/obj/structure/machinery/camera/autoname/almayer/dropship_one
Expand Down
Loading