Exemplo n.º 1
0
        /// <summary>
        /// Uses the template property attributes to assign values to properties.
        /// </summary>
        /// <param name="pEntry">Target template to work on</param>
        /// <param name="prop">Base WZ property node</param>
        protected void AssignProviderAttributes(AbstractTemplate pEntry, WzProperty prop)
        {
            var pTypeInfo     = pEntry.GetType();
            var pClassMembers = pTypeInfo.GetMembers();

            foreach (var templateMember in pClassMembers)
            {
                var apCustomAttributes = System.Attribute.GetCustomAttributes(templateMember);

                if (apCustomAttributes.Any(t => t is ProviderIgnoreAttribute))
                {
                    continue;
                }

                foreach (var attribute in apCustomAttributes)
                {
                    if (attribute is ProviderPropertyAttribute paa)
                    {
                        var pi = pEntry.GetType().GetProperty(templateMember.Name);

                        // if pi is null: throw -- should not happen

                        SetProviderPropertyValue(pEntry, pi, prop, paa);
                    }
                    else if (attribute is ProviderListAttribute pla)
                    {
                        ;                         // TODO

                        var pi = pEntry.GetType().GetProperty(templateMember.Name);

                        ;
                    }
                }
            }
        }
Exemplo n.º 2
0
        public void Dispose()
        {
            _images?.Clear();
            _images = null;

            _imageHashCode?.Clear();
            _imageHashCode = null;

            _obj = null;
        }
Exemplo n.º 3
0
        public static object GetImgPropVal(this WzProperty prop, Type type, string attributeName)
        {
            var tc = Type.GetTypeCode(type);

            switch (tc)
            {
            case TypeCode.Boolean:
                return(prop.GetInt32(attributeName) != 0);

            case TypeCode.Byte:
                return(prop.GetInt8(attributeName));

            case TypeCode.Int16:
                return(prop.GetInt16(attributeName));

            case TypeCode.Int32:
                if (prop.GetAllChildren().Count > 0)
                {
                    return(0);
                }

                return(prop.GetInt32(attributeName));

            case TypeCode.Int64:
                return(prop.GetInt64(attributeName));

            case TypeCode.String:
                return(prop.GetString(attributeName));

            case TypeCode.Object:
                switch (type.Name)
                {
                case "Point":
                {
                    if (prop[attributeName] is WzVector2D vector)
                    {
                        return(new Point(vector.X, vector.Y));
                    }
                    else
                    {
                        return(new Point());
                    }
                }
                }
                break;

            case TypeCode.Double:
                return(Convert.ToDouble(prop.Get(attributeName)));
            }

            throw new InvalidOperationException();
        }
Exemplo n.º 4
0
        private void FillWzPropertyElements(JsonWriter w, WzProperty wp)
        {
            foreach (var kvp in wp)
            {
                // Skip certain props that the user dont need
                if (kvp.Key == "_hash" || kvp.Key == "_outlink" || kvp.Key == "_inlink")
                {
                    continue;
                }


                w.WritePropertyName(kvp.Key);
                ObjectToJson(w, kvp.Value);
            }
        }
Exemplo n.º 5
0
        private void FinishTemplate(AbstractItemTemplate itemTemplate, WzProperty infoProp)
        {
            itemTemplate.TradeBlock     = infoProp.GetInt32("tradeBlock") > 0;
            itemTemplate.Cash           = infoProp.GetInt32("cash") > 0;
            itemTemplate.NotSale        = infoProp.GetInt32("notSale") > 0;
            itemTemplate.Quest          = infoProp.GetInt32("quest") > 0;
            itemTemplate.Price          = infoProp.GetInt32("price");
            itemTemplate.Only           = infoProp.GetInt32("only") > 0;
            itemTemplate.Max            = infoProp.GetInt32("max");
            itemTemplate.ExpireOnLogout = infoProp.GetInt32("expireOnLogout") > 0;
            itemTemplate.TimeLimited    = infoProp.GetInt32("timeLimited") > 0;
            itemTemplate.MCType         = infoProp.GetInt32("mcType");
            itemTemplate.SlotMax        = infoProp.GetInt32("slotMax");

            if (!(infoProp["time"] is WzProperty))
            {
                itemTemplate.Time = (infoProp.Parent["spec"] as WzProperty)?.GetInt32("time") ?? 0;
            }
        }
