diff --git a/Content.Server/GameObjects/Components/Mobs/DamageStates.cs b/Content.Server/GameObjects/Components/Mobs/DamageStates.cs index ed17681720..515cf77e60 100644 --- a/Content.Server/GameObjects/Components/Mobs/DamageStates.cs +++ b/Content.Server/GameObjects/Components/Mobs/DamageStates.cs @@ -72,6 +72,11 @@ namespace Content.Server.GameObjects { return true; } + + bool IActionBlocker.CanAttack() + { + return true; + } } /// @@ -128,6 +133,11 @@ namespace Content.Server.GameObjects { return false; } + + bool IActionBlocker.CanAttack() + { + return false; + } } /// @@ -204,5 +214,10 @@ namespace Content.Server.GameObjects { return false; } + + bool IActionBlocker.CanAttack() + { + return false; + } } } diff --git a/Content.Server/GameObjects/Components/Mobs/SpeciesComponent.cs b/Content.Server/GameObjects/Components/Mobs/SpeciesComponent.cs index 084af3a3e7..f3952cb92d 100644 --- a/Content.Server/GameObjects/Components/Mobs/SpeciesComponent.cs +++ b/Content.Server/GameObjects/Components/Mobs/SpeciesComponent.cs @@ -117,6 +117,11 @@ namespace Content.Server.GameObjects return CurrentDamageState.CanEmote(); } + bool IActionBlocker.CanAttack() + { + return CurrentDamageState.CanAttack(); + } + List IOnDamageBehavior.GetAllDamageThresholds() { var thresholdlist = DamageTemplate.DamageThresholds; diff --git a/Content.Server/GameObjects/Components/Weapon/Ranged/RangedWeapon.cs b/Content.Server/GameObjects/Components/Weapon/Ranged/RangedWeapon.cs index 6b0d17dfe6..0417729934 100644 --- a/Content.Server/GameObjects/Components/Weapon/Ranged/RangedWeapon.cs +++ b/Content.Server/GameObjects/Components/Weapon/Ranged/RangedWeapon.cs @@ -1,5 +1,6 @@ using System; using Content.Server.GameObjects.Components.Mobs; +using Content.Server.GameObjects.EntitySystems; using Content.Shared.GameObjects.Components.Weapons.Ranged; using Robust.Server.Interfaces.Player; using Robust.Shared.GameObjects; @@ -30,7 +31,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged private bool UserCanFire(IEntity user) { - return UserCanFireHandler == null || UserCanFireHandler(user); + return (UserCanFireHandler == null || UserCanFireHandler(user)) && ActionBlockerSystem.CanAttack(user); } private void Fire(IEntity user, GridCoordinates clickLocation) diff --git a/Content.Server/GameObjects/EntitySystems/ActionBlockerSystem.cs b/Content.Server/GameObjects/EntitySystems/ActionBlockerSystem.cs index d653568e5a..ce3205bb01 100644 --- a/Content.Server/GameObjects/EntitySystems/ActionBlockerSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/ActionBlockerSystem.cs @@ -20,6 +20,8 @@ namespace Content.Server.GameObjects.EntitySystems bool CanPickup(); bool CanEmote(); + + bool CanAttack(); } public class ActionBlockerSystem : EntitySystem @@ -105,5 +107,17 @@ namespace Content.Server.GameObjects.EntitySystems return canemote; } + + public static bool CanAttack(IEntity entity) + { + bool canattack = true; + + foreach (var actionblockercomponents in entity.GetAllComponents()) + { + canattack &= actionblockercomponents.CanAttack(); + } + + return canattack; + } } } diff --git a/Content.Server/GameObjects/EntitySystems/Click/InteractionSystem.cs b/Content.Server/GameObjects/EntitySystems/Click/InteractionSystem.cs index 6ed819e814..e30d961669 100644 --- a/Content.Server/GameObjects/EntitySystems/Click/InteractionSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/Click/InteractionSystem.cs @@ -853,7 +853,7 @@ namespace Content.Server.GameObjects.EntitySystems var item = hands.GetActiveHand?.Owner; // TODO: If item is null we need some kinda unarmed combat. - if (!ActionBlockerSystem.CanInteract(player) || item == null) + if (!ActionBlockerSystem.CanAttack(player) || item == null) { return; }