예제 #1
0
        private static void PatchNodes(ref CraftNode nodes, List <CustomCraftNode> customNodes, CraftScheme scheme)
        {
            foreach (var customNode in customNodes)
            {
                if (customNode.Scheme != scheme)
                {
                    continue;
                }

                var path        = customNode.Path.SplitByChar('/');
                var currentNode = default(TreeNode);
                currentNode = nodes;

                for (int i = 0; i < path.Length; i++)
                {
                    var currentPath = path[i];
                    if (i == (path.Length - 1))
                    {
                        break;
                    }

                    currentNode = currentNode[currentPath];
                }

                currentNode.AddNode(new TreeNode[]
                {
                    new CraftNode(path[path.Length - 1], TreeAction.Craft, customNode.TechType)
                });
            }
        }
예제 #2
0
        private static void AddCustomTabs(ref CraftNode nodes, List <CustomCraftTab> customTabs, CraftScheme scheme)
        {
            foreach (var tab in customTabs)
            {
                if (tab.Scheme != scheme)
                {
                    continue;
                }

                var path        = tab.Path.SplitByChar('/');
                var currentNode = default(TreeNode);
                currentNode = nodes;

                for (int i = 0; i < path.Length; i++)
                {
                    var currentPath = path[i];

                    var node = currentNode[currentPath];
                    if (node == null)
                    {
                        var newNode = new CraftNode(currentPath, TreeAction.Expand, TechType.None);
                        currentNode.AddNode(new TreeNode[]
                        {
                            newNode
                        });

                        node = newNode;
                    }

                    currentNode = node;
                }
            }
        }
예제 #3
0
        public static void Postfix(ref CraftNode __result)
        {
            foreach (var craftNode2 in customCraftNodes)
            {
                var path = craftNode2.Key.SplitByChar('/');

                var currentNode = default(TreeNode);
                currentNode = __result;

                for (int i = 0; i < path.Length; i++)
                {
                    var currentPath = path[i];
                    if (i == (path.Length - 1))
                    {
                        break;
                    }

                    currentNode = currentNode[currentPath];
                }

                currentNode.AddNode(new TreeNode[]
                {
                    new CraftNode(path[path.Length - 1], TreeAction.Craft, craftNode2.Value)
                });
            }
        }
        private CraftTree CreateCraftingTree()
        {
            if (craftTree == null)
            {
                Dictionary <string, string>       langLines = Language.main.strings;
                Dictionary <string, Atlas.Sprite> group     = SpriteManager.groups[SpriteManager.Group.Category];
                Dictionary <string, Atlas.Sprite> atlas     = Atlas.GetAtlas("Categories").nameToSprite;

                CraftNode fab = CraftTree.FabricatorScheme();
                CloneTabDetails(FabricatorScheme, fab, ref langLines, ref group, ref atlas);

                CraftNode wb = CraftTree.WorkbenchScheme();
                CloneTabDetails(WorkBenchScheme, wb, ref langLines, ref group, ref atlas);

                CraftNode su = CraftTree.SeamothUpgradesScheme();
                CloneTabDetails(SeamothUpgradesScheme, su, ref langLines, ref group, ref atlas);

                CraftNode map = CraftTree.MapRoomSheme();
                CloneTabDetails(MapRoomScheme, map, ref langLines, ref group, ref atlas);

                CraftNode cy = CraftTree.CyclopsFabricatorScheme();
                CloneTabDetails(CyclopsFabScheme, cy, ref langLines, ref group, ref atlas);

                CraftNode aioRoot = new CraftNode("Root").AddNode(fab, wb, su, map, cy);

                Type smlCTPatcher = typeof(CraftTreeHandler).Assembly.GetType("SMLHelper.V2.Patchers.CraftTreePatcher");
                var  customTrees  = (Dictionary <CraftTree.Type, ModCraftTreeRoot>)smlCTPatcher.GetField("CustomTrees", BindingFlags.NonPublic | BindingFlags.Static).GetValue(null);
                foreach (KeyValuePair <CraftTree.Type, ModCraftTreeRoot> entry in customTrees)
                {
                    if (entry.Key == this.TreeTypeID)
                    {
                        continue;
                    }

                    CraftTree tree   = entry.Value.CraftTreeCreation.Invoke();
                    CraftNode root   = tree.nodes;
                    string    scheme = entry.Key.ToString();

                    CloneTabDetails(scheme, root, ref langLines, ref group, ref atlas);
                    CloneTopLevelModTab(scheme, ref langLines, ref group);
                    aioRoot.AddNode(root);
                }

                craftTree = new CraftTree(AioFabScheme, aioRoot);
            }

            return(craftTree);
        }
예제 #5
0
        private static void AddCustomTabs(ref CraftNode nodes, List <TabNode> customTabs, CraftTree.Type scheme)
        {
            foreach (TabNode tab in customTabs)
            {
                // Wrong crafter, skip.
                if (tab.Scheme != scheme)
                {
                    continue;
                }

                TreeNode currentNode = default;
                currentNode = nodes;

                // Patch into game's CraftTree.
                for (int i = 0; i < tab.Path.Length; i++)
                {
                    string currentPath = tab.Path[i];
                    Logger.Log("Tab Current Path: " + currentPath + " Tab: " + tab.Name + " Crafter: " + tab.Scheme.ToString(), LogLevel.Debug);

                    TreeNode node = currentNode[currentPath];

                    // Reached the end of the line.
                    if (node != null)
                    {
                        currentNode = node;
                    }
                    else
                    {
                        break;
                    }
                }

                // Add the new tab node.
                var newNode = new CraftNode(tab.Name, TreeAction.Expand, TechType.None);
                currentNode.AddNode(new TreeNode[]
                {
                    newNode
                });
            }
        }
예제 #6
0
        private static void PatchNodes(ref CraftNode nodes, List <CraftingNode> customNodes, CraftTree.Type scheme)
        {
            foreach (CraftingNode customNode in customNodes)
            {
                // Wrong crafter, just skip the node.
                if (customNode.Scheme != scheme)
                {
                    continue;
                }

                // Have to do this to make sure C# shuts up.
                TreeNode node = default;
                node = nodes;

                // Loop through the path provided by the node.
                // Get the node for the last path.
                for (int i = 0; i < customNode.Path.Length; i++)
                {
                    string   currentPath = customNode.Path[i];
                    TreeNode currentNode = node[currentPath];

                    if (currentNode != null)
                    {
                        node = currentNode;
                    }
                    else
                    {
                        break;
                    }
                }

                // Add the node.
                node.AddNode(new TreeNode[]
                {
                    new CraftNode(customNode.TechType.AsString(false), TreeAction.Craft, customNode.TechType)
                });
            }
        }
예제 #7
0
        private CraftTree CreateCraftingTree()
        {
            if (craftTree == null)
            {
                Dictionary <string, string> langLines = Language.main.strings;

                var atlasName = SpriteManager.mapping[SpriteManager.Group.Category];
#if SUBNAUTICA
                var group = Atlas.GetAtlas(atlasName).nameToSprite;
#elif BELOWZERO
                var group = SpriteManager.atlases[atlasName];
#endif
                List <CraftNode> craftNodes = new List <CraftNode>();

                CraftNode fab = CraftTree.FabricatorScheme();
                CloneTabDetails(FabricatorScheme, fab, ref langLines, ref group);
                craftNodes.Add(fab);

                CraftNode wb = CraftTree.WorkbenchScheme();
                CloneTabDetails(WorkBenchScheme, wb, ref langLines, ref group);
                craftNodes.Add(wb);

                CraftNode su = CraftTree.SeamothUpgradesScheme();
                CloneTabDetails(SeamothUpgradesScheme, su, ref langLines, ref group);
                craftNodes.Add(su);

                CraftNode map = CraftTree.MapRoomSheme();
                CloneTabDetails(MapRoomScheme, map, ref langLines, ref group);
                craftNodes.Add(map);
#if SUBNAUTICA
                CraftNode cy = CraftTree.CyclopsFabricatorScheme();
                CloneTabDetails(CyclopsFabScheme, cy, ref langLines, ref group);
                craftNodes.Add(cy);
#elif BELOWZERO
                CraftNode st = CraftTree.SeaTruckFabricatorScheme();
                CloneTabDetails(SeaTruckFabScheme, st, ref langLines, ref group);
                craftNodes.Add(st);
#endif

                CraftNode aioRoot = new CraftNode("Root").AddNode(craftNodes.ToArray());

                Type smlCTPatcher = typeof(CraftTreeHandler).Assembly.GetType("SMLHelper.V2.Patchers.CraftTreePatcher");
                var  customTrees  = (Dictionary <CraftTree.Type, ModCraftTreeRoot>)smlCTPatcher.GetField("CustomTrees", BindingFlags.NonPublic | BindingFlags.Static).GetValue(null);
                foreach (KeyValuePair <CraftTree.Type, ModCraftTreeRoot> entry in customTrees)
                {
                    if (entry.Key == this.TreeTypeID)
                    {
                        continue;
                    }

                    CraftTree tree   = entry.Value.CraftTreeCreation.Invoke();
                    CraftNode root   = tree.nodes;
                    string    scheme = entry.Key.ToString();

                    CloneTabDetails(scheme, root, ref langLines, ref group);
                    CloneTopLevelModTab(scheme, ref langLines, ref group);
                    aioRoot.AddNode(root);
                }

                craftTree = new CraftTree(AioFabScheme, aioRoot);
            }

            return(craftTree);
        }