]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix climbing and bonking simultaneously (#27268)
authorTayrtahn <tayrtahn@gmail.com>
Wed, 24 Apr 2024 13:02:43 +0000 (09:02 -0400)
committerGitHub <noreply@github.com>
Wed, 24 Apr 2024 13:02:43 +0000 (23:02 +1000)
* Properly network ClumsyComponent

* Fix being able to climb and bonk at the same time.
Also properly subscribe to AttemptClimbEvent by-ref.

* Update Content.Shared/Interaction/Components/ClumsyComponent.cs

Content.Shared/Climbing/Systems/BonkSystem.cs
Content.Shared/Climbing/Systems/ClimbSystem.cs
Content.Shared/Interaction/Components/ClumsyComponent.cs

index ea4e04c621af74244c378ec135b5dc3e864d904b..f59fe925736a3a14ad94290ca512ed33179069a9 100644 (file)
@@ -107,17 +107,16 @@ public sealed partial class BonkSystem : EntitySystem
         var doAfterArgs = new DoAfterArgs(EntityManager, user, bonkableComponent.BonkDelay, new BonkDoAfterEvent(), uid, target: uid, used: climber)
         {
             BreakOnMove = true,
-            BreakOnDamage = true
+            BreakOnDamage = true,
+            DuplicateCondition = DuplicateConditions.SameTool | DuplicateConditions.SameTarget
         };
 
-        _doAfter.TryStartDoAfter(doAfterArgs);
-
-        return true;
+        return _doAfter.TryStartDoAfter(doAfterArgs);
     }
 
-    private void OnAttemptClimb(EntityUid uid, BonkableComponent component, AttemptClimbEvent args)
+    private void OnAttemptClimb(EntityUid uid, BonkableComponent component, ref AttemptClimbEvent args)
     {
-        if (args.Cancelled || !HasComp<ClumsyComponent>(args.Climber) || !HasComp<HandsComponent>(args.User))
+        if (args.Cancelled)
             return;
 
         if (TryStartBonk(uid, args.User, args.Climber, component))
index 1bdaecf730fe127772c34195411a876b7d2449e3..ac01c4e9acbc2be4b5cb5f3d37f824d31f098a43 100644 (file)
@@ -222,7 +222,8 @@ public sealed partial class ClimbSystem : VirtualController
             used: entityToMove)
         {
             BreakOnMove = true,
-            BreakOnDamage = true
+            BreakOnDamage = true,
+            DuplicateCondition = DuplicateConditions.SameTool | DuplicateConditions.SameTarget
         };
 
         _audio.PlayPredicted(comp.StartClimbSound, climbable, user);
index 5b72fc224c80f69bfc10d317ee02d3fbd4a0f87b..824696c8385de22406317d36461aebce11201c9b 100644 (file)
@@ -1,22 +1,24 @@
 using Content.Shared.Damage;
 using Robust.Shared.Audio;
+using Robust.Shared.GameStates;
 
-namespace Content.Shared.Interaction.Components
+namespace Content.Shared.Interaction.Components;
+
+/// <summary>
+/// A simple clumsy tag-component.
+/// </summary>
+[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
+public sealed partial class ClumsyComponent : Component
 {
     /// <summary>
-    /// A simple clumsy tag-component.
+    /// Damage dealt to a clumsy character when they try to fire a gun.
     /// </summary>
-    [RegisterComponent]
-    public sealed partial class ClumsyComponent : Component
-    {
-        [DataField("clumsyDamage", required: true)]
-        [ViewVariables(VVAccess.ReadWrite)]
-        public DamageSpecifier ClumsyDamage = default!;
+    [DataField(required: true), AutoNetworkedField]
+    public DamageSpecifier ClumsyDamage = default!;
 
-        /// <summary>
-        ///     Sound to play when clumsy interactions fail
-        /// </summary>
-        [DataField("clumsySound")]
-        public SoundSpecifier ClumsySound = new SoundPathSpecifier("/Audio/Items/bikehorn.ogg");
-    }
+    /// <summary>
+    /// Sound to play when clumsy interactions fail.
+    /// </summary>
+    [DataField]
+    public SoundSpecifier ClumsySound = new SoundPathSpecifier("/Audio/Items/bikehorn.ogg");
 }