Fix H-pulling? (#4425)
In retrospect the answer is easy, but man this took a while.
This commit is contained in:
@@ -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 JetBrains.Annotations;
|
||||||
using Robust.Server.GameObjects;
|
using Robust.Server.GameObjects;
|
||||||
|
using Robust.Shared.Input.Binding;
|
||||||
|
using Robust.Shared.Players;
|
||||||
|
|
||||||
namespace Content.Server.Pulling
|
namespace Content.Server.Pulling
|
||||||
{
|
{
|
||||||
@@ -15,6 +19,32 @@ namespace Content.Server.Pulling
|
|||||||
|
|
||||||
SubscribeLocalEvent<PullableComponent, PullableMoveMessage>(OnPullableMove);
|
SubscribeLocalEvent<PullableComponent, PullableMoveMessage>(OnPullableMove);
|
||||||
SubscribeLocalEvent<PullableComponent, PullableStopMovingMessage>(OnPullableStopMove);
|
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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,7 +62,6 @@ namespace Content.Shared.Pulling
|
|||||||
|
|
||||||
CommandBinds.Builder
|
CommandBinds.Builder
|
||||||
.Bind(ContentKeyFunctions.MovePulledObject, new PointerInputCmdHandler(HandleMovePulledObject))
|
.Bind(ContentKeyFunctions.MovePulledObject, new PointerInputCmdHandler(HandleMovePulledObject))
|
||||||
.Bind(ContentKeyFunctions.ReleasePulledObject, InputCmdHandler.FromDelegate(HandleReleasePulledObject))
|
|
||||||
.Register<SharedPullingSystem>();
|
.Register<SharedPullingSystem>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -194,28 +193,6 @@ namespace Content.Shared.Pulling
|
|||||||
return false;
|
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)
|
private void SetPuller(IEntity puller, IEntity pulled)
|
||||||
{
|
{
|
||||||
_pullers[puller] = pulled;
|
_pullers[puller] = pulled;
|
||||||
|
|||||||
Reference in New Issue
Block a user