Files
Bubberstation/code/modules/modular_computers/computers/item/computer_power.dm
Gandalf 9361376345 PDA update (Messenger works while dead, Microwave works, etc). (#80069) [REMIRROR] (#25829)
* PDA update (Messenger works while dead, Microwave works, etc). (#80069)

This is an update that touches many more things all at once (compared to
my other PRs) meant to make PDAs in general feel more consistent and not
take away from one of the experiences we want to encourage: interaction
between players.

1. Replaced all checks of a 'pda' with a 'modular pc'. This means
technically (though not done in-game currently) other modpcs can hold an
uplink, and microwaves can charge laptops.
2. Speaking of microwave, they now don't break and require
deconstruction if the cell is removed mid-charge.
3. When a Mod PC is out of power, it will now allow the Messenger to
work (which now also doesn't consume any additional power), if the app
exists on the PC. Here's a video demonstration

https://github.com/tgstation/tgstation/assets/53777086/7ae12f81-a271-49b8-95fa-2ba54d2e2d1f

4. Flashlights can't be turned on while the cell is dead
5. I replaced a bunch of program vars with ``program_flags`` and renamed
``usage_flags`` to ``can_run_on_flags``.
6. Added a debug modPC that has every app installed by default. Mafia
had some issues in the past that were unknown because Mafia wasn't
preinstalled with any tablet so was never in create & destroy nor in any
other unit test. This was just an easy solution I had, but PDAs should
get more in-depth unit tests in the future for running apps n stuff- I
just wanted to make sure no other apps were broken/harddeling.

Currently when a PDA dies, its only use is to reply to PDA messages sent
to you, since you can still reply to them. Instead of just fixing it and
telling players to cope, I thought it would be nice to allow PDA
Messenger to still work, as it is a vital app.
You can call it some emergency power mode or whatever, I don't really
mind the reason behind why it is this way.

When I made cells used more on PDAs, my main goal was to encourage
upgrading your PDA and/or limiting how many apps you use at once, I did
not want this to hit on players who use it as a form of interaction.
This is the best of both worlds, I think.

The rest of the changes is just for modularity, if some downstream wants
to add tablets, phone computers, or whatever the hell else, they can
still get just as far as PDAs should be able to get to, hopefully.

🆑
add: PDAs with a dead power cell are now limited to using their
Messenger app.
fix: Microwaves now stop charging PDAs if the cell was removed
mid-charge.
fix: Microwaves can now charge laptops.
fix: PDA Flashlights can't be turned on while the PDA is dead.
fix: You can now hold a laptop up to a camera (if it has a notekeeper
app installed) like PDAs already could.
/🆑

---------

Co-authored-by: lessthanthree <83487515+lessthnthree@users.noreply.github.com>

* ok

---------

Co-authored-by: John Willard <53777086+JohnFulpWillard@users.noreply.github.com>
Co-authored-by: lessthanthree <83487515+lessthnthree@users.noreply.github.com>
2023-12-24 23:20:11 +00: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_power(amount = 0)
if(check_power_override())
return TRUE
if(!internal_cell)
return FALSE
if(!internal_cell.charge && (isnull(active_program) || !(active_program.program_flags & PROGRAM_RUNS_WITHOUT_POWER)))
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
if(!internal_cell.use(amount JOULES))
internal_cell.use(min(amount JOULES, internal_cell.charge)) //drain it anyways.
return FALSE
return TRUE
/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()
return (!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