2021-09-20 19:06:48 +10:00
|
|
|
using Content.Shared.ActionBlocker;
|
2023-01-13 16:57:10 -08:00
|
|
|
using Content.Shared.Mobs.Systems;
|
2021-09-20 19:06:48 +10:00
|
|
|
using Content.Shared.Pulling.Components;
|
2022-06-24 17:44:30 +10:00
|
|
|
using Content.Shared.Movement.Events;
|
2021-09-20 19:06:48 +10:00
|
|
|
|
|
|
|
|
namespace Content.Shared.Pulling.Systems
|
|
|
|
|
{
|
2022-02-16 00:23:23 -07:00
|
|
|
public sealed class SharedPullableSystem : EntitySystem
|
2021-09-20 19:06:48 +10:00
|
|
|
{
|
|
|
|
|
[Dependency] private readonly ActionBlockerSystem _blocker = default!;
|
2023-01-13 16:57:10 -08:00
|
|
|
[Dependency] private readonly MobStateSystem _mobState = default!;
|
2021-10-04 16:10:54 +01:00
|
|
|
[Dependency] private readonly SharedPullingSystem _pullSystem = default!;
|
2021-09-20 19:06:48 +10:00
|
|
|
|
|
|
|
|
public override void Initialize()
|
|
|
|
|
{
|
|
|
|
|
base.Initialize();
|
2022-07-16 13:51:52 +10:00
|
|
|
SubscribeLocalEvent<SharedPullableComponent, MoveInputEvent>(OnRelayMoveInput);
|
2021-09-20 19:06:48 +10:00
|
|
|
}
|
|
|
|
|
|
2022-07-16 13:51:52 +10:00
|
|
|
private void OnRelayMoveInput(EntityUid uid, SharedPullableComponent component, ref MoveInputEvent args)
|
2021-09-20 19:06:48 +10:00
|
|
|
{
|
2022-07-16 13:51:52 +10:00
|
|
|
var entity = args.Entity;
|
|
|
|
|
if (_mobState.IsIncapacitated(entity) || !_blocker.CanMove(entity)) return;
|
|
|
|
|
|
2021-10-04 16:10:54 +01:00
|
|
|
_pullSystem.TryStopPull(component);
|
2021-09-20 19:06:48 +10:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|