Reduce knocked down players tile friction (#11035)

This commit is contained in:
metalgearsloth
2022-09-11 16:49:10 +10:00
committed by GitHub
parent 47dd0ff2e8
commit 12e1a961d6
12 changed files with 80 additions and 124 deletions

View File

@@ -26,6 +26,12 @@ namespace Content.Shared.Stunnable
[Dependency] private readonly StatusEffectsSystem _statusEffectSystem = default!;
[Dependency] private readonly MovementSpeedModifierSystem _movementSpeedModifierSystem = default!;
/// <summary>
/// Friction modifier for knocked down players.
/// Doesn't make them faster but makes them slow down... slower.
/// </summary>
public const float KnockDownModifier = 0.4f;
public override void Initialize()
{
SubscribeLocalEvent<KnockedDownComponent, ComponentInit>(OnKnockInit);
@@ -48,6 +54,8 @@ namespace Content.Shared.Stunnable
SubscribeLocalEvent<KnockedDownComponent, InteractHandEvent>(OnInteractHand);
SubscribeLocalEvent<SlowedDownComponent, RefreshMovementSpeedModifiersEvent>(OnRefreshMovespeed);
SubscribeLocalEvent<KnockedDownComponent, TileFrictionEvent>(OnKnockedTileFriction);
// Attempt event subscriptions.
SubscribeLocalEvent<StunnedComponent, UpdateCanMoveEvent>(OnMoveAttempt);
SubscribeLocalEvent<StunnedComponent, InteractionAttemptEvent>(OnInteractAttempt);
@@ -205,6 +213,7 @@ namespace Content.Shared.Stunnable
if (args.Handled || knocked.HelpTimer > 0f)
return;
// TODO: This should be an event.
if (HasComp<SleepingComponent>(uid))
return;
@@ -215,11 +224,16 @@ namespace Content.Shared.Stunnable
SoundSystem.Play(knocked.StunAttemptSound.GetSound(), Filter.Pvs(uid), uid, AudioHelpers.WithVariation(0.05f));
knocked.Dirty();
Dirty(knocked);
args.Handled = true;
}
private void OnKnockedTileFriction(EntityUid uid, KnockedDownComponent component, ref TileFrictionEvent args)
{
args.Modifier *= KnockDownModifier;
}
#region Attempt Event Handling
private void OnMoveAttempt(EntityUid uid, StunnedComponent stunned, UpdateCanMoveEvent args)