Bandaid pullcontroller (#7176)

This commit is contained in:
metalgearsloth
2022-03-19 14:18:43 +11:00
committed by GitHub
parent 2e857824bc
commit e630deafe1
3 changed files with 19 additions and 4 deletions

View File

@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using Content.Shared.Pulling;
using Content.Shared.Pulling.Components;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Maths;
@@ -23,7 +24,7 @@ namespace Content.Server.Physics.Controllers
private const float AccelModifierLowMass = 5.0f; // roundstart saltern emergency crowbar
// Used to control settling (turns off pulling).
private const float MaximumSettleVelocity = 0.1f;
private const float MaximumSettleDistance = 0.01f;
private const float MaximumSettleDistance = 0.1f;
// Settle shutdown control.
// Mustn't be too massive, as that causes severe mispredicts *and can prevent it ever resolving*.
// Exists to bleed off "I pulled my crowbar" overshoots.
@@ -39,10 +40,19 @@ namespace Content.Server.Physics.Controllers
public override void Initialize()
{
UpdatesAfter.Add(typeof(MoverController));
SubscribeLocalEvent<SharedPullerComponent, MoveEvent>(OnPullerMove);
base.Initialize();
}
private void OnPullerMove(EntityUid uid, SharedPullerComponent component, ref MoveEvent args)
{
if (component.Pulling == null ||
!TryComp<SharedPullableComponent>(component.Pulling.Value, out var pullable)) return;
_pullableSystem.StopMoveTo(pullable);
}
public override void UpdateBeforeSolve(bool prediction, float frameTime)
{
base.UpdateBeforeSolve(prediction, frameTime);

View File

@@ -135,8 +135,8 @@ namespace Content.Shared.Pulling
RaiseLocalEvent(pullable.Owner, message);
// Networking
puller.Dirty();
pullable.Dirty();
Dirty(puller);
Dirty(pullable);
}
}

View File

@@ -4,6 +4,7 @@ using System.Diagnostics.CodeAnalysis;
using Content.Shared.Alert;
using Content.Shared.GameTicking;
using Content.Shared.Input;
using Content.Shared.Movement.Components;
using Content.Shared.Physics.Pull;
using Content.Shared.Pulling.Components;
using Content.Shared.Rotatable;
@@ -217,6 +218,10 @@ namespace Content.Shared.Pulling
return false;
}
if (_containerSystem.IsEntityInContainer(player) ||
player.IsWeightless(entityManager: EntityManager))
return false;
TryMoveTo(pullable, coords);
return false;