Fix H-pulling? (#4425)

In retrospect the answer is easy, but man this took a while.
This commit is contained in:
Leon Friedrich
2021-08-20 15:47:59 +10:00
committed by GitHub
parent 837ec62c3a
commit fcc7ca09ef
2 changed files with 31 additions and 24 deletions

View File

@@ -1,6 +1,10 @@
using Content.Shared.Pulling;
using Content.Shared.Input;
using Content.Shared.Pulling;
using Content.Shared.Pulling.Components;
using JetBrains.Annotations;
using Robust.Server.GameObjects;
using Robust.Shared.Input.Binding;
using Robust.Shared.Players;
namespace Content.Server.Pulling
{
@@ -15,6 +19,32 @@ namespace Content.Server.Pulling
SubscribeLocalEvent<PullableComponent, PullableMoveMessage>(OnPullableMove);
SubscribeLocalEvent<PullableComponent, PullableStopMovingMessage>(OnPullableStopMove);
CommandBinds.Builder
.Bind(ContentKeyFunctions.ReleasePulledObject, InputCmdHandler.FromDelegate(HandleReleasePulledObject))
.Register<PullingSystem>();
}
private void HandleReleasePulledObject(ICommonSession? session)
{
var player = session?.AttachedEntity;
if (player == null)
{
return;
}
if (!TryGetPulled(player, out var pulled))
{
return;
}
if (!pulled.TryGetComponent(out SharedPullableComponent? pullable))
{
return;
}
pullable.TryStopPull();
}
}
}

View File

@@ -62,7 +62,6 @@ namespace Content.Shared.Pulling
CommandBinds.Builder
.Bind(ContentKeyFunctions.MovePulledObject, new PointerInputCmdHandler(HandleMovePulledObject))
.Bind(ContentKeyFunctions.ReleasePulledObject, InputCmdHandler.FromDelegate(HandleReleasePulledObject))
.Register<SharedPullingSystem>();
}
@@ -194,28 +193,6 @@ namespace Content.Shared.Pulling
return false;
}
private void HandleReleasePulledObject(ICommonSession? session)
{
var player = session?.AttachedEntity;
if (player == null)
{
return;
}
if (!TryGetPulled(player, out var pulled))
{
return;
}
if (!pulled.TryGetComponent(out SharedPullableComponent? pullable))
{
return;
}
pullable.TryStopPull();
}
private void SetPuller(IEntity puller, IEntity pulled)
{
_pullers[puller] = pulled;