示例#1
0
        public static IEnumerable <string> GetItemRemakeDictionary(string pathBCSV, string fn = "ItemParam.bcsv")
        {
            var path = Path.Combine(pathBCSV, fn);
            var data = File.ReadAllBytes(path);
            var bcsv = new BCSV(data);

            var dict = bcsv.GetFieldDictionary();
            var fID  = dict[0x54706054];
            var fRid = dict[0xCB5EB33F];

            var result = new Dictionary <ushort, short>();

            for (int i = 0; i < bcsv.EntryCount; i++)
            {
                var rid   = bcsv.ReadValue(i, fRid);
                var rival = short.Parse(rid);

                if (rival < 0)
                {
                    continue;
                }

                var id   = bcsv.ReadValue(i, fID);
                var ival = ushort.Parse(id);

                result.Add(ival, rival);
            }

            var str = GameInfo.Strings.itemlist;

            return(result.Select(z => $"{{{z.Key:00000}, {z.Value:0000}}}, // {str[z.Key]}"));
        }
示例#2
0
        private static IEnumerable <string> GetNumberedEnumValues(string pathBCSV, string fn, uint keyName, uint keyValue)
        {
            var path = Path.Combine(pathBCSV, fn);
            var data = File.ReadAllBytes(path);
            var bcsv = new BCSV(data);

            var dict    = bcsv.GetFieldDictionary();
            var fType   = dict[keyName];
            var fitemID = dict[keyValue];

            var types = new List <string>();
            var set   = new Dictionary <string, int>();

            for (int i = 0; i < bcsv.EntryCount; i++)
            {
                var iid  = bcsv.ReadValue(i, fitemID);
                var ival = ushort.Parse(iid);
                var type = bcsv.ReadValue(i, fType).TrimEnd('\0');
                if (set.TryGetValue(type, out var count))
                {
                    count++;
                    set[type] = count;
                    type     += $"_{count}";
                }
                else
                {
                    set.Add(type, 1);
                }

                types.Add($"{type} = 0x{ival:X2},");
            }

            return(types);
        }
示例#3
0
        public static string[] GetItemSizeDictionary(string pathBCSV, string fn = "ItemSize.bcsv")
        {
            var path = Path.Combine(pathBCSV, fn);
            var data = File.ReadAllBytes(path);
            var bcsv = new BCSV(data);

            var dict = bcsv.GetFieldDictionary();

            var fw = dict[0x16B8F524];
            var fh = dict[0xBCB13DAF];
            var fs = dict[0x87BF00E8];
            var fc = dict[0x977ADFCE];

            string[] result = new string[bcsv.EntryCount];

            const string prefix = nameof(ItemSizeType) + "." + ItemSizeExtensions.EnumPrefix;

            for (int i = 0; i < bcsv.EntryCount; i++)
            {
                var w = bcsv.ReadValue(i, fw).TrimEnd('\0');
                var h = bcsv.ReadValue(i, fh).TrimEnd('\0');
                var s = bcsv.ReadValue(i, fs).TrimEnd('\0');
                var c = bcsv.ReadValue(i, fc).TrimEnd('\0');

                result[i] = $"{{{prefix}{s,-12}, new ItemSize({w,2}, {h,2})}}, // {c}";
            }

            return(result);
        }
示例#4
0
        public static byte[] GetItemSizeArray(string pathBCSV, string fn = "ItemParam.bcsv")
        {
            var path = Path.Combine(pathBCSV, fn);
            var data = File.ReadAllBytes(path);
            var bcsv = new BCSV(data);

            var dict = bcsv.GetFieldDictionary();
            var fType = dict[0xE06FB090];
            var fID = dict[0x54706054];

            var types = new Dictionary<ushort, ItemSizeType>();
            ushort max = 0;
            for (int i = 0; i < bcsv.EntryCount; i++)
            {
                var id = bcsv.ReadValue(i, fID);
                var ival = ushort.Parse(id);
                var type = bcsv.ReadValue(i, fType).TrimEnd('\0');
                type = ItemSizeExtensions.EnumPrefix + type; // can't start with numbers

                if (!Enum.TryParse<ItemSizeType>(type, out var k))
                    throw new InvalidEnumArgumentException($"{type} is not a known enum value @ index {i}. Update the enum index first.");
                types.Add(ival, k);

                if (ival > max)
                    max = ival;
            }

            byte[] result = new byte[max + 1];
            foreach (var kvp in types)
                result[kvp.Key] = (byte)kvp.Value;

            return result;
        }
