Un-jank diagonal movement (#17872)

* Un-jank diagonal movement

* grab fix
This commit is contained in:
moxian
2022-05-27 20:15:40 +01:00
committed by GitHub
parent e5266bdcac
commit 4f299c403a
2 changed files with 28 additions and 23 deletions
+11 -6
View File
@@ -180,18 +180,23 @@
if(mob.pulling)
prev_pulling_loc = mob.pulling.loc
. = mob.SelfMove(n, direct, delay) // The actual movement
if(!(direct & (direct - 1))) // cardinal direction
. = mob.SelfMove(n, direct, delay)
else // diagonal movements take twice as long
. = mob.SelfMove(n, direct, delay * 2)
if(mob.loc == n)
// only incur the extra delay if the move was *actually* diagonal
// There would be a bit of visual jank if we try to walk diagonally next to a wall
// and the move ends up being cardinal, rather than diagonal,
// but that's better than it being jank on every *successful* diagonal move.
delay *= 2
move_delay += delay
if(prev_pulling_loc && mob.pulling?.face_while_pulling && (mob.pulling.loc != prev_pulling_loc))
mob.setDir(get_dir(mob, mob.pulling)) // Face welding tanks and stuff when pulling
else
mob.setDir(direct)
if((direct & (direct - 1)) && mob.loc == n) //moved diagonally successfully
delay = mob.movement_delay() * 2 //Will prevent mob diagonal moves from smoothing accurately, sadly
move_delay += delay
for(var/obj/item/grab/G in mob)
if(G.state == GRAB_NECK)
mob.setDir(angle2dir((dir2angle(direct) + 202.5) % 365))