ActionBlocker CanMove uses EntityUid exclusively
This commit is contained in:
@@ -21,17 +21,12 @@ namespace Content.Shared.ActionBlocker
|
||||
// TODO: Make the EntityUid the main overload for all these methods.
|
||||
// TODO: Move each of these to their relevant EntitySystems?
|
||||
|
||||
public bool CanMove(IEntity entity)
|
||||
{
|
||||
var ev = new MovementAttemptEvent(entity);
|
||||
|
||||
RaiseLocalEvent(entity.Uid, ev);
|
||||
return !ev.Cancelled;
|
||||
}
|
||||
|
||||
public bool CanMove(EntityUid uid)
|
||||
{
|
||||
return CanMove(EntityManager.GetEntity(uid));
|
||||
var ev = new MovementAttemptEvent(uid);
|
||||
RaiseLocalEvent(uid, ev);
|
||||
|
||||
return !ev.Cancelled;
|
||||
}
|
||||
|
||||
public bool CanInteract(IEntity entity)
|
||||
|
||||
@@ -4,11 +4,11 @@ namespace Content.Shared.Movement
|
||||
{
|
||||
public class MovementAttemptEvent : CancellableEntityEventArgs
|
||||
{
|
||||
public MovementAttemptEvent(IEntity entity)
|
||||
public MovementAttemptEvent(EntityUid uid)
|
||||
{
|
||||
Entity = entity;
|
||||
Uid = uid;
|
||||
}
|
||||
|
||||
public IEntity Entity { get; }
|
||||
public EntityUid Uid { get; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,7 +163,7 @@ namespace Content.Shared.Movement
|
||||
body.Owner.HasComponent<MobStateComponent>() &&
|
||||
// If we're being pulled then don't mess with our velocity.
|
||||
(!body.Owner.TryGetComponent(out SharedPullableComponent? pullable) || !pullable.BeingPulled) &&
|
||||
_blocker.CanMove(body.Owner);
|
||||
_blocker.CanMove(body.OwnerUid);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -19,8 +19,8 @@ namespace Content.Shared.Pulling.Systems
|
||||
|
||||
private void OnRelayMoveInput(EntityUid uid, SharedPullableComponent component, RelayMoveInputEvent args)
|
||||
{
|
||||
var entity = args.Session.AttachedEntity;
|
||||
if (entity == null || !_blocker.CanMove(entity)) return;
|
||||
var entity = args.Session.AttachedEntityUid;
|
||||
if (entity == null || !_blocker.CanMove(entity.Value)) return;
|
||||
_pullSystem.TryStopPull(component);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user