예제 #1
0
        public async Task <List <IItemModel> > GetSameVariantList(IItemModel item)
        {
            var sameModelItems = new List <IItemModel>();

            if (!item.PrimaryCategory.Equals(XivStrings.Gear))

            {
                sameModelItems.Add((IItemModel)item.Clone());
                return(sameModelItems);
            }
            sameModelItems = await GetSameModelList(item);

            var imc          = new Imc(_gameDirectory, XivDataFile._04_Chara);
            var originalInfo = await imc.GetImcInfo(item);

            var sameMaterialItems = new List <IItemModel>();

            foreach (var i in sameModelItems)
            {
                var info = await imc.GetImcInfo(i);

                if (info.Variant == originalInfo.Variant)
                {
                    sameMaterialItems.Add(i);
                }
            }

            return(sameMaterialItems);
        }
예제 #2
0
        public async Task <List <IItemModel> > GetSameModelList(IItemModel item)
        {
            var sameModelItems = new List <IItemModel>();

            //gear
            if (item.PrimaryCategory.Equals(XivStrings.Gear))
            {
                sameModelItems.AddRange(
                    (await GetGearList())
                    .Where(it =>
                           it.ModelInfo.PrimaryID == item.ModelInfo.PrimaryID &&
                           it.ModelInfo.SecondaryID == item.ModelInfo.SecondaryID &&
                           it.SecondaryCategory == item.SecondaryCategory).Select(it => it as IItemModel).ToList()
                    );
            }
            else
            {
                //character
                sameModelItems.Add((IItemModel)item.Clone());
            }
            return(sameModelItems);
        }
예제 #3
0
        static void BatchExportItem(string path, IItemModel item, XivModelInfo secondaryModelInfo, Func <IEnumerable <XivRace> > getRaces)
        {
            if (File.Exists(path))
            {
                return;
            }

            WriteLine($"Exporting {item.GetType().Name} {item.Name}: {Path.GetFileNameWithoutExtension(path)}");

            var items = new List <IItemModel>();

            var metadata = new ExportMetadata();

            metadata.Name = item.Name;

            var mdl   = new Mdl(_gameDir, item.DataFile);
            var races = getRaces();

            items.Add(item);

            if (item.ModelInfo is XivMonsterModelInfo)
            {
                var info = item.ModelInfo as XivMonsterModelInfo;
                if (info.ModelType.Equals(XivItemType.demihuman) && item is XivMount)
                {
                    items.Clear();
                    var met = item.Clone() as XivMount;
                    met.TertiaryCategory = "Head";
                    var top = item.Clone() as XivMount;
                    top.TertiaryCategory = "Body";
                    var glv = item.Clone() as XivMount;
                    glv.TertiaryCategory = "Hand";
                    var dwn = item.Clone() as XivMount;
                    dwn.TertiaryCategory = "Leg";
                    var sho = item.Clone() as XivMount;
                    sho.TertiaryCategory = "Feet";

                    items.Add(met);
                    items.Add(top);
                    items.Add(glv);
                    items.Add(dwn);
                    items.Add(sho);
                }
            }

            foreach (var race in races)
            {
                var mdlDatas    = new List <XivMdl>();
                var textureSets = new List <Dictionary <string, ModelTextureData> >();

                foreach (var iItem in items)
                {
                    try
                    {
                        var mdlData = mdl.GetRawMdlData(iItem, race).Result;
                        if (mdlData != null)
                        {
                            mdlDatas.Add(mdlData);

                            textureSets.Add(TexTools.MaterialsHelper.GetMaterials(_gameDir, item, mdlData, race).Result);

                            continue;
                        }
                    }
                    catch
                    { }
                    WriteLine($"Failed to get {iItem.Name}。 Got null.");
                    if (items.Count > 1)
                    {
                        WriteLine($"{iItem.Name} has no components like {iItem.TertiaryCategory}.");
                    }
                }

                try
                {
                    var set = BatchExportSets(mdlDatas, textureSets);
                    set.Name = TexTools.XivStringRaces.ToRaceGenderName(race);
                    metadata.Sets.Add(set);
                }
                catch (NotImplementedException e)
                { }
            }
            if (metadata.Sets[0].Models.Count == 0)
            {
                WriteLine($"Empty model {item.Name}.");
                return;
            }

            var metadataJson = JsonConvert.SerializeObject(metadata);

            File.WriteAllText(path, metadataJson);

            WriteLine($"Exported {item.GetType().Name} {item.Name}: {Path.GetFileNameWithoutExtension(path)}");
        }