Files
Bubberstation/code/modules/modular_computers/computers/item/computer_power.dm
Waterpig bb70889f6e TG Upstream Part 1
3591 individual conflicts

Update build.js

Update install_node.sh

Update byond.js

oh my fucking god

hat

slow

huh

holy shit

we all fall down

2 more I missed

2900 individual conflicts

2700 Individual conflicts

replaces yarn file with tg version, bumping us down to 2200-ish

Down to 2000 individual conflicts

140 down

mmm

aaaaaaaaaaaaaaaaaaa

not yt

575

soon

900 individual conflicts

600 individual conflicts, 121 file conflicts

im not okay

160 across 19 files

29 in 4 files

0 conflicts, compiletime fix time

some minor incap stuff

missed ticks

weird dupe definition stuff

missed ticks 2

incap fixes

undefs and pie fix

Radio update and some extra minor stuff

returns a single override

no more dupe definitions, 175 compiletime errors

Unticked file fix

sound and emote stuff

honk and more radio stuff
2024-10-19 08:04:33 -07:00

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_energy(amount = 0, check_programs = TRUE)
if(check_power_override(amount))
return TRUE
if(!internal_cell)
return FALSE
if(internal_cell.use(amount))
return TRUE
if(!check_programs)
return FALSE
internal_cell.use(min(amount, 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_energy(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