mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-24 08:31:54 +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. /🆑
71 lines
2.7 KiB
Plaintext
71 lines
2.7 KiB
Plaintext
///The multiplier given to the base overtime charge drain value if its flashlight is on.
|
|
#define FLASHLIGHT_DRAIN_MULTIPLIER 1.1
|
|
|
|
///Draws power from its rightful source (area if its a computer, the cell otherwise)
|
|
///Takes into account special cases, like silicon PDAs through override, and nopower apps.
|
|
/obj/item/modular_computer/proc/use_power(amount = 0, check_programs = TRUE)
|
|
if(check_power_override(amount))
|
|
return TRUE
|
|
|
|
if(!internal_cell)
|
|
return FALSE
|
|
if(internal_cell.use(amount JOULES))
|
|
return TRUE
|
|
if(!check_programs)
|
|
return FALSE
|
|
internal_cell.use(min(amount JOULES, internal_cell.charge)) //drain it anyways.
|
|
if(active_program?.program_flags & PROGRAM_RUNS_WITHOUT_POWER)
|
|
return TRUE
|
|
INVOKE_ASYNC(src, PROC_REF(close_all_programs))
|
|
for(var/datum/computer_file/program/programs as anything in stored_files)
|
|
if((programs.program_flags & PROGRAM_RUNS_WITHOUT_POWER) && open_program(program = programs))
|
|
return TRUE
|
|
return FALSE
|
|
|
|
/obj/item/modular_computer/proc/give_power(amount)
|
|
if(internal_cell)
|
|
return internal_cell.give(amount)
|
|
return 0
|
|
|
|
///Shuts down the computer from powerloss.
|
|
/obj/item/modular_computer/proc/power_failure()
|
|
if(!enabled)
|
|
return
|
|
if(active_program)
|
|
active_program.event_powerfailure()
|
|
if(light_on)
|
|
set_light_on(FALSE)
|
|
for(var/datum/computer_file/program/programs as anything in idle_threads)
|
|
programs.event_powerfailure()
|
|
shutdown_computer(loud = FALSE)
|
|
|
|
///Takes the charge necessary from the Computer, shutting it off if it's unable to provide it.
|
|
///Charge depends on whether the PC is on, and what programs are running/idle on it.
|
|
/obj/item/modular_computer/proc/handle_power(seconds_per_tick)
|
|
var/power_usage = screen_on ? base_active_power_usage : base_idle_power_usage
|
|
if(light_on)
|
|
power_usage *= FLASHLIGHT_DRAIN_MULTIPLIER
|
|
if(active_program)
|
|
power_usage += active_program.power_cell_use
|
|
for(var/datum/computer_file/program/open_programs as anything in idle_threads)
|
|
if(!open_programs.power_cell_use)
|
|
continue
|
|
if(open_programs in idle_threads)
|
|
power_usage += (open_programs.power_cell_use / 2)
|
|
|
|
if(use_power(power_usage * seconds_per_tick))
|
|
return TRUE
|
|
power_failure()
|
|
return FALSE
|
|
|
|
///Returns TRUE if the PC should not be using any power, FALSE otherwise.
|
|
///Checks to see if the current app allows to be ran without power, if so we'll run with it.
|
|
/obj/item/modular_computer/proc/check_power_override(amount)
|
|
return !amount && !internal_cell?.charge && (active_program?.program_flags & PROGRAM_RUNS_WITHOUT_POWER)
|
|
|
|
//Integrated (Silicon) tablets don't drain power, because the tablet is required to state laws, so it being disabled WILL cause problems.
|
|
/obj/item/modular_computer/pda/silicon/check_power_override()
|
|
return TRUE
|
|
|
|
#undef FLASHLIGHT_DRAIN_MULTIPLIER
|