From 4fa093fb2ccafbad0f212f6785804358a4066791 Mon Sep 17 00:00:00 2001 From: Tayyyyyyy Date: Mon, 19 Aug 2019 18:31:18 -0700 Subject: [PATCH] Improve shuttle parallax stopping --- code/_onclick/hud/parallax.dm | 9 ++++++--- code/game/area/Space Station 13 areas.dm | 2 ++ code/game/area/areas.dm | 1 + code/game/turfs/space/space.dm | 6 ------ code/modules/shuttle/on_move.dm | 13 +++---------- code/modules/shuttle/shuttle.dm | 15 ++++----------- 6 files changed, 16 insertions(+), 30 deletions(-) diff --git a/code/_onclick/hud/parallax.dm b/code/_onclick/hud/parallax.dm index 0d981962cc0..46fe7331dbe 100644 --- a/code/_onclick/hud/parallax.dm +++ b/code/_onclick/hud/parallax.dm @@ -8,7 +8,6 @@ var/last_parallax_shift //world.time of last update var/parallax_throttle = 0 //ds between updates var/parallax_movedir = 0 - var/new_parallax_movedir = 0 var/parallax_layers_max = 3 var/parallax_animate_timer @@ -155,7 +154,11 @@ var/area/areaobj = posobj.loc // Update the movement direction of the parallax if necessary (for shuttles) - set_parallax_movedir(C.new_parallax_movedir) + var/area/shuttle/SA = areaobj + if(!SA || !SA.moving) + set_parallax_movedir(0) + else + set_parallax_movedir(SA.parallax_movedir) var/force if(!C.previous_turf || (C.previous_turf.z != posobj.z)) @@ -204,7 +207,7 @@ if(L.offset_y < -240) L.offset_y += 480 - if(!areaobj.parallax_movedir && C.dont_animate_parallax <= world.time && (offset_x || offset_y) && abs(offset_x) <= max(C.parallax_throttle/world.tick_lag+1,1) && abs(offset_y) <= max(C.parallax_throttle/world.tick_lag+1,1) && (round(abs(change_x)) > 1 || round(abs(change_y)) > 1)) + if(!(areaobj.parallax_movedir && areaobj.moving) && C.dont_animate_parallax <= world.time && (offset_x || offset_y) && abs(offset_x) <= max(C.parallax_throttle/world.tick_lag+1,1) && abs(offset_y) <= max(C.parallax_throttle/world.tick_lag+1,1) && (round(abs(change_x)) > 1 || round(abs(change_y)) > 1)) L.transform = matrix(1, 0, offset_x*L.speed, 0, 1, offset_y*L.speed) animate(L, transform=matrix(), time = last_delay) diff --git a/code/game/area/Space Station 13 areas.dm b/code/game/area/Space Station 13 areas.dm index d5b4faef17c..b063c17492d 100644 --- a/code/game/area/Space Station 13 areas.dm +++ b/code/game/area/Space Station 13 areas.dm @@ -100,6 +100,7 @@ var/list/ghostteleportlocs = list() requires_power = FALSE valid_territory = FALSE dynamic_lighting = DYNAMIC_LIGHTING_FORCED + parallax_movedir = NORTH /area/shuttle/arrival name = "\improper Arrival Shuttle" @@ -247,6 +248,7 @@ var/list/ghostteleportlocs = list() /area/shuttle/specops name = "\improper Special Ops Shuttle" icon_state = "shuttlered" + parallax_movedir = EAST /area/shuttle/specops/centcom name = "\improper Special Ops Shuttle" diff --git a/code/game/area/areas.dm b/code/game/area/areas.dm index 442bde3aa68..26dc6ddbf56 100644 --- a/code/game/area/areas.dm +++ b/code/game/area/areas.dm @@ -68,6 +68,7 @@ var/hide_attacklogs = FALSE // For areas such as thunderdome, lavaland syndiebase, etc which generate a lot of spammy attacklogs. Reduces log priority. var/parallax_movedir = 0 + var/moving = FALSE /area/Initialize(mapload) GLOB.all_areas += src diff --git a/code/game/turfs/space/space.dm b/code/game/turfs/space/space.dm index daecd225355..40c0d83272e 100644 --- a/code/game/turfs/space/space.dm +++ b/code/game/turfs/space/space.dm @@ -106,12 +106,6 @@ ..() if((!(A) || !(src in A.locs))) return - - if(ismob(A)) - var/mob/M = A - if(M && M.client && M.client.new_parallax_movedir) - M.client.new_parallax_movedir = 0 - M.update_parallax_contents() if(destination_z && destination_x && destination_y) A.forceMove(locate(destination_x, destination_y, destination_z)) diff --git a/code/modules/shuttle/on_move.dm b/code/modules/shuttle/on_move.dm index 77c6a21dd0d..42e710d0cf6 100644 --- a/code/modules/shuttle/on_move.dm +++ b/code/modules/shuttle/on_move.dm @@ -30,7 +30,7 @@ if(id_tag == "s_docking_airlock") INVOKE_ASYNC(src, .proc/lock) -/mob/onShuttleMove(turf/oldT, turf/T1, rotation, travelDir) +/mob/onShuttleMove(turf/oldT, turf/T1, rotation) if(!move_on_shuttle) return 0 . = ..() @@ -44,7 +44,6 @@ else shake_camera(src, 7, 1) - client.new_parallax_movedir = travelDir ? WEST : NORTH update_parallax_contents() /mob/living/carbon/onShuttleMove() @@ -59,14 +58,8 @@ if(smooth) queue_smooth(src) -/mob/postDock(obj/docking_port/S1, transit, list/parallax_mobs) - if(!client) - return - if(transit) - parallax_mobs.Add(src) - return - client.new_parallax_movedir = 0 - update_parallax_contents() +/mob/postDock() + update_parallax_contents() /obj/machinery/door/airlock/postDock(obj/docking_port/stationary/S1) . = ..() diff --git a/code/modules/shuttle/shuttle.dm b/code/modules/shuttle/shuttle.dm index b2d710ba215..2d68c3db292 100644 --- a/code/modules/shuttle/shuttle.dm +++ b/code/modules/shuttle/shuttle.dm @@ -215,7 +215,6 @@ var/roundstart_move //id of port to send shuttle to at roundstart var/travelDir = 0 //direction the shuttle would travel in var/rebuildable = 0 //can build new shuttle consoles for this one - var/list/parallax_mobs = list() //mobs to unparallax var/obj/docking_port/stationary/destination var/obj/docking_port/stationary/previous @@ -493,9 +492,10 @@ var/turf/simulated/Ts1 = T1 Ts1.copy_air_with_tile(T0) + areaInstance.moving = TRUE //move mobile to new location for(var/atom/movable/AM in T0) - AM.onShuttleMove(T0, T1, rotation, travelDir) + AM.onShuttleMove(T0, T1, rotation) if(rotation) T1.shuttleRotate(rotation) @@ -513,19 +513,12 @@ T0.CalculateAdjacentTurfs() SSair.add_to_active(T0,1) + areaInstance.moving = transit for(var/A1 in L1) var/turf/T1 = A1 T1.postDock(S1) for(var/atom/movable/M in T1) - M.postDock(S1, transit, parallax_mobs) - - // For mobs who move away from a transiting shuttle for whatever reason (teleportation, jumping, etc) so that they don't get stuck parallaxing - if(!transit) - for(var/mob/M in parallax_mobs) - if(M.client && M.client.new_parallax_movedir) - M.client.new_parallax_movedir = 0 - M.update_parallax_contents() - parallax_mobs = list() + M.postDock(S1) loc = S1.loc dir = S1.dir