コード例 #1
0
ファイル: WeaponReader.cs プロジェクト: woshimj001/MHW-Editor
        public static LangMap GetWeaponsOfType(string targetFile, WeaponType weaponType, IndexOrId by)
        {
            var weaponClassType = weaponType.ToClassType();
            var weaponTypeName  = Path.GetFileNameWithoutExtension(weaponType.ToDatFileName());
            var values          = new LangMap();

            IEnumerable <IWeapon> weapons;

            if (weaponClassType == typeof(Melee))
            {
                weapons = Melee.LoadData(targetFile).GetSingleStructList();
            }
            else if (weaponClassType == typeof(Ranged))
            {
                weapons = Ranged.LoadData(targetFile).GetSingleStructList();
            }
            else
            {
                throw new InvalidOperationException($"Unrecognized weapon type: {weaponClassType.Name}");
            }

            foreach (var weapon in weapons)
            {
                foreach (var lang in Global.LANGUAGES)
                {
                    if (!values.ContainsKey(lang))
                    {
                        values[lang] = new Dictionary <uint, string>();
                    }

                    values[lang][(uint)(by == IndexOrId.Id ? weapon.Id : weapon.Index)] = DataHelper.weaponData[lang][weaponTypeName ?? throw new InvalidOperationException()][weapon.GMD_Name_Index];