Example #1
0
        /// <summary>
        /// Safely adds a new crafting node to the custom crafting tree of this fabricator.<para/>
        /// If the item has not been patched yet, its <see cref="Spawnable.Patch"/> method will first be invoked.
        /// </summary>
        /// <param name="item">The <see cref="Craftable"/> item to craft from this fabricator.</param>
        /// <param name="parentTabId">Optional. The parent tab of this craft node.<para/>
        /// When this value is null, the item's <see cref="Craftable.StepsToFabricatorTab"/> property will be checked instead.<para/>
        /// The craft node will be added to the root of the craft tree if both are null.</param>
        public void AddCraftNode(Craftable item, string parentTabId = null)
        {
            Logger.Debug($"'{item.ClassID}' will be added to the custom craft tree '{this.ClassID}'");
            OrderedCraftTreeActions.Add(() =>
            {
                if (item.TechType == TechType.None)
                {
                    Logger.Info($"'{item.ClassID} had to be patched early to obtain its TechType value for the custom craft tree '{this.ClassID}'");
                    item.Patch();
                }

                string[] stepsToParent = item.StepsToFabricatorTab;

                if (parentTabId == null)
                {
                    if (stepsToParent != null && stepsToParent.Length > 0)
                    {
                        int last    = stepsToParent.Length - 1;
                        parentTabId = stepsToParent[last];
                    }
                    else
                    {
                        parentTabId = RootNode;
                    }
                }

                ModCraftTreeLinkingNode parentTab = CraftTreeLinkingNodes[parentTabId];
                parentTab.AddCraftingNode(item.TechType);
            });
        }
Example #2
0
        public static void OverrideDefaults()
        {
            LanguageHandler.SetTechTypeTooltip(TI_1, "1 Titanium");
            LanguageHandler.SetTechTypeTooltip(TI_10, "10 Titanium");

            CraftTreeHandler.RemoveNode(CraftTree.Type.Fabricator, "Resources", "BasicMaterials", "TitaniumIngot");
            CompressTab.AddCraftingNode(TI_10);

            TechType TI_10_Decompress          = TechTypeHandler.AddTechType("titaniumIngotDecompress", "Titanium", "1 Titanium", TI_1_Sprite);
            TechData TI_10_Decompress_TechData = new TechData(new Ingredient(TI_10, 1))
            {
                craftAmount = 0, LinkedItems = TI_1.Repeat(10)
            };

            CraftDataHandler.SetTechData(TI_10_Decompress, TI_10_Decompress_TechData);
            DecompressTab?.AddCraftingNode(TI_10_Decompress);
        }
Example #3
0
 /// <summary>
 /// Adds a new crafting node to the custom crafting tree of this fabricator.
 /// </summary>
 /// <param name="techType">The item to craft.</param>
 /// <param name="parentTabId">Optional. The parent tab of this craft node.<para/>
 /// When this value is null, the craft node will be added to the root of the craft tree.</param>
 public void AddCraftNode(TechType techType, string parentTabId = null)
 {
     Logger.Debug($"'{techType.AsString()}' will be added to the custom craft tree '{this.ClassID}'");
     OrderedCraftTreeActions.Add(() =>
     {
         ModCraftTreeLinkingNode parentTab = CraftTreeLinkingNodes[parentTabId ?? RootNode];
         parentTab.AddCraftingNode(techType);
     });
 }
Example #4
0
 /// <summary>
 /// Safely attempts to add a new crafting node to the custom crafting tree of this fabricator.<para/>
 /// If the modded TechType is not found, the craft node will not be added.
 /// </summary>
 /// <param name="moddedTechType">The modded item to craft.</param>
 /// <param name="parentTabId">Optional. The parent tab of this craft node.<para/>
 /// When this value is null, the craft node will be added to the root of the craft tree.</param>
 public void AddCraftNode(string moddedTechType, string parentTabId = null)
 {
     Logger.Debug($"'{moddedTechType}' will be added to the custom craft tree '{this.ClassID}'");
     OrderedCraftTreeActions.Add(() =>
     {
         if (this.TechTypeHandler.TryGetModdedTechType(moddedTechType, out TechType techType))
         {
             ModCraftTreeLinkingNode parentTab = CraftTreeLinkingNodes[parentTabId ?? RootNode];
             parentTab.AddCraftingNode(techType);
         }
         else
         {
             Logger.Info($"Did not find a TechType value for '{moddedTechType}' to add to the custom craft tree '{this.ClassID}'");
         }
     });
 }
Example #5
0
 protected void addCraftingNodeTo(ModCraftTreeLinkingNode modCraftTreeNode) =>
 modCraftTreeNode.AddCraftingNode(TechType);