コード例 #1
0
        /// <summary>
        /// 情報抽出
        /// </summary>
        /// <param name="module"></param>
        /// <returns></returns>
        private IEnumerable <ModuleTurret> GetRecords(XElement module)
        {
            try
            {
                var moduleID = module.Attribute("id")?.Value;
                if (string.IsNullOrEmpty(moduleID))
                {
                    return(Enumerable.Empty <ModuleTurret>());
                }

                var macroName    = module.XPathSelectElement("component").Attribute("ref").Value;
                var macroXml     = _CatFile.OpenIndexXml("index/macros.xml", macroName);
                var componentXml = _CatFile.OpenIndexXml("index/components.xml", macroXml.Root.XPathSelectElement("macro/component").Attribute("ref").Value);

                // 装備集計用辞書
                var sizeDict = new Dictionary <string, int>()
                {
                    { "extrasmall", 0 },
                    { "small", 0 },
                    { "medium", 0 },
                    { "large", 0 },
                    { "extralarge", 0 }
                };


                // タレットが記載されているタグを取得する
                foreach (var connections in componentXml.Root.XPathSelectElements("component/connections/connection[contains(@tags, 'turret')]"))
                {
                    // タレットのサイズを取得
                    var attr = connections.Attribute("tags").Value;
                    var size = sizeDict.Keys.Where(x => attr.Contains(x)).FirstOrDefault();

                    if (string.IsNullOrEmpty(size))
                    {
                        continue;
                    }

                    sizeDict[size]++;
                }

                return(sizeDict.Where
                       (
                           x => 0 < x.Value
                       )
                       .Select
                       (
                           x => new ModuleTurret(moduleID, x.Key, x.Value)
                       ));
            }
            catch
            {
                return(Enumerable.Empty <ModuleTurret>());
            }
        }
コード例 #2
0
        /// <summary>
        /// 1レコード分の情報を抽出する
        /// </summary>
        /// <param name="equipment"></param>
        /// <returns></returns>
        private Equipment?GetRecord(XElement equipment)
        {
            try
            {
                var equipmentID = equipment.Attribute("id")?.Value;
                if (string.IsNullOrEmpty(equipmentID))
                {
                    return(null);
                }

                var macroName = equipment.XPathSelectElement("component").Attribute("ref")?.Value;
                if (string.IsNullOrEmpty(macroName))
                {
                    return(null);
                }

                var equipmentTypeID = equipment.Attribute("group")?.Value;
                if (string.IsNullOrEmpty(equipmentTypeID))
                {
                    return(null);
                }

                var macroXml     = _CatFile.OpenIndexXml("index/macros.xml", macroName);
                var componentXml = _CatFile.OpenIndexXml("index/components.xml", macroXml.Root.XPathSelectElement("macro/component").Attribute("ref").Value);

                // 装備が記載されているタグを取得する
                var component = componentXml.Root.XPathSelectElement("component/connections/connection[contains(@tags, 'component')]");

                // サイズ一覧
                string[] sizes = { "extrasmall", "small", "medium", "large", "extralarge" };

                // 一致するサイズを探す
                var tags   = component?.Attribute("tags").Value.Split(" ");
                var sizeID = sizes.Where(x => tags?.Contains(x) == true).FirstOrDefault();
                // 一致するサイズがなかった場合
                if (string.IsNullOrEmpty(sizeID))
                {
                    return(null);
                }

                var name = _Resolver.Resolve(equipment.Attribute("name").Value);
                name = string.IsNullOrEmpty(name) ? macroName : name;

                return(new Equipment(equipmentID, macroName, equipmentTypeID, sizeID, name));
            }
            catch
            {
                return(null);
            }
        }
コード例 #3
0
        /// <summary>
        /// 1レコード分の情報抽出
        /// </summary>
        /// <param name="module"></param>
        /// <returns></returns>
        private ModuleProduct?GetRecord(XElement module)
        {
            try
            {
                var moduleID = module.Attribute("id").Value;
                if (string.IsNullOrEmpty(moduleID))
                {
                    return(null);
                }

                var macroName = module.XPathSelectElement("component").Attribute("ref").Value;
                var macroXml  = _CatFile.OpenIndexXml("index/macros.xml", macroName);
                var prod      = macroXml.Root.XPathSelectElement("macro/properties/production/queue");

                var wareID = prod?.Attribute("ware")?.Value;
                if (string.IsNullOrEmpty(wareID))
                {
                    return(null);
                }

                var method = prod?.Attribute("method")?.Value ?? "default";

                return(new ModuleProduct(moduleID, wareID, method));
            }
            catch
            {
                return(null);
            }
        }
