コード例 #1
0
        internal static void ModifyRecipe(IModifiedRecipe modifiedRecipe)
        {
            Assert.IsTrue(modifiedRecipe.ItemID <= TechType.Databox, "This API in intended only for use with standard, non-modded TechTypes.");

            HandleModifiedRecipe(modifiedRecipe);

            HandleUnlocks(modifiedRecipe);
        }
コード例 #2
0
        private static void HandleUnlocks(IModifiedRecipe modifiedRecipe)
        {
            if (modifiedRecipe.ForceUnlockAtStart)
            {
                KnownTechHandler.UnlockOnStart(modifiedRecipe.ItemID);
            }

            if (modifiedRecipe.UnlocksCount.HasValue)
            {
                KnownTechHandler.SetAnalysisTechEntry(modifiedRecipe.ItemID, modifiedRecipe.Unlocks);
            }
        }
コード例 #3
0
        private static void HandleModifiedRecipe(IModifiedRecipe modifiedRecipe)
        {
            bool overrideRecipe = false;

            ITechData original = CraftData.Get(modifiedRecipe.ItemID);

            var replacement = new TechData();

            // Amount
            if (modifiedRecipe.AmountCrafted.HasValue)
            {
                overrideRecipe         |= true;
                replacement.craftAmount = modifiedRecipe.AmountCrafted.Value;
            }
            else
            {
                replacement.craftAmount = original.craftAmount;
            }

            // Ingredients
            if (modifiedRecipe.IngredientsCount.HasValue)
            {
                overrideRecipe |= true;
                foreach (EmIngredient ingredient in modifiedRecipe.Ingredients)
                {
                    replacement.Ingredients.Add(
                        new Ingredient(
                            ingredient.ItemID,
                            ingredient.Required));
                }
            }
            else
            {
                for (int i = 0; i < original.ingredientCount; i++)
                {
                    replacement.Ingredients.Add(
                        new Ingredient(
                            original.GetIngredient(i).techType,
                            original.GetIngredient(i).amount));
                }
            }

            // Linked Items
            if (modifiedRecipe.LinkedItemsCount.HasValue)
            {
                overrideRecipe |= true;
                foreach (TechType linkedItem in modifiedRecipe.LinkedItems)
                {
                    replacement.LinkedItems.Add(linkedItem);
                }
            }
            else
            {
                for (int i = 0; i < original.linkedItemCount; i++)
                {
                    replacement.LinkedItems.Add(original.GetLinkedItem(i));
                }
            }

            if (overrideRecipe)
            {
                CraftDataHandler.SetTechData(modifiedRecipe.ItemID, replacement);
            }
        }