From: Tayrtahn Date: Thu, 8 May 2025 07:55:41 +0000 (-0400) Subject: Fix debug asserts in WoolySystem and UdderSystem (#35314) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=4aa635620c867bf2d52f288feec771050496289e;p=space-station-14.git Fix debug asserts in WoolySystem and UdderSystem (#35314) --- diff --git a/Content.Shared/Animals/UdderSystem.cs b/Content.Shared/Animals/UdderSystem.cs index 177fbab2f2..90cc717321 100644 --- a/Content.Shared/Animals/UdderSystem.cs +++ b/Content.Shared/Animals/UdderSystem.cs @@ -8,6 +8,7 @@ using Content.Shared.Nutrition.EntitySystems; using Content.Shared.Popups; using Content.Shared.Udder; using Content.Shared.Verbs; +using Robust.Shared.Containers; using Robust.Shared.Timing; namespace Content.Shared.Animals; @@ -31,6 +32,7 @@ public sealed class UdderSystem : EntitySystem SubscribeLocalEvent(OnMapInit); SubscribeLocalEvent>(AddMilkVerb); SubscribeLocalEvent(OnDoAfter); + SubscribeLocalEvent(OnEntRemoved); } private void OnMapInit(EntityUid uid, UdderComponent component, MapInitEvent args) @@ -38,6 +40,16 @@ public sealed class UdderSystem : EntitySystem component.NextGrowth = _timing.CurTime + component.GrowthDelay; } + private void OnEntRemoved(Entity entity, ref EntRemovedFromContainerMessage args) + { + // Make sure the removed entity was our contained solution + if (entity.Comp.Solution == null || args.Entity != entity.Comp.Solution.Value.Owner) + return; + + // Cleared our cached reference to the solution entity + entity.Comp.Solution = null; + } + public override void Update(float frameTime) { base.Update(frameTime); diff --git a/Content.Shared/Animals/WoolySystem.cs b/Content.Shared/Animals/WoolySystem.cs index b7e0f52982..172e3b56e1 100644 --- a/Content.Shared/Animals/WoolySystem.cs +++ b/Content.Shared/Animals/WoolySystem.cs @@ -3,6 +3,7 @@ using Content.Shared.Mobs.Systems; using Content.Shared.Nutrition; using Content.Shared.Nutrition.Components; using Content.Shared.Nutrition.EntitySystems; +using Robust.Shared.Containers; using Robust.Shared.Timing; namespace Content.Shared.Animals; @@ -24,6 +25,7 @@ public sealed class WoolySystem : EntitySystem SubscribeLocalEvent(OnBeforeFullyEaten); SubscribeLocalEvent(OnMapInit); + SubscribeLocalEvent(OnEntRemoved); } private void OnMapInit(EntityUid uid, WoolyComponent component, MapInitEvent args) @@ -31,6 +33,16 @@ public sealed class WoolySystem : EntitySystem component.NextGrowth = _timing.CurTime + component.GrowthDelay; } + private void OnEntRemoved(Entity entity, ref EntRemovedFromContainerMessage args) + { + // Make sure the removed entity was our contained solution + if (entity.Comp.Solution == null || args.Entity != entity.Comp.Solution.Value.Owner) + return; + + // Clear our cached reference to the solution entity + entity.Comp.Solution = null; + } + public override void Update(float frameTime) { base.Update(frameTime);