Fix bug with holding objects (#31009)

Main
This commit is contained in:
IgorAnt028
2024-08-16 07:53:34 +03:00
committed by GitHub
parent 0a9535e67c
commit 1d2c72da80

View File

@@ -9,6 +9,8 @@ using Content.Shared.Hands.EntitySystems;
using Content.Shared.Input;
using Content.Shared.Interaction;
using Content.Shared.Item;
using Content.Shared.Mobs;
using Content.Shared.Mobs.Systems;
using Content.Shared.Movement.Events;
using Content.Shared.Movement.Pulling.Components;
using Content.Shared.Movement.Pulling.Events;
@@ -60,6 +62,7 @@ public sealed class PullingSystem : EntitySystem
SubscribeLocalEvent<PullableComponent, ModifyUncuffDurationEvent>(OnModifyUncuffDuration);
SubscribeLocalEvent<PullableComponent, StopBeingPulledAlertEvent>(OnStopBeingPulledAlert);
SubscribeLocalEvent<PullerComponent, UpdateMobStateEvent>(OnStateChanged);
SubscribeLocalEvent<PullerComponent, AfterAutoHandleStateEvent>(OnAfterState);
SubscribeLocalEvent<PullerComponent, EntGotInsertedIntoContainerMessage>(OnPullerContainerInsert);
SubscribeLocalEvent<PullerComponent, EntityUnpausedEvent>(OnPullerUnpaused);
@@ -76,6 +79,17 @@ public sealed class PullingSystem : EntitySystem
.Register<PullingSystem>();
}
private void OnStateChanged(EntityUid uid, PullerComponent component, ref UpdateMobStateEvent args)
{
if (component.Pulling == null)
return;
if (TryComp<PullableComponent>(component.Pulling, out var comp) && (args.State == MobState.Critical || args.State == MobState.Dead))
{
TryStopPull(component.Pulling.Value, comp);
}
}
private void OnBuckled(Entity<PullableComponent> ent, ref StrappedEvent args)
{
// Prevent people from pulling the entity they are buckled to