ActionBlocker CanUse uses EntityUid exclusively
This commit is contained in:
@@ -43,18 +43,12 @@ namespace Content.Shared.ActionBlocker
|
||||
return CanInteract(EntityManager.GetEntity(uid));
|
||||
}
|
||||
|
||||
public bool CanUse(IEntity entity)
|
||||
{
|
||||
var ev = new UseAttemptEvent(entity);
|
||||
|
||||
RaiseLocalEvent(entity.Uid, ev);
|
||||
|
||||
return !ev.Cancelled;
|
||||
}
|
||||
|
||||
public bool CanUse(EntityUid uid)
|
||||
{
|
||||
return CanUse(EntityManager.GetEntity(uid));
|
||||
var ev = new UseAttemptEvent(uid);
|
||||
RaiseLocalEvent(uid, ev);
|
||||
|
||||
return !ev.Cancelled;
|
||||
}
|
||||
|
||||
public bool CanThrow(IEntity entity)
|
||||
|
||||
@@ -4,11 +4,11 @@ namespace Content.Shared.Interaction.Events
|
||||
{
|
||||
public class UseAttemptEvent : CancellableEntityEventArgs
|
||||
{
|
||||
public UseAttemptEvent(IEntity entity)
|
||||
public UseAttemptEvent(EntityUid uid)
|
||||
{
|
||||
Entity = entity;
|
||||
Uid = uid;
|
||||
}
|
||||
|
||||
public IEntity Entity { get; }
|
||||
public EntityUid Uid { get; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -444,7 +444,7 @@ namespace Content.Shared.Interaction
|
||||
delayComponent.BeginDelay();
|
||||
}
|
||||
|
||||
if (!_actionBlockerSystem.CanInteract(user) || !_actionBlockerSystem.CanUse(user))
|
||||
if (!_actionBlockerSystem.CanInteract(user) || !_actionBlockerSystem.CanUse(user.Uid))
|
||||
return;
|
||||
|
||||
// all activates should only fire when in range / unobstructed
|
||||
@@ -474,7 +474,7 @@ namespace Content.Shared.Interaction
|
||||
/// <param name="used"></param>
|
||||
public void TryUseInteraction(IEntity user, IEntity used, bool altInteract = false)
|
||||
{
|
||||
if (user != null && used != null && _actionBlockerSystem.CanUse(user))
|
||||
if (user != null && used != null && _actionBlockerSystem.CanUse(user.Uid))
|
||||
{
|
||||
if (altInteract)
|
||||
AltInteract(user, used);
|
||||
|
||||
@@ -166,7 +166,7 @@ namespace Content.Shared.Verbs
|
||||
/// The entity currently being held by the active hand.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This is only ever not null when <see cref="ActionBlockerSystem.CanUse(IEntity)"/> is true and the user
|
||||
/// This is only ever not null when <see cref="ActionBlockerSystem.CanUse(EntityUid)"/> is true and the user
|
||||
/// has hands.
|
||||
/// </remarks>
|
||||
public IEntity? Using;
|
||||
@@ -185,7 +185,7 @@ namespace Content.Shared.Verbs
|
||||
CanInteract = force || actionBlockerSystem.CanInteract(user);
|
||||
|
||||
if (!user.TryGetComponent(out Hands) ||
|
||||
!actionBlockerSystem.CanUse(user))
|
||||
!actionBlockerSystem.CanUse(user.Uid))
|
||||
return;
|
||||
|
||||
Hands.TryGetActiveHeldEntity(out Using);
|
||||
|
||||
Reference in New Issue
Block a user