Example #1
0
        /// <summary>
        /// Gets the node at the specified path from the root.
        /// </summary>
        /// <param name="stepsToNode">
        /// <para>The steps to the target tab.</para>
        /// <para>These must match the id value of the CraftNode in the crafting tree you're targeting.</para>
        /// <para>Do not include "root" in this path.</para>
        /// </param>
        /// <returns>If the specified tab node is found, returns that <see cref="ModCraftTreeNode"/>; Otherwise, returns null.</returns>
        public ModCraftTreeNode GetNode(params string[] stepsToNode)
        {
            if (stepsToNode.Length == 1)
            {
                return(base.GetNode(stepsToNode[0]));
            }

            int stepCountToTab = stepsToNode.Length - 1;

            string nodeID = stepsToNode[stepCountToTab];

            string[] stepsToTab = new string[stepCountToTab];
            Array.Copy(stepsToNode, stepsToTab, stepCountToTab);

            ModCraftTreeTab tab = GetTabNode(stepsToTab);

            return(tab?.GetNode(nodeID));
        }
Example #2
0
        /// <summary>
        /// Gets the node at the specified path from the root.
        /// </summary>
        /// <param name="stepsToNode">
        /// <para>The steps to the target tab.</para>
        /// <para>These must match the id value of the CraftNode in the crafting tree you're targeting.</para>
        /// <para>Do not include "root" in this path.</para>
        /// </param>
        /// <returns>If the specified tab node is found, returns that <see cref="ModCraftTreeNode"/>; Otherwise, returns null.</returns>
        public ModCraftTreeNode GetNode(params string[] stepsToNode)
        {
            if (stepsToNode.Length == 1)
            {
                return(base.GetNode(stepsToNode[0]));
            }

            string nodeID = stepsToNode[stepsToNode.Length - 1];

            string[]        stepsToTab = stepsToNode.Take(stepsToNode.Length - 1).ToArray();
            ModCraftTreeTab tab        = GetTabNode(stepsToTab);

            if (tab == null)
            {
                return(null);
            }

            return(tab.GetNode(nodeID));
        }