Files
Aurora.3/code/modules/shieldgen/shield_gen_external.dm
Matt Atlas 1af71a7c45 Unfuck shields by not making them process a huge list constantly. (#21428)
Ship shields currently occupy something like 40% of every machinery
process ticks. Basically generators make a fuckhuge list of all
generated shields (1.5k in the Horizon's case) and then they iterate
over this list every tick strengthening the shields.

The idea in this PR is to shunt shield logic to an abstract datum.
Fields no longer store strength individually; they store damage taken.
They only process once they take damage, they reduce that damage by the
field gain tick value every tick, and then they stop processing when
they no longer need to. Shield strengthening is shunted off to a signal,
so we only need to traverse the big ass list once every round probably.

---------

Co-authored-by: Matt Atlas <liermattia@gmail.com>
2025-10-07 12:34:20 +00:00

59 lines
1.8 KiB
Plaintext

//---------- external shield generator
//generates an energy field that loops around any built up area in space (is useless inside) halts movement and airflow, is blocked by walls, windows, airlocks etc
/obj/machinery/shield_gen/external
name = "hull shield generator"
//Search for space turfs within range that are adjacent to a simulated turf.
/obj/machinery/shield_gen/external/get_shielded_turfs()
var/list/out = list()
var/turf/gen_turf = get_turf(src)
if (!gen_turf)
return
var/turf/U
var/turf/T
for (var/tt in RANGE_TURFS(field_radius, gen_turf))
T = tt
// Ignore station areas.
if (GLOB.the_station_areas[T.loc] || is_shuttle_area(T.loc))
continue
else if (istype(T, /turf/space) || istype(T, /turf/simulated/floor/exoplanet/asteroid) || isopenturf(T) || istype(T, /turf/simulated/floor/reinforced))
for (var/uu in RANGE_TURFS(1, T))
U = uu
if (T == U)
continue
if (GLOB.the_station_areas[U.loc] || istype(U, /turf/simulated/mineral/surface))
out += T
break
if(multiz)
var/connected_levels = list()
var/list/turf/above = getzabove(get_turf(src))
var/list/turf/below = getzbelow(get_turf(src))
if(above)
for(var/turf/z as anything in above)
connected_levels += z
if(below)
for(var/turf/z as anything in below)
connected_levels += z
for(var/turf/z in connected_levels)
for (var/tt in RANGE_TURFS(field_radius, z))
T = tt
// Ignore station areas.
if (GLOB.the_station_areas[T.loc] || istype(T.loc, /area/shuttle))
continue
else if (istype(T, /turf/space) || istype(T, /turf/simulated/floor/exoplanet/asteroid) || isopenturf(T) || istype(T, /turf/simulated/floor/reinforced))
for (var/uu in RANGE_TURFS(1, T))
U = uu
if (T == U)
continue
if (GLOB.the_station_areas[U.loc])
out += T
break
return out