From 64860b2f873724822e9a0cdf3160228ab1e969cb Mon Sep 17 00:00:00 2001 From: ReeZer2 Date: Thu, 12 Dec 2024 11:24:36 +0200 Subject: [PATCH] FIX: Multi cluster grenade --- .../Explosion/Components/ClusterGrenadeComponent.cs | 6 ++++++ .../Explosion/EntitySystems/ClusterGrenadeSystem.cs | 11 ++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Content.Server/Explosion/Components/ClusterGrenadeComponent.cs b/Content.Server/Explosion/Components/ClusterGrenadeComponent.cs index fe1b8caede7fd2..bae6c194155432 100644 --- a/Content.Server/Explosion/Components/ClusterGrenadeComponent.cs +++ b/Content.Server/Explosion/Components/ClusterGrenadeComponent.cs @@ -1,4 +1,5 @@ using Content.Server.Explosion.EntitySystems; +using Content.Shared.Whitelist; using Robust.Shared.Containers; using Robust.Shared.Prototypes; @@ -106,6 +107,11 @@ public sealed partial class ClusterGrenadeComponent : Component /// This is the end. /// public bool CountDown; + + //ss220 cluster grenade whitelist start + [DataField] + public EntityWhitelist? Whitelist; + //ss220 cluster grenade whitelist end } public enum GrenadeType diff --git a/Content.Server/Explosion/EntitySystems/ClusterGrenadeSystem.cs b/Content.Server/Explosion/EntitySystems/ClusterGrenadeSystem.cs index 78e41c59ae2ec1..8907d4485fa631 100644 --- a/Content.Server/Explosion/EntitySystems/ClusterGrenadeSystem.cs +++ b/Content.Server/Explosion/EntitySystems/ClusterGrenadeSystem.cs @@ -7,6 +7,7 @@ using Content.Server.Weapons.Ranged.Systems; using System.Numerics; using Content.Shared.Explosion.Components; +using Content.Shared.Whitelist; using Robust.Server.Containers; using Robust.Server.GameObjects; @@ -21,6 +22,7 @@ public sealed class ClusterGrenadeSystem : EntitySystem [Dependency] private readonly GunSystem _gun = default!; [Dependency] private readonly TransformSystem _transformSystem = default!; [Dependency] private readonly ContainerSystem _containerSystem = default!; + [Dependency] private readonly EntityWhitelistSystem _whitelist = default!; public override void Initialize() { @@ -53,11 +55,14 @@ private void OnClugUsing(Entity clug, ref InteractUsing var component = clug.Comp; - // TODO: Should use whitelist. - if (component.GrenadesContainer.ContainedEntities.Count >= component.MaxGrenades || - !HasComp(args.Used)) + //ss220 cluster grenade whitelist start + if (component.GrenadesContainer.ContainedEntities.Count >= component.MaxGrenades) return; + if (_whitelist.IsWhitelistFailOrNull(clug.Comp.Whitelist, args.Used)) + return; + //ss220 cluster grenade whitelist end + _containerSystem.Insert(args.Used, component.GrenadesContainer); UpdateAppearance(clug); args.Handled = true;