ActionBlocker CanAttack uses EntityUid exclusively

This commit is contained in:
Vera Aguilera Puerto
2021-11-09 13:40:27 +01:00
parent 51e785c0fd
commit d4ded87448
4 changed files with 10 additions and 16 deletions

View File

@@ -65,7 +65,7 @@ namespace Content.Server.Actions.Actions
}
if (!args.Performer.TryGetComponent<SharedActionsComponent>(out var actions)) return;
if (args.Target == args.Performer || !EntitySystem.Get<ActionBlockerSystem>().CanAttack(args.Performer)) return;
if (args.Target == args.Performer || !EntitySystem.Get<ActionBlockerSystem>().CanAttack(args.Performer.Uid)) return;
var random = IoCManager.Resolve<IRobustRandom>();
var system = EntitySystem.Get<MeleeWeaponSystem>();

View File

@@ -430,7 +430,7 @@ namespace Content.Server.Interaction
if (!ValidateInteractAndFace(user, coordinates))
return;
if (!_actionBlockerSystem.CanAttack(user))
if (!_actionBlockerSystem.CanAttack(user.Uid))
return;
IEntity? targetEnt = null;

View File

@@ -66,7 +66,7 @@ namespace Content.Shared.ActionBlocker
return !ev.Cancelled;
}
public bool CanDrop(EntityUid uid)
{
var ev = new DropAttemptEvent(uid);
@@ -103,18 +103,12 @@ namespace Content.Shared.ActionBlocker
return CanEmote(EntityManager.GetEntity(uid));
}
public bool CanAttack(IEntity entity)
{
var ev = new AttackAttemptEvent(entity);
RaiseLocalEvent(entity.Uid, ev);
return !ev.Cancelled;
}
public bool CanAttack(EntityUid uid)
{
return CanAttack(EntityManager.GetEntity(uid));
var ev = new AttackAttemptEvent(uid);
RaiseLocalEvent(uid, ev);
return !ev.Cancelled;
}
public bool CanEquip(IEntity entity)

View File

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