示例#5
0
        public static List <string> GetMilestoneList(string pathBCSV, string fn = "EventFlagsLifeSupportAchievementParam.bcsv")
        {
            var path = Path.Combine(pathBCSV, fn);
            var data = File.ReadAllBytes(path);
            var bcsv = new BCSV(data);

            var dict   = bcsv.GetFieldDictionary();
            var findex = dict[0x54706054];
            var fname  = dict[0x45F320F2];
            var fjp    = dict[0x85CF1615];

            var result = new List <string>();

            for (int i = 0; i < bcsv.EntryCount; i++)
            {
                var iid  = bcsv.ReadValue(i, findex);
                var ival = ushort.Parse(iid);

                var name = bcsv.ReadValue(i, fname).TrimEnd('\0');
                var jp   = bcsv.ReadValue(i, fjp).TrimEnd('\0');

                var kvp = $"{{{ival:00}, \"{name}\"}}, // {jp}";
                result.Add(kvp);
            }

            result.Sort();
            return(result);
        }
示例#6
0
        public static List <string> GetRecipeList(string pathBCSV, string fn = "RecipeCraftParam.bcsv")
        {
            var path = Path.Combine(pathBCSV, fn);
            var data = File.ReadAllBytes(path);
            var bcsv = new BCSV(data);

            var dict    = bcsv.GetFieldDictionary();
            var frecipe = dict[0x54706054];
            var fitemID = dict[0x89A3482C];

            var items = GameInfo.Strings.itemlist;

            var result = new List <string>();

            for (int i = 0; i < bcsv.EntryCount; i++)
            {
                var iid  = bcsv.ReadValue(i, fitemID);
                var ival = ushort.Parse(iid);

                var rid  = bcsv.ReadValue(i, frecipe);
                var rval = ushort.Parse(rid);

                var kvp = $"{{0x{rval:X3}, {ival:00000}}}, // {items[ival]}";
                result.Add(kvp);
            }

            result.Sort();
            return(result);
        }
示例#7
0
        public static Dictionary <ItemKind, ushort> GetItemStackDict(string pathBCSV, string fn = "ItemKind.bcsv")
        {
            var path = Path.Combine(pathBCSV, fn);
            var data = File.ReadAllBytes(path);
            var bcsv = new BCSV(data);

            var dict   = bcsv.GetFieldDictionary();
            var fStack = dict[0x4C9BA961]; // MultiHoldMaxNum
            var fKind  = dict[0x87BF00E8]; // Label

            // clothing is split out more granularly in ItemKind and would cause errors
            // since it's not likely to ever be stackable, we can skip
            // none-type can be skipped and doesn't exist in ItemKind either
            List <string> skipLabels = new()
            {
                "TopsDefault",
                "Tops",
                "OnePiece",
                "MarineSuit",
                "BottomsDefault",
                "Bottoms",
                "Shoes",
                "None"
            };

            var result = new Dictionary <ItemKind, ushort>();

            for (int i = 0; i < bcsv.EntryCount; i++)
            {
                var stack = bcsv.ReadValue(i, fStack);
                switch (stack)
                {
                case "-1":     // for some reason turnips have a stack value of -1, should be 10...
                    stack = "10";
                    break;

                case "0":     // the game stores items that cannot be stacked as 0, so technically they stack to 1
                    stack = "1";
                    break;
                }

                var stackval = ushort.Parse(stack);
                var kind     = bcsv.ReadValue(i, fKind).TrimEnd('\0');
                if (skipLabels.Contains(kind))
                {
                    continue;
                }

                kind = "Kind_" + kind;
                if (!Enum.TryParse <ItemKind>(kind, out var k))
                {
                    throw new InvalidEnumArgumentException($"{kind} is not a known enum value @ index {i}. Update the enum index first.");
                }
                result.Add(k, stackval);
            }

            return(result);
        }
示例#8
0
        public static void Dump(string path, string dest, string delim = "\t")
        {
            var data   = File.ReadAllBytes(path);
            var bcsv   = new BCSV(data);
            var result = bcsv.ReadCSV(delim);

            File.WriteAllLines(dest, result);
            Console.WriteLine($"Dumped to CSV: {path}");
        }
