-
-
Notifications
You must be signed in to change notification settings - Fork 414
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
42076b1
commit 48a59dc
Showing
19 changed files
with
842 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,236 @@ | ||
/obj/machinery/computer/camera_advanced | ||
name = "advanced camera console" | ||
desc = "Used to access the various cameras on the station." | ||
icon_state = "cameras" | ||
var/list/z_lock = list() // Lock use to these z levels | ||
var/lock_override = NONE | ||
var/mob/camera/Eye/remote/eyeobj | ||
var/mob/living/current_user = null | ||
var/list/networks = list("ss13") | ||
var/datum/action/camera_off/off_action = new | ||
var/datum/action/camera_jump/jump_action = new | ||
var/list/actions = list() | ||
|
||
circuit = /obj/item/weapon/circuitboard/camera_advanced | ||
|
||
light_color = "#a91515" | ||
|
||
/obj/machinery/computer/camera_advanced/atom_init() | ||
. = ..() | ||
for(var/i in networks) | ||
networks -= i | ||
networks += lowertext(i) | ||
if(lock_override) | ||
if(lock_override & CAMERA_LOCK_STATION) | ||
z_lock |= SSmapping.levels_by_trait(ZTRAIT_STATION) | ||
if(lock_override & CAMERA_LOCK_MINING) | ||
z_lock |= SSmapping.levels_by_trait(ZTRAIT_MINING) | ||
if(lock_override & CAMERA_LOCK_CENTCOM) | ||
z_lock |= SSmapping.levels_by_trait(ZTRAIT_CENTCOM) | ||
|
||
/obj/machinery/computer/camera_advanced/proc/CreateEye() | ||
eyeobj = new() | ||
eyeobj.origin = src | ||
|
||
/obj/machinery/computer/camera_advanced/proc/GrantActions(mob/living/user) | ||
if(off_action) | ||
off_action.target = user | ||
off_action.Grant(user) | ||
actions += off_action | ||
|
||
if(jump_action) | ||
jump_action.target = user | ||
jump_action.Grant(user) | ||
actions += jump_action | ||
|
||
/obj/machinery/proc/remove_eye_control(mob/living/user) | ||
CRASH("[type] does not implement ai eye handling") | ||
|
||
/obj/machinery/computer/camera_advanced/remove_eye_control(mob/living/user) | ||
if(!user) | ||
return | ||
for(var/V in actions) | ||
var/datum/action/A = V | ||
A.Remove(user) | ||
actions.Cut() | ||
for(var/V in eyeobj.visibleCameraChunks) | ||
var/datum/camerachunk/C = V | ||
C.remove(eyeobj) | ||
if(user.client) | ||
user.reset_view(null) | ||
if(eyeobj.visible_icon && user.client) | ||
user.client.images -= eyeobj.user_image | ||
eyeobj.master = null | ||
user.remote_control = null | ||
|
||
current_user = null | ||
user.unset_machine() | ||
|
||
/obj/machinery/computer/camera_advanced/check_eye(mob/user) | ||
if( (stat & (NOPOWER|BROKEN)) || (!Adjacent(user) && !user.has_unlimited_silicon_privilege) || user.eye_blind || user.incapacitated() ) | ||
user.unset_machine() | ||
return FALSE | ||
return TRUE | ||
|
||
/obj/machinery/computer/camera_advanced/Destroy() | ||
if(current_user) | ||
current_user.unset_machine() | ||
if(eyeobj) | ||
qdel(eyeobj) | ||
QDEL_LIST(actions) | ||
return ..() | ||
|
||
/obj/machinery/computer/camera_advanced/on_unset_machine(mob/M) | ||
if(M == current_user) | ||
remove_eye_control(M) | ||
..() | ||
|
||
/obj/machinery/computer/camera_advanced/proc/can_use(mob/living/user) | ||
return TRUE | ||
|
||
/obj/machinery/computer/camera_advanced/abductor/can_use(mob/user) | ||
if(!isabductor(user)) | ||
return FALSE | ||
return ..() | ||
|
||
/obj/machinery/computer/camera_advanced/interact(mob/user) | ||
user.machine = src | ||
var/mob/living/L = user | ||
|
||
if(!can_use(user)) | ||
return | ||
if(!eyeobj) | ||
CreateEye() | ||
|
||
if(!eyeobj.eye_initialized) | ||
var/camera_location | ||
var/turf/myturf = get_turf(src) | ||
camera_location = myturf | ||
if(z_lock.len && !(myturf.z in z_lock)) | ||
camera_location = locate(round(world.maxx/2), round(world.maxy/2), z_lock[1]) | ||
|
||
if(camera_location) | ||
eyeobj.eye_initialized = TRUE | ||
give_eye_control(L) | ||
eyeobj.setLoc(camera_location) | ||
else | ||
user.unset_machine() | ||
else | ||
give_eye_control(L) | ||
eyeobj.setLoc(eyeobj.loc) | ||
|
||
|
||
/obj/machinery/computer/camera_advanced/attack_hand(mob/user) | ||
if(!is_operational()) | ||
return | ||
if(current_user) | ||
to_chat(user, "<span class='warning'>The console is already in use!</span>") | ||
return | ||
..() | ||
|
||
/obj/machinery/computer/camera_advanced/attack_robot(mob/user) | ||
return attack_hand(user) | ||
|
||
/obj/machinery/computer/camera_advanced/attack_ai(mob/user) | ||
return //AIs would need to disable their own camera procs to use the console safely. Bugs happen otherwise. | ||
|
||
/obj/machinery/computer/camera_advanced/proc/give_eye_control(mob/user) | ||
GrantActions(user) | ||
current_user = user | ||
eyeobj.master = user | ||
eyeobj.name = "Camera Eye ([user.name])" | ||
user.remote_control = eyeobj | ||
user.reset_view(eyeobj) | ||
eyeobj.setLoc(eyeobj.loc) | ||
if(eyeobj.visible_icon && user.client) | ||
user.client.images += eyeobj.user_image | ||
|
||
/mob/camera/Eye/remote | ||
name = "Inactive Camera Eye" | ||
var/sprint = 10 | ||
var/cooldown = 0 | ||
var/acceleration = 0 | ||
var/obj/machinery/origin | ||
var/eye_initialized = 0 | ||
var/visible_icon = 0 | ||
var/image/user_image = null | ||
|
||
|
||
/mob/camera/Eye/remote/Destroy() | ||
if(origin && master) | ||
origin.remove_eye_control(master,src) | ||
origin = null | ||
master = null | ||
. = ..() | ||
|
||
/mob/camera/Eye/remote/atom_init() | ||
if(!user_image && visible_icon) | ||
user_image = image(icon,src,icon_state,LIGHTING_LAYER+1) | ||
. = ..() | ||
|
||
|
||
/mob/camera/Eye/remote/relaymove(mob/user,direct) | ||
var/initial = initial(sprint) | ||
var/max_sprint = 50 | ||
|
||
if(cooldown && cooldown < world.timeofday) // 3 seconds | ||
sprint = initial | ||
|
||
for(var/i = 0; i < max(sprint, initial); i += 20) | ||
var/turf/step = get_turf(get_step(src, direct)) | ||
if(step) | ||
setLoc(step) | ||
|
||
cooldown = world.timeofday + 5 | ||
if(acceleration) | ||
sprint = min(sprint + 0.5, max_sprint) | ||
else | ||
sprint = initial | ||
|
||
/datum/action/camera_off | ||
name = "End Camera View" | ||
button_icon = 'icons/mob/actions.dmi' | ||
button_icon_state = "camera_off" | ||
action_type = AB_INNATE | ||
|
||
/datum/action/camera_off/Activate() | ||
if(!target || !isliving(target)) | ||
return | ||
var/mob/living/C = target | ||
var/mob/camera/Eye/remote/remote_eye = C.remote_control | ||
var/obj/machinery/computer/camera_advanced/console = remote_eye.origin | ||
console.remove_eye_control(target) | ||
|
||
/datum/action/camera_jump | ||
name = "Jump To Camera" | ||
button_icon = 'icons/mob/actions.dmi' | ||
button_icon_state = "camera_jump" | ||
action_type = AB_INNATE | ||
|
||
/datum/action/camera_jump/Activate() | ||
if(!target || !isliving(target)) | ||
return | ||
var/mob/living/C = target | ||
var/mob/camera/Eye/remote/remote_eye = C.remote_control | ||
var/obj/machinery/computer/camera_advanced/origin = remote_eye.origin | ||
|
||
var/list/L = list() | ||
|
||
for (var/obj/machinery/camera/cam in cameranet.cameras) | ||
if(origin.z_lock.len && !(cam.z in origin.z_lock)) | ||
continue | ||
L.Add(cam) | ||
|
||
camera_sort(L) | ||
|
||
var/list/T = list() | ||
|
||
for (var/obj/machinery/camera/netcam in L) | ||
var/list/tempnetwork = netcam.network & origin.networks | ||
if (tempnetwork.len) | ||
T["[netcam.c_tag][netcam.can_use() ? null : " (Deactivated)"]"] = netcam | ||
|
||
var/camera = input("Choose which camera you want to view", "Cameras") as null|anything in T | ||
var/obj/machinery/camera/final = T[camera] | ||
if(final) | ||
remote_eye.setLoc(get_turf(final)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.