Make CanAttack check for container (#11650)
This commit is contained in:
@@ -10,6 +10,7 @@ using Content.Shared.Movement.Events;
|
|||||||
using Content.Shared.Speech;
|
using Content.Shared.Speech;
|
||||||
using Content.Shared.Throwing;
|
using Content.Shared.Throwing;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
|
using Robust.Shared.Containers;
|
||||||
|
|
||||||
namespace Content.Shared.ActionBlocker
|
namespace Content.Shared.ActionBlocker
|
||||||
{
|
{
|
||||||
@@ -19,6 +20,8 @@ namespace Content.Shared.ActionBlocker
|
|||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
public sealed class ActionBlockerSystem : EntitySystem
|
public sealed class ActionBlockerSystem : EntitySystem
|
||||||
{
|
{
|
||||||
|
[Dependency] private readonly SharedContainerSystem _container = default!;
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
@@ -151,6 +154,9 @@ namespace Content.Shared.ActionBlocker
|
|||||||
|
|
||||||
public bool CanAttack(EntityUid uid, EntityUid? target = null)
|
public bool CanAttack(EntityUid uid, EntityUid? target = null)
|
||||||
{
|
{
|
||||||
|
if (_container.IsEntityInContainer(uid))
|
||||||
|
return false;
|
||||||
|
|
||||||
var ev = new AttackAttemptEvent(uid, target);
|
var ev = new AttackAttemptEvent(uid, target);
|
||||||
RaiseLocalEvent(uid, ev);
|
RaiseLocalEvent(uid, ev);
|
||||||
|
|
||||||
|
|||||||
@@ -229,14 +229,14 @@ public abstract class SharedMeleeWeaponSystem : EntitySystem
|
|||||||
if (weapon.NextAttack > curTime)
|
if (weapon.NextAttack > curTime)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (!CombatMode.IsInCombatMode(user))
|
||||||
|
return;
|
||||||
|
|
||||||
if (!Blocker.CanAttack(user))
|
if (!Blocker.CanAttack(user))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Windup time checked elsewhere.
|
// Windup time checked elsewhere.
|
||||||
|
|
||||||
if (!CombatMode.IsInCombatMode(user))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (weapon.NextAttack < curTime)
|
if (weapon.NextAttack < curTime)
|
||||||
weapon.NextAttack = curTime;
|
weapon.NextAttack = curTime;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user