From 75615d63744c25d81c64800fcbf6b34c817f4659 Mon Sep 17 00:00:00 2001 From: MrMatsay <142046219+MrMatsay@users.noreply.github.com> Date: Thu, 14 Sep 2023 04:19:20 +0200 Subject: [PATCH] Update ingredient transfert --- Source/ProcessorFramework/CompProcessor.cs | 23 +++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/Source/ProcessorFramework/CompProcessor.cs b/Source/ProcessorFramework/CompProcessor.cs index 65790b5..46621d7 100644 --- a/Source/ProcessorFramework/CompProcessor.cs +++ b/Source/ProcessorFramework/CompProcessor.cs @@ -488,7 +488,7 @@ public Thing TakeOutProduct(ActiveProcess activeProcess) thing.stackCount = GenMath.RoundRandom(activeProcess.ingredientCount * activeProcess.processDef.efficiency); //Ingredient transfer - CompIngredients compIngredients = thing.TryGetComp(); + /* CompIngredients compIngredients = thing.TryGetComp(); List ingredientList = new List(); foreach (Thing ingredientThing in activeProcess.ingredientThings) { @@ -501,6 +501,27 @@ public Thing TakeOutProduct(ActiveProcess activeProcess) if (compIngredients != null && !ingredientList.NullOrEmpty()) { compIngredients.ingredients.AddRange(ingredientList); + } */ + + if (thing.TryGetComp() is CompIngredients compIngredients) + { + List ingredientList = new List(); + foreach (Thing ingredientThing in activeProcess.ingredientThings) + { + List innerIngredients = ingredientThing.TryGetComp()?.ingredients; + if (!innerIngredients.NullOrEmpty()) + { + ingredientList.AddRange(innerIngredients); + } + else + { + compIngredients.RegisterIngredient(ingredientThing.def); + } + } + if (compIngredients != null && !ingredientList.NullOrEmpty()) + { + compIngredients.ingredients.AddRange(ingredientList); + } } //Quality