Fix being able to pull multiple entities at once (#2398)

This commit is contained in:
DrSmugleaf
2020-10-26 18:15:19 +01:00
committed by GitHub
parent 847ff6dd34
commit 7dcaa1ff88
2 changed files with 17 additions and 3 deletions

View File

@@ -118,12 +118,20 @@ namespace Content.Shared.GameObjects.Components.Pulling
public bool TogglePull(IEntity puller) public bool TogglePull(IEntity puller)
{ {
if (Puller == null) if (BeingPulled)
{ {
return TryStartPull(puller); if (Puller == puller)
{
return TryStopPull();
}
else
{
TryStopPull();
return TryStartPull(puller);
}
} }
return TryStopPull(); return TryStartPull(puller);
} }
public bool TryMoveTo(EntityCoordinates to) public bool TryMoveTo(EntityCoordinates to)

View File

@@ -41,6 +41,12 @@ namespace Content.Shared.GameObjects.EntitySystems
private void OnPullStarted(PullStartedMessage message) private void OnPullStarted(PullStartedMessage message)
{ {
if (_pullers.TryGetValue(message.Puller.Owner, out var pulled) &&
pulled.TryGetComponent(out SharedPullableComponent? pulledComponent))
{
pulledComponent.TryStopPull();
}
SetPuller(message.Puller.Owner, message.Pulled.Owner); SetPuller(message.Puller.Owner, message.Pulled.Owner);
} }