ActionBlocker CanInteract uses EntityUid exclusively

ActionBlockerSystem fully uses EntityUid now!
This commit is contained in:
Vera Aguilera Puerto
2021-11-09 14:54:00 +01:00
parent b6337ffe7a
commit 48f8dd2284
44 changed files with 66 additions and 75 deletions

View File

@@ -18,9 +18,6 @@ namespace Content.Shared.ActionBlocker
[UsedImplicitly]
public class ActionBlockerSystem : EntitySystem
{
// TODO: Make the EntityUid the main overload for all these methods.
// TODO: Move each of these to their relevant EntitySystems?
public bool CanMove(EntityUid uid)
{
var ev = new MovementAttemptEvent(uid);
@@ -29,18 +26,12 @@ namespace Content.Shared.ActionBlocker
return !ev.Cancelled;
}
public bool CanInteract(IEntity entity)
{
var ev = new InteractionAttemptEvent(entity);
RaiseLocalEvent(entity.Uid, ev);
return !ev.Cancelled;
}
public bool CanInteract(EntityUid uid)
{
return CanInteract(EntityManager.GetEntity(uid));
var ev = new InteractionAttemptEvent(uid);
RaiseLocalEvent(uid, ev);
return !ev.Cancelled;
}
public bool CanUse(EntityUid uid)

View File

@@ -4,11 +4,11 @@ namespace Content.Shared.Interaction.Events
{
public class InteractionAttemptEvent : CancellableEntityEventArgs
{
public InteractionAttemptEvent(IEntity entity)
public InteractionAttemptEvent(EntityUid uid)
{
Entity = entity;
Uid = uid;
}
public IEntity Entity { get; }
public EntityUid Uid { get; }
}
}

View File

@@ -373,7 +373,7 @@ namespace Content.Shared.Interaction
/// </summary>
public async Task InteractUsing(IEntity user, IEntity used, IEntity target, EntityCoordinates clickLocation)
{
if (!_actionBlockerSystem.CanInteract(user))
if (!_actionBlockerSystem.CanInteract(user.Uid))
return;
if (InteractDoBefore(user, used, target, clickLocation, true))
@@ -444,7 +444,7 @@ namespace Content.Shared.Interaction
delayComponent.BeginDelay();
}
if (!_actionBlockerSystem.CanInteract(user) || !_actionBlockerSystem.CanUse(user.Uid))
if (!_actionBlockerSystem.CanInteract(user.Uid) || !_actionBlockerSystem.CanUse(user.Uid))
return;
// all activates should only fire when in range / unobstructed

View File

@@ -34,7 +34,7 @@ namespace Content.Shared.Storage
bool IDraggable.Drop(DragDropEvent eventArgs)
{
if (!EntitySystem.Get<ActionBlockerSystem>().CanInteract(eventArgs.User))
if (!EntitySystem.Get<ActionBlockerSystem>().CanInteract(eventArgs.User.Uid))
{
return false;
}

View File

@@ -17,7 +17,7 @@ namespace Content.Shared.Strip.Components
{
return by != Owner
&& by.HasComponent<SharedHandsComponent>()
&& EntitySystem.Get<ActionBlockerSystem>().CanInteract(by);
&& EntitySystem.Get<ActionBlockerSystem>().CanInteract(by.Uid);
}
bool IDraggable.CanDrop(CanDropEvent args)

View File

@@ -182,7 +182,7 @@ namespace Content.Shared.Verbs
// A large number of verbs need to check action blockers. Instead of repeatedly having each system individually
// call ActionBlocker checks, just cache it for the verb request.
var actionBlockerSystem = EntitySystem.Get<ActionBlockerSystem>();
CanInteract = force || actionBlockerSystem.CanInteract(user);
CanInteract = force || actionBlockerSystem.CanInteract(user.Uid);
if (!user.TryGetComponent(out Hands) ||
!actionBlockerSystem.CanUse(user.Uid))