fix #31963: Stopped climbing movent while in containers (#32033)

* hack to resolve offset issues while in locker

* moved movment cancel from lerp to init

* Added DoAfter canceling for buckling and stowing

* changed container event & removed inventory check from climb initation

* resolved integration test fail

* style

---------

Co-authored-by: Milon <milonpl.git@proton.me>
This commit is contained in:
Ben
2025-04-14 11:56:14 -04:00
committed by GitHub
parent c4b4063cb9
commit b01ca8e57e
2 changed files with 44 additions and 2 deletions

View File

@@ -1,3 +1,4 @@
using Content.Shared.DoAfter;
using System.Numerics;
using Robust.Shared.GameStates;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
@@ -25,6 +26,12 @@ public sealed partial class ClimbingComponent : Component
[AutoNetworkedField, DataField]
public bool IsClimbing;
/// <summary>
/// The Climbing DoAfter.
/// </summary>
[DataField]
public DoAfterId? DoAfter;
/// <summary>
/// Whether the owner is being moved onto the climbed entity.
/// </summary>

View File

@@ -62,6 +62,7 @@ public sealed partial class ClimbSystem : VirtualController
SubscribeLocalEvent<ClimbingComponent, ClimbDoAfterEvent>(OnDoAfter);
SubscribeLocalEvent<ClimbingComponent, EndCollideEvent>(OnClimbEndCollide);
SubscribeLocalEvent<ClimbingComponent, BuckledEvent>(OnBuckled);
SubscribeLocalEvent<ClimbingComponent, EntGotInsertedIntoContainerMessage>(OnStored);
SubscribeLocalEvent<ClimbableComponent, CanDropTargetEvent>(OnCanDragDropOn);
SubscribeLocalEvent<ClimbableComponent, GetVerbsEvent<AlternativeVerb>>(AddClimbableVerb);
@@ -234,14 +235,28 @@ public sealed partial class ClimbSystem : VirtualController
};
_audio.PlayPredicted(comp.StartClimbSound, climbable, user);
return _doAfterSystem.TryStartDoAfter(args, out id);
var success = _doAfterSystem.TryStartDoAfter(args, out id);
if (success)
climbing.DoAfter = id;
return success;
}
private void OnDoAfter(EntityUid uid, ClimbingComponent component, ClimbDoAfterEvent args)
{
component.DoAfter = null;
if (args.Handled || args.Cancelled || args.Args.Target == null || args.Args.Used == null)
return;
if (_containers.IsEntityInContainer(uid))
{
args.Handled = true;
return;
}
Climb(uid, args.Args.User, args.Args.Target.Value, climbing: component);
args.Handled = true;
}
@@ -520,7 +535,27 @@ public sealed partial class ClimbSystem : VirtualController
private void OnBuckled(EntityUid uid, ClimbingComponent component, ref BuckledEvent args)
{
StopClimb(uid, component);
StopOrCancelClimb(uid, component);
}
private void OnStored(EntityUid uid, ClimbingComponent component, ref EntGotInsertedIntoContainerMessage args)
{
StopOrCancelClimb(uid, component);
}
private void StopOrCancelClimb(EntityUid uid, ClimbingComponent component)
{
if (component.IsClimbing)
{
StopClimb(uid, component);
return;
}
if (component.DoAfter != null)
{
_doAfterSystem.Cancel(component.DoAfter);
component.DoAfter = null;
}
}
private void OnGlassClimbed(EntityUid uid, GlassTableComponent component, ref ClimbedOnEvent args)