Exemplo n.º 6
0
        private void SetProviderPropertyValue(AbstractTemplate pEntry, PropertyInfo pi, WzProperty dataProp, ProviderPropertyAttribute paa)
        {
            WzProperty realPropDir = dataProp;

            var    propNameSplit = paa.AttributePath.Split('/');
            string attributeName;

            for (var i = 0; i < propNameSplit.Length - 1; ++i)
            {
                attributeName = propNameSplit[i];

                if (realPropDir is null)
                {
                    continue;                                      // cant find path
                }
                realPropDir = realPropDir.GetChild(attributeName) as WzProperty;
            }

            attributeName = propNameSplit[propNameSplit.Length - 1];             // should always be last of the split

            if (realPropDir is null)
            {
                return;                                  // cant find path
            }
            var val = realPropDir.GetImgPropVal(pi.PropertyType, attributeName);

            if (val.IsNullOrDefault() || val is string s && s.Length <= 0)
            {
                foreach (var attrName in paa.AltPaths)
                {
                    val = realPropDir.GetImgPropVal(pi.PropertyType, attrName);

                    if (!val.IsNullOrDefault() || val is string ss && ss.Length <= 0)
                    {
                        break;
                    }
                }
            }

            pi.SetValue(pEntry, val);
        }
Exemplo n.º 7
0
        public void TestSubPropSerializingAndDeserializing()
        {
            var parentProp = new WzProperty();
            var subProp    = new WzProperty();

            parentProp.Set("sub", subProp);


            var ms = new MemoryStream();
            var aw = new ArchiveWriter(ms);

            parentProp.Write(aw);


            ms.Position = 0;

            var outProp = new WzProperty();

            outProp.Read(new ArchiveReader(ms));

            Assert.IsTrue(outProp.HasChild("sub"));
            Assert.IsInstanceOfType(outProp["sub"], typeof(WzProperty));
        }
Exemplo n.º 8
0
        private static int GetSumDelay(WzProperty wzProp)
        {
            if (wzProp is null)
            {
                return(-1);
            }

            var nDelay = 0;

            for (var i = 0; ; i++)
            {
                var data = wzProp.GetChild(i.ToString()) as WzProperty;

                if (data is null)
                {
                    break;
                }

                nDelay += data.GetInt32("delay");
            }

            return(nDelay);
        }
