Prevent pacified players from throwing dangerous stuff (#22268)

This commit is contained in:
KP
2023-12-11 15:40:22 -08:00
committed by GitHub
parent 5143030baf
commit d0085f9428
9 changed files with 136 additions and 20 deletions

View File

@@ -1,4 +1,5 @@
using Content.Server.Damage.Components;
using Content.Shared.CombatMode.Pacification;
using Content.Shared.Damage;
using Content.Shared.Throwing;
@@ -12,6 +13,19 @@ 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.Any())
{
args.Cancel("pacified-cannot-throw");
}
}
private void DamageOnLand(EntityUid uid, DamageOnLandComponent component, ref LandEvent args)