public LiveHeXController(ISaveFileProvider boxes, IPKMView editor, InjectorCommunicationType ict)
        {
            SAV    = boxes;
            Editor = editor;
            var ValidVers = RamOffsets.GetValidVersions(boxes.SAV);

            Bot = new PokeSysBotMini(ValidVers[0], ict);
        }
Exemplo n.º 2
0
 public PokeSysBotMini(LiveHeXVersion lv, InjectorCommunicationType ict)
 {
     Version   = lv;
     com       = RamOffsets.GetCommunicator(lv, ict);
     BoxStart  = RamOffsets.GetB1S1Offset(lv);
     SlotSize  = RamOffsets.GetSlotSize(lv);
     SlotCount = RamOffsets.GetSlotCount(lv);
     GapSize   = RamOffsets.GetGapSize(lv);
 }
        public void WriteActiveSlot(int box, int slot)
        {
            var pkm = Editor.PreparePKM();

            pkm.ResetPartyStats();
            var data = RamOffsets.WriteBoxData(Bot.Version) ? pkm.EncryptedBoxData : pkm.EncryptedPartyData;

            Bot.SendSlot(data, box, slot);
        }
        public void ReadBox(int box)
        {
            var sav  = SAV.SAV;
            var len  = SAV.SAV.BoxSlotCount * (RamOffsets.GetSlotSize(Bot.Version) + RamOffsets.GetGapSize(Bot.Version));
            var data = Bot.ReadBox(box, len);

            sav.SetBoxBinary(data, box);
            SAV.ReloadSlots();
        }
Exemplo n.º 5
0
        // Reflection method
        public static bool ReadBlockFromString(PokeSysBotMini psb, SaveFile sav, string block, out byte[]?read)
        {
            read = null;
            var obj = RamOffsets.GetOffsets(psb.Version);

            if (obj == null)
            {
                return(false);
            }
            try
            {
                var offset = obj.GetType().GetField(block).GetValue(obj);
                if (offset is uint and 0)
                {
                    return(false);
                }
                var    allblocks = sav.GetType().GetProperty("Blocks").GetValue(sav);
                var    blockprop = allblocks.GetType().GetProperty(block);
                object data;
                if (allblocks is SCBlockAccessor scba && blockprop == null)
                {
                    var key = allblocks.GetType().GetField(block, BindingFlags.NonPublic | BindingFlags.Static).GetValue(allblocks);
                    data = scba.GetBlock((uint)key);
                }
                else
                {
                    data = blockprop.GetValue(allblocks);
                }

                if (data is SaveBlock sb)
                {
                    read = psb.com.ReadBytes((uint)offset, sb.Data.Length);
                    read.CopyTo(sb.Data, sb.Offset);
                }
                else if (data is SCBlock scb)
                {
                    read = psb.com.ReadBytes((ulong)offset, scb.Data.Length);
                    read.CopyTo(scb.Data, 0);
                }
                else
                {
                    return(false);
                }
                return(true);
            }