ActionBlocker CanAttack uses EntityUid exclusively
This commit is contained in:
@@ -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>();
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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; }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user