Retrofit TG pathfinder with upstream improvements (#25583)

* Retrofit TG pathfinder with upstream improvements

* i know how things work

* don't use HAS_TRAIT for things that aren't traits

* unique filenames

* i'm just a goofy lil moron

* use new block syntax

* apparently values don't need clamping with new block syntax?

* silence invalid JPS dest runtime

* fix runtime passing ID instead of access list
This commit is contained in:
warriorstar-orion
2024-07-08 15:48:43 +00:00
committed by GitHub
parent 62dc3d57dd
commit ca93f6bc77
34 changed files with 1324 additions and 580 deletions
+10 -14
View File
@@ -14,6 +14,8 @@
/// pass_flags that we are. If any of this matches a pass_flag on a moving thing, by default, we let them through.
var/pass_flags_self = NONE
/// How this atom should react to having its astar blocking checked
var/can_pathfind_pass = CANPATHFINDPASS_DENSITY
var/list/blood_DNA
var/blood_color
@@ -1254,14 +1256,6 @@ GLOBAL_LIST_EMPTY(blood_splatter_icons)
color = C
return
/*
Checks whether this atom can traverse the destination object when used as source for AStar.
This should only be used as an override to /obj/proc/CanPathfindPass. Aka don't use this unless you can't change the object's proc.
Returning TRUE here will override the above proc's result.
*/
/atom/proc/CanPathfindPassTo(ID, dir, obj/destination)
return FALSE
/** Call this when you want to present a renaming prompt to the user.
It's a simple proc, but handles annoying edge cases such as forgetting to add a "cancel" button,
@@ -1365,16 +1359,18 @@ GLOBAL_LIST_EMPTY(blood_splatter_icons)
* For turfs this will only be used if pathing_pass_method is TURF_PATHING_PASS_PROC
*
* Arguments:
* * ID- An ID card representing what access we have (and thus if we can open things like airlocks or windows to pass through them). The ID card's physical location does not matter, just the reference
* * to_dir- What direction we're trying to move in, relevant for things like directional windows that only block movement in certain directions
* * caller- The movable we're checking pass flags for, if we're making any such checks
* * no_id: When true, doors with public access will count as impassible
* * to_dir - What direction we're trying to move in, relevant for things like directional windows that only block movement in certain directions
* * pass_info - Datum that stores info about the thing that's trying to pass us
*
* IMPORTANT NOTE: /turf/proc/LinkBlockedWithAccess assumes that overrides of CanPathfindPass will always return true if density is FALSE
* If this is NOT you, ensure you edit your can_pathfind_pass variable. Check __DEFINES/path.dm
**/
/atom/proc/CanPathfindPass(obj/item/card/id/ID, to_dir, atom/movable/caller, no_id = FALSE)
if(caller && (caller.pass_flags & pass_flags_self))
/atom/proc/CanPathfindPass(to_dir, datum/can_pass_info/pass_info)
if(pass_info.pass_flags & pass_flags_self)
return TRUE
. = !density
/atom/proc/atom_prehit(obj/item/projectile/P)
return SEND_SIGNAL(src, COMSIG_ATOM_PREHIT, P)
+3 -3
View File
@@ -1375,13 +1375,13 @@ GLOBAL_LIST_EMPTY(airlock_emissive_underlays)
update_icon()
return 1
/obj/machinery/door/airlock/CanPathfindPass(obj/item/card/id/ID, to_dir, atom/movable/caller, no_id = FALSE)
/obj/machinery/door/airlock/CanPathfindPass(to_dir, datum/can_pass_info/pass_info)
if(!density)
return TRUE
if(caller?.checkpass(PASSDOOR) && !locked)
if(pass_info.pass_flags & PASSDOOR && !locked)
return TRUE
//Airlock is passable if it is open (!density), bot has access, and is not bolted or welded shut)
return check_access(ID) && !locked && !welded && arePowerSystemsOn() && !no_id
return check_access_list(pass_info.access) && !locked && !welded && arePowerSystemsOn() && !pass_info.no_id
/obj/machinery/door/airlock/emag_act(mob/user)
if(!operating && density && arePowerSystemsOn() && !emagged)
+4 -4
View File
@@ -509,12 +509,12 @@
zap_flags &= ~ZAP_OBJ_DAMAGE
. = ..()
/obj/machinery/door/CanPathfindPass(obj/item/card/id/ID, to_dir, atom/movable/caller, no_id)
if(QDELETED(caller))
/obj/machinery/door/CanPathfindPass(to_dir, datum/can_pass_info/pass_info)
if(!locateUID(pass_info.caller_uid))
return ..()
if(caller.checkpass(PASSDOOR) && !locked)
if(pass_info.pass_flags & PASSDOOR && !locked)
return TRUE
if(caller.checkpass(PASSGLASS))
if(pass_info.pass_flags & PASSGLASS)
return !opacity
return ..()
+2 -2
View File
@@ -169,8 +169,8 @@
return TRUE
//used in the AStar algorithm to determinate if the turf the door is on is passable
/obj/machinery/door/window/CanPathfindPass(obj/item/card/id/ID, to_dir, no_id = FALSE)
return !density || (dir != to_dir) || (check_access(ID) && hasPower())
/obj/machinery/door/window/CanPathfindPass(to_dir, datum/can_pass_info/pass_info)
return !density || (dir != to_dir) || (check_access_list(pass_info.access) && hasPower())
/obj/machinery/door/window/CheckExit(atom/movable/mover, turf/target)
if(istype(mover) && mover.checkpass(PASSGLASS))
+4 -4
View File
@@ -1085,8 +1085,8 @@ GLOBAL_LIST_EMPTY(turret_icons)
/obj/machinery/porta_turret/syndicate/CanPass(atom/A)
return ((stat & BROKEN) || !isliving(A))
/obj/machinery/porta_turret/syndicate/CanPathfindPass(obj/item/card/id/ID, to_dir, atom/movable/caller, no_id = FALSE)
return ((stat & BROKEN) || !isliving(caller))
/obj/machinery/porta_turret/syndicate/CanPathfindPass(to_dir, datum/can_pass_info/pass_info)
return ((stat & BROKEN) || !pass_info.is_living)
/obj/machinery/porta_turret/syndicate/die()
. = ..()
@@ -1208,5 +1208,5 @@ GLOBAL_LIST_EMPTY(turret_icons)
/obj/machinery/porta_turret/inflatable_turret/CanPass(atom/A)
return ((stat & BROKEN) || !isliving(A))
/obj/machinery/porta_turret/inflatable_turret/CanPathfindPass(obj/item/card/id/ID, to_dir, atom/movable/caller, no_id = FALSE)
return ((stat & BROKEN) || !isliving(caller))
/obj/machinery/porta_turret/inflatable_turret/CanPathfindPass(to_dir, datum/can_pass_info/pass_info)
return ((stat & BROKEN) || !pass_info.is_living)
+4 -6
View File
@@ -573,12 +573,10 @@
return FALSE
return ..(mover, target, height)
/obj/machinery/shieldwall/syndicate/CanPathfindPass(obj/item/card/id/ID, to_dir, caller, no_id = FALSE)
if(isliving(caller))
var/mob/living/M = caller
if("syndicate" in M.faction)
return TRUE
return ..(ID, to_dir, caller)
/obj/machinery/shieldwall/syndicate/CanPathfindPass(to_dir, datum/can_pass_info/pass_info)
if(pass_info.is_living && ("syndicate" in pass_info.factions))
return TRUE
return ..(to_dir, pass_info)
/obj/machinery/shieldwall/syndicate/proc/phaseout()
// If you're bumping into an invisible shield, make it fully visible, then fade out over a couple of seconds.
+3 -4
View File
@@ -419,11 +419,10 @@
else
return 0
/obj/structure/girder/CanPathfindPass(obj/item/card/id/ID, dir, caller, no_id = FALSE)
/obj/structure/girder/CanPathfindPass(to_dir, datum/can_pass_info/pass_info)
. = !density
if(ismovable(caller))
var/atom/movable/mover = caller
. = . || mover.checkpass(PASSGRILLE)
if(pass_info.is_movable)
. = . || pass_info.pass_flags & PASSGRILLE
/obj/structure/girder/deconstruct(disassembled = TRUE)
if(!(flags & NODECONSTRUCT))
+3 -4
View File
@@ -126,11 +126,10 @@
if(isprojectile(mover))
return (prob(30) || !density)
/obj/structure/grille/CanPathfindPass(obj/item/card/id/ID, dir, caller, no_id = FALSE)
/obj/structure/grille/CanPathfindPass(to_dir, datum/can_pass_info/pass_info)
. = !density
if(ismovable(caller))
var/atom/movable/mover = caller
. = . || mover.checkpass(PASSGRILLE)
if(pass_info.is_movable)
. = . || pass_info.pass_flags & PASSGRILLE
/obj/structure/grille/attackby(obj/item/I, mob/user, params)
user.changeNext_move(CLICK_CD_MELEE)
+3 -4
View File
@@ -308,11 +308,10 @@
return FALSE
/obj/structure/m_tray/CanPathfindPass(obj/item/card/id/ID, dir, caller, no_id = FALSE)
/obj/structure/m_tray/CanPathfindPass(to_dir, datum/can_pass_info/pass_info)
. = !density
if(ismovable(caller))
var/atom/movable/mover = caller
. = . || mover.checkpass(PASSTABLE)
if(pass_info.is_movable)
. = . || pass_info.pass_flags & PASSTABLE
/obj/structure/m_tray/Process_Spacemove(movement_dir)
return TRUE
+9 -10
View File
@@ -76,17 +76,16 @@
return ..()
/obj/structure/plasticflaps/CanPathfindPass(obj/item/card/id/ID, to_dir, caller, no_id = FALSE)
if(isliving(caller))
if(isbot(caller) || isdrone(caller))
return TRUE
/obj/structure/plasticflaps/CanPathfindPass(to_dir, datum/can_pass_info/pass_info)
if(pass_info.is_bot || pass_info.is_drone)
return TRUE
if(!pass_info.can_ventcrawl && pass_info.mob_size != MOB_SIZE_TINY)
return FALSE
if(pass_info.pulling_info)
return CanPathfindPass(to_dir, pass_info.pulling_info)
var/mob/living/M = caller
if(!M.ventcrawler && M.mob_size != MOB_SIZE_TINY)
return FALSE
var/atom/movable/M = caller
if(M && M.pulling)
return CanPathfindPass(ID, to_dir, M.pulling)
return TRUE //diseases, stings, etc can pass
/obj/structure/plasticflaps/deconstruct(disassembled = TRUE)
+3 -3
View File
@@ -84,7 +84,7 @@
/obj/structure/railing/corner/CanPass()
return TRUE
/obj/structure/railing/corner/CanPathfindPass(obj/item/card/id/ID, to_dir, caller, no_id = FALSE)
/obj/structure/railing/corner/CanPathfindPass(to_dir, datum/can_pass_info/pass_info)
return TRUE
/obj/structure/railing/corner/CheckExit()
@@ -93,7 +93,7 @@
/obj/structure/railing/cap/CanPass()
return TRUE
/obj/structure/railing/cap/CanPathfindPass(obj/item/card/id/ID, to_dir, caller, no_id = FALSE)
/obj/structure/railing/cap/CanPathfindPass(to_dir, datum/can_pass_info/pass_info)
return TRUE
/obj/structure/railing/cap/CheckExit()
@@ -118,7 +118,7 @@
return density
return FALSE
/obj/structure/railing/CanPathfindPass(obj/item/card/id/ID, to_dir, caller, no_id = FALSE)
/obj/structure/railing/CanPathfindPass(to_dir, datum/can_pass_info/pass_info)
if(to_dir == dir)
return FALSE
if(ordinal_direction_check(to_dir))
+6 -8
View File
@@ -150,11 +150,10 @@
return TRUE
return FALSE
/obj/structure/table/CanPathfindPass(obj/item/card/id/ID, dir, caller, no_id = FALSE)
/obj/structure/table/CanPathfindPass(to_dir, datum/can_pass_info/pass_info)
. = !density
if(ismovable(caller))
var/atom/movable/mover = caller
. = . || mover.checkpass(PASSTABLE)
if(pass_info.is_movable)
. = . || pass_info.pass_flags & PASSTABLE
/**
* Determines whether a projectile crossing our turf should be stopped.
@@ -887,11 +886,10 @@
else
return 0
/obj/structure/rack/CanPathfindPass(obj/item/card/id/ID, dir, caller, no_id = FALSE)
/obj/structure/rack/CanPathfindPass(to_dir, datum/can_pass_info/pass_info)
. = !density
if(ismovable(caller))
var/atom/movable/mover = caller
. = . || mover.checkpass(PASSTABLE)
if(pass_info.is_movable)
. = . || pass_info.pass_flags & PASSTABLE
/obj/structure/rack/MouseDrop_T(obj/O, mob/user)
if((!isitem(O) || user.get_active_hand() != O))
+4 -4
View File
@@ -137,13 +137,13 @@
return FALSE
return TRUE
/obj/structure/window/CanPathfindPass(obj/item/card/id/ID, to_dir, atom/movable/caller, no_id = FALSE)
/obj/structure/window/CanPathfindPass(to_dir, datum/can_pass_info/pass_info)
if(!density)
return 1
return TRUE
if((dir == FULLTILE_WINDOW_DIR) || (dir & to_dir) || fulltile)
return 0
return FALSE
return 1
return TRUE
/obj/structure/window/attack_tk(mob/user)
user.changeNext_move(CLICK_CD_MELEE)
+4 -4
View File
@@ -50,11 +50,11 @@
if(!drop_stuff())
STOP_PROCESSING(SSprocessing, src)
/turf/simulated/floor/chasm/CanPathfindPass(obj/item/card/id/ID, to_dir, caller, no_id = FALSE)
if(!isliving(caller))
/turf/simulated/floor/chasm/CanPathfindPass(to_dir, datum/can_pass_info/pass_info)
if(!pass_info.is_living)
return TRUE
var/mob/living/L = caller
return (L.flying || ismegafauna(caller))
return pass_info.is_flying || pass_info.is_megafauna
/turf/simulated/floor/chasm/get_smooth_underlay_icon(mutable_appearance/underlay_appearance, turf/asking_turf, adjacency_dir)
underlay_appearance.icon = 'icons/turf/floors.dmi'