Set mover velocity via system (#6288)

This commit is contained in:
metalgearsloth
2022-02-02 17:34:25 +11:00
committed by GitHub
parent 0349a854ac
commit 2e5808085d
12 changed files with 44 additions and 47 deletions

View File

@@ -19,9 +19,9 @@ namespace Content.Client.Physics.Controllers
base.UpdateBeforeSolve(prediction, frameTime);
if (_playerManager.LocalPlayer?.ControlledEntity is not {Valid: true} player ||
!EntityManager.TryGetComponent(player, out IMoverComponent? mover) ||
!EntityManager.TryGetComponent(player, out PhysicsComponent? body) ||
!EntityManager.TryGetComponent(player, out TransformComponent? xform))
!TryComp(player, out IMoverComponent? mover) ||
!TryComp(player, out PhysicsComponent? body) ||
!TryComp(player, out TransformComponent? xform))
{
return;
}
@@ -37,7 +37,7 @@ namespace Content.Client.Physics.Controllers
// We set joints to predicted given these can affect how our mob moves.
// I would only recommend disabling this if you make pulling not use joints anymore (someday maybe?)
if (EntityManager.TryGetComponent(player, out JointComponent? jointComponent))
if (TryComp(player, out JointComponent? jointComponent))
{
foreach (var joint in jointComponent.GetJoints)
{
@@ -47,9 +47,9 @@ namespace Content.Client.Physics.Controllers
}
// If we're being pulled then we won't predict anything and will receive server lerps so it looks way smoother.
if (EntityManager.TryGetComponent(player, out SharedPullableComponent? pullableComp))
if (TryComp(player, out SharedPullableComponent? pullableComp))
{
if (pullableComp.Puller is {Valid: true} puller && EntityManager.TryGetComponent<PhysicsComponent?>(puller, out var pullerBody))
if (pullableComp.Puller is {Valid: true} puller && TryComp<PhysicsComponent?>(puller, out var pullerBody))
{
pullerBody.Predict = false;
body.Predict = false;
@@ -57,20 +57,20 @@ namespace Content.Client.Physics.Controllers
}
// If we're pulling a mob then make sure that isn't predicted so it doesn't fuck our velocity up.
if (EntityManager.TryGetComponent(player, out SharedPullerComponent? pullerComp))
if (TryComp(player, out SharedPullerComponent? pullerComp))
{
if (pullerComp.Pulling is {Valid: true} pulling &&
EntityManager.HasComponent<MobStateComponent>(pulling) &&
EntityManager.TryGetComponent(pulling, out PhysicsComponent? pullingBody))
HasComp<MobStateComponent>(pulling) &&
TryComp(pulling, out PhysicsComponent? pullingBody))
{
pullingBody.Predict = false;
}
}
// Server-side should just be handled on its own so we'll just do this shizznit
if (EntityManager.TryGetComponent(player, out IMobMoverComponent? mobMover))
if (TryComp(player, out IMobMoverComponent? mobMover))
{
HandleMobMovement(mover, body, mobMover);
HandleMobMovement(mover, body, mobMover, xform);
return;
}