Fix 0-length climbs (#21224)

This commit is contained in:
metalgearsloth
2023-10-24 21:44:09 +11:00
committed by GitHub
parent ea0459fe6c
commit 4701b853ef

View File

@@ -257,15 +257,25 @@ public sealed partial class ClimbSystem : VirtualController
// Need direction relative to climber's parent.
var localDirection = (-parentRot).RotateVec(worldDirection);
climbing.IsClimbing = true;
var climbDuration = TimeSpan.FromSeconds(distance / climbing.TransitionRate);
climbing.NextTransition = _timing.CurTime + climbDuration;
// On top of it already so just do it in place.
if (localDirection.LengthSquared() < 0.01f)
{
climbing.NextTransition = null;
}
// VirtualController over to the thing.
else
{
var climbDuration = TimeSpan.FromSeconds(distance / climbing.TransitionRate);
climbing.NextTransition = _timing.CurTime + climbDuration;
climbing.Direction = localDirection.Normalized() * climbing.TransitionRate;
climbing.Direction = localDirection.Normalized() * climbing.TransitionRate;
_actionBlockerSystem.UpdateCanMove(uid);
}
climbing.IsClimbing = true;
Dirty(uid, climbing);
_audio.PlayPredicted(comp.FinishClimbSound, climbable, user);
_actionBlockerSystem.UpdateCanMove(uid);
var startEv = new StartClimbEvent(climbable);
var climbedEv = new ClimbedOnEvent(uid, user);