ActionBlocker CanDrop uses EntityUid exclusively
This commit is contained in:
@@ -7,7 +7,7 @@ using Robust.Shared.Localization;
|
|||||||
|
|
||||||
namespace Content.Server.Access
|
namespace Content.Server.Access
|
||||||
{
|
{
|
||||||
public class IdCardConsoleSystem : EntitySystem
|
public class IdCardConsoleSystem : EntitySystem
|
||||||
{
|
{
|
||||||
[Dependency] private readonly ActionBlockerSystem _actionBlockerSystem = default!;
|
[Dependency] private readonly ActionBlockerSystem _actionBlockerSystem = default!;
|
||||||
|
|
||||||
@@ -24,10 +24,10 @@ namespace Content.Server.Access
|
|||||||
!args.CanAccess ||
|
!args.CanAccess ||
|
||||||
!args.CanInteract ||
|
!args.CanInteract ||
|
||||||
!args.Using.HasComponent<IdCardComponent>() ||
|
!args.Using.HasComponent<IdCardComponent>() ||
|
||||||
!_actionBlockerSystem.CanDrop(args.User))
|
!_actionBlockerSystem.CanDrop(args.User.Uid))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Can we insert a privileged ID?
|
// Can we insert a privileged ID?
|
||||||
if (component.PrivilegedIDEmpty)
|
if (component.PrivilegedIDEmpty)
|
||||||
{
|
{
|
||||||
Verb verb = new();
|
Verb verb = new();
|
||||||
@@ -56,7 +56,7 @@ namespace Content.Server.Access
|
|||||||
!_actionBlockerSystem.CanPickup(args.User))
|
!_actionBlockerSystem.CanPickup(args.User))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Can we eject a privileged ID?
|
// Can we eject a privileged ID?
|
||||||
if (!component.PrivilegedIDEmpty)
|
if (!component.PrivilegedIDEmpty)
|
||||||
{
|
{
|
||||||
Verb verb = new();
|
Verb verb = new();
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ namespace Content.Server.Chemistry.EntitySystems
|
|||||||
!args.CanInteract ||
|
!args.CanInteract ||
|
||||||
component.HasBeaker ||
|
component.HasBeaker ||
|
||||||
!args.Using.HasComponent<FitsInDispenserComponent>() ||
|
!args.Using.HasComponent<FitsInDispenserComponent>() ||
|
||||||
!_actionBlockerSystem.CanDrop(args.User))
|
!_actionBlockerSystem.CanDrop(args.User.Uid))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Verb verb = new();
|
Verb verb = new();
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ namespace Content.Server.Chemistry.EntitySystems
|
|||||||
!args.CanInteract ||
|
!args.CanInteract ||
|
||||||
component.HasBeaker ||
|
component.HasBeaker ||
|
||||||
!args.Using.HasComponent<FitsInDispenserComponent>() ||
|
!args.Using.HasComponent<FitsInDispenserComponent>() ||
|
||||||
!_actionBlockerSystem.CanDrop(args.User))
|
!_actionBlockerSystem.CanDrop(args.User.Uid))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Verb verb = new();
|
Verb verb = new();
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ namespace Content.Server.Power.EntitySystems
|
|||||||
!args.CanInteract ||
|
!args.CanInteract ||
|
||||||
component.HasCell ||
|
component.HasCell ||
|
||||||
!component.IsEntityCompatible(args.Using) ||
|
!component.IsEntityCompatible(args.Using) ||
|
||||||
!_actionBlockerSystem.CanDrop(args.User))
|
!_actionBlockerSystem.CanDrop(args.User.Uid))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Verb verb = new();
|
Verb verb = new();
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ namespace Content.Server.PowerCell
|
|||||||
!args.CanInteract ||
|
!args.CanInteract ||
|
||||||
component.HasCell ||
|
component.HasCell ||
|
||||||
!args.Using.HasComponent<PowerCellComponent>() ||
|
!args.Using.HasComponent<PowerCellComponent>() ||
|
||||||
!_actionBlockerSystem.CanDrop(args.User))
|
!_actionBlockerSystem.CanDrop(args.User.Uid))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Verb verb = new();
|
Verb verb = new();
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ namespace Content.Server.Weapon.Ranged.Barrels
|
|||||||
!args.CanInteract ||
|
!args.CanInteract ||
|
||||||
component.PowerCell != null ||
|
component.PowerCell != null ||
|
||||||
!args.Using.HasComponent<BatteryComponent>() ||
|
!args.Using.HasComponent<BatteryComponent>() ||
|
||||||
!_actionBlockerSystem.CanDrop(args.User))
|
!_actionBlockerSystem.CanDrop(args.User.Uid))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Verb verb = new();
|
Verb verb = new();
|
||||||
@@ -135,7 +135,7 @@ namespace Content.Server.Weapon.Ranged.Barrels
|
|||||||
// Are we holding a mag that we can insert?
|
// Are we holding a mag that we can insert?
|
||||||
if (args.Using == null ||
|
if (args.Using == null ||
|
||||||
!component.CanInsertMagazine(args.User, args.Using) ||
|
!component.CanInsertMagazine(args.User, args.Using) ||
|
||||||
!_actionBlockerSystem.CanDrop(args.User))
|
!_actionBlockerSystem.CanDrop(args.User.Uid))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Insert mag verb
|
// Insert mag verb
|
||||||
|
|||||||
@@ -54,7 +54,6 @@ namespace Content.Shared.ActionBlocker
|
|||||||
public bool CanThrow(EntityUid uid)
|
public bool CanThrow(EntityUid uid)
|
||||||
{
|
{
|
||||||
var ev = new ThrowAttemptEvent(uid);
|
var ev = new ThrowAttemptEvent(uid);
|
||||||
|
|
||||||
RaiseLocalEvent(uid, ev);
|
RaiseLocalEvent(uid, ev);
|
||||||
|
|
||||||
return !ev.Cancelled;
|
return !ev.Cancelled;
|
||||||
@@ -63,24 +62,17 @@ namespace Content.Shared.ActionBlocker
|
|||||||
public bool CanSpeak(EntityUid uid)
|
public bool CanSpeak(EntityUid uid)
|
||||||
{
|
{
|
||||||
var ev = new SpeakAttemptEvent(uid);
|
var ev = new SpeakAttemptEvent(uid);
|
||||||
|
|
||||||
RaiseLocalEvent(uid, ev);
|
RaiseLocalEvent(uid, ev);
|
||||||
|
|
||||||
return !ev.Cancelled;
|
return !ev.Cancelled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool CanDrop(IEntity entity)
|
|
||||||
{
|
|
||||||
var ev = new DropAttemptEvent(entity);
|
|
||||||
|
|
||||||
RaiseLocalEvent(entity.Uid, ev);
|
|
||||||
|
|
||||||
return !ev.Cancelled;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool CanDrop(EntityUid uid)
|
public bool CanDrop(EntityUid uid)
|
||||||
{
|
{
|
||||||
return CanDrop(EntityManager.GetEntity(uid));
|
var ev = new DropAttemptEvent(uid);
|
||||||
|
RaiseLocalEvent(uid, ev);
|
||||||
|
|
||||||
|
return !ev.Cancelled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool CanPickup(IEntity entity)
|
public bool CanPickup(IEntity entity)
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ namespace Content.Shared.Containers.ItemSlots
|
|||||||
if (args.Using == null ||
|
if (args.Using == null ||
|
||||||
!args.CanAccess ||
|
!args.CanAccess ||
|
||||||
!args.CanInteract ||
|
!args.CanInteract ||
|
||||||
!_actionBlockerSystem.CanDrop(args.User))
|
!_actionBlockerSystem.CanDrop(args.User.Uid))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
foreach (var (slotName, slot) in component.Slots)
|
foreach (var (slotName, slot) in component.Slots)
|
||||||
|
|||||||
@@ -4,11 +4,11 @@ namespace Content.Shared.DragDrop
|
|||||||
{
|
{
|
||||||
public class DropAttemptEvent : CancellableEntityEventArgs
|
public class DropAttemptEvent : CancellableEntityEventArgs
|
||||||
{
|
{
|
||||||
public DropAttemptEvent(IEntity entity)
|
public DropAttemptEvent(EntityUid uid)
|
||||||
{
|
{
|
||||||
Entity = entity;
|
Uid = uid;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEntity Entity { get; }
|
public EntityUid Uid { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -430,7 +430,7 @@ namespace Content.Shared.Hands.Components
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private bool PlayerCanDrop()
|
private bool PlayerCanDrop()
|
||||||
{
|
{
|
||||||
if (!IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<ActionBlockerSystem>().CanDrop(Owner))
|
if (!IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<ActionBlockerSystem>().CanDrop(OwnerUid))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -660,7 +660,7 @@ namespace Content.Shared.Interaction
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool TryDroppedInteraction(IEntity user, IEntity item, bool intentional)
|
public bool TryDroppedInteraction(IEntity user, IEntity item, bool intentional)
|
||||||
{
|
{
|
||||||
if (user == null || item == null || !_actionBlockerSystem.CanDrop(user)) return false;
|
if (user == null || item == null || !_actionBlockerSystem.CanDrop(user.Uid)) return false;
|
||||||
|
|
||||||
DroppedInteraction(user, item, intentional);
|
DroppedInteraction(user, item, intentional);
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user