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

[MIRROR] Advanced camera consoles correctly deactivates when something happens to it or the user #2901

Merged
merged 5 commits into from
Apr 16, 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
4 changes: 3 additions & 1 deletion code/game/machinery/_machinery.dm
Original file line number Diff line number Diff line change
Expand Up @@ -588,13 +588,15 @@
set_panel_open(!panel_open)

/obj/machinery/can_interact(mob/user)
if(QDELETED(user))
return FALSE

if((machine_stat & (NOPOWER|BROKEN)) && !(interaction_flags_machine & INTERACT_MACHINE_OFFLINE)) // Check if the machine is broken, and if we can still interact with it if so
return FALSE

if(SEND_SIGNAL(user, COMSIG_TRY_USE_MACHINE, src) & COMPONENT_CANT_USE_MACHINE_INTERACT)
return FALSE


if(isAdminGhostAI(user))
return TRUE //the Gods have unlimited power and do not care for things such as range or blindness

Expand Down
35 changes: 21 additions & 14 deletions code/game/machinery/computer/camera_advanced.dm
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
icon_screen = "cameras"
icon_keyboard = "security_key"
light_color = COLOR_SOFT_RED
processing_flags = START_PROCESSING_MANUALLY

var/list/z_lock = list() // Lock use to these z levels
var/lock_override = NONE
var/mob/camera/ai_eye/remote/eyeobj
Expand Down Expand Up @@ -50,6 +52,20 @@
if(move_down_action)
actions += new move_down_action(src)

/obj/machinery/computer/camera_advanced/Destroy()
if(!QDELETED(current_user))
unset_machine(current_user)
if(eyeobj)
QDEL_NULL(eyeobj)
QDEL_LIST(actions)
current_user = null
return ..()

/obj/machinery/computer/camera_advanced/process()
if(!can_use(current_user) || (issilicon(current_user) && !current_user.has_unlimited_silicon_privilege))
unset_machine(current_user)
return PROCESS_KILL

/obj/machinery/computer/camera_advanced/connect_to_shuttle(mapload, obj/docking_port/mobile/port, obj/docking_port/stationary/dock)
for(var/i in networks)
networks -= i
Expand Down Expand Up @@ -85,7 +101,7 @@
eyeobj.setLoc(eyeobj.loc)
if(should_supress_view_changes)
user.client.view_size.supress()
RegisterSignal(user, COMSIG_MOVABLE_MOVED, PROC_REF(check_eye))
begin_processing()

/obj/machinery/computer/camera_advanced/remove_eye_control(mob/living/user)
if(isnull(user?.client))
Expand All @@ -104,25 +120,16 @@
eyeobj.eye_user = null
user.remote_control = null
current_user = null
unset_machine(user)
playsound(src, 'sound/machines/terminal_off.ogg', 25, FALSE)
UnregisterSignal(user, COMSIG_MOVABLE_MOVED)

/obj/machinery/computer/camera_advanced/proc/check_eye(mob/user)
SIGNAL_HANDLER
if(!can_use(user) || (issilicon(user) && !user.has_unlimited_silicon_privilege))
unset_machine(user)

/obj/machinery/computer/camera_advanced/Destroy()
if(eyeobj)
QDEL_NULL(eyeobj)
QDEL_LIST(actions)
current_user = null
return ..()
/obj/machinery/computer/camera_advanced/on_set_is_operational(old_value)
if(!is_operational)
unset_machine(current_user)

/obj/machinery/computer/camera_advanced/proc/unset_machine(mob/M)
if(M == current_user)
remove_eye_control(M)
end_processing()

/obj/machinery/computer/camera_advanced/proc/can_use(mob/living/user)
return can_interact(user)
Expand Down
Loading