Removes clown abuse (#15145)
This commit is contained in:
@@ -41,7 +41,6 @@ public sealed class ClimbSystem : SharedClimbSystem
|
|||||||
[Dependency] private readonly InteractionSystem _interactionSystem = default!;
|
[Dependency] private readonly InteractionSystem _interactionSystem = default!;
|
||||||
[Dependency] private readonly StunSystem _stunSystem = default!;
|
[Dependency] private readonly StunSystem _stunSystem = default!;
|
||||||
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
|
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
|
||||||
[Dependency] private readonly BonkSystem _bonkSystem = default!;
|
|
||||||
|
|
||||||
private const string ClimbingFixtureName = "climb";
|
private const string ClimbingFixtureName = "climb";
|
||||||
private const int ClimbingCollisionGroup = (int) (CollisionGroup.TableLayer | CollisionGroup.LowImpassable);
|
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)
|
if (!TryComp(entityToMove, out ClimbingComponent? climbingComponent) || climbingComponent.IsClimbing)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (_bonkSystem.TryBonk(entityToMove, climbable))
|
|
||||||
return;
|
|
||||||
|
|
||||||
var args = new DoAfterArgs(user, component.ClimbDelay, new ClimbDoAfterEvent(), entityToMove, target: climbable, used: entityToMove)
|
var args = new DoAfterArgs(user, component.ClimbDelay, new ClimbDoAfterEvent(), entityToMove, target: climbable, used: entityToMove)
|
||||||
{
|
{
|
||||||
BreakOnTargetMove = true,
|
BreakOnTargetMove = true,
|
||||||
|
|||||||
@@ -2,11 +2,13 @@ using Content.Shared.Interaction;
|
|||||||
using Content.Shared.Stunnable;
|
using Content.Shared.Stunnable;
|
||||||
using Content.Shared.CCVar;
|
using Content.Shared.CCVar;
|
||||||
using Content.Shared.Damage;
|
using Content.Shared.Damage;
|
||||||
|
using Content.Shared.DoAfter;
|
||||||
using Content.Shared.DragDrop;
|
using Content.Shared.DragDrop;
|
||||||
using Robust.Shared.Configuration;
|
using Robust.Shared.Configuration;
|
||||||
using Content.Shared.Popups;
|
using Content.Shared.Popups;
|
||||||
using Content.Shared.IdentityManagement;
|
using Content.Shared.IdentityManagement;
|
||||||
using Robust.Shared.Player;
|
using Robust.Shared.Player;
|
||||||
|
using Robust.Shared.Serialization;
|
||||||
|
|
||||||
namespace Content.Shared.Climbing;
|
namespace Content.Shared.Climbing;
|
||||||
|
|
||||||
@@ -18,13 +20,26 @@ public sealed class BonkSystem : EntitySystem
|
|||||||
[Dependency] private readonly SharedStunSystem _stunSystem = default!;
|
[Dependency] private readonly SharedStunSystem _stunSystem = default!;
|
||||||
[Dependency] private readonly SharedAudioSystem _audioSystem = default!;
|
[Dependency] private readonly SharedAudioSystem _audioSystem = default!;
|
||||||
[Dependency] private readonly SharedPopupSystem _popupSystem = default!;
|
[Dependency] private readonly SharedPopupSystem _popupSystem = default!;
|
||||||
|
[Dependency] private readonly SharedDoAfterSystem _doAfter = default!;
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
SubscribeLocalEvent<BonkableComponent, DragDropTargetEvent>(OnDragDrop);
|
SubscribeLocalEvent<BonkableComponent, DragDropTargetEvent>(OnDragDrop);
|
||||||
|
SubscribeLocalEvent<BonkableComponent, BonkDoAfterEvent>(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)
|
public bool TryBonk(EntityUid user, EntityUid bonkableUid, BonkableComponent? bonkableComponent = null)
|
||||||
{
|
{
|
||||||
if (!Resolve(bonkableUid, ref bonkableComponent, false))
|
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,4 +37,10 @@ public sealed class BonkableComponent : Component
|
|||||||
/// <seealso cref="Bonk"/>
|
/// <seealso cref="Bonk"/>
|
||||||
[DataField("bonkDamage")]
|
[DataField("bonkDamage")]
|
||||||
public DamageSpecifier? BonkDamage;
|
public DamageSpecifier? BonkDamage;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// How long it takes to bonk.
|
||||||
|
/// </summary>
|
||||||
|
[DataField("bonkDelay")]
|
||||||
|
public float BonkDelay = 0.8f;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user