diff --git a/code/game/area/Space_Station_13_areas.dm b/code/game/area/Space_Station_13_areas.dm index cbad2f7ab0..5310b24202 100644 --- a/code/game/area/Space_Station_13_areas.dm +++ b/code/game/area/Space_Station_13_areas.dm @@ -43,6 +43,7 @@ NOTE: there are two lists of areas in the end of this file: centcom and station outdoors = TRUE ambientsounds = SPACE blob_allowed = FALSE //Eating up space doesn't count for victory as a blob. + considered_hull_exterior = TRUE /area/space/nearstation icon_state = "space_near" @@ -1592,4 +1593,4 @@ NOTE: there are two lists of areas in the end of this file: centcom and station valid_territory = FALSE outdoors = TRUE ambientsounds = SPACE - blob_allowed = FALSE //While part of the station, what good will it do you? \ No newline at end of file + blob_allowed = FALSE //While part of the station, what good will it do you? diff --git a/code/game/area/areas.dm b/code/game/area/areas.dm index 672d5c096f..b9415f3cf8 100644 --- a/code/game/area/areas.dm +++ b/code/game/area/areas.dm @@ -34,6 +34,9 @@ /// If megafauna can be spawned by natural random generation var/megafauna_spawn_allowed = FALSE + /// Considered space for hull shielding + var/considered_hull_exterior = FALSE + var/fire = null var/atmos = TRUE var/atmosalm = FALSE diff --git a/code/modules/shielding/helpers.dm b/code/modules/shielding/helpers.dm new file mode 100644 index 0000000000..51aa3d10f8 --- /dev/null +++ b/code/modules/shielding/helpers.dm @@ -0,0 +1,85 @@ +//////// HELPER FILE FOR SHIELDING ///////// + +// HULL SHIELD GENERATION HELPERS +/** + * Gets hull exterior adjacent tiles of a certain area + * Area method. + * EXPENSIVE. + * If the area itself is already considered exterior, it'll find all tiles inside it that's next to an interior area. + */ +/proc/hull_shielding_get_tiles_around_area(area/instance, check_tick = FALSE) + var/list/cache = list() + var/area/A + if(instance.considered_hull_exterior) + for(var/turf/potential in instance) + for(var/turf/looking in orange(1, potential)) + A = looking.loc + if(!A.considered_hull_exterior) + cache[potential] = TRUE // we're the exterior area, grab the one that's reaching out + if(check_tick) + CHECK_TICK + else + for(var/turf/potential in instance) + for(var/turf/looking in orange(1, potential)) + A = looking.loc + if(A.considered_hull_exterior) + cache[looking] = TRUE // we're not the exterior area, grab the one that's being reached to + if(check_tick) + CHECK_TICK + . = list() + for(var/i in cache) + . += i // strip assoc value + +/** + * Gets hull adjacent exterior tiles of an entire zlevel + * EXPENSIVE. + * Gets the tiles in the exterior area touching to a non-exterior area + */ +/proc/hull_shielding_get_tiles_in_z(zlevel, check_tick = FALSE, recurse = FALSE, list/outlist = list(), list/scanned_zlevels = list()) + . = outlist + if(zlevel in scanned_zlevels) + return + scanned_zlevels |= zlevel + if(recurse) + var/up = SSmapping.level_trait(zlevel, ZTRAIT_UP) + var/down = SSmapping.level_trait(zlevel, ZTRAIT_DOWN) + if(isnum(up) && (up != 0)) + hull_shielding_get_tiles_in_z(up, check_tick, recurse, outlist, scanned_zlevels) + if(isnum(down) && (down != 0)) + hull_shielding_get_tiles_in_z(down, check_tick, recurse, outlist, scanned_zlevels) + // sigh. why. + var/turf/potential + var/area/p_area + var/area/l_area + for(var/x in 1 to world.maxx) + for(var/y in 1 to world.maxy) + if(check_tick) + CHECK_TICK + potential = locate(x, y) + p_area = potential.loc + if(!p_area.considered_hull_exterior) + continue + for(var/turf/looking in orange(1, potential)) + l_area = looking.loc + if(!l_area.considered_hull_exterior) + outlist += potential + +/proc/debug1(area/A) + for(var/turf/T in hull_shielding_get_tiles_around_area(A, FALSE)) + T.maptext = "Found" + T.plane = 50 + T.layer = 50 + spawn(100) + T.maptext = null + T.plane = initial(T.plane) + T.layer = initial(T.layer) + +/proc/debug2(z) + for(var/turf/T in hull_shielding_get_tiles_in_z(z, FALSE, TRUE)) + T.maptext = "Found" + T.plane = 50 + T.layer = 50 + spawn(100) + T.maptext = null + T.plane = initial(T.plane) + T.layer = initial(T.layer) diff --git a/tgstation.dme b/tgstation.dme index c3e51d49cc..13fc4eb42f 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -3287,6 +3287,7 @@ #include "code\modules\ruins\spaceruin_code\whiteshipruin_box.dm" #include "code\modules\security_levels\keycard_authentication.dm" #include "code\modules\security_levels\security_levels.dm" +#include "code\modules\shielding\helpers.dm" #include "code\modules\shuttle\arrivals.dm" #include "code\modules\shuttle\assault_pod.dm" #include "code\modules\shuttle\computer.dm"