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,11 +1,10 @@
using System.Numerics;
using Content.Shared.CombatMode.Pacification;
using Content.Shared.Damage;
using Content.Shared.DoAfter;
using Content.Shared.Hands.EntitySystems;
using Content.Shared.Interaction;
using Content.Shared.Throwing;
using Content.Shared.Weapons.Ranged.Components;
using Robust.Shared.Audio;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Map;
using Robust.Shared.Network;
@@ -37,6 +36,7 @@ public abstract partial class SharedProjectileSystem : EntitySystem
SubscribeLocalEvent<EmbeddableProjectileComponent, ThrowDoHitEvent>(OnEmbedThrowDoHit);
SubscribeLocalEvent<EmbeddableProjectileComponent, ActivateInWorldEvent>(OnEmbedActivate);
SubscribeLocalEvent<EmbeddableProjectileComponent, RemoveEmbeddedProjectileEvent>(OnEmbedRemove);
SubscribeLocalEvent<EmbeddableProjectileComponent, AttemptPacifiedThrowEvent>(OnAttemptPacifiedThrow);
}
private void OnEmbedActivate(EntityUid uid, EmbeddableProjectileComponent component, ActivateInWorldEvent args)
@@ -152,6 +152,14 @@ public abstract partial class SharedProjectileSystem : EntitySystem
{
public override DoAfterEvent Clone() => this;
}
/// <summary>
/// Prevent players with the Pacified status effect from throwing embeddable projectiles.
/// </summary>
private void OnAttemptPacifiedThrow(Entity<EmbeddableProjectileComponent> ent, ref AttemptPacifiedThrowEvent args)
{
args.Cancel("pacified-cannot-throw-embed");
}
}
[Serializable, NetSerializable]