From fe93f2ac30e27352f57e79149818d4371dd7433f Mon Sep 17 00:00:00 2001 From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Tue, 8 Dec 2020 22:21:12 +1100 Subject: [PATCH] Fix thrown throwing (#2723) Technically some stuff could be dependent upon the entity regardless if it's deleted but this is how ICollideBehavior does it (not by my design) so I figured we'd make it consistent. If someone really needs the functionality even if it's deleted then they can refactor it. Co-authored-by: Metal Gear Sloth --- .../GameObjects/Components/Nutrition/CreamPiedComponent.cs | 2 +- .../GameObjects/EntitySystems/Click/InteractionSystem.cs | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Content.Server/GameObjects/Components/Nutrition/CreamPiedComponent.cs b/Content.Server/GameObjects/Components/Nutrition/CreamPiedComponent.cs index 917ca65617..1e1188efa9 100644 --- a/Content.Server/GameObjects/Components/Nutrition/CreamPiedComponent.cs +++ b/Content.Server/GameObjects/Components/Nutrition/CreamPiedComponent.cs @@ -52,7 +52,7 @@ namespace Content.Server.GameObjects.Components.Nutrition public void HitBy(ThrowCollideEventArgs eventArgs) { - if (!eventArgs.Thrown.TryGetComponent(out CreamPieComponent creamPie) || CreamPied) return; + if (!eventArgs.Thrown.HasComponent() || CreamPied) return; CreamPied = true; Owner.PopupMessage(Loc.GetString("You have been creamed by {0:theName}!", eventArgs.Thrown)); diff --git a/Content.Server/GameObjects/EntitySystems/Click/InteractionSystem.cs b/Content.Server/GameObjects/EntitySystems/Click/InteractionSystem.cs index c1ecd0d991..0210f5de3b 100644 --- a/Content.Server/GameObjects/EntitySystems/Click/InteractionSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/Click/InteractionSystem.cs @@ -624,11 +624,13 @@ namespace Content.Server.GameObjects.EntitySystems.Click foreach (var comp in thrown.GetAllComponents().ToArray()) { + if (thrown.Deleted) break; comp.DoHit(eventArgs); } foreach (var comp in target.GetAllComponents().ToArray()) { + if (target.Deleted) break; comp.HitBy(eventArgs); } }