コード例 #4
0
        public void OpenIndexFile2()
        {
            var ex = Assert.Throws <FileNotFoundException>(() =>
            {
                var cat = new CatFile(Path.Combine(_BaseDir, "VanillaIndexXml"));

                var xml1 = cat.OpenIndexXml("index/macros.xml", "not_exists_macro");
            });
        }
コード例 #5
0
        public void OpenIndexFile3()
        {
            var cat = new CatFile(Path.Combine(_BaseDir, "ModIndexXml"));

            var xml1 = cat.OpenIndexXml("index/macros.xml", "baz_macro");

            var xml2 = XDocument.Load(MakePath("ModIndexXmlOrig/extensions/baz_mod/ext_01/assets/fx/macros/baz_macro.xml"));

            Assert.True(XNode.DeepEquals(xml1, xml2));
        }
コード例 #6
0
        public void OpenIndexFile1()
        {
            var cat = new CatFile(Path.Combine(_BaseDir, "VanillaIndexXml"));

            var xml1 = cat.OpenIndexXml("index/macros.xml", "foo_macro");

            var xml2 = XDocument.Load(MakePath("VanillaIndexXmlOrig/01/assets/fx/macros/foo_macro.xml"));

            Assert.True(XNode.DeepEquals(xml1, xml2));
        }
コード例 #7
0
        /// <summary>
        /// 1レコード分の情報抽出
        /// </summary>
        /// <param name="module"></param>
        /// <returns></returns>
        private Module?GetRecord(XElement module)
        {
            try
            {
                var moduleID = module.Attribute("id").Value;
                if (string.IsNullOrEmpty(moduleID))
                {
                    return(null);
                }

                var macroName = module.XPathSelectElement("component").Attribute("ref").Value;
                if (string.IsNullOrEmpty(macroName))
                {
                    return(null);
                }

                var macroXml     = _CatFile.OpenIndexXml("index/macros.xml", macroName);
                var moduleTypeID = macroXml.Root.XPathSelectElement("macro").Attribute("class").Value;
                if (string.IsNullOrEmpty(moduleTypeID))
                {
                    return(null);
                }

                // 従業員数/最大収容人数取得
                var workForce  = macroXml?.Root?.XPathSelectElement("macro/properties/workforce");
                var maxWorkers = int.Parse(workForce?.Attribute("max")?.Value ?? "0");
                var capacity   = int.Parse(workForce?.Attribute("capacity")?.Value ?? "0");

                var name = _Resolver.Resolve(module.Attribute("name")?.Value ?? "");
                name = string.IsNullOrEmpty(name) ? macroName : name;

                return(new Module(moduleID, moduleTypeID, name, macroName, maxWorkers, capacity));
            }
            catch
            {
                return(null);
            }
        }
コード例 #8
0
        /// <summary>
        /// 1レコード分の情報抽出
        /// </summary>
        /// <param name="module"></param>
        /// <returns></returns>
        private ModuleStorage?GetRecord(XElement module)
        {
            try
            {
                var moduleID = module.Attribute("id")?.Value;
                if (string.IsNullOrEmpty(moduleID))
                {
                    return(null);
                }

                var macroName = module.XPathSelectElement("component").Attribute("ref").Value;
                var macroXml  = _CatFile.OpenIndexXml("index/macros.xml", macroName);

                // 容量が記載されている箇所を抽出
                var cargo = macroXml.Root.XPathSelectElement("macro/properties/cargo");

                // 総合保管庫は飛ばす
                var transportTypeID = cargo?.Attribute("tags")?.Value;
                if (string.IsNullOrEmpty(transportTypeID))
                {
                    return(null);
                }
                if (transportTypeID.Contains(' ') == true)
                {
                    return(null);
                }

                var amount = int.Parse(cargo?.Attribute("max")?.Value ?? "");

                return(new ModuleStorage(moduleID, transportTypeID, amount));
            }
            catch
            {
                return(null);
            }
        }