mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-30 11:32:20 +00:00
## 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. /🆑
89 lines
3.4 KiB
Plaintext
89 lines
3.4 KiB
Plaintext
/// Scan the turf where the computer is on.
|
|
#define ATMOZPHERE_SCAN_ENV "env"
|
|
/// Scan the objects that the tablet clicks.
|
|
#define ATMOZPHERE_SCAN_CLICK "click"
|
|
|
|
/datum/computer_file/program/atmosscan
|
|
filename = "atmosscan"
|
|
filedesc = "AtmoZphere"
|
|
downloader_category = PROGRAM_CATEGORY_ENGINEERING
|
|
program_open_overlay = "air"
|
|
extended_desc = "A small built-in sensor reads out the atmospheric conditions around the device."
|
|
size = 4
|
|
tgui_id = "NtosGasAnalyzer"
|
|
program_icon = "thermometer-half"
|
|
|
|
/// Whether we scan the current turf automatically (env) or scan tapped objects manually (click).
|
|
var/atmozphere_mode = ATMOZPHERE_SCAN_ENV
|
|
/// Saved [GasmixParser][/proc/gas_mixture_parser] data of the last thing we scanned.
|
|
var/list/last_gasmix_data
|
|
|
|
/// Secondary attack self.
|
|
/datum/computer_file/program/atmosscan/proc/turf_analyze(datum/source, mob/user)
|
|
SIGNAL_HANDLER
|
|
if(atmozphere_mode != ATMOZPHERE_SCAN_CLICK)
|
|
return
|
|
atmos_scan(user=user, target=get_turf(computer), silent=FALSE)
|
|
on_analyze(source=source, target=get_turf(computer))
|
|
return COMPONENT_CANCEL_ATTACK_CHAIN
|
|
|
|
/// Keep this in sync with it's tool based counterpart [/obj/proc/analyzer_act] and [/atom/proc/tool_act]
|
|
/datum/computer_file/program/atmosscan/tap(atom/A, mob/living/user, params)
|
|
if(atmozphere_mode != ATMOZPHERE_SCAN_CLICK)
|
|
return FALSE
|
|
if(!atmos_scan(user=user, target=A, silent=FALSE))
|
|
return FALSE
|
|
on_analyze(source=computer, target=A)
|
|
return TRUE
|
|
|
|
/// Updates our gasmix data if on click mode.
|
|
/datum/computer_file/program/atmosscan/proc/on_analyze(datum/source, atom/target)
|
|
var/mixture = target.return_analyzable_air()
|
|
if(!mixture)
|
|
return FALSE
|
|
var/list/airs = islist(mixture) ? mixture : list(mixture)
|
|
var/list/new_gasmix_data = list()
|
|
for(var/datum/gas_mixture/air as anything in airs)
|
|
var/mix_name = capitalize(lowertext(target.name))
|
|
if(airs.len != 1) //not a unary gas mixture
|
|
mix_name += " - Node [airs.Find(air)]"
|
|
new_gasmix_data += list(gas_mixture_parser(air, mix_name))
|
|
last_gasmix_data = new_gasmix_data
|
|
|
|
/datum/computer_file/program/atmosscan/ui_static_data(mob/user)
|
|
return return_atmos_handbooks()
|
|
|
|
/datum/computer_file/program/atmosscan/ui_data(mob/user)
|
|
var/list/data = list()
|
|
var/turf/turf = get_turf(computer)
|
|
data["atmozphereMode"] = atmozphere_mode
|
|
data["clickAtmozphereCompatible"] = (computer.hardware_flag & PROGRAM_PDA)
|
|
switch (atmozphere_mode) //Null air wont cause errors, don't worry.
|
|
if(ATMOZPHERE_SCAN_ENV)
|
|
var/datum/gas_mixture/air = turf?.return_air()
|
|
data["gasmixes"] = list(gas_mixture_parser(air, "Location Reading"))
|
|
if(ATMOZPHERE_SCAN_CLICK)
|
|
LAZYINITLIST(last_gasmix_data)
|
|
data["gasmixes"] = last_gasmix_data
|
|
return data
|
|
|
|
/datum/computer_file/program/atmosscan/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state)
|
|
. = ..()
|
|
switch(action)
|
|
if("scantoggle")
|
|
if(atmozphere_mode == ATMOZPHERE_SCAN_CLICK)
|
|
atmozphere_mode = ATMOZPHERE_SCAN_ENV
|
|
UnregisterSignal(computer, COMSIG_ITEM_ATTACK_SELF_SECONDARY)
|
|
return TRUE
|
|
if(!(computer.hardware_flag & PROGRAM_PDA))
|
|
computer.say("Device incompatible for scanning objects!")
|
|
return FALSE
|
|
atmozphere_mode = ATMOZPHERE_SCAN_CLICK
|
|
RegisterSignal(computer, COMSIG_ITEM_ATTACK_SELF_SECONDARY, PROC_REF(turf_analyze))
|
|
var/turf/turf = get_turf(computer)
|
|
last_gasmix_data = list(gas_mixture_parser(turf?.return_air(), "Location Reading"))
|
|
return TRUE
|
|
|
|
#undef ATMOZPHERE_SCAN_ENV
|
|
#undef ATMOZPHERE_SCAN_CLICK
|