mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-18 11:36:24 +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:
@@ -0,0 +1,76 @@
|
||||
///A simple circuit component compatible with stationary consoles, laptops and PDAs, independent from programs.
|
||||
/obj/item/circuit_component/modpc
|
||||
display_name = "Modular Computer"
|
||||
desc = "Circuit for basic functions of a modular computer."
|
||||
var/obj/item/modular_computer/computer
|
||||
///Turns the PC on/off
|
||||
var/datum/port/input/on_off
|
||||
///When set, will print a piece of paper with the value as text.
|
||||
var/datum/port/input/print
|
||||
|
||||
///Toggles lights on and off. Also RGB.
|
||||
var/datum/port/input/lights
|
||||
var/datum/port/input/red
|
||||
var/datum/port/input/green
|
||||
var/datum/port/input/blue
|
||||
|
||||
/obj/item/circuit_component/modpc/register_shell(atom/movable/shell)
|
||||
. = ..()
|
||||
if(istype(shell, /obj/item/modular_computer))
|
||||
computer = shell
|
||||
else if(istype(shell, /obj/machinery/modular_computer))
|
||||
var/obj/machinery/modular_computer/console = shell
|
||||
computer = console.cpu
|
||||
|
||||
/**
|
||||
* Some mod pc have lights while some don't, but populate_ports()
|
||||
* is called before we get to know which object this has attahed to,
|
||||
* I hope you're cool with me doing it here.
|
||||
*/
|
||||
if(computer?.has_light)
|
||||
lights = add_input_port("Toggle Lights", PORT_TYPE_SIGNAL)
|
||||
red = add_input_port("Red", PORT_TYPE_NUMBER)
|
||||
green = add_input_port("Green", PORT_TYPE_NUMBER)
|
||||
blue = add_input_port("Blue", PORT_TYPE_NUMBER)
|
||||
|
||||
/obj/item/circuit_component/modpc/unregister_shell(atom/movable/shell)
|
||||
computer = null
|
||||
return ..()
|
||||
|
||||
/obj/item/circuit_component/modpc/populate_ports()
|
||||
on_off = add_input_port("Turn On/Off", PORT_TYPE_SIGNAL)
|
||||
print = add_input_port("Print Text", PORT_TYPE_STRING)
|
||||
|
||||
/obj/item/circuit_component/modpc/pre_input_received(datum/port/input/port)
|
||||
if(isnull(computer))
|
||||
return
|
||||
if(COMPONENT_TRIGGERED_BY(print, port))
|
||||
print.set_value(html_encode(trim(print.value, MAX_PAPER_LENGTH)))
|
||||
else if(COMPONENT_TRIGGERED_BY(red, port))
|
||||
red.set_value(clamp(red.value, 0, 255))
|
||||
else if(COMPONENT_TRIGGERED_BY(blue, port))
|
||||
blue.set_value(clamp(blue.value, 0, 255))
|
||||
else if(COMPONENT_TRIGGERED_BY(green, port))
|
||||
green.set_value(clamp(green.value, 0, 255))
|
||||
|
||||
/obj/item/circuit_component/modpc/input_received(datum/port/input/port)
|
||||
if(isnull(computer))
|
||||
return
|
||||
if(COMPONENT_TRIGGERED_BY(on_off, port))
|
||||
if(computer.enabled)
|
||||
INVOKE_ASYNC(computer, TYPE_PROC_REF(/obj/item/modular_computer, shutdown_computer))
|
||||
else
|
||||
INVOKE_ASYNC(computer, TYPE_PROC_REF(/obj/item/modular_computer, turn_on))
|
||||
return
|
||||
|
||||
if(!computer.enabled)
|
||||
return
|
||||
|
||||
if(COMPONENT_TRIGGERED_BY(print, port))
|
||||
computer.print_text(print.value)
|
||||
|
||||
if(lights)
|
||||
if(COMPONENT_TRIGGERED_BY(lights, port))
|
||||
computer.toggle_flashlight()
|
||||
if(COMPONENT_TRIGGERED_BY(red, port) || COMPONENT_TRIGGERED_BY(green, port) || COMPONENT_TRIGGERED_BY(blue, port))
|
||||
computer.set_flashlight_color(rgb(red.value || 0, green.value || 0, blue.value || 0))
|
||||
Reference in New Issue
Block a user