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.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 random = IoCManager.Resolve<IRobustRandom>();
|
||||||
var system = EntitySystem.Get<MeleeWeaponSystem>();
|
var system = EntitySystem.Get<MeleeWeaponSystem>();
|
||||||
|
|||||||
@@ -430,7 +430,7 @@ namespace Content.Server.Interaction
|
|||||||
if (!ValidateInteractAndFace(user, coordinates))
|
if (!ValidateInteractAndFace(user, coordinates))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!_actionBlockerSystem.CanAttack(user))
|
if (!_actionBlockerSystem.CanAttack(user.Uid))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
IEntity? targetEnt = null;
|
IEntity? targetEnt = null;
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ namespace Content.Shared.ActionBlocker
|
|||||||
|
|
||||||
return !ev.Cancelled;
|
return !ev.Cancelled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool CanDrop(EntityUid uid)
|
public bool CanDrop(EntityUid uid)
|
||||||
{
|
{
|
||||||
var ev = new DropAttemptEvent(uid);
|
var ev = new DropAttemptEvent(uid);
|
||||||
@@ -103,18 +103,12 @@ namespace Content.Shared.ActionBlocker
|
|||||||
return CanEmote(EntityManager.GetEntity(uid));
|
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)
|
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)
|
public bool CanEquip(IEntity entity)
|
||||||
|
|||||||
@@ -4,11 +4,11 @@ namespace Content.Shared.Interaction.Events
|
|||||||
{
|
{
|
||||||
public class AttackAttemptEvent : CancellableEntityEventArgs
|
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