Buckle Bugfix + Dynamic CPR Prio (#6375)

* Fix long-time carrying bug with buckling. Also change CPR priority

* remove TODO comment

* small nitpick

Refactor OnRemoved method and improve code formatting.

Signed-off-by: Sir Warock <67167466+SirWarock@users.noreply.github.com>

---------

Signed-off-by: Sir Warock <67167466+SirWarock@users.noreply.github.com>
Co-authored-by: Sir Warock <67167466+SirWarock@users.noreply.github.com>
This commit is contained in:
Vanessa 2026-07-23 15:07:03 -05:00 committed by GitHub
parent 25f4ffda47
commit 898101b18e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 19 additions and 7 deletions

View File

@ -392,7 +392,6 @@ public abstract partial class SharedBuckleSystem
if (TryComp<PhysicsComponent>(buckle, out var physics))
_physics.ResetDynamics(buckle, physics);
// TOOD: DV - This fails when you try to buckle the entity you're carrying to something. Figure out why later.
DebugTools.AssertEqual(xform.ParentUid, strap.Owner);
}

View File

@ -1,5 +1,6 @@
using Content.Shared._DV.Body.Components;
using Content.Shared._DV.Body.Events;
using Content.Shared.Buckle;
using Content.Shared.DoAfter;
using Content.Shared.Mobs.Components;
using Content.Shared.Mobs.Systems;
@ -13,6 +14,7 @@ public sealed class CPRSystem : EntitySystem
[Dependency] private readonly MobStateSystem _mobStateSystem = default!;
[Dependency] private readonly SharedDoAfterSystem _doAfterSystem = default!;
[Dependency] private readonly SharedPopupSystem _popupSystem = default!;
[Dependency] private readonly SharedBuckleSystem _buckle = default!;
public override void Initialize()
{
@ -85,7 +87,7 @@ public sealed class CPRSystem : EntitySystem
{
Act = () => StartCPR(user, target, cprComp.TimeLength),
Text = Loc.GetString("cpr-verb-start"),
Priority = 2,
Priority = _buckle.IsBuckled(target) ? 3 : 1, // Higher priority if they are buckled. Otherwise, this conflicts with trying to carry.
Disabled = alreadyAffected,
Message = alreadyAffected ? Loc.GetString("cpr-verb-disabled-description") : Loc.GetString("cpr-verb-description"),
};

View File

@ -30,6 +30,7 @@ using System.Numerics;
using Content.Shared._DV.Polymorph;
using Content.Shared._Floof.OfferItem;
using Content.Shared.Hands.EntitySystems;
using Content.Shared.Buckle;
namespace Content.Shared._DV.Carrying;
@ -70,7 +71,7 @@ public sealed class CarryingSystem : EntitySystem
SubscribeLocalEvent<BeingCarriedComponent, GettingInteractedWithAttemptEvent>(OnInteractedWith);
SubscribeLocalEvent<BeingCarriedComponent, PullAttemptEvent>(OnPullAttempt);
SubscribeLocalEvent<BeingCarriedComponent, StartClimbEvent>(OnDrop);
SubscribeLocalEvent<BeingCarriedComponent, BuckledEvent>(OnDrop);
SubscribeLocalEvent<BeingCarriedComponent, BuckledEvent>(OnBuckle);
SubscribeLocalEvent<BeingCarriedComponent, UnbuckledEvent>(OnDrop);
SubscribeLocalEvent<BeingCarriedComponent, StrappedEvent>(OnDrop);
SubscribeLocalEvent<BeingCarriedComponent, UnstrappedEvent>(OnDrop);
@ -220,6 +221,13 @@ public sealed class CarryingSystem : EntitySystem
DropCarried(ent.Comp.Carrier, ent);
}
private void OnBuckle(Entity<BeingCarriedComponent> ent, ref BuckledEvent args)
{
// Buckling to a bed already handles the reparenting to the entity that the carried
// entity is buckled to, and then relays the BuckledEvent, so don't reparent to the grid.
DropCarried(ent.Comp.Carrier, ent, attachToGrid: false);
}
private void OnRemoved(Entity<BeingCarriedComponent> ent, ref ComponentRemove args)
{
/*
@ -327,9 +335,9 @@ public sealed class CarryingSystem : EntitySystem
return true;
}
public void DropCarried(EntityUid carrier, EntityUid carried)
public void DropCarried(EntityUid carrier, EntityUid carried, bool attachToGrid = true)
{
Drop(carried);
Drop(carried, attachToGrid);
CleanupCarrier(carrier, carried);
}
@ -341,12 +349,15 @@ public sealed class CarryingSystem : EntitySystem
_movementSpeed.RefreshMovementSpeedModifiers(carrier);
}
private void Drop(EntityUid carried)
private void Drop(EntityUid carried, bool attachToGrid = true)
{
RemComp<BeingCarriedComponent>(carried);
RemComp<KnockedDownComponent>(carried); // TODO SHITMED: make sure this doesnt let you make someone with no legs walk
_actionBlocker.UpdateCanMove(carried);
_transform.AttachToGridOrMap(carried);
// Some systems will handle re-parenting and then throw an event, and this changes the parent when it should not
if (attachToGrid)
_transform.AttachToGridOrMap(carried);
_standingState.Stand(carried);
}