/// <summary> /// Tries to get an <see cref="IEnumerable{T}"/> object from the input parameters. /// </summary> /// <param name="data">Binary data</param> /// <param name="pkms">Output result</param> /// <param name="sav">Reference savefile used for PC Binary compatibility checks.</param> /// <returns>True if file object reference is valid, false if none found.</returns> public static bool TryGetPCBoxBin(byte[] data, out IEnumerable <byte[]> pkms, SaveFile?sav) { if (sav == null) { pkms = Array.Empty <byte[]>(); return(false); } var length = data.Length; if (PKX.IsPKM(length / sav.SlotCount) || PKX.IsPKM(length / sav.BoxSlotCount)) { pkms = ArrayUtil.EnumerateSplit(data, length); return(true); } pkms = Array.Empty <byte[]>(); return(false); }
private static HashSet <WC8> GetWC8DB(byte[] wc8bin) => new HashSet <WC8>(ArrayUtil.EnumerateSplit(wc8bin, WC8.Size).Select(d => new WC8(d)));
private static HashSet <WB7> GetWB7DB(byte[] wc7full) => new HashSet <WB7>(ArrayUtil.EnumerateSplit(wc7full, WB7.SizeFull).Select(d => new WB7(d)));
private static HashSet <WC7> GetWC7DB(byte[] wc7bin, byte[] wc7full) => new HashSet <WC7>( ArrayUtil.EnumerateSplit(wc7full, WC7Full.Size).Select(d => new WC7Full(d).Gift) .Concat(ArrayUtil.EnumerateSplit(wc7bin, WC7.Size).Select(d => new WC7(d))));
private static HashSet <WC6> GetWC6DB(byte[] wc6bin, byte[] wc6full) => new HashSet <WC6>( ArrayUtil.EnumerateSplit(wc6full, WC6Full.Size).Select(d => new WC6Full(d).Gift) .Concat(ArrayUtil.EnumerateSplit(wc6bin, WC6.Size).Select(d => new WC6(d))));
private static HashSet <PGF> GetPGFDB(byte[] bin) => new HashSet <PGF>(ArrayUtil.EnumerateSplit(bin, PGF.Size).Select(d => new PGF(d)));
private static HashSet <PCD> GetPCDDB(byte[] bin) => new HashSet <PCD>(ArrayUtil.EnumerateSplit(bin, PCD.Size).Select(d => new PCD(d)));