Exemplo n.º 9
0
        private static QuestDemand RegisterQuestDemand(WzProperty baseNode)
        {
            if (baseNode.GetAllChildren().Count <= 0)
            {
                return(null);
            }

            var demands = new QuestDemand
            {
                LevelMax          = baseNode.GetInt32("lvmax"),
                LevelMin          = baseNode.GetInt32("lvmin"),
                TamingMobLevelMax = baseNode.GetInt32("pettamenessmax"),
                TamingMobLevelMin = baseNode.GetInt32("pettamenessmin"),
                PetTamenessMax    = baseNode.GetInt32("tamingmoblevelmin"),
                PetTamenessMin    = baseNode.GetInt32("tamingmoblevelmax"),
                Pop             = baseNode.GetInt32("pop"),
                RepeatByDay     = baseNode.GetInt32("dayByDay") != 0,
                SubJobFlags     = baseNode.GetInt32("subJobFlags"),
                NormalAutoStart = baseNode.GetInt32("normalAutoStart") > 0,
            };

            if (baseNode["mob"] is WzProperty mobNode)
            {
                demands.DemandMob = mobNode.GetAllChildren()
                                    .Values
                                    .Cast <WzProperty>()
                                    .Select(item =>
                                            new MobInfo
                {
                    MobID = item.GetInt32("id"),
                    Count = item.GetInt32("count")
                })
                                    .ToArray();
            }

            if (baseNode["quest"] is WzProperty questNode)
            {
                demands.DemandQuest = questNode.GetAllChildren()
                                      .Values
                                      .Cast <WzProperty>()
                                      .Select(item =>
                                              new QuestDemand.QuestRecord
                {
                    QuestID = item.GetInt16("id"),
                    State   = item.GetInt32("state")
                })
                                      .ToArray();
            }

            if (baseNode["item"] is WzProperty itemNode)
            {
                demands.DemandItem = itemNode.GetAllChildren()
                                     .Values
                                     .Cast <WzProperty>()
                                     .Select(item =>
                                             new ItemInfo
                {
                    ItemID = item.GetInt32("id"),
                    Count  = item.GetInt32("count")
                })
                                     .ToArray();
            }

            if (baseNode["skill"] is WzProperty skillNode)
            {
                demands.DemandSkill = skillNode.GetAllChildren()
                                      .Values
                                      .Cast <WzProperty>()
                                      .Select(item =>
                                              new SkillInfo
                {
                    SkillID = item.GetInt32("id"),
                    Acquire = item.GetInt32("acquire")
                })
                                      .ToArray();
            }

            if (baseNode["equipSelectNeed"] is WzProperty equipSelectNode)
            {
                demands.EquipSelectNeed = equipSelectNode.GetAllChildren().Values.Cast <int>().ToArray();
            }

            if (baseNode["equipAllNeed"] is WzProperty equipNode)
            {
                demands.EquipAllNeed = equipNode.GetAllChildren().Values.Cast <int>().ToArray();
            }

            if (baseNode["job"] is WzProperty jobNode)
            {
                demands.Job = jobNode.GetAllChildren().Values.Cast <int>().ToArray();
            }

            if (baseNode["fieldEnter"] is WzProperty fieldNode)
            {
                demands.FieldEnter = fieldNode.GetAllChildren().Values.Cast <int>().ToArray();
            }

            return(demands);
        }
Exemplo n.º 10
0
        private static QuestAct RegisterQuestAct(WzProperty baseNode)
        {
            if (baseNode.GetAllChildren().Count <= 0)
            {
                return(null);
            }

            var rewards = new QuestAct
            {
                IncExp         = baseNode.GetInt32("exp"),
                IncMoney       = baseNode.GetInt32("money"),
                IncPop         = baseNode.GetInt32("pop"),
                IncPetTameness = baseNode.GetInt32("pettameness"),
                IncPetSpeed    = baseNode.GetInt32("petspeed"),
                PetSkill       = baseNode.GetInt32("petskill"),
                NextQuest      = baseNode.GetInt32("nextQuest"),
                BuffItemID     = baseNode.GetInt32("buffItemID"),
                LevelMin       = baseNode.GetInt32("lvmin"),
                LevelMax       = baseNode.GetInt32("lvmax"),
                Info           = baseNode.GetString("info")
            };

            if (baseNode["item"] is WzProperty itemRewards)
            {
                rewards.Items = itemRewards.GetAllChildren()
                                .Values
                                .Cast <WzProperty>()
                                .Select(item =>
                                        new QuestAct.ActItem
                {
                    Item = new ItemInfo
                    {
                        ItemID = item.GetInt32("id"),
                        Count  = item.GetInt32("count"),
                    },
                    Period        = item.GetInt32("period"),
                    JobFlag       = item.GetInt32("job"),
                    Gender        = item.GetInt32("gender"),
                    ProbRate      = item.GetInt32("prop"),
                    ItemVariation = item.GetInt32("var"),
                })
                                .ToArray();
            }

            if (baseNode["skill"] is WzProperty skillRewards)
            {
                rewards.Skills = skillRewards.GetAllChildren()
                                 .Values
                                 .Cast <WzProperty>()
                                 .Select(item =>
                                         new QuestAct.ActSkill
                {
                    SkillID     = item.GetInt32("id"),
                    MasterLevel = item.GetInt32("masterLevel"),
                    SkillLevel  = item.GetInt32("skillLevel") != 0
                                                                ? item.GetInt32("skillLevel")
                                                                : item.GetInt32("acquire"),
                    Job = (item["job"] as WzProperty)?.GetAllChildren().Values.Cast <int>()
                          .ToArray() ?? new int[0]
                })
                                 .ToArray();
            }

            return(rewards);
        }
