2021-08-20 15:47:59 +10:00
|
|
|
using Content.Shared.Input;
|
|
|
|
|
using Content.Shared.Pulling;
|
|
|
|
|
using Content.Shared.Pulling.Components;
|
2021-04-05 14:08:45 +02:00
|
|
|
using JetBrains.Annotations;
|
|
|
|
|
using Robust.Server.GameObjects;
|
2021-08-20 15:47:59 +10:00
|
|
|
using Robust.Shared.Input.Binding;
|
2023-10-28 09:59:53 +11:00
|
|
|
using Robust.Shared.Player;
|
2021-04-05 14:08:45 +02:00
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
namespace Content.Server.Pulling
|
2021-04-05 14:08:45 +02:00
|
|
|
{
|
|
|
|
|
[UsedImplicitly]
|
2022-02-16 00:23:23 -07:00
|
|
|
public sealed class PullingSystem : SharedPullingSystem
|
2021-04-05 14:08:45 +02:00
|
|
|
{
|
|
|
|
|
public override void Initialize()
|
|
|
|
|
{
|
|
|
|
|
base.Initialize();
|
|
|
|
|
|
|
|
|
|
UpdatesAfter.Add(typeof(PhysicsSystem));
|
|
|
|
|
|
2022-03-18 15:40:02 +11:00
|
|
|
SubscribeLocalEvent<SharedPullableComponent, PullableMoveMessage>(OnPullableMove);
|
|
|
|
|
SubscribeLocalEvent<SharedPullableComponent, PullableStopMovingMessage>(OnPullableStopMove);
|
|
|
|
|
|
2021-08-20 15:47:59 +10:00
|
|
|
CommandBinds.Builder
|
|
|
|
|
.Bind(ContentKeyFunctions.ReleasePulledObject, InputCmdHandler.FromDelegate(HandleReleasePulledObject))
|
|
|
|
|
.Register<PullingSystem>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void HandleReleasePulledObject(ICommonSession? session)
|
|
|
|
|
{
|
2021-12-06 00:52:58 +01:00
|
|
|
if (session?.AttachedEntity is not {Valid: true} player)
|
2021-08-20 15:47:59 +10:00
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!TryGetPulled(player, out var pulled))
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-06 00:52:58 +01:00
|
|
|
if (!EntityManager.TryGetComponent(pulled.Value, out SharedPullableComponent? pullable))
|
2021-08-20 15:47:59 +10:00
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-04 16:10:54 +01:00
|
|
|
TryStopPull(pullable);
|
2021-04-05 14:08:45 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|