]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix bug with ActivelyMicrowavedComponent being stuck in powercuts (#23997)
authorJ. Brown <DrMelon@users.noreply.github.com>
Wed, 24 Jan 2024 01:14:55 +0000 (01:14 +0000)
committerGitHub <noreply@github.com>
Wed, 24 Jan 2024 01:14:55 +0000 (21:14 -0400)
Content.Server/Kitchen/EntitySystems/MicrowaveSystem.cs

index e724a71987a215147760a16b9ebca93afaa1345c..b8ea32c2a6fe51592c6031dbf372e03a4dd687fe 100644 (file)
@@ -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<ActivelyMicrowavedComponent>(solid);
-            }
         }
 
         private void OnEntityUnpaused(Entity<ActiveMicrowaveComponent> ent, ref EntityUnpausedEvent args)
@@ -332,7 +327,7 @@ namespace Content.Server.Kitchen.EntitySystems
         {
             ent.Comp.Broken = true;
             SetAppearance(ent, MicrowaveVisualState.Broken, ent.Comp);
-            RemComp<ActiveMicrowaveComponent>(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<ActiveMicrowaveComponent>(ent);
+                StopCooking(ent);
             }
             UpdateUserInterfaceState(ent, ent.Comp);
         }
@@ -502,6 +497,15 @@ namespace Content.Server.Kitchen.EntitySystems
             UpdateUserInterfaceState(uid, component);
         }
 
+        private void StopCooking(Entity<MicrowaveComponent> ent)
+        {
+            RemCompDeferred<ActiveMicrowaveComponent>(ent);
+            foreach (var solid in ent.Comp.Storage.ContainedEntities)
+            {
+                RemCompDeferred<ActivelyMicrowavedComponent>(solid);
+            }
+        }
+
         public static (FoodRecipePrototype, int) CanSatisfyRecipe(MicrowaveComponent component, FoodRecipePrototype recipe, Dictionary<string, int> solids, Dictionary<string, FixedPoint2> 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<ActivelyMicrowavedComponent>(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<ActiveMicrowaveComponent>(uid);
                 _audio.PlayPvs(microwave.FoodDoneSound, uid);
+                StopCooking((uid, microwave));
             }
         }