From 034d489be21307dd41d03101093376094f432ac2 Mon Sep 17 00:00:00 2001 From: keronshb <54602815+keronshb@users.noreply.github.com> Date: Wed, 5 Apr 2023 18:44:26 -0400 Subject: [PATCH] Removes clown abuse (#15145) --- Content.Server/Climbing/ClimbSystem.cs | 4 --- Content.Shared/Climbing/BonkSystem.cs | 36 ++++++++++++++++++-- Content.Shared/Climbing/BonkableComponent.cs | 6 ++++ 3 files changed, 40 insertions(+), 6 deletions(-) diff --git a/Content.Server/Climbing/ClimbSystem.cs b/Content.Server/Climbing/ClimbSystem.cs index 82e41d66ce..4dc8921910 100644 --- a/Content.Server/Climbing/ClimbSystem.cs +++ b/Content.Server/Climbing/ClimbSystem.cs @@ -41,7 +41,6 @@ public sealed class ClimbSystem : SharedClimbSystem [Dependency] private readonly InteractionSystem _interactionSystem = default!; [Dependency] private readonly StunSystem _stunSystem = default!; [Dependency] private readonly SharedPhysicsSystem _physics = default!; - [Dependency] private readonly BonkSystem _bonkSystem = default!; private const string ClimbingFixtureName = "climb"; private const int ClimbingCollisionGroup = (int) (CollisionGroup.TableLayer | CollisionGroup.LowImpassable); @@ -110,9 +109,6 @@ public sealed class ClimbSystem : SharedClimbSystem if (!TryComp(entityToMove, out ClimbingComponent? climbingComponent) || climbingComponent.IsClimbing) return; - if (_bonkSystem.TryBonk(entityToMove, climbable)) - return; - var args = new DoAfterArgs(user, component.ClimbDelay, new ClimbDoAfterEvent(), entityToMove, target: climbable, used: entityToMove) { BreakOnTargetMove = true, diff --git a/Content.Shared/Climbing/BonkSystem.cs b/Content.Shared/Climbing/BonkSystem.cs index 02c3686041..1a68f9cf08 100644 --- a/Content.Shared/Climbing/BonkSystem.cs +++ b/Content.Shared/Climbing/BonkSystem.cs @@ -2,11 +2,13 @@ using Content.Shared.Interaction; using Content.Shared.Stunnable; using Content.Shared.CCVar; using Content.Shared.Damage; +using Content.Shared.DoAfter; using Content.Shared.DragDrop; using Robust.Shared.Configuration; using Content.Shared.Popups; using Content.Shared.IdentityManagement; using Robust.Shared.Player; +using Robust.Shared.Serialization; namespace Content.Shared.Climbing; @@ -18,13 +20,26 @@ public sealed class BonkSystem : EntitySystem [Dependency] private readonly SharedStunSystem _stunSystem = default!; [Dependency] private readonly SharedAudioSystem _audioSystem = default!; [Dependency] private readonly SharedPopupSystem _popupSystem = default!; + [Dependency] private readonly SharedDoAfterSystem _doAfter = default!; public override void Initialize() { base.Initialize(); SubscribeLocalEvent(OnDragDrop); + SubscribeLocalEvent(OnBonkDoAfter); } + private void OnBonkDoAfter(EntityUid uid, BonkableComponent component, BonkDoAfterEvent args) + { + if (args.Handled || args.Cancelled || args.Args.Target == null) + return; + + TryBonk(args.Args.User, uid, component); + + args.Handled = true; + } + + public bool TryBonk(EntityUid user, EntityUid bonkableUid, BonkableComponent? bonkableComponent = null) { if (!Resolve(bonkableUid, ref bonkableComponent, false)) @@ -55,8 +70,25 @@ public sealed class BonkSystem : EntitySystem } - private void OnDragDrop(EntityUid uid, BonkableComponent bonkableComponent, ref DragDropTargetEvent args) + private void OnDragDrop(EntityUid uid, BonkableComponent component, ref DragDropTargetEvent args) + { + if (args.Handled) + return; + + var doAfterArgs = new DoAfterArgs(args.Dragged, component.BonkDelay, new BonkDoAfterEvent(), uid, target: uid) + { + BreakOnTargetMove = true, + BreakOnUserMove = true, + BreakOnDamage = true + }; + + _doAfter.TryStartDoAfter(doAfterArgs); + + args.Handled = true; + } + + [Serializable, NetSerializable] + private sealed class BonkDoAfterEvent : SimpleDoAfterEvent { - TryBonk(args.Dragged, uid); } } diff --git a/Content.Shared/Climbing/BonkableComponent.cs b/Content.Shared/Climbing/BonkableComponent.cs index 63f4f8c739..7fccde5bc4 100644 --- a/Content.Shared/Climbing/BonkableComponent.cs +++ b/Content.Shared/Climbing/BonkableComponent.cs @@ -37,4 +37,10 @@ public sealed class BonkableComponent : Component /// [DataField("bonkDamage")] public DamageSpecifier? BonkDamage; + + /// + /// How long it takes to bonk. + /// + [DataField("bonkDelay")] + public float BonkDelay = 0.8f; } -- 2.51.2