From 0984fe933370df6cd683cf6a5ccce779fe98f56e Mon Sep 17 00:00:00 2001 From: Spatison <137375981+Spatison@users.noreply.github.com> Date: Sun, 1 Sep 2024 21:18:54 +0300 Subject: [PATCH] fix: The thrown item is now triggered once --- Content.Shared/Throwing/ThrownItemComponent.cs | 2 ++ Content.Shared/Throwing/ThrownItemSystem.cs | 11 +++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Content.Shared/Throwing/ThrownItemComponent.cs b/Content.Shared/Throwing/ThrownItemComponent.cs index f7defaa4aa..bdb59fa681 100644 --- a/Content.Shared/Throwing/ThrownItemComponent.cs +++ b/Content.Shared/Throwing/ThrownItemComponent.cs @@ -50,5 +50,7 @@ public sealed partial class ThrownItemComponent : Component /// [DataField] public Vector2? OriginalScale = null; + + public readonly List Processed = new(); // WD EDIT } } diff --git a/Content.Shared/Throwing/ThrownItemSystem.cs b/Content.Shared/Throwing/ThrownItemSystem.cs index ef28db2672..7615b8e86c 100644 --- a/Content.Shared/Throwing/ThrownItemSystem.cs +++ b/Content.Shared/Throwing/ThrownItemSystem.cs @@ -65,7 +65,13 @@ private void HandleCollision(EntityUid uid, ThrownItemComponent component, ref S if (args.OtherEntity == component.Thrower) return; + // WD EDIT START + if (component.Processed.Contains(args.OtherEntity)) + return; + // WD EDIT END + ThrowCollideInteraction(component, args.OurEntity, args.OtherEntity); + component.Processed.Add(args.OtherEntity); // WD EDIT } private void PreventCollision(EntityUid uid, ThrownItemComponent component, ref PreventCollideEvent args) @@ -110,6 +116,7 @@ public void StopThrow(EntityUid uid, ThrownItemComponent thrownItemComponent) EntityManager.EventBus.RaiseLocalEvent(uid, new StopThrowEvent { User = thrownItemComponent.Thrower }, true); EntityManager.RemoveComponent(uid); + thrownItemComponent.Processed.Clear(); // WD EDIT } public void LandComponent(EntityUid uid, ThrownItemComponent thrownItem, PhysicsComponent physics, bool playSound) @@ -137,10 +144,10 @@ public void ThrowCollideInteraction(ThrownItemComponent component, EntityUid thr _adminLogger.Add(LogType.ThrowHit, LogImpact.Low, $"{ToPrettyString(thrown):thrown} thrown by {ToPrettyString(component.Thrower.Value):thrower} hit {ToPrettyString(target):target}."); - if (component.Thrower is not null)// Nyano - Summary: Gotta check if there was a thrower. + if (component.Thrower is not null)// Nyano - Summary: Gotta check if there was a thrower. RaiseLocalEvent(target, new ThrowHitByEvent(component.Thrower.Value, thrown, target, component), true); // Nyano - Summary: Gotta update for who threw it. else - RaiseLocalEvent(target, new ThrowHitByEvent(null, thrown, target, component), true); // Nyano - Summary: No thrower. + RaiseLocalEvent(target, new ThrowHitByEvent(null, thrown, target, component), true); // Nyano - Summary: No thrower. RaiseLocalEvent(thrown, new ThrowDoHitEvent(thrown, target, component), true); }