Пример #1
0
        public static int ImportPKMs(this SaveFile SAV, IEnumerable <PKM> compat, int boxStart, bool?noSetb)
        {
            int startCount = boxStart * SAV.BoxSlotCount;
            int maxCount   = SAV.BoxCount * SAV.BoxSlotCount;
            int i          = startCount;

            int getbox() => i / SAV.BoxSlotCount;
            int getslot() => i % SAV.BoxSlotCount;

            foreach (var pk in compat)
            {
                int box  = getbox();
                int slot = getslot();
                while (SAV.IsSlotLocked(box, slot))
                {
                    ++i;
                    box  = getbox();
                    slot = getslot();
                }

                int offset = SAV.GetBoxOffset(box) + slot * SAV.SIZE_STORED;
                SAV.SetStoredSlot(pk, offset, noSetb);

                if (++i == maxCount) // Boxes full!
                {
                    break;
                }
            }
            i -= startCount; // actual imported count
            return(i);
        }