ActionBlocker CanUse uses EntityUid exclusively
This commit is contained in:
@@ -174,7 +174,7 @@ namespace Content.Server.AME.Components
|
||||
var actionBlocker = EntitySystem.Get<ActionBlockerSystem>();
|
||||
|
||||
//Check if player can interact in their current state
|
||||
if (!actionBlocker.CanInteract(playerEntity) || !actionBlocker.CanUse(playerEntity))
|
||||
if (!actionBlocker.CanInteract(playerEntity) || !actionBlocker.CanUse(playerEntity.Uid))
|
||||
return false;
|
||||
//Check if device is powered
|
||||
if (needsPower && !Powered)
|
||||
|
||||
@@ -218,7 +218,7 @@ namespace Content.Server.Atmos.Components
|
||||
{
|
||||
var user = GetInternalsComponent()?.Owner;
|
||||
|
||||
if (user == null || !EntitySystem.Get<ActionBlockerSystem>().CanUse(user))
|
||||
if (user == null || !EntitySystem.Get<ActionBlockerSystem>().CanUse(user.Uid))
|
||||
return;
|
||||
|
||||
if (IsConnected)
|
||||
|
||||
@@ -165,7 +165,7 @@ namespace Content.Server.Chemistry.Components
|
||||
var actionBlocker = EntitySystem.Get<ActionBlockerSystem>();
|
||||
|
||||
//Check if player can interact in their current state
|
||||
if (!actionBlocker.CanInteract(playerEntity) || !actionBlocker.CanUse(playerEntity))
|
||||
if (!actionBlocker.CanInteract(playerEntity) || !actionBlocker.CanUse(playerEntity.Uid))
|
||||
return false;
|
||||
//Check if device is powered
|
||||
if (needsPower && !Powered)
|
||||
|
||||
@@ -218,7 +218,7 @@ namespace Content.Server.Chemistry.Components
|
||||
var actionBlocker = EntitySystem.Get<ActionBlockerSystem>();
|
||||
|
||||
//Check if player can interact in their current state
|
||||
if (!actionBlocker.CanInteract(playerEntity) || !actionBlocker.CanUse(playerEntity))
|
||||
if (!actionBlocker.CanInteract(playerEntity) || !actionBlocker.CanUse(playerEntity.Uid))
|
||||
return false;
|
||||
//Check if device is powered
|
||||
if (needsPower && !Powered)
|
||||
|
||||
@@ -147,7 +147,7 @@ namespace Content.Server.Cuffs.Components
|
||||
{
|
||||
if (_cuffing) return true;
|
||||
|
||||
if (eventArgs.Target == null || !EntitySystem.Get<ActionBlockerSystem>().CanUse(eventArgs.User) || !eventArgs.Target.TryGetComponent<CuffableComponent>(out var cuffed))
|
||||
if (eventArgs.Target == null || !EntitySystem.Get<ActionBlockerSystem>().CanUse(eventArgs.User.Uid) || !eventArgs.Target.TryGetComponent<CuffableComponent>(out var cuffed))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ namespace Content.Server.Disposal.Tube.Components
|
||||
var actionBlocker = EntitySystem.Get<ActionBlockerSystem>();
|
||||
var groupController = IoCManager.Resolve<IConGroupController>();
|
||||
//Check if player can interact in their current state
|
||||
if (!groupController.CanAdminMenu(session) && (!actionBlocker.CanInteract(session.AttachedEntity) || !actionBlocker.CanUse(session.AttachedEntity)))
|
||||
if (!groupController.CanAdminMenu(session) && (!actionBlocker.CanInteract(session.AttachedEntity) || !actionBlocker.CanUse(session.AttachedEntityUid!.Value)))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
||||
@@ -94,7 +94,7 @@ namespace Content.Server.Disposal.Tube.Components
|
||||
var actionBlocker = EntitySystem.Get<ActionBlockerSystem>();
|
||||
var groupController = IoCManager.Resolve<IConGroupController>();
|
||||
//Check if player can interact in their current state
|
||||
if (!groupController.CanAdminMenu(session) && (!actionBlocker.CanInteract(session.AttachedEntity) || !actionBlocker.CanUse(session.AttachedEntity)))
|
||||
if (!groupController.CanAdminMenu(session) && (!actionBlocker.CanInteract(session.AttachedEntity) || !actionBlocker.CanUse(session.AttachedEntityUid!.Value)))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
||||
@@ -97,7 +97,7 @@ namespace Content.Server.Disposal.Unit.Components
|
||||
var actionBlocker = EntitySystem.Get<ActionBlockerSystem>();
|
||||
|
||||
if (!actionBlocker.CanInteract(player) ||
|
||||
!actionBlocker.CanUse(player))
|
||||
!actionBlocker.CanUse(player.Uid))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ namespace Content.Server.HandLabeler
|
||||
{
|
||||
if (session.AttachedEntity is not { } entity
|
||||
|| !Get<ActionBlockerSystem>().CanInteract(entity)
|
||||
|| !Get<ActionBlockerSystem>().CanUse(entity))
|
||||
|| !Get<ActionBlockerSystem>().CanUse(entity.Uid))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
||||
@@ -105,7 +105,7 @@ namespace Content.Server.Light.Components
|
||||
/// <returns>True if the light's status was toggled, false otherwise.</returns>
|
||||
public bool ToggleStatus(IEntity user)
|
||||
{
|
||||
if (!EntitySystem.Get<ActionBlockerSystem>().CanUse(user)) return false;
|
||||
if (!EntitySystem.Get<ActionBlockerSystem>().CanUse(user.Uid)) return false;
|
||||
return Activated ? TurnOff() : TurnOn(user);
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace Content.Server.Light.EntitySystems
|
||||
return;
|
||||
|
||||
// standard interaction checks
|
||||
if (!_blocker.CanUse(eventArgs.User)) return;
|
||||
if (!_blocker.CanUse(eventArgs.User.Uid)) return;
|
||||
if (!eventArgs.CanReach) return;
|
||||
|
||||
// behaviour will depends on target type
|
||||
|
||||
@@ -73,7 +73,7 @@ namespace Content.Server.Stunnable
|
||||
|
||||
private void OnUseInHand(EntityUid uid, StunbatonComponent comp, UseInHandEvent args)
|
||||
{
|
||||
if (!Get<ActionBlockerSystem>().CanUse(args.User))
|
||||
if (!Get<ActionBlockerSystem>().CanUse(args.User.Uid))
|
||||
return;
|
||||
|
||||
if (comp.Activated)
|
||||
|
||||
@@ -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