Files
tbd-station-14/Content.Server/Pulling/PullingSystem.cs
20kdc 2a8486a384 Pullability partial ECS refactor, monkey-gibbing error fix (#4695)
* Migrate lots of pulling logic out of the components and clean it up

* It's buggy, but move more code out of the pullable component

* Pulling system now throws less errors than it did before the refactor

* Finally finish the big parts of refactoring pullability

* Pulling: Handle disconnect properly if the pull joint has been removed by physics shutdown

* Port 2b68449328 to this branch

* Changes as per PR reviews

* Port e801ffac45 (SharedJointSystem) and fix issues encountered during testing

SharedJointSystem.

Also, MinLength and Stiffness appear to have suddenly gained enough meaning that pulling is broken unless they're set.
2021-10-04 17:10:54 +02:00

51 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.Players;
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;
}
TryStopPull(pullable);
}
}
}