Files
Bubberstation/code/modules/events/anomaly/anomaly_placer.dm
tontyandGitHub 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

75 lines
2.1 KiB
Plaintext

/datum/anomaly_placer
var/static/list/allowed_areas
/**
* Returns an area which is safe to place an anomaly inside.
*/
/datum/anomaly_placer/proc/findValidArea()
if(!allowed_areas)
generateAllowedAreas()
var/list/possible_areas = typecache_filter_list(GLOB.areas, allowed_areas)
if (!length(possible_areas))
CRASH("No valid areas for anomaly found.")
var/area/landing_area = pick(possible_areas)
var/list/turf_test = get_area_turfs(landing_area)
if(!turf_test.len)
CRASH("Anomaly : No valid turfs found for [landing_area] - [landing_area.type]")
return landing_area
/**
* Returns a turf which is safe to place an anomaly on.
*
* Arguments
* * target_area - Area to return a turf from.
*/
/datum/anomaly_placer/proc/findValidTurf(area/target_area)
var/list/valid_turfs = list()
for (var/turf/try_turf as anything in get_area_turfs(target_area))
if (!is_valid_destination(try_turf))
continue
valid_turfs += try_turf
if (!valid_turfs.len)
CRASH("Dimensional anomaly attempted to reach invalid location [target_area].")
return pick(valid_turfs)
/**
* Returns true if the provided turf is valid to place an anomaly on.
*
* Arguments
* * tested - Turf to try landing on.
*/
/datum/anomaly_placer/proc/is_valid_destination(turf/tested)
if (isspaceturf(tested))
return FALSE
if (tested.is_blocked_turf(exclude_mobs = TRUE))
return FALSE
if (islava(tested))
return FALSE
if (ischasm(tested))
return FALSE
return TRUE
/**
* Populates the allowed areas list.
*/
/datum/anomaly_placer/proc/generateAllowedAreas()
//Places that shouldn't explode
var/static/list/safe_area_types = typecacheof(list(
/area/station/ai/satellite/chamber,
/area/station/ai/upload/chamber,
/area/station/engineering,
/area/station/science/ordnance/bomb,
/area/station/solars,
/area/station/holodeck,
/area/station/maintenance,
))
//Subtypes from the above that actually should explode.
var/static/list/unsafe_area_subtypes = typecacheof(list(/area/station/engineering/break_room))
allowed_areas = make_associative(GLOB.the_station_areas) - safe_area_types + unsafe_area_subtypes