Fix pulling lerping (#4550)

This commit is contained in:
metalgearsloth
2021-09-02 12:35:16 +10:00
committed by GitHub
parent 744b4e5ce6
commit 5ade8c2695
3 changed files with 31 additions and 1 deletions

View File

@@ -1,5 +1,8 @@
using Content.Shared.Body.Components;
using Content.Shared.MobState;
using Content.Shared.Movement;
using Content.Shared.Movement.Components;
using Content.Shared.Pulling.Components;
using Robust.Client.Player;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
@@ -32,6 +35,30 @@ namespace Content.Client.Physics.Controllers
joint.BodyB.Predict = true;
}
// If we're being pulled then we won't predict anything and will receive server lerps so it looks way smoother.
if (player.TryGetComponent(out SharedPullableComponent? pullableComp))
{
var puller = pullableComp.Puller;
if (puller != null && puller.TryGetComponent<PhysicsComponent>(out var pullerBody))
{
pullerBody.Predict = false;
body.Predict = false;
}
}
// If we're pulling a mob then make sure that isn't predicted so it doesn't fuck our velocity up.
if (player.TryGetComponent(out SharedPullerComponent? pullerComp))
{
var pulling = pullerComp.Pulling;
if (pulling != null &&
pulling.HasComponent<IMobStateComponent>() &&
pulling.TryGetComponent(out PhysicsComponent? pullingBody))
{
pullingBody.Predict = false;
}
}
// Server-side should just be handled on its own so we'll just do this shizznit
if (player.TryGetComponent(out IMobMoverComponent? mobMover))
{