Files
tbd-station-14/Content.Shared/Pulling/Systems/SharedPullableSystem.cs
Jezithyr eeb5b17b34 Mobstate Refactor (#13389)
Refactors mobstate and moves mob health thresholds to their own component

Co-authored-by: DrSmugleaf <drsmugleaf@gmail.com>
2023-01-13 16:57:10 -08:00

29 lines
999 B
C#

using Content.Shared.ActionBlocker;
using Content.Shared.Mobs.Systems;
using Content.Shared.Pulling.Components;
using Content.Shared.Movement.Events;
namespace Content.Shared.Pulling.Systems
{
public sealed class SharedPullableSystem : EntitySystem
{
[Dependency] private readonly ActionBlockerSystem _blocker = default!;
[Dependency] private readonly MobStateSystem _mobState = default!;
[Dependency] private readonly SharedPullingSystem _pullSystem = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<SharedPullableComponent, MoveInputEvent>(OnRelayMoveInput);
}
private void OnRelayMoveInput(EntityUid uid, SharedPullableComponent component, ref MoveInputEvent args)
{
var entity = args.Entity;
if (_mobState.IsIncapacitated(entity) || !_blocker.CanMove(entity)) return;
_pullSystem.TryStopPull(component);
}
}
}