示例#9
0
        public static ushort[] GetItemMenuIconArray(string pathBCSV, string fn = "ItemParam.bcsv")
        {
            var path = Path.Combine(pathBCSV, fn);
            var data = File.ReadAllBytes(path);
            var bcsv = new BCSV(data);

            var dict  = bcsv.GetFieldDictionary();
            var fType = dict[0x348D7B06];
            var fID   = dict[0x54706054];

            var    types = new Dictionary <ushort, ItemMenuIconType>();
            ushort max   = 0;

            for (int i = 0; i < bcsv.EntryCount; i++)
            {
                var id   = bcsv.ReadValue(i, fID);
                var ival = ushort.Parse(id);
                var type = bcsv.ReadValue(i, fType).TrimEnd('\0');

                if (type.StartsWith("0x"))
                {
                    type = $"_{type}"; // enum name can't start with number
                }
                if (!Enum.TryParse <ItemMenuIconType>(type, out var k))
                {
                    throw new InvalidEnumArgumentException($"{type} is not a known enum value @ index {i}. Update the enum index first.");
                }
                types.Add(ival, k);

                if (ival > max)
                {
                    max = ival;
                }
            }

            ushort[] result = new ushort[max + 1];
            foreach (var kvp in types)
            {
                result[kvp.Key] = (ushort)kvp.Value;
            }

            return(result);
        }
示例#10
0
        private static IEnumerable<string> GetPossibleEnumValues(string pathBCSV, string fn, uint key)
        {
            var path = Path.Combine(pathBCSV, fn);
            var data = File.ReadAllBytes(path);
            var bcsv = new BCSV(data);

            var dict = bcsv.GetFieldDictionary();
            var fType = dict[key];

            var types = new HashSet<string>();
            for (int i = 0; i < bcsv.EntryCount; i++)
            {
                var type = bcsv.ReadValue(i, fType).TrimEnd('\0');
                if (!types.Contains(type))
                    types.Add(type);
            }

            return types;
        }
示例#11
0
        public static byte[] GetItemTypeArray(string pathBCSV, string fn = "ItemParam.bcsv")
        {
            var path = Path.Combine(pathBCSV, fn);
            var data = File.ReadAllBytes(path);
            var bcsv = new BCSV(data);

            var dict  = bcsv.GetFieldDictionary();
            var fType = dict[0xFC275E86];
            var fID   = dict[0x54706054];

            var    types = new Dictionary <ushort, ItemKind>();
            ushort max   = 0;

            for (int i = 0; i < bcsv.EntryCount; i++)
            {
                var id   = bcsv.ReadValue(i, fID);
                var ival = ushort.Parse(id);
                var type = bcsv.ReadValue(i, fType).TrimEnd('\0');

                if (!Enum.TryParse <ItemKind>(type, out var k))
                {
                    throw new InvalidEnumArgumentException($"{type} is not a known enum value @ index {i}.");
                }
                types.Add(ival, k);

                if (ival > max)
                {
                    max = ival;
                }
            }

            byte[] result = new byte[max + 1];
            foreach (var kvp in types)
            {
                result[kvp.Key] = (byte)kvp.Value;
            }

            return(result);
        }
