Пример #1
0
        public MySortableBindingList <DGVItem <int> > getComponents(MySortableBindingList <DGVItem <int> > bpBlocks)
        {
            Dictionary <string, Dictionary <string, int> > blockDict = readBlocksData();
            Dictionary <string, string> iconPaths = readCompsIconsData();
            string partialPath = readGameDir() + "\\Content\\";
            MySortableBindingList <DGVItem <int> > comps = new MySortableBindingList <DGVItem <int> >();

            foreach (var bpBlock in bpBlocks)
            {
                if (blockDict.ContainsKey(bpBlock.Name))
                {
                    foreach (var comp in blockDict[bpBlock.Name])
                    {
                        DGVItem <int> foundComp = comps.FirstOrDefault(p => p.Name == comp.Key);
                        if (foundComp != null)
                        {
                            foundComp.Count += comp.Value * bpBlock.Count;
                        }
                        else
                        {
                            comps.Add(new DGVItem <int>(comp.Key, comp.Value * bpBlock.Count, partialPath + iconPaths[comp.Key]));
                        }
                    }
                }
            }
            return(comps);
        }
Пример #2
0
        public MySortableBindingList <DGVItem <float> > getIngots(MySortableBindingList <DGVItem <int> > bpComps)
        {
            Dictionary <string, Dictionary <string, float> > compDict = readCompsData();
            Dictionary <string, string> iconPaths = readIngotsIconsData();
            string partialPath = readGameDir() + "\\Content\\";
            MySortableBindingList <DGVItem <float> > ingots = new MySortableBindingList <DGVItem <float> >();

            foreach (var bpComp in bpComps)
            {
                if (bpComp.Name == "ZoneChip")
                {
                    continue;
                }
                foreach (var ingot in compDict[bpComp.Name])
                {
                    DGVItem <float> foundIngot = ingots.FirstOrDefault(p => p.Name == ingot.Key);
                    if (foundIngot != null)
                    {
                        foundIngot.Count += ingot.Value * bpComp.Count;
                    }
                    else
                    {
                        ingots.Add(new DGVItem <float>(ingot.Key, ingot.Value * bpComp.Count, partialPath + iconPaths[ingot.Key]));
                    }
                }
            }
            return(ingots);
        }
Пример #3
0
        public MySortableBindingList <DGVItem <int> > readXMLBlueprintBlocks(string file)
        {
            MySortableBindingList <DGVItem <int> > bpBlocks = new MySortableBindingList <DGVItem <int> >();
            var         iconPaths = readBlocksIconsData();
            bool        mod = false;
            string      name, partialPath = readGameDir() + "\\Content\\";
            XmlDocument bp = new XmlDocument();

            bp.LoadXml(file);

            var blocks = bp.DocumentElement.SelectNodes("//CubeGrids/CubeGrid/CubeBlocks/MyObjectBuilder_CubeBlock/SubtypeName");

            foreach (XmlNode block in blocks)
            {
                name = block?.InnerText ?? "";
                if (name == "")
                {
                    name = block.ParentNode.Attributes[0]?.InnerText ?? "";
                    name = name.Substring(16);
                }
                if (name == "")
                {
                    continue;
                }
                if (!iconPaths.ContainsKey(name))
                {
                    mod = true;
                    continue;
                }
                DGVItem <int> foundBlock = bpBlocks.FirstOrDefault(p => p.Name == name);
                if (foundBlock != null)
                {
                    foundBlock.Count++;
                }
                else
                {
                    bpBlocks.Add(new DGVItem <int>(name, 1, partialPath + iconPaths[name]));
                }
            }
            if (mod)
            {
                MessageBox.Show("Some unrecognized blocks have been ignored");
            }
            return(bpBlocks);
        }