Files
tbd-station-14/Content.Server/Pulling/PullingSystem.cs
Jezithyr c15b0691ec Emergency revert for pulling (#24923)
Revert "Pulling rework (#20906)"

This reverts commit 0d8254b2a2.
2024-02-03 10:32:30 -08:00

49 lines
1.4 KiB
C#

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.Player;
namespace Content.Server.Pulling
{
[UsedImplicitly]
public sealed class PullingSystem : SharedPullingSystem
{
public override void Initialize()
{
base.Initialize();
UpdatesAfter.Add(typeof(PhysicsSystem));
SubscribeLocalEvent<SharedPullableComponent, PullableMoveMessage>(OnPullableMove);
SubscribeLocalEvent<SharedPullableComponent, PullableStopMovingMessage>(OnPullableStopMove);
CommandBinds.Builder
.Bind(ContentKeyFunctions.ReleasePulledObject, InputCmdHandler.FromDelegate(HandleReleasePulledObject))
.Register<PullingSystem>();
}
private void HandleReleasePulledObject(ICommonSession? session)
{
if (session?.AttachedEntity is not {Valid: true} player)
{
return;
}
if (!TryGetPulled(player, out var pulled))
{
return;
}
if (!EntityManager.TryGetComponent(pulled.Value, out SharedPullableComponent? pullable))
{
return;
}
TryStopPull(pullable);
}
}
}