示例#12
0
        public static IEnumerable <string> GetItemRemakeColors(string pathBCSV, string fn = "ItemRemake.bcsv")
        {
            var path = Path.Combine(pathBCSV, fn);
            var data = File.ReadAllBytes(path);
            var bcsv = new BCSV(data);

            var dict = bcsv.GetFieldDictionary();

            var fid = dict[0xFD9AF1E1]; // ItemUniqueID
            //var fct = dict[0x29ECB129]; // RemakeKitNum
            var rid = dict[0x54706054]; // UniqueID
            // var unk = dict[0xD4F43B0B]; //
            var b00 = dict[0x1B98FDF8]; // ReBodyPattern0Color0
            var b01 = dict[0xA3249A9D]; // ReBodyPattern0Color1
            var b10 = dict[0xF45A96C6]; // ReBodyPattern1Color0
            var b11 = dict[0x4CE6F1A3]; // ReBodyPattern1Color1
            var b20 = dict[0x1F6D2DC5]; // ReBodyPattern2Color0
            var b21 = dict[0xA7D14AA0]; // ReBodyPattern2Color1
            var b30 = dict[0xF0AF46FB]; // ReBodyPattern3Color0
            var b31 = dict[0x4813219E]; // ReBodyPattern3Color1
            var b40 = dict[0x12735D82]; // ReBodyPattern4Color0
            var b41 = dict[0xAACF3AE7]; // ReBodyPattern4Color1
            var b50 = dict[0xFDB136BC]; // ReBodyPattern5Color0
            var b51 = dict[0x450D51D9]; // ReBodyPattern5Color1
            var b60 = dict[0x16868DBF]; // ReBodyPattern6Color0
            var b61 = dict[0xAE3AEADA]; // ReBodyPattern6Color1
            var b70 = dict[0xF944E681]; // ReBodyPattern7Color0
            var b71 = dict[0x41F881E4]; // ReBodyPattern7Color1
            var bct = dict[0xB0304B0D]; // ReBodyPatternNum
            var f00 = dict[0x545F8769]; // ReFabricPattern0Color0
            var f01 = dict[0xECE3E00C]; // ReFabricPattern0Color1
            var fvf = dict[0x62C23ED0]; // ReFabricPattern0VisibleOff
            var f10 = dict[0xBB9DEC57]; // ReFabricPattern1Color0
            var f11 = dict[0x03218B32]; // ReFabricPattern1Color1
            var f20 = dict[0x50AA5754]; // ReFabricPattern2Color0
            var f21 = dict[0xE8163031]; // ReFabricPattern2Color1
            var f30 = dict[0xBF683C6A]; // ReFabricPattern3Color0
            var f31 = dict[0x07D45B0F]; // ReFabricPattern3Color1
            var f40 = dict[0x5DB42713]; // ReFabricPattern4Color0
            var f41 = dict[0xE5084076]; // ReFabricPattern4Color1
            var f50 = dict[0xB2764C2D]; // ReFabricPattern5Color0
            var f51 = dict[0x0ACA2B48]; // ReFabricPattern5Color1
            var f60 = dict[0x5941F72E]; // ReFabricPattern6Color0
            var f61 = dict[0xE1FD904B]; // ReFabricPattern6Color1
            var f70 = dict[0xB6839C10]; // ReFabricPattern7Color0
            var f71 = dict[0x0E3FFB75]; // ReFabricPattern7Color1

            var str = GameInfo.Strings.itemlist;
            var bc0 = new[] { b00, b10, b20, b30, b40, b50, b60, b70 };
            var bc1 = new[] { b01, b11, b21, b31, b41, b51, b61, b71 };
            var fc0 = new[] { f00, f10, f20, f30, f40, f50, f60, f70 };
            var fc1 = new[] { f01, f11, f21, f31, f41, f51, f61, f71 };

            for (int i = 0; i < bcsv.EntryCount; i++)
            {
                var index = i;
                int get(BCSVFieldParam f)
                {
                    var val = bcsv.ReadValue(index, f);

                    return(int.Parse(val));
                }

                string getArr(IEnumerable <BCSVFieldParam> arr)
                {
                    var entries = arr.Select(get).Select(z => z.ToString("00"));
                    var bytes   = string.Join(", ", entries);

                    return($"new byte[] {{{bytes}}}");
                }

                var vbc0 = getArr(bc0);
                var vbc1 = getArr(bc1);
                var vfc0 = getArr(fc0);
                var vfc1 = getArr(fc1);

                var vfvf = get(fvf) == 1;
                var ct   = get(bct);

                var vid = get(fid);
                //var vct = get(fct);
                var vrd = get(rid);

                // (short index, ushort id, sbyte count, byte[] bc0, byte[] bc1, byte[] fc0, byte[] fc1, bool fp0)
                yield return($"{{{vrd:0000}, new {nameof(ItemRemakeInfo)}({vrd:0000}, {vid:00000}, {(sbyte)ct,2}, {vbc0}, {vbc1}, {vfc0}, {vfc1}, {(vfvf ? " true": "false")})}}, // {str[vid]}");
            }
        }
示例#13
0
 public static IReadOnlyDictionary <uint, BCSVFieldParam> GetFieldDictionary(this BCSV csv)
 {
     return(csv.FieldOffsets.ToDictionary(z => z.ColumnKey, z => z));
 }