From d862dc3dc39cdefc7d4f4d4a3bc51384131b8642 Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Mon, 5 Jul 2021 16:54:31 +0200 Subject: [PATCH] [MIRROR] fix buckling to a vehicle not setting your initial sprite position correctly (#6733) * fix buckling to a vehicle not setting your initial sprite position correctly (#59999) * fix buckling to a vehicle not setting your initial sprite position correctly Co-authored-by: Bobbahbrown --- code/datums/components/riding/riding.dm | 9 +++++++++ code/datums/components/riding/riding_mob.dm | 6 ++++++ 2 files changed, 15 insertions(+) diff --git a/code/datums/components/riding/riding.dm b/code/datums/components/riding/riding.dm index a4ad68c69b1..ca5cca15f0b 100644 --- a/code/datums/components/riding/riding.dm +++ b/code/datums/components/riding/riding.dm @@ -60,6 +60,7 @@ . = ..() RegisterSignal(parent, COMSIG_ATOM_DIR_CHANGE, .proc/vehicle_turned) RegisterSignal(parent, COMSIG_MOVABLE_UNBUCKLE, .proc/vehicle_mob_unbuckle) + RegisterSignal(parent, COMSIG_MOVABLE_BUCKLE, .proc/vehicle_mob_buckle) RegisterSignal(parent, COMSIG_MOVABLE_MOVED, .proc/vehicle_moved) RegisterSignal(parent, COMSIG_MOVABLE_BUMP, .proc/vehicle_bump) @@ -84,6 +85,14 @@ if(!movable_parent.has_buckled_mobs()) qdel(src) +/// This proc is called when a rider buckles, allowing for offsets to be set properly +/datum/component/riding/proc/vehicle_mob_buckle(datum/source, mob/living/rider, force = FALSE) + SIGNAL_HANDLER + + var/atom/movable/movable_parent = parent + handle_vehicle_layer(movable_parent.dir) + handle_vehicle_offsets(movable_parent.dir) + /// Some ridable atoms may want to only show on top of the rider in certain directions, like wheelchairs /datum/component/riding/proc/handle_vehicle_layer(dir) var/atom/movable/AM = parent diff --git a/code/datums/components/riding/riding_mob.dm b/code/datums/components/riding/riding_mob.dm index 67b7a2544ad..6f29fc61424 100644 --- a/code/datums/components/riding/riding_mob.dm +++ b/code/datums/components/riding/riding_mob.dm @@ -68,6 +68,12 @@ rider.Knockdown(4 SECONDS) living_parent.unbuckle_mob(rider) +/datum/component/riding/creature/vehicle_mob_buckle(datum/source, mob/living/rider, force = FALSE) + // Ensure that the /mob/post_buckle_mob(mob/living/M) does not mess us up with layers + // If we do not do this override we'll be stuck with the above proc (+ 0.1)-ing our rider's layer incorrectly + rider.layer = initial(rider.layer) + return ..() + /datum/component/riding/creature/vehicle_mob_unbuckle(mob/living/living_parent, mob/living/former_rider, force = FALSE) if(istype(living_parent) && istype(former_rider)) living_parent.log_message("is no longer being ridden by [former_rider]", LOG_ATTACK, color="pink")