Integrated circuits for modular computers (#80530)

## About The Pull Request
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.

## Why It's Good For The Game
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.

## Changelog

🆑
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.
/🆑
This commit is contained in:
Ghom
2024-01-20 21:21:42 +01:00
committed by GitHub
parent d0f07e4dcf
commit f9957b0373
60 changed files with 1286 additions and 239 deletions
@@ -9,8 +9,10 @@
program_flags = PROGRAM_ON_NTNET_STORE | PROGRAM_REQUIRES_NTNET
tgui_id = "NtosNetMonitor"
program_icon = "network-wired"
circuit_comp_type = /obj/item/circuit_component/mod_program/ntnetmonitor
/datum/computer_file/program/ntnetmonitor/ui_act(action, list/params, datum/tgui/ui)
/datum/computer_file/program/ntnetmonitor/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state)
. = ..()
switch(action)
if("resetIDS")
SSmodular_computers.intrusion_detection_alarm = FALSE
@@ -66,3 +68,64 @@
data["tablets"] += list(tablet_data)
return data
/obj/item/circuit_component/mod_program/ntnetmonitor
associated_program = /datum/computer_file/program/ntnetmonitor
///The stored NTnet relay or PDA to be used as the target of triggers
var/datum/port/input/target
///Sets `intrusion_detection_alarm` when triggered
var/datum/port/input/toggle_ids
///Toggles the target ntnet relay on/off when triggered
var/datum/port/input/toggle_relay
///Purges modpc logs when triggered
var/datum/port/input/purge_logs
///Toggles the spam mode of the target PDA when triggered
var/datum/port/input/toggle_mass_pda
///Toggle mime mode of the target PDA when triggered
var/datum/port/input/toggle_mime_mode
///Returns a list of all PDA Messengers when the "Get Messengers" input is pinged
var/datum/port/output/all_messengers
///See above
var/datum/port/input/get_pdas
/obj/item/circuit_component/mod_program/ntnetmonitor/populate_ports()
. = ..()
target = add_input_port("Target Messenger/Relay", PORT_TYPE_DATUM, order = 0.5)
toggle_ids = add_input_port("Toggle IDS Status", PORT_TYPE_SIGNAL, trigger = PROC_REF(toggle_ids))
toggle_relay = add_input_port("Toggle NTnet Relay", PORT_TYPE_SIGNAL, trigger = PROC_REF(toggle_relay))
purge_logs = add_input_port("Purge Logs", PORT_TYPE_SIGNAL, trigger = PROC_REF(purge_logs))
toggle_mass_pda = add_input_port("Toggle Mass Messenger", PORT_TYPE_SIGNAL, trigger = PROC_REF(toggle_pda_stuff))
toggle_mime_mode = add_input_port("Toggle Mime Mode", PORT_TYPE_SIGNAL, trigger = PROC_REF(toggle_pda_stuff))
get_pdas = add_input_port("Get PDAs", PORT_TYPE_SIGNAL, trigger = PROC_REF(get_pdas))
all_messengers = add_output_port("List of PDAs", PORT_TYPE_LIST(PORT_TYPE_ATOM))
/obj/item/circuit_component/mod_program/ntnetmonitor/proc/get_pdas(datum/port/port)
var/list/computers_with_messenger = list()
for(var/messenger_ref as anything in GLOB.pda_messengers)
var/datum/computer_file/program/messenger/messenger = GLOB.pda_messengers[messenger_ref]
computers_with_messenger += messenger.computer
all_messengers.set_value(computers_with_messenger)
/obj/item/circuit_component/mod_program/ntnetmonitor/proc/toggle_ids(datum/port/port)
SSmodular_computers.intrusion_detection_enabled = !SSmodular_computers.intrusion_detection_enabled
/obj/item/circuit_component/mod_program/ntnetmonitor/proc/toggle_relay(datum/port/port)
var/obj/machinery/ntnet_relay/target_relay = target.value
if(!istype(target_relay))
return
target_relay.set_relay_enabled(!target_relay.relay_enabled)
/obj/item/circuit_component/mod_program/ntnetmonitor/proc/purge_logs(datum/port/port)
SSmodular_computers.purge_logs()
/obj/item/circuit_component/mod_program/ntnetmonitor/proc/toggle_pda_stuff(datum/port/port)
var/obj/item/modular_computer/computer = target.value
if(!istype(computer))
return
var/datum/computer_file/program/messenger/target_messenger = locate() in computer.stored_files
if(isnull(target_messenger))
return
if(COMPONENT_TRIGGERED_BY(toggle_mass_pda, port))
target_messenger.spam_mode = !target_messenger.spam_mode
if(COMPONENT_TRIGGERED_BY(toggle_mime_mode, port))
target_messenger.mime_mode = !target_messenger.mime_mode