]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Microwave recipes now uses stacktype id instead of entity prototype id for stacked...
authorblueDev2 <89804215+blueDev2@users.noreply.github.com>
Tue, 4 Jun 2024 17:12:01 +0000 (13:12 -0400)
committerGitHub <noreply@github.com>
Tue, 4 Jun 2024 17:12:01 +0000 (13:12 -0400)
Content.Server/Kitchen/EntitySystems/MicrowaveSystem.cs
Resources/Prototypes/Recipes/Cooking/medical_recipes.yml

index 8938aa8b1dc420bd879595a65c715e175475cafa..c69ed49d50a67c8868ab56979adf505c72d06818 100644 (file)
@@ -35,6 +35,7 @@ using Robust.Shared.Player;
 using System.Linq;
 using Robust.Shared.Prototypes;
 using Robust.Shared.Timing;
+using Content.Shared.Stacks;
 
 namespace Content.Server.Kitchen.EntitySystems
 {
@@ -58,6 +59,8 @@ namespace Content.Server.Kitchen.EntitySystems
         [Dependency] private readonly UserInterfaceSystem _userInterface = default!;
         [Dependency] private readonly HandsSystem _handsSystem = default!;
         [Dependency] private readonly SharedItemSystem _item = default!;
+        [Dependency] private readonly SharedStackSystem _stack = default!;
+        [Dependency] private readonly IPrototypeManager _prototype = default!;
 
         [ValidatePrototypeId<EntityPrototype>]
         private const string MalfunctionSpark = "Spark";
@@ -199,16 +202,41 @@ namespace Content.Server.Kitchen.EntitySystems
                 {
                     foreach (var item in component.Storage.ContainedEntities)
                     {
-                        var metaData = MetaData(item);
-                        if (metaData.EntityPrototype == null)
+                        string? itemID = null;
+
+                        // If an entity has a stack component, use the stacktype instead of prototype id
+                        if (TryComp<StackComponent>(item, out var stackComp))
+                        {
+                            itemID = _prototype.Index<StackPrototype>(stackComp.StackTypeId).Spawn;
+                        }
+                        else
+                        {
+                            var metaData = MetaData(item);
+                            if (metaData.EntityPrototype == null)
+                            {
+                                continue;
+                            }
+                            itemID = metaData.EntityPrototype.ID;
+                        }
+
+                        if (itemID != recipeSolid.Key)
                         {
                             continue;
                         }
 
-                        if (metaData.EntityPrototype.ID == recipeSolid.Key)
+                        if (stackComp is not null)
+                        {
+                            if (stackComp.Count == 1)
+                            {
+                                _container.Remove(item, component.Storage);
+                            }
+                            _stack.Use(item, 1, stackComp);
+                            break;
+                        }
+                        else
                         {
                             _container.Remove(item, component.Storage);
-                            EntityManager.DeleteEntity(item);
+                            Del(item);
                             break;
                         }
                     }
@@ -448,17 +476,35 @@ namespace Content.Server.Kitchen.EntitySystems
 
                 AddComp<ActivelyMicrowavedComponent>(item);
 
-                var metaData = MetaData(item); //this simply begs for cooking refactor
-                if (metaData.EntityPrototype == null)
+                string? solidID = null;
+                int amountToAdd = 1;
+
+                // If a microwave recipe uses a stacked item, use the default stack prototype id instead of prototype id
+                if (TryComp<StackComponent>(item, out var stackComp))
+                {
+                    solidID = _prototype.Index<StackPrototype>(stackComp.StackTypeId).Spawn;
+                    amountToAdd = stackComp.Count;
+                }
+                else
+                {
+                    var metaData = MetaData(item); //this simply begs for cooking refactor
+                    if (metaData.EntityPrototype is not null)
+                        solidID = metaData.EntityPrototype.ID;
+                }
+
+                if (solidID is null)
+                {
                     continue;
+                }
+
 
-                if (solidsDict.ContainsKey(metaData.EntityPrototype.ID))
+                if (solidsDict.ContainsKey(solidID))
                 {
-                    solidsDict[metaData.EntityPrototype.ID]++;
+                    solidsDict[solidID] += amountToAdd;
                 }
                 else
                 {
-                    solidsDict.Add(metaData.EntityPrototype.ID, 1);
+                    solidsDict.Add(solidID, amountToAdd);
                 }
 
                 if (!TryComp<SolutionContainerManagerComponent>(item, out var solMan))
index 9d1947f03ebc1ce6d87e647259b16fd9f6b68f46..3bc9e22b0e4fa897dbe10b9c3fef85b2aab023ca 100644 (file)
@@ -13,7 +13,7 @@
   time: 10
   solids:
     FoodPoppy: 1
-    Brutepack: 1
+    Brutepack: 10
     MaterialCloth1: 1
   reagents:
     TranexamicAcid: 20
@@ -26,7 +26,7 @@
   time: 10
   solids:
     FoodAloe: 1
-    Ointment: 1
+    Ointment: 10
     MaterialCloth1: 1
   reagents:
     Sigynate: 20