mirror of
https://github.com/Skyrat-SS13/Skyrat-tg.git
synced 2026-07-19 20:04:03 +01:00
[MIRROR] Integrated circuits for modular computers (#26196)
Integrated circuits for modular computers (#80530) This PR integrates circuits for modular computers and a good bits of their programs. The peculiarity here is that modular computers have no fixed amount of unremovable components (except the base one with just a couple ports for now), instead, they're added and removed along with programs. With a few exceptions (such as the messenger and signaler), for these program circuits to work, their associated program has to be either open or in the background. For a reason or another, not all programs have a circuit associated to them, still, however the programs with a circuit are still a handful. They are: - Nanotrasen Pay System - Notepad - SiliConnect - WireCarp - MODsuit Control - Spectre Meter - Direct Messenger* - LifeConnect - Custodial Locator - Fission360 - Camera - Status Display - SignalCommander *By the by, sending messages has a cooldown, so it shouldn't be as spammy. If it turns out to not be enough, I can make it so messages from circuit will be ignored by other messenger circuits. The PR is no longer WIP. I believe modular computers could make for some interesting setups with circuits, since they're fairly flexible and stocked with features unlike many other appliances, therefore also a speck more abusable, though limits, cooldowns, logging and sanitization have been implemented to keep it in check. 🆑 add: Modular Computers now support integrated circuits. What can be done with them depends on the programs installed and whether they're running (open or background). add: Modular Consoles (the machinery) now have a small backup cell they draw power from if the power goes out. /🆑 Co-authored-by: Ghom <42542238+Ghommie@users.noreply.github.com>
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
can_run_on_flags = PROGRAM_PDA
|
||||
tgui_id = "NtosCamera"
|
||||
program_icon = "camera"
|
||||
circuit_comp_type = /obj/item/circuit_component/mod_program/camera
|
||||
|
||||
/// Camera built-into the tablet.
|
||||
var/obj/item/camera/internal_camera
|
||||
@@ -16,6 +17,48 @@
|
||||
/// How many pictures were taken already, used for the camera's TGUI photo display
|
||||
var/picture_number = 1
|
||||
|
||||
/obj/item/circuit_component/mod_program/camera
|
||||
associated_program = /datum/computer_file/program/maintenance/camera
|
||||
circuit_flags = CIRCUIT_FLAG_INPUT_SIGNAL
|
||||
|
||||
///A target to take a picture of.
|
||||
var/datum/port/input/picture_target
|
||||
///The photographed target
|
||||
var/datum/port/output/photographed
|
||||
|
||||
/obj/item/circuit_component/mod_program/camera/populate_ports()
|
||||
. = ..()
|
||||
picture_target = add_input_port("Picture Target", PORT_TYPE_ATOM)
|
||||
photographed = add_output_port("Photographed Entity", PORT_TYPE_ATOM)
|
||||
|
||||
/obj/item/circuit_component/mod_program/camera/register_shell(atom/movable/shell)
|
||||
. = ..()
|
||||
var/datum/computer_file/program/maintenance/camera/cam = associated_program
|
||||
RegisterSignal(cam.internal_camera, COMSIG_CAMERA_IMAGE_CAPTURED, PROC_REF(on_image_captured))
|
||||
|
||||
/obj/item/circuit_component/mod_program/camera/unregister_shell()
|
||||
var/datum/computer_file/program/maintenance/camera/cam = associated_program
|
||||
UnregisterSignal(cam.internal_camera, COMSIG_CAMERA_IMAGE_CAPTURED)
|
||||
return ..()
|
||||
|
||||
/obj/item/circuit_component/mod_program/camera/input_received(datum/port/input/port)
|
||||
var/atom/target = picture_target.value
|
||||
if(!target)
|
||||
var/turf/our_turf = get_location()
|
||||
target = locate(our_turf.x, our_turf.y, our_turf.z)
|
||||
if(!target)
|
||||
return
|
||||
var/datum/computer_file/program/maintenance/camera/cam = associated_program
|
||||
if(!cam.internal_camera.can_target(target))
|
||||
return
|
||||
var/pic_size_x = cam.internal_camera.picture_size_x - 1
|
||||
var/pic_size_y = cam.internal_camera.picture_size_y - 1
|
||||
INVOKE_ASYNC(cam.internal_camera, TYPE_PROC_REF(/obj/item/camera, captureimage), target, null, pic_size_x, pic_size_y)
|
||||
|
||||
/obj/item/circuit_component/mod_program/camera/proc/on_image_captured(obj/item/camera/source, atom/target, mob/user)
|
||||
SIGNAL_HANDLER
|
||||
photographed.set_output(target)
|
||||
|
||||
/datum/computer_file/program/maintenance/camera/on_install()
|
||||
. = ..()
|
||||
internal_camera = new(computer)
|
||||
@@ -50,13 +93,13 @@
|
||||
|
||||
return data
|
||||
|
||||
/datum/computer_file/program/maintenance/camera/ui_act(action, params, datum/tgui/ui)
|
||||
var/mob/living/user = usr
|
||||
/datum/computer_file/program/maintenance/camera/ui_act(action, params, datum/tgui/ui, datum/ui_state/state)
|
||||
. = ..()
|
||||
switch(action)
|
||||
if("print_photo")
|
||||
if(computer.stored_paper <= 0)
|
||||
to_chat(usr, span_notice("Hardware error: Printer out of paper."))
|
||||
return
|
||||
internal_camera.printpicture(user, internal_picture)
|
||||
internal_camera.printpicture(usr, internal_picture)
|
||||
computer.stored_paper--
|
||||
computer.visible_message(span_notice("\The [computer] prints out a paper."))
|
||||
|
||||
Reference in New Issue
Block a user