Remove IActionBlocker.CanMove (#4449)
* Remove IActionBlocker.CanMove Ported the remainders over to using MovementAttemptEvent which should also help make mob movement a bit faster. * Make that check faster
This commit is contained in:
9
Content.Client/Climbing/ClimbingSystem.cs
Normal file
9
Content.Client/Climbing/ClimbingSystem.cs
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
using Content.Shared.Climbing;
|
||||||
|
|
||||||
|
namespace Content.Client.Climbing
|
||||||
|
{
|
||||||
|
public sealed class ClimbingSystem : SharedClimbSystem
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Content.Server.Climbing.Components;
|
using Content.Server.Climbing.Components;
|
||||||
|
using Content.Shared.Climbing;
|
||||||
using Content.Shared.GameTicking;
|
using Content.Shared.GameTicking;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
@@ -8,7 +9,7 @@ using Robust.Shared.GameObjects;
|
|||||||
namespace Content.Server.Climbing
|
namespace Content.Server.Climbing
|
||||||
{
|
{
|
||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
internal sealed class ClimbSystem : EntitySystem
|
internal sealed class ClimbSystem : SharedClimbSystem
|
||||||
{
|
{
|
||||||
private readonly HashSet<ClimbingComponent> _activeClimbers = new();
|
private readonly HashSet<ClimbingComponent> _activeClimbers = new();
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ namespace Content.Server.Climbing.Components
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool OwnerIsTransitioning
|
public override bool OwnerIsTransitioning
|
||||||
{
|
{
|
||||||
get => base.OwnerIsTransitioning;
|
get => base.OwnerIsTransitioning;
|
||||||
set
|
set
|
||||||
|
|||||||
@@ -25,16 +25,6 @@ namespace Content.Shared.ActionBlocker
|
|||||||
var ev = new MovementAttemptEvent(entity);
|
var ev = new MovementAttemptEvent(entity);
|
||||||
|
|
||||||
RaiseLocalEvent(entity.Uid, ev);
|
RaiseLocalEvent(entity.Uid, ev);
|
||||||
|
|
||||||
foreach (var blocker in entity.GetAllComponents<IActionBlocker>())
|
|
||||||
{
|
|
||||||
if (!blocker.CanMove())
|
|
||||||
{
|
|
||||||
ev.Cancel();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return !ev.Cancelled;
|
return !ev.Cancelled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,9 +10,6 @@ namespace Content.Shared.ActionBlocker
|
|||||||
[Obsolete("Use events instead")]
|
[Obsolete("Use events instead")]
|
||||||
public interface IActionBlocker
|
public interface IActionBlocker
|
||||||
{
|
{
|
||||||
[Obsolete("Use MoveAttemptEvent instead")]
|
|
||||||
bool CanMove() => true;
|
|
||||||
|
|
||||||
[Obsolete("Use InteractAttemptEvent instead")]
|
[Obsolete("Use InteractAttemptEvent instead")]
|
||||||
bool CanInteract() => true;
|
bool CanInteract() => true;
|
||||||
|
|
||||||
|
|||||||
@@ -36,11 +36,6 @@ namespace Content.Shared.Buckle.Components
|
|||||||
|
|
||||||
public abstract bool TryBuckle(IEntity? user, IEntity to);
|
public abstract bool TryBuckle(IEntity? user, IEntity to);
|
||||||
|
|
||||||
bool IActionBlocker.CanMove()
|
|
||||||
{
|
|
||||||
return !Buckled;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool IActionBlocker.CanChangeDirection()
|
bool IActionBlocker.CanChangeDirection()
|
||||||
{
|
{
|
||||||
return !Buckled;
|
return !Buckled;
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using Content.Shared.Buckle.Components;
|
using Content.Shared.Buckle.Components;
|
||||||
|
using Content.Shared.Movement;
|
||||||
using Content.Shared.Standing;
|
using Content.Shared.Standing;
|
||||||
using Content.Shared.Throwing;
|
using Content.Shared.Throwing;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
@@ -15,6 +16,13 @@ namespace Content.Shared.Buckle
|
|||||||
SubscribeLocalEvent<SharedBuckleComponent, DownAttemptEvent>(HandleDown);
|
SubscribeLocalEvent<SharedBuckleComponent, DownAttemptEvent>(HandleDown);
|
||||||
SubscribeLocalEvent<SharedBuckleComponent, StandAttemptEvent>(HandleStand);
|
SubscribeLocalEvent<SharedBuckleComponent, StandAttemptEvent>(HandleStand);
|
||||||
SubscribeLocalEvent<SharedBuckleComponent, ThrowPushbackAttemptEvent>(HandleThrowPushback);
|
SubscribeLocalEvent<SharedBuckleComponent, ThrowPushbackAttemptEvent>(HandleThrowPushback);
|
||||||
|
SubscribeLocalEvent<SharedBuckleComponent, MovementAttemptEvent>(HandleMove);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void HandleMove(EntityUid uid, SharedBuckleComponent component, MovementAttemptEvent args)
|
||||||
|
{
|
||||||
|
if (component.Buckled)
|
||||||
|
args.Cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void HandleStand(EntityUid uid, SharedBuckleComponent component, StandAttemptEvent args)
|
private void HandleStand(EntityUid uid, SharedBuckleComponent component, StandAttemptEvent args)
|
||||||
|
|||||||
20
Content.Shared/Climbing/SharedClimbSystem.cs
Normal file
20
Content.Shared/Climbing/SharedClimbSystem.cs
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
using Content.Shared.Movement;
|
||||||
|
using Robust.Shared.GameObjects;
|
||||||
|
|
||||||
|
namespace Content.Shared.Climbing
|
||||||
|
{
|
||||||
|
public abstract class SharedClimbSystem : EntitySystem
|
||||||
|
{
|
||||||
|
public override void Initialize()
|
||||||
|
{
|
||||||
|
base.Initialize();
|
||||||
|
SubscribeLocalEvent<SharedClimbingComponent, MovementAttemptEvent>(HandleMoveAttempt);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void HandleMoveAttempt(EntityUid uid, SharedClimbingComponent component, MovementAttemptEvent args)
|
||||||
|
{
|
||||||
|
if (component.OwnerIsTransitioning)
|
||||||
|
args.Cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -29,10 +29,8 @@ namespace Content.Shared.Climbing
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IActionBlocker.CanMove() => !OwnerIsTransitioning;
|
|
||||||
|
|
||||||
[ViewVariables]
|
[ViewVariables]
|
||||||
protected virtual bool OwnerIsTransitioning
|
public virtual bool OwnerIsTransitioning
|
||||||
{
|
{
|
||||||
get => _ownerIsTransitioning;
|
get => _ownerIsTransitioning;
|
||||||
set
|
set
|
||||||
|
|||||||
@@ -14,8 +14,6 @@ namespace Content.Shared.Cuffs.Components
|
|||||||
{
|
{
|
||||||
public override string Name => "Cuffable";
|
public override string Name => "Cuffable";
|
||||||
|
|
||||||
[ComponentDependency] private readonly SharedPullableComponent? _pullable = default!;
|
|
||||||
|
|
||||||
[ViewVariables]
|
[ViewVariables]
|
||||||
public bool CanStillInteract { get; set; } = true;
|
public bool CanStillInteract { get; set; } = true;
|
||||||
|
|
||||||
@@ -28,8 +26,6 @@ namespace Content.Shared.Cuffs.Components
|
|||||||
bool IActionBlocker.CanAttack() => CanStillInteract;
|
bool IActionBlocker.CanAttack() => CanStillInteract;
|
||||||
bool IActionBlocker.CanEquip() => CanStillInteract;
|
bool IActionBlocker.CanEquip() => CanStillInteract;
|
||||||
bool IActionBlocker.CanUnequip() => CanStillInteract;
|
bool IActionBlocker.CanUnequip() => CanStillInteract;
|
||||||
bool IActionBlocker.CanMove() => _pullable == null || !_pullable.BeingPulled || CanStillInteract;
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
[Serializable, NetSerializable]
|
[Serializable, NetSerializable]
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using Content.Shared.Cuffs.Components;
|
using Content.Shared.Cuffs.Components;
|
||||||
|
using Content.Shared.Movement;
|
||||||
using Content.Shared.Pulling.Components;
|
using Content.Shared.Pulling.Components;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
|
|
||||||
@@ -10,6 +11,15 @@ namespace Content.Shared.Cuffs
|
|||||||
{
|
{
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
SubscribeLocalEvent<SharedCuffableComponent, StopPullingEvent>(HandleStopPull);
|
SubscribeLocalEvent<SharedCuffableComponent, StopPullingEvent>(HandleStopPull);
|
||||||
|
SubscribeLocalEvent<SharedCuffableComponent, MovementAttemptEvent>(HandleMoveAttempt);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void HandleMoveAttempt(EntityUid uid, SharedCuffableComponent component, MovementAttemptEvent args)
|
||||||
|
{
|
||||||
|
if (component.CanStillInteract || !ComponentManager.TryGetComponent(uid, out SharedPullableComponent? pullable) || !pullable.BeingPulled)
|
||||||
|
return;
|
||||||
|
|
||||||
|
args.Cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void HandleStopPull(EntityUid uid, SharedCuffableComponent component, StopPullingEvent args)
|
private void HandleStopPull(EntityUid uid, SharedCuffableComponent component, StopPullingEvent args)
|
||||||
|
|||||||
@@ -338,11 +338,6 @@ namespace Content.Shared.MobState.Components
|
|||||||
return CurrentState?.CanInteract() ?? true;
|
return CurrentState?.CanInteract() ?? true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IActionBlocker.CanMove()
|
|
||||||
{
|
|
||||||
return CurrentState?.CanMove() ?? true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool IActionBlocker.CanUse()
|
bool IActionBlocker.CanUse()
|
||||||
{
|
{
|
||||||
return CurrentState?.CanUse() ?? true;
|
return CurrentState?.CanUse() ?? true;
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
using Content.Shared.MobState.Components;
|
using Content.Shared.MobState.Components;
|
||||||
|
using Content.Shared.MobState.State;
|
||||||
|
using Content.Shared.Movement;
|
||||||
using Content.Shared.Pulling.Events;
|
using Content.Shared.Pulling.Events;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
|
|
||||||
@@ -11,6 +13,7 @@ namespace Content.Shared.MobState.EntitySystems
|
|||||||
base.Initialize();
|
base.Initialize();
|
||||||
|
|
||||||
SubscribeLocalEvent<SharedMobStateComponent, StartPullAttemptEvent>(OnStartPullAttempt);
|
SubscribeLocalEvent<SharedMobStateComponent, StartPullAttemptEvent>(OnStartPullAttempt);
|
||||||
|
SubscribeLocalEvent<SharedMobStateComponent, MovementAttemptEvent>(OnMoveAttempt);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnStartPullAttempt(EntityUid uid, SharedMobStateComponent component, StartPullAttemptEvent args)
|
private void OnStartPullAttempt(EntityUid uid, SharedMobStateComponent component, StartPullAttemptEvent args)
|
||||||
@@ -18,5 +21,18 @@ namespace Content.Shared.MobState.EntitySystems
|
|||||||
if(component.IsIncapacitated())
|
if(component.IsIncapacitated())
|
||||||
args.Cancel();
|
args.Cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnMoveAttempt(EntityUid uid, SharedMobStateComponent component, MovementAttemptEvent args)
|
||||||
|
{
|
||||||
|
switch (component.CurrentState)
|
||||||
|
{
|
||||||
|
case SharedCriticalMobState:
|
||||||
|
case SharedDeadMobState:
|
||||||
|
args.Cancel();
|
||||||
|
return;
|
||||||
|
default:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,11 +39,6 @@ namespace Content.Shared.MobState.State
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual bool CanMove()
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual bool CanUse()
|
public virtual bool CanUse()
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -41,11 +41,6 @@ namespace Content.Shared.MobState.State
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool CanMove()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool CanUse()
|
public override bool CanUse()
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -49,11 +49,6 @@ namespace Content.Shared.MobState.State
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool CanMove()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool CanUse()
|
public override bool CanUse()
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -27,11 +27,6 @@ namespace Content.Shared.MobState.State
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool CanMove()
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool CanUse()
|
public override bool CanUse()
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -323,8 +323,6 @@ namespace Content.Shared.Stunnable
|
|||||||
}
|
}
|
||||||
|
|
||||||
#region ActionBlockers
|
#region ActionBlockers
|
||||||
public bool CanMove() => (!Stunned);
|
|
||||||
|
|
||||||
public bool CanInteract() => (!Stunned);
|
public bool CanInteract() => (!Stunned);
|
||||||
|
|
||||||
public bool CanUse() => (!Stunned);
|
public bool CanUse() => (!Stunned);
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
using Content.Shared.Movement;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
|
|
||||||
@@ -6,6 +7,18 @@ namespace Content.Shared.Stunnable
|
|||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
internal sealed class StunSystem : EntitySystem
|
internal sealed class StunSystem : EntitySystem
|
||||||
{
|
{
|
||||||
|
public override void Initialize()
|
||||||
|
{
|
||||||
|
base.Initialize();
|
||||||
|
SubscribeLocalEvent<SharedStunnableComponent, MovementAttemptEvent>(HandleMoveAttempt);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void HandleMoveAttempt(EntityUid uid, SharedStunnableComponent component, MovementAttemptEvent args)
|
||||||
|
{
|
||||||
|
if (component.Stunned)
|
||||||
|
args.Cancel();
|
||||||
|
}
|
||||||
|
|
||||||
public override void Update(float frameTime)
|
public override void Update(float frameTime)
|
||||||
{
|
{
|
||||||
base.Update(frameTime);
|
base.Update(frameTime);
|
||||||
|
|||||||
Reference in New Issue
Block a user