ActionBlocker CanThrow uses EntityUid exclusively

This commit is contained in:
Vera Aguilera Puerto
2021-11-09 13:20:55 +01:00
parent c051b1e056
commit c68c3219f8
3 changed files with 9 additions and 14 deletions

View File

@@ -51,18 +51,13 @@ namespace Content.Shared.ActionBlocker
return !ev.Cancelled; return !ev.Cancelled;
} }
public bool CanThrow(IEntity entity)
{
var ev = new ThrowAttemptEvent(entity);
RaiseLocalEvent(entity.Uid, ev);
return !ev.Cancelled;
}
public bool CanThrow(EntityUid uid) public bool CanThrow(EntityUid uid)
{ {
return CanThrow(EntityManager.GetEntity(uid)); var ev = new ThrowAttemptEvent(uid);
RaiseLocalEvent(uid, ev);
return !ev.Cancelled;
} }
public bool CanSpeak(IEntity entity) public bool CanSpeak(IEntity entity)

View File

@@ -543,7 +543,7 @@ namespace Content.Shared.Interaction
/// </summary> /// </summary>
public bool TryThrowInteraction(IEntity user, IEntity item) public bool TryThrowInteraction(IEntity user, IEntity item)
{ {
if (user == null || item == null || !_actionBlockerSystem.CanThrow(user)) return false; if (user == null || item == null || !_actionBlockerSystem.CanThrow(user.Uid)) return false;
ThrownInteraction(user, item); ThrownInteraction(user, item);
return true; return true;

View File

@@ -4,12 +4,12 @@ namespace Content.Shared.Throwing
{ {
public class ThrowAttemptEvent : CancellableEntityEventArgs public class ThrowAttemptEvent : CancellableEntityEventArgs
{ {
public ThrowAttemptEvent(IEntity entity) public ThrowAttemptEvent(EntityUid uid)
{ {
Entity = entity; Uid = uid;
} }
public IEntity Entity { get; } public EntityUid Uid { get; }
} }
/// <summary> /// <summary>