Merge pull request #15536 from SandPoot/JPS

Implements JPS (Jump Point Search) Pathfinding
This commit is contained in:
silicons
2022-03-10 16:51:07 -07:00
committed by GitHub
24 changed files with 477 additions and 296 deletions
+20
View File
@@ -638,3 +638,23 @@ GLOBAL_LIST_EMPTY(station_turfs)
var/obj/machinery/door/D = locate() in src
if(D?.density)
. += D.opacity? 29 : 19 // glass doors are slightly more resistant to screaming
/**
* Returns adjacent turfs to this turf that are reachable, in all cardinal directions
*
* Arguments:
* * caller: The movable, if one exists, being used for mobility checks to see what tiles it can reach
* * ID: An ID card that decides if we can gain access to doors that would otherwise block a turf
* * simulated_only: Do we only worry about turfs with simulated atmos, most notably things that aren't space?
*/
/turf/proc/reachableAdjacentTurfs(caller, ID, simulated_only)
var/static/space_type_cache = typecacheof(/turf/open/space)
. = list()
for(var/iter_dir in GLOB.cardinals)
var/turf/turf_to_check = get_step(src,iter_dir)
if(!turf_to_check || (simulated_only && space_type_cache[turf_to_check.type]))
continue
if(turf_to_check.density || LinkBlockedWithAccess(turf_to_check, caller, ID))
continue
. += turf_to_check