Cache CanMove (#7480)
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using Content.Shared.ActionBlocker;
|
||||
using Content.Shared.Audio;
|
||||
using Content.Shared.DragDrop;
|
||||
using Content.Shared.Interaction;
|
||||
@@ -25,6 +26,7 @@ namespace Content.Shared.Stunnable
|
||||
[UsedImplicitly]
|
||||
public abstract class SharedStunSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly ActionBlockerSystem _blocker = default!;
|
||||
[Dependency] private readonly StandingStateSystem _standingStateSystem = default!;
|
||||
[Dependency] private readonly StatusEffectsSystem _statusEffectSystem = default!;
|
||||
[Dependency] private readonly MovementSpeedModifierSystem _movementSpeedModifierSystem = default!;
|
||||
@@ -37,6 +39,9 @@ namespace Content.Shared.Stunnable
|
||||
SubscribeLocalEvent<SlowedDownComponent, ComponentInit>(OnSlowInit);
|
||||
SubscribeLocalEvent<SlowedDownComponent, ComponentRemove>(OnSlowRemove);
|
||||
|
||||
SubscribeLocalEvent<StunnedComponent, ComponentStartup>(UpdateCanMove);
|
||||
SubscribeLocalEvent<StunnedComponent, ComponentShutdown>(UpdateCanMove);
|
||||
|
||||
SubscribeLocalEvent<SlowedDownComponent, ComponentGetState>(OnSlowGetState);
|
||||
SubscribeLocalEvent<SlowedDownComponent, ComponentHandleState>(OnSlowHandleState);
|
||||
|
||||
@@ -48,7 +53,7 @@ namespace Content.Shared.Stunnable
|
||||
SubscribeLocalEvent<SlowedDownComponent, RefreshMovementSpeedModifiersEvent>(OnRefreshMovespeed);
|
||||
|
||||
// Attempt event subscriptions.
|
||||
SubscribeLocalEvent<StunnedComponent, MovementAttemptEvent>(OnMoveAttempt);
|
||||
SubscribeLocalEvent<StunnedComponent, UpdateCanMoveEvent>(OnMoveAttempt);
|
||||
SubscribeLocalEvent<StunnedComponent, InteractionAttemptEvent>(OnInteractAttempt);
|
||||
SubscribeLocalEvent<StunnedComponent, UseAttemptEvent>(OnUseAttempt);
|
||||
SubscribeLocalEvent<StunnedComponent, ThrowAttemptEvent>(OnThrowAttempt);
|
||||
@@ -58,6 +63,11 @@ namespace Content.Shared.Stunnable
|
||||
SubscribeLocalEvent<StunnedComponent, IsUnequippingAttemptEvent>(OnUnequipAttempt);
|
||||
}
|
||||
|
||||
private void UpdateCanMove(EntityUid uid, StunnedComponent component, EntityEventArgs args)
|
||||
{
|
||||
_blocker.UpdateCanMove(uid);
|
||||
}
|
||||
|
||||
private void OnSlowGetState(EntityUid uid, SlowedDownComponent component, ref ComponentGetState args)
|
||||
{
|
||||
args.State = new SlowedDownComponentState(component.SprintSpeedModifier, component.WalkSpeedModifier);
|
||||
@@ -205,8 +215,11 @@ namespace Content.Shared.Stunnable
|
||||
|
||||
#region Attempt Event Handling
|
||||
|
||||
private void OnMoveAttempt(EntityUid uid, StunnedComponent stunned, MovementAttemptEvent args)
|
||||
private void OnMoveAttempt(EntityUid uid, StunnedComponent stunned, UpdateCanMoveEvent args)
|
||||
{
|
||||
if (stunned.LifeStage > ComponentLifeStage.Running)
|
||||
return;
|
||||
|
||||
args.Cancel();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user