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:
metalgearsloth
2021-08-10 10:34:01 +10:00
committed by GitHub
parent 0f5f9a7f38
commit b2322864e9
19 changed files with 80 additions and 54 deletions

View File

@@ -338,11 +338,6 @@ namespace Content.Shared.MobState.Components
return CurrentState?.CanInteract() ?? true;
}
bool IActionBlocker.CanMove()
{
return CurrentState?.CanMove() ?? true;
}
bool IActionBlocker.CanUse()
{
return CurrentState?.CanUse() ?? true;

View File

@@ -1,4 +1,6 @@
using Content.Shared.MobState.Components;
using Content.Shared.MobState.State;
using Content.Shared.Movement;
using Content.Shared.Pulling.Events;
using Robust.Shared.GameObjects;
@@ -11,6 +13,7 @@ namespace Content.Shared.MobState.EntitySystems
base.Initialize();
SubscribeLocalEvent<SharedMobStateComponent, StartPullAttemptEvent>(OnStartPullAttempt);
SubscribeLocalEvent<SharedMobStateComponent, MovementAttemptEvent>(OnMoveAttempt);
}
private void OnStartPullAttempt(EntityUid uid, SharedMobStateComponent component, StartPullAttemptEvent args)
@@ -18,5 +21,18 @@ namespace Content.Shared.MobState.EntitySystems
if(component.IsIncapacitated())
args.Cancel();
}
private void OnMoveAttempt(EntityUid uid, SharedMobStateComponent component, MovementAttemptEvent args)
{
switch (component.CurrentState)
{
case SharedCriticalMobState:
case SharedDeadMobState:
args.Cancel();
return;
default:
return;
}
}
}
}

View File

@@ -39,11 +39,6 @@ namespace Content.Shared.MobState.State
return true;
}
public virtual bool CanMove()
{
return true;
}
public virtual bool CanUse()
{
return true;

View File

@@ -41,11 +41,6 @@ namespace Content.Shared.MobState.State
return false;
}
public override bool CanMove()
{
return false;
}
public override bool CanUse()
{
return false;

View File

@@ -49,11 +49,6 @@ namespace Content.Shared.MobState.State
return false;
}
public override bool CanMove()
{
return false;
}
public override bool CanUse()
{
return false;

View File

@@ -27,11 +27,6 @@ namespace Content.Shared.MobState.State
return true;
}
public override bool CanMove()
{
return true;
}
public override bool CanUse()
{
return true;