Exemplo n.º 11
0
        public void TestPrimitiveSerializingAndDeserializing()
        {
            var prop = new WzProperty();

            prop.Set("byte", (byte)0xaf);
            prop.Set("sbyte", (sbyte)0x7a);
            prop.Set("ushort", (ushort)0xaaff);
            prop.Set("uint", (uint)0xaaffaaff);
            prop.Set("ulong", (ulong)0xaaffaaffaaffaaff);

            prop.Set("short", (short)0x7aff);
            prop.Set("int", (int)0x7affaaff);
            prop.Set("long", (long)0x7affaaffaaffaaff);
            prop.Set("l", (long)0x7affaaffaaffaaff);

            prop.Set("single", (Single)1234.6789f);
            prop.Set("double", (Double)1234.6789d);
            prop.Set("ascii", "test1234");
            prop.Set("unicode", "hurr emoji 😋");

            prop.Set("null", null);
            prop.Set("dt", DateTime.Now);

            var testEncryptions = EncryptionTest.TestEncryptions();

            foreach (var testEncryption in testEncryptions)
            {
                using (var ms = new MemoryStream())
                    using (var aw = new ArchiveWriter(ms))
                    {
                        aw.Encryption = testEncryption;
                        prop.Write(aw);


                        ms.Position = 0;


                        var outProp = new WzProperty();
                        var ar      = new ArchiveReader(ms);
                        ar.SetEncryption(testEncryption);
                        outProp.Read(ar);

                        foreach (var kvp in outProp)
                        {
                            Console.WriteLine("Got key {0} of {1}", kvp.Key, testEncryption);
                        }

                        foreach (var kvp in prop)
                        {
                            Console.WriteLine("Checking key {0} of {1}", kvp.Key, testEncryption);

                            var hasKey = outProp.HasChild(kvp.Key);

                            Assert.IsTrue(hasKey, $"Missing key {kvp.Key}");
                            if (hasKey)
                            {
                                Assert.AreEqual(kvp.Value, outProp[kvp.Key], $"Unequal values! {kvp.Key} {kvp.Value}");
                            }
                        }
                    }
            }
        }
Exemplo n.º 12
0
 public Exporter(Options opts, WzProperty baseObject)
 {
     _obj     = baseObject;
     _options = opts;
 }
Exemplo n.º 13
0
 public static int IMGNameToID(this WzProperty property)
 {
     return(int.Parse(property.Name.Replace(".img", ""), NumberStyles.Number));
 }
Exemplo n.º 14
0
        private void ProcessSkillData(WzProperty baseNode, SkillTemplate entry)
        {
            // level data
            entry.ItemConsumeAmount = baseNode.GetInt32("itemConNo");
            entry.BulletCount       = baseNode.GetInt32("bulletCount");
            entry.BulletConsume     = baseNode.GetInt32("bulletCon");
            entry.ItemConsume       = baseNode.GetInt32("itemCon");
            entry.OptionalItemCost  = baseNode.GetInt32("itemConsume");
            entry.Morph             = baseNode.GetInt32("morph");

            // verified
            if (baseNode.Get("lt") is WzVector2D lt)
            {
                entry.LT = new Point(lt.X, lt.Y);
            }

            // verified
            if (baseNode["rb"] is WzVector2D rb)
            {
                entry.RB = new Point(rb.X, rb.Y);
            }

            entry.InitSLD(entry.MaxLevel + entry.CombatOrders);

            var isLevelNode = baseNode.Name.Equals("level");

            var parentNode = baseNode;

            // verified
            for (var i = 0; i < entry.DataLength; i++)
            {
                var level = i + 1;

                entry[level] = new SkillLevelData();

                if (isLevelNode)
                {
                    baseNode = parentNode[level.ToString()] as WzProperty ?? parentNode;
                }

                entry[level].FixDamage   = GetEvalInt(baseNode.GetString("fixdamage"), level);
                entry[level].AttackCount = GetEvalInt(baseNode.GetString("attackCount"), level);
                entry[level].MobCount    = GetEvalInt(baseNode.GetString("mobCount"), level);
                entry[level].Time        = GetEvalInt(baseNode.GetString("time"), level);
                entry[level].SubTime     = GetEvalInt(baseNode.GetString("subTime"), level);
                entry[level].MpCon       = GetEvalInt(baseNode.GetString("mpCon"), level);
                entry[level].HpCon       = GetEvalInt(baseNode.GetString("hpCon"), level);
                entry[level].Damage      = GetEvalInt(baseNode.GetString("damage"), level);
                entry[level].Mastery     = GetEvalInt(baseNode.GetString("mastery"), level);
                entry[level].DamR        = GetEvalInt(baseNode.GetString("damR"), level);
                entry[level].Dot         = GetEvalInt(baseNode.GetString("dot"), level);
                entry[level].DotTime     = GetEvalInt(baseNode.GetString("dotTime"), level);
                entry[level].MESOr       = GetEvalInt(baseNode.GetString("mesoR"), level);
                entry[level].Speed       = GetEvalInt(baseNode.GetString("speed"), level);
                entry[level].Jump        = GetEvalInt(baseNode.GetString("jump"), level);
                entry[level].PAD         = GetEvalInt(baseNode.GetString("pad"), level);
                entry[level].MAD         = GetEvalInt(baseNode.GetString("mad"), level);
                entry[level].PDD         = GetEvalInt(baseNode.GetString("pdd"), level);
                entry[level].MDD         = GetEvalInt(baseNode.GetString("mdd"), level);
                entry[level].EVA         = GetEvalInt(baseNode.GetString("eva"), level);
                entry[level].ACC         = GetEvalInt(baseNode.GetString("acc"), level);
                entry[level].HP          = GetEvalInt(baseNode.GetString("hp"), level);
                entry[level].MHPr        = GetEvalInt(baseNode.GetString("mhpR"), level);
                entry[level].MP          = GetEvalInt(baseNode.GetString("mp"), level);
                entry[level].MMPr        = GetEvalInt(baseNode.GetString("mmpR"), level);
                entry[level].Prop        = GetEvalInt(baseNode.GetString("prop"), level);
                entry[level].SubProp     = GetEvalInt(baseNode.GetString("subProp"), level);
                entry[level].Cooltime    = GetEvalInt(baseNode.GetString("cooltime"), level);
                entry[level].ASRr        = GetEvalInt(baseNode.GetString("asrR"), level);
                entry[level].TERr        = GetEvalInt(baseNode.GetString("terR"), level);
                entry[level].EMDD        = GetEvalInt(baseNode.GetString("emdd"), level);
                entry[level].EMHP        = GetEvalInt(baseNode.GetString("emhp"), level);
                entry[level].EMMP        = GetEvalInt(baseNode.GetString("emmp"), level);
                entry[level].EPAD        = GetEvalInt(baseNode.GetString("epad"), level);
                entry[level].EPDD        = GetEvalInt(baseNode.GetString("epdd"), level);
                entry[level].Cr          = GetEvalInt(baseNode.GetString("cr"), level);
                entry[level].T           = GetEvalDouble(baseNode.GetString("t"), level);
                entry[level].U           = GetEvalDouble(baseNode.GetString("u"), level);
                entry[level].V           = GetEvalDouble(baseNode.GetString("v"), level);
                entry[level].W           = GetEvalDouble(baseNode.GetString("w"), level);
                entry[level].X           = GetEvalDouble(baseNode.GetString("x"), level);
                entry[level].Y           = GetEvalDouble(baseNode.GetString("y"), level);
                entry[level].Z           = GetEvalDouble(baseNode.GetString("z"), level);
                entry[level].PADr        = GetEvalInt(baseNode.GetString("padR"), level);
                entry[level].PADx        = GetEvalInt(baseNode.GetString("padX"), level);
                entry[level].MADr        = GetEvalInt(baseNode.GetString("madR"), level);
                entry[level].MADx        = GetEvalInt(baseNode.GetString("madX"), level);
                entry[level].PDDr        = GetEvalInt(baseNode.GetString("pddR"), level);
                entry[level].MDDr        = GetEvalInt(baseNode.GetString("mddR"), level);
                entry[level].EVAr        = GetEvalInt(baseNode.GetString("evaR"), level);
                entry[level].ACCr        = GetEvalInt(baseNode.GetString("accR"), level);
                entry[level].IMPr        = GetEvalInt(baseNode.GetString("ignoreMobpdpR"), level);
                entry[level].IMDr        = GetEvalInt(baseNode.GetString("ignoreMobDamR"), level);
                entry[level].CDMin       = GetEvalInt(baseNode.GetString("criticaldamageMin"), level);
                entry[level].CDMax       = GetEvalInt(baseNode.GetString("criticaldamageMax"), level);
                entry[level].EXPr        = GetEvalInt(baseNode.GetString("expR"), level);
                entry[level].Er          = GetEvalInt(baseNode.GetString("er"), level);
                entry[level].Ar          = GetEvalInt(baseNode.GetString("ar"), level);
                entry[level].OCr         = GetEvalInt(baseNode.GetString("overChargeR"), level);
                entry[level].DCr         = GetEvalInt(baseNode.GetString("disCountR"), level);
                entry[level].PDamr       = GetEvalInt(baseNode.GetString("pdR"), level);
                entry[level].MDamr       = GetEvalInt(baseNode.GetString("mdR"), level);
                entry[level].PsdJump     = GetEvalInt(baseNode.GetString("psdJump"), level);
                entry[level].PsdSpeed    = GetEvalInt(baseNode.GetString("psdSpeed"), level);

                // skill bufftime modification
                switch ((Skills)entry.TemplateId)
                {
                case Skills.MECHANIC_FLAMETHROWER:
                case Skills.MECHANIC_FLAMETHROWER_UP:
                    entry[level].Time = 1;
                    break;

                case Skills.MECHANIC_HN07:                         // mount
                case Skills.WILDHUNTER_JAGUAR_RIDING:              // mount
                case Skills.MECHANIC_SAFETY:                       // permanent
                case Skills.MECHANIC_PERFECT_ARMOR:                // permanent
                case Skills.MECHANIC_SIEGE2:                       // semi-permanent (uses hp per sec)
                    entry[level].Time = -1;
                    break;

                case Skills.MECHANIC_SG88:
                case Skills.MECHANIC_SATELITE:
                case Skills.MECHANIC_SATELITE2:
                case Skills.MECHANIC_SATELITE3:
                    entry[level].Time = 2100000;
                    break;

                case Skills.CROSSBOWMAN_FINAL_ATTACK_CROSSBOW:
                case Skills.FIGHTER_FINAL_ATTACK:
                case Skills.HUNTER_FINAL_ATTACK_BOW:
                case Skills.PAGE_FINAL_ATTACK:
                case Skills.SOULMASTER_FINAL_ATTACK_SWORD:
                case Skills.SPEARMAN_FINAL_ATTACK:
                case Skills.WILDHUNTER_FINAL_ATTACK:
                case Skills.WINDBREAKER_FINAL_ATTACK_BOW:
                    entry[level].MobCount = 3;
                    break;
                }

                // bullet/attack/mob count modification
                switch ((Skills)entry.TemplateId)
                {
                case Skills.MECHANIC_SIEGE1:
                case Skills.MECHANIC_SIEGE2:
                case Skills.MECHANIC_SIEGE2_SPECIAL:
                    entry[level].AttackCount = 6;
                    entry.BulletCount        = 6;
                    break;
                }
            }
        }
Exemplo n.º 15
0
        public static IEnumerable <string> CheckLife(TreeView tree, WzProperty mainNode)
        {
            if (mainNode == null)
            {
                yield break;
            }
            if (!(mainNode["life"] is WzProperty lifeNode))
            {
                yield break;
            }

            foreach (var listElement in lifeNode)
            {
                var lifeNodeData = listElement.Value as WzProperty;
                var type         = (string)lifeNodeData["type"];

                var typeName  = "";
                var lookupDir = "";
                switch (type)
                {
                case "n": typeName = "Npc"; break;

                case "m": typeName = "Mob"; break;

                case "r":
                    lookupDir = "Reactor/Reactor.img";
                    typeName  = "Reactor";
                    break;

                default: continue;
                }
                if (lookupDir == "")
                {
                    lookupDir = typeName;
                }

                string id     = "";
                var    idNode = lifeNodeData["id"];
                if (idNode is string x)
                {
                    id = x;
                }
                else if (idNode is int y)
                {
                    id = y.ToString();
                }
                if (id.Length != 7)
                {
                    yield return($"Invalid ID found for {typeName}: {idNode} (parsed as {id}), type {idNode.GetType()}) (life node {listElement.Key})");

                    continue;
                }


                var path       = $"{lookupDir}/{id}.img";
                var lifeExists = tree.FindNode <NameSpaceFile>(path) != null;

                if (!lifeExists)
                {
                    yield return($"Unable to find {typeName} {idNode} (life node {listElement.Key}).");
                }
            }
        }
Exemplo n.º 16
0
        private void ProcessStringNameSpaceFile(StringDataType type, NameSpaceFile imgFile)
        {
            if (!Contains((int)type))
            {
                InsertItem(new GenericKeyedTemplate <StringTemplate>((int)type));
            }

            WzProperty dataBlob = imgFile.Object as WzFileProperty;

            if (dataBlob.Name.Equals("Eqp.img"))
            {
                foreach (var eqpTypeBlob in dataBlob["Eqp"] as WzProperty)
                {
                    run(eqpTypeBlob.Value as WzProperty);
                }
            }
            else if (dataBlob.Name.Equals("Etc.img"))
            {
                run(dataBlob["Etc"] as WzProperty);
            }
            else if (dataBlob.Name.Equals("Map.img"))
            {
                foreach (var mapBlob in dataBlob)
                {
                    run(mapBlob.Value as WzProperty);
                }
            }
            else
            {
                run(dataBlob);
            }

            void run(WzProperty blob)
            {
                foreach (var stringBlob in blob)
                {
                    var templateId = Convert.ToInt32(stringBlob.Key);
                    var prop       = stringBlob.Value as WzProperty;

                    if (prop.HasChild("bookName"))
                    {
                        continue;                                                // skill book, we only want skill names
                    }
                    var pEntry = new StringTemplate(templateId);

                    AssignProviderAttributes(pEntry, prop);

                    this[type].Add(pEntry);

                    // BEGIN PROPERTY AUTO POPULATION

                    //foreach (var templateMember in pEntry.GetType().GetMembers())
                    //{
                    //	var memberData = templateMember.GetCustomAttributes();

                    //	var providerAttribute = memberData
                    //		.FirstOrDefault(md => md is ProviderAttributeAttribute);

                    //	if (providerAttribute is ProviderAttributeAttribute paa)
                    //	{
                    //		var pi = pEntry.GetType().GetProperty(templateMember.Name);

                    //		// if pi is null: throw -- should not happen

                    //		var val = prop.GetImgPropVal(pi.PropertyType, paa.AttributeName);

                    //		if (val.IsNullOrDefault() || val is string s && s.Length <= 0)
                    //		{
                    //			foreach (var attrName in paa.AltAttributeNames)
                    //			{
                    //				val = prop.GetImgPropVal(pi.PropertyType, attrName);

                    //				if (!val.IsNullOrDefault() || val is string ss && ss.Length <= 0) break;
                    //			}
                    //		}

                    //		pi.SetValue(pEntry, prop.GetImgPropVal(pi.PropertyType, paa.AttributeName));
                    //	}
                    //}

                    // END PROPERTY AUTO POPULATION

                    //this[type].Add(new StringTemplate(templateId)
                    //{
                    //	Name = prop.GetString("name"),
                    //	StreetName = prop.GetString("streetName"),
                    //	Description = prop.GetString("desc")
                    //});

                    //if (this[type][templateId].Name is null)
                    //{
                    //	this[type][templateId].Name = prop.GetString("mapName");
                    //}

                    //if (this[type][templateId].Name is null)
                    //{
                    //	throw new NullReferenceException($"Template name is null. ID: {templateId}");
                    //}
                }
            }
        }