Files
tonty 14d2514aa9 [MDB IGNORE] Refactors away /area/station/ai_monitored and its subtypes (with bonus neat repathing) (#93704)
## About The Pull Request

/area/station/ai_monitored's behaviour was isolated into a component,
`/datum/component/monitored_area`, which itself uses
`/datum/motion_group`s to query cameras. Functionally, it (should) work
identically to the old implementation. I'm sure that behaviour could
have been further cleaned up, camera code is quite dreadful, but it's
better to focus on isolating the behaviour first. Baby steps.

Areas that want to opt into monitoring can set `var/motion_monitored` to
TRUE (this approach was taken to make subtyping easier).

The following non-AI areas were changed:
- /area/station/ai_monitored/security/armory ->
/area/station/security/armory
- /area/station/ai_monitored/command/nuke_storage ->
/area/station/command/vault
- /area/station/ai_monitored/command/storage/eva ->
/area/station/command/eva

All other `/area/station/ai_monitored` subtypes were repathed into
`/area/station/ai` and cleaned up in a way that I thought made logical
sense. It is **much** more readable now. For example:

- /area/station/ai_monitored/turret_protected/aisat ->
/area/station/ai/satellite
- /area/station/ai_monitored/command/storage/satellite ->
/area/station/ai/satellite/maintenance/storage
- /area/station/ai_monitored/turret_protected/ai ->
/area/station/ai/satellite/chamber
2025-11-03 11:27:14 -06:00

94 lines
3.7 KiB
Plaintext

/**
* Causes a power failure across the station.
*
* All SMESs and APCs will be fully drained, and all areas will power down.
*
* The drain is permanent (that is, it won't automatically come back after some time like the grid check event),
* but the crew themselves can return power via the engine, solars, or other means of creating power.
*/
/proc/power_failure()
priority_announce("Abnormal activity detected in [station_name()]'s powernet. As a precautionary measure, the station's power will be shut off for an indeterminate duration.", "Critical Power Failure", ANNOUNCER_POWEROFF)
var/list/all_smes = SSmachines.get_machines_by_type_and_subtypes(/obj/machinery/power/smes)
for(var/obj/machinery/power/smes/smes as anything in all_smes)
if(istype(get_area(smes), /area/station/ai) || !is_station_level(smes.z))
continue
smes.charge = 0
smes.output_level = 0
smes.output_attempt = FALSE
smes.update_appearance()
smes.power_change()
for(var/area/station_area as anything in GLOB.areas)
if(!station_area.z || !is_station_level(station_area.z))
continue
if(!station_area.requires_power || station_area.always_unpowered )
continue
if(GLOB.typecache_powerfailure_safe_areas[station_area.type])
continue
station_area.power_light = FALSE
station_area.power_equip = FALSE
station_area.power_environ = FALSE
station_area.power_change()
for(var/obj/machinery/power/apc/C as anything in SSmachines.get_machines_by_type_and_subtypes(/obj/machinery/power/apc))
if(C.cell && is_station_level(C.z))
var/area/A = C.area
if(GLOB.typecache_powerfailure_safe_areas[A.type])
continue
C.cell.charge = 0
/**
* Restores power to all rooms on the station.
*
* Magically fills ALL APCs and SMESs to capacity, and restores power to depowered areas.
*/
/proc/power_restore()
priority_announce("Power has been restored to [station_name()]. We apologize for the inconvenience.", "Power Systems Nominal", ANNOUNCER_POWERON)
for(var/obj/machinery/power/apc/C as anything in SSmachines.get_machines_by_type_and_subtypes(/obj/machinery/power/apc))
if(C.cell && is_station_level(C.z))
C.cell.charge = C.cell.maxcharge
COOLDOWN_RESET(C, failure_timer)
var/list/all_smes = SSmachines.get_machines_by_type_and_subtypes(/obj/machinery/power/smes)
for(var/obj/machinery/power/smes/smes as anything in all_smes)
if(!is_station_level(smes.z))
continue
smes.adjust_charge(INFINITY)
smes.output_level = smes.output_level_max
smes.output_attempt = TRUE
smes.update_appearance()
smes.power_change()
for(var/area/station_area as anything in GLOB.areas)
if(!station_area.z || !is_station_level(station_area.z))
continue
if(!station_area.requires_power || station_area.always_unpowered)
continue
if(istype(station_area, /area/shuttle))
continue
station_area.power_light = TRUE
station_area.power_equip = TRUE
station_area.power_environ = TRUE
station_area.power_change()
/**
* A quicker version of [/proc/power_restore] that only handles recharging SMESs.
*
* This will also repower an entire station - it is not instantaneous like power restore,
* but it is faster performance-wise as it only handles SMES units.
*
* Great as a less magical / more IC way to return power to a sapped station.
*/
/proc/power_restore_quick()
priority_announce("All SMESs on [station_name()] have been recharged. We apologize for the inconvenience.", "Power Systems Nominal", ANNOUNCER_POWERON)
var/list/all_smes = SSmachines.get_machines_by_type_and_subtypes(/obj/machinery/power/smes)
for(var/obj/machinery/power/smes/smes as anything in all_smes)
if(!is_station_level(smes.z))
continue
smes.adjust_charge(INFINITY)
smes.output_level = smes.output_level_max
smes.output_attempt = TRUE
smes.update_appearance()
smes.power_change()