コード例 #1
0
        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);
        }
コード例 #2
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);
        }