Files
Bubberstation/code/game/objects/structures/stairs.dm
cacogen 07022a3ffb Makes navigate verb use landmarks instead of navigation beacons (#65906)
About The Pull Request

#65741 replaced wayfinding pinpointers with the navigate verb.

However, one of the features of wayfinding pinpointers was the ability to edit the codes of the navigation beacons they pointed to in order to change the names of the destinations in their list.

While it makes sense that an in-game object can be fallible, it doesn't make a lot of sense for a UI button that creates a path only the player can see. People will expect it to be objective and reliable.

So this removes that in favour of landmarks that add their location to a global list used by the verb on LateInitialize() and delete themselves afterwards.

StrongDMM_4KNvlSYNy5.png

This also adds "Nearest Way Up" and "Nearest Way Down" to the navigate destination list. This paths to the nearest staircase or ladder.
Why It's Good For The Game

    Removes confusion for newer players on the off-chance somebody decides to modify destination names of wayfinding beacons
    Makes mapping these easier, because instead of placing an underfloor navigation beacon, you're placing a map pin that is above most things on the map
    Makes the existence of this feature more obvious to mappers by replacing underfloor wayfinding beacons that look identical to other navigation beacons with bright red pins (I noticed when looking at Ice Box for this PR that some wayfinding beacons have been removed in areas that have been remapped since I placed them)
    Somewhat compensates for the inability to path between z levels by allowing players to find the nearest ladder or staircase instead (does nothing to indicate destinations on other z levels or the direction they're in though)

Changelog

cl
del: Navigate verb uses landmarks now, which means that underfloor wayfinding beacons (which could be used to change the names of destinations) are gone
qol: Adds Nearest Way Up and Nearest Way Down to the navigate list, which point to the nearest ladder or staircase up or down
fix: Fixes runtime with navigation verb paths where deleted paths were still attempting to animate
/cl
2022-04-11 09:32:01 +12:00

153 lines
4.6 KiB
Plaintext

#define STAIR_TERMINATOR_AUTOMATIC 0
#define STAIR_TERMINATOR_NO 1
#define STAIR_TERMINATOR_YES 2
// dir determines the direction of travel to go upwards
// stairs require /turf/open/openspace as the tile above them to work, unless your stairs have 'force_open_above' set to TRUE
// multiple stair objects can be chained together; the Z level transition will happen on the final stair object in the chain
/obj/structure/stairs
name = "stairs"
icon = 'icons/obj/stairs.dmi'
icon_state = "stairs"
anchored = TRUE
var/force_open_above = FALSE // replaces the turf above this stair obj with /turf/open/openspace
var/terminator_mode = STAIR_TERMINATOR_AUTOMATIC
var/turf/listeningTo
/obj/structure/stairs/north
dir = NORTH
/obj/structure/stairs/south
dir = SOUTH
/obj/structure/stairs/east
dir = EAST
/obj/structure/stairs/west
dir = WEST
/obj/structure/stairs/Initialize(mapload)
GLOB.stairs += src
if(force_open_above)
force_open_above()
build_signal_listener()
update_surrounding()
var/static/list/loc_connections = list(
COMSIG_ATOM_EXIT = .proc/on_exit,
)
AddElement(/datum/element/connect_loc, loc_connections)
return ..()
/obj/structure/stairs/Destroy()
listeningTo = null
GLOB.stairs -= src
return ..()
/obj/structure/stairs/Move() //Look this should never happen but...
. = ..()
if(force_open_above)
build_signal_listener()
update_surrounding()
/obj/structure/stairs/proc/update_surrounding()
update_appearance()
for(var/i in GLOB.cardinals)
var/turf/T = get_step(get_turf(src), i)
var/obj/structure/stairs/S = locate() in T
if(S)
S.update_appearance()
/obj/structure/stairs/proc/on_exit(datum/source, atom/movable/leaving, direction)
SIGNAL_HANDLER
if(leaving == src)
return //Let's not block ourselves.
if(!isobserver(leaving) && isTerminator() && direction == dir)
leaving.set_currently_z_moving(CURRENTLY_Z_ASCENDING)
INVOKE_ASYNC(src, .proc/stair_ascend, leaving)
leaving.Bump(src)
return COMPONENT_ATOM_BLOCK_EXIT
/obj/structure/stairs/Cross(atom/movable/AM)
if(isTerminator() && (get_dir(src, AM) == dir))
return FALSE
return ..()
/obj/structure/stairs/update_icon_state()
icon_state = "stairs[isTerminator() ? "_t" : null]"
return ..()
/obj/structure/stairs/proc/stair_ascend(atom/movable/climber)
var/turf/checking = get_step_multiz(get_turf(src), UP)
if(!istype(checking))
return
if(!checking.zPassIn(climber, UP, get_turf(src)))
return
var/turf/target = get_step_multiz(get_turf(src), (dir|UP))
if(istype(target) && !climber.can_z_move(DOWN, target, z_move_flags = ZMOVE_FALL_FLAGS)) //Don't throw them into a tile that will just dump them back down.
climber.zMove(target = target, z_move_flags = ZMOVE_STAIRS_FLAGS)
/// Moves anything that's being dragged by src or anything buckled to it to the stairs turf.
climber.pulling?.move_from_pull(climber, loc, climber.glide_size)
for(var/mob/living/buckled as anything in climber.buckled_mobs)
buckled.pulling?.move_from_pull(buckled, loc, buckled.glide_size)
/obj/structure/stairs/vv_edit_var(var_name, var_value)
. = ..()
if(!.)
return
if(var_name != NAMEOF(src, force_open_above))
return
if(!var_value)
if(listeningTo)
UnregisterSignal(listeningTo, COMSIG_TURF_MULTIZ_NEW)
listeningTo = null
else
build_signal_listener()
force_open_above()
/obj/structure/stairs/proc/build_signal_listener()
if(listeningTo)
UnregisterSignal(listeningTo, COMSIG_TURF_MULTIZ_NEW)
var/turf/open/openspace/T = get_step_multiz(get_turf(src), UP)
RegisterSignal(T, COMSIG_TURF_MULTIZ_NEW, .proc/on_multiz_new)
listeningTo = T
/obj/structure/stairs/proc/force_open_above()
var/turf/open/openspace/T = get_step_multiz(get_turf(src), UP)
if(T && !istype(T))
T.ChangeTurf(/turf/open/openspace, flags = CHANGETURF_INHERIT_AIR)
/obj/structure/stairs/proc/on_multiz_new(turf/source, dir)
SIGNAL_HANDLER
if(dir == UP)
var/turf/open/openspace/T = get_step_multiz(get_turf(src), UP)
if(T && !istype(T))
T.ChangeTurf(/turf/open/openspace, flags = CHANGETURF_INHERIT_AIR)
/obj/structure/stairs/intercept_zImpact(list/falling_movables, levels = 1)
. = ..()
if(levels == 1 && isTerminator()) // Stairs won't save you from a steep fall.
. |= FALL_INTERCEPTED | FALL_NO_MESSAGE | FALL_RETAIN_PULL
/obj/structure/stairs/proc/isTerminator() //If this is the last stair in a chain and should move mobs up
if(terminator_mode != STAIR_TERMINATOR_AUTOMATIC)
return (terminator_mode == STAIR_TERMINATOR_YES)
var/turf/T = get_turf(src)
if(!T)
return FALSE
var/turf/them = get_step(T, dir)
if(!them)
return FALSE
for(var/obj/structure/stairs/S in them)
if(S.dir == dir)
return FALSE
return TRUE