Separated Bonk functionality and component from ClimbSystem and ClimbComponent (#13635)
This commit is contained in:
@@ -8,7 +8,6 @@ using Content.Shared.ActionBlocker;
|
||||
using Content.Shared.Body.Components;
|
||||
using Content.Shared.Body.Part;
|
||||
using Content.Shared.Buckle.Components;
|
||||
using Content.Shared.CCVar;
|
||||
using Content.Shared.Climbing;
|
||||
using Content.Shared.Climbing.Events;
|
||||
using Content.Shared.Damage;
|
||||
@@ -46,6 +45,7 @@ public sealed class ClimbSystem : SharedClimbSystem
|
||||
[Dependency] private readonly StunSystem _stunSystem = default!;
|
||||
[Dependency] private readonly AudioSystem _audioSystem = 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);
|
||||
@@ -92,9 +92,6 @@ public sealed class ClimbSystem : SharedClimbSystem
|
||||
if (!args.CanAccess || !args.CanInteract || !_actionBlockerSystem.CanMove(args.User))
|
||||
return;
|
||||
|
||||
if (component.Bonk && _cfg.GetCVar(CCVars.GameTableBonk))
|
||||
return;
|
||||
|
||||
if (!TryComp(args.User, out ClimbingComponent? climbingComponent) || climbingComponent.IsClimbing)
|
||||
return;
|
||||
|
||||
@@ -117,7 +114,7 @@ public sealed class ClimbSystem : SharedClimbSystem
|
||||
if (!TryComp(entityToMove, out ClimbingComponent? climbingComponent) || climbingComponent.IsClimbing)
|
||||
return;
|
||||
|
||||
if (TryBonk(component, user))
|
||||
if (_bonkSystem.TryBonk(entityToMove, climbable))
|
||||
return;
|
||||
|
||||
_doAfterSystem.DoAfter(new DoAfterEventArgs(user, component.ClimbDelay, default, climbable, entityToMove)
|
||||
@@ -130,29 +127,6 @@ public sealed class ClimbSystem : SharedClimbSystem
|
||||
});
|
||||
}
|
||||
|
||||
private bool TryBonk(ClimbableComponent component, EntityUid user)
|
||||
{
|
||||
if (!component.Bonk)
|
||||
return false;
|
||||
|
||||
if (!_cfg.GetCVar(CCVars.GameTableBonk))
|
||||
{
|
||||
// Not set to always bonk, try clumsy roll.
|
||||
if (!_interactionSystem.TryRollClumsy(user, component.BonkClumsyChance))
|
||||
return false;
|
||||
}
|
||||
|
||||
// BONK!
|
||||
|
||||
_audioSystem.PlayPvs(component.BonkSound, component.Owner);
|
||||
_stunSystem.TryParalyze(user, TimeSpan.FromSeconds(component.BonkTime), true);
|
||||
|
||||
if (component.BonkDamage is { } bonkDmg)
|
||||
_damageableSystem.TryChangeDamage(user, bonkDmg, true, origin: user);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void OnClimbFinished(EntityUid uid, ClimbingComponent climbing, ClimbFinishedEvent args)
|
||||
{
|
||||
Climb(uid, args.User, args.Instigator, args.Climbable, climbing: climbing);
|
||||
|
||||
Reference in New Issue
Block a user