Files
OldThink/Content.Server/Pulling/PullingSystem.cs

51 lines
1.4 KiB
C#
Raw Normal View History

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;
2021-06-09 22:19:39 +02:00
namespace Content.Server.Pulling
{
[UsedImplicitly]
public class PullingSystem : SharedPullingSystem
{
public override void Initialize()
{
base.Initialize();
UpdatesAfter.Add(typeof(PhysicsSystem));
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();
}
}
}