Allows pacifists to throw Items with DamageOnLand (#31060)

This commit is contained in:
IProduceWidgets
2025-02-09 20:24:10 -05:00
committed by GitHub
parent 2e2a3a9cb1
commit fe064adaec
2 changed files with 9 additions and 14 deletions

View File

@@ -1,10 +1,12 @@
using Content.Server.Damage.Components;
using Content.Shared.CombatMode.Pacification;
using Content.Shared.Damage;
using Content.Shared.Throwing;
namespace Content.Server.Damage.Systems
{
/// <summary>
/// Damages the thrown item when it lands.
/// </summary>
public sealed class DamageOnLandSystem : EntitySystem
{
[Dependency] private readonly DamageableSystem _damageableSystem = default!;
@@ -13,19 +15,6 @@ namespace Content.Server.Damage.Systems
{
base.Initialize();
SubscribeLocalEvent<DamageOnLandComponent, LandEvent>(DamageOnLand);
SubscribeLocalEvent<DamageOnLandComponent, AttemptPacifiedThrowEvent>(OnAttemptPacifiedThrow);
}
/// <summary>
/// Prevent Pacified entities from throwing damaging items.
/// </summary>
private void OnAttemptPacifiedThrow(Entity<DamageOnLandComponent> ent, ref AttemptPacifiedThrowEvent args)
{
// Allow healing projectiles, forbid any that do damage:
if (ent.Comp.Damage.AnyPositive())
{
args.Cancel("pacified-cannot-throw");
}
}
private void DamageOnLand(EntityUid uid, DamageOnLandComponent component, ref LandEvent args)