Add CanAttack to IActionBlocker, prevent using guns when dead (#769)
This commit is contained in:
committed by
GitHub
parent
5e2cac78ac
commit
d1ff84e95d
@@ -72,6 +72,11 @@ namespace Content.Server.GameObjects
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IActionBlocker.CanAttack()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -128,6 +133,11 @@ namespace Content.Server.GameObjects
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IActionBlocker.CanAttack()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -204,5 +214,10 @@ namespace Content.Server.GameObjects
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IActionBlocker.CanAttack()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -117,6 +117,11 @@ namespace Content.Server.GameObjects
|
|||||||
return CurrentDamageState.CanEmote();
|
return CurrentDamageState.CanEmote();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IActionBlocker.CanAttack()
|
||||||
|
{
|
||||||
|
return CurrentDamageState.CanAttack();
|
||||||
|
}
|
||||||
|
|
||||||
List<DamageThreshold> IOnDamageBehavior.GetAllDamageThresholds()
|
List<DamageThreshold> IOnDamageBehavior.GetAllDamageThresholds()
|
||||||
{
|
{
|
||||||
var thresholdlist = DamageTemplate.DamageThresholds;
|
var thresholdlist = DamageTemplate.DamageThresholds;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using Content.Server.GameObjects.Components.Mobs;
|
using Content.Server.GameObjects.Components.Mobs;
|
||||||
|
using Content.Server.GameObjects.EntitySystems;
|
||||||
using Content.Shared.GameObjects.Components.Weapons.Ranged;
|
using Content.Shared.GameObjects.Components.Weapons.Ranged;
|
||||||
using Robust.Server.Interfaces.Player;
|
using Robust.Server.Interfaces.Player;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
@@ -30,7 +31,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged
|
|||||||
|
|
||||||
private bool UserCanFire(IEntity user)
|
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)
|
private void Fire(IEntity user, GridCoordinates clickLocation)
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ namespace Content.Server.GameObjects.EntitySystems
|
|||||||
bool CanPickup();
|
bool CanPickup();
|
||||||
|
|
||||||
bool CanEmote();
|
bool CanEmote();
|
||||||
|
|
||||||
|
bool CanAttack();
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ActionBlockerSystem : EntitySystem
|
public class ActionBlockerSystem : EntitySystem
|
||||||
@@ -105,5 +107,17 @@ namespace Content.Server.GameObjects.EntitySystems
|
|||||||
|
|
||||||
return canemote;
|
return canemote;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool CanAttack(IEntity entity)
|
||||||
|
{
|
||||||
|
bool canattack = true;
|
||||||
|
|
||||||
|
foreach (var actionblockercomponents in entity.GetAllComponents<IActionBlocker>())
|
||||||
|
{
|
||||||
|
canattack &= actionblockercomponents.CanAttack();
|
||||||
|
}
|
||||||
|
|
||||||
|
return canattack;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -853,7 +853,7 @@ namespace Content.Server.GameObjects.EntitySystems
|
|||||||
var item = hands.GetActiveHand?.Owner;
|
var item = hands.GetActiveHand?.Owner;
|
||||||
|
|
||||||
// TODO: If item is null we need some kinda unarmed combat.
|
// TODO: If item is null we need some kinda unarmed combat.
|
||||||
if (!ActionBlockerSystem.CanInteract(player) || item == null)
|
if (!ActionBlockerSystem.CanAttack(player) || item == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user