From db6158931a470907ed06ef32cbdb48cbda252690 Mon Sep 17 00:00:00 2001 From: "J. Brown" Date: Wed, 24 Jan 2024 01:14:55 +0000 Subject: [PATCH] Fix bug with ActivelyMicrowavedComponent being stuck in powercuts (#23997) --- .../Kitchen/EntitySystems/MicrowaveSystem.cs | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/Content.Server/Kitchen/EntitySystems/MicrowaveSystem.cs b/Content.Server/Kitchen/EntitySystems/MicrowaveSystem.cs index e724a71987..b8ea32c2a6 100644 --- a/Content.Server/Kitchen/EntitySystems/MicrowaveSystem.cs +++ b/Content.Server/Kitchen/EntitySystems/MicrowaveSystem.cs @@ -110,11 +110,6 @@ namespace Content.Server.Kitchen.EntitySystems SetAppearance(ent.Owner, MicrowaveVisualState.Idle, microwaveComponent); microwaveComponent.PlayingStream = _audio.Stop(microwaveComponent.PlayingStream); - - foreach (var solid in microwaveComponent.Storage.ContainedEntities) - { - RemComp(solid); - } } private void OnEntityUnpaused(Entity ent, ref EntityUnpausedEvent args) @@ -332,7 +327,7 @@ namespace Content.Server.Kitchen.EntitySystems { ent.Comp.Broken = true; SetAppearance(ent, MicrowaveVisualState.Broken, ent.Comp); - RemComp(ent); + StopCooking(ent); _container.EmptyContainer(ent.Comp.Storage); UpdateUserInterfaceState(ent, ent.Comp); } @@ -342,7 +337,7 @@ namespace Content.Server.Kitchen.EntitySystems if (!args.Powered) { SetAppearance(ent, MicrowaveVisualState.Idle, ent.Comp); - RemComp(ent); + StopCooking(ent); } UpdateUserInterfaceState(ent, ent.Comp); } @@ -502,6 +497,15 @@ namespace Content.Server.Kitchen.EntitySystems UpdateUserInterfaceState(uid, component); } + private void StopCooking(Entity ent) + { + RemCompDeferred(ent); + foreach (var solid in ent.Comp.Storage.ContainedEntities) + { + RemCompDeferred(solid); + } + } + public static (FoodRecipePrototype, int) CanSatisfyRecipe(MicrowaveComponent component, FoodRecipePrototype recipe, Dictionary solids, Dictionary reagents) { var portions = 0; @@ -565,11 +569,6 @@ namespace Content.Server.Kitchen.EntitySystems //this means the microwave has finished cooking. AddTemperature(microwave, Math.Max(frameTime + active.CookTimeRemaining, 0)); //Though there's still a little bit more heat to pump out - foreach (var solid in microwave.Storage.ContainedEntities) - { - EntityManager.RemoveComponentDeferred(solid); - } - if (active.PortionedRecipe.Item1 != null) { var coords = Transform(uid).Coordinates; @@ -582,8 +581,8 @@ namespace Content.Server.Kitchen.EntitySystems _container.EmptyContainer(microwave.Storage); UpdateUserInterfaceState(uid, microwave); - EntityManager.RemoveComponentDeferred(uid); _audio.PlayPvs(microwave.FoodDoneSound, uid); + StopCooking((uid, microwave)); } } -- 2.51.2