]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
fix #31963: Stopped climbing movent while in containers (#32033)
authorBen <benjaminevanownby@gmail.com>
Mon, 14 Apr 2025 15:56:14 +0000 (11:56 -0400)
committerGitHub <noreply@github.com>
Mon, 14 Apr 2025 15:56:14 +0000 (17:56 +0200)
* 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>
Content.Shared/Climbing/Components/ClimbingComponent.cs
Content.Shared/Climbing/Systems/ClimbSystem.cs

index 1ab861b1f70e6843199d3c61ad1eb7eb988e04cb..df4632d8f70ed785502a8ed61221f35783f792bd 100644 (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>
index 467d96187e53c8accdd09984dab073804f12e8bf..f8f2ffda88c0b32b54e4541f60c058fedf4419d5 100644 (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)