/// <summary>
    /// Returns null if settings selected bot is active
    /// </summary>
    /// <returns>Active readwriter</returns>
    public IRAMReadWriter GetCurrentlyActiveReadWriter()
    {
        InjectionProtocol currentIP = UI_Settings.GetInjectionProtocol();
        IRAMReadWriter    toRet     = null;

        switch (currentIP)
        {
        case InjectionProtocol.Sysbot:
            if (CurrentSysBot.Connected)
            {
                toRet = CurrentSysBot;
            }
            break;

        case InjectionProtocol.UsbBot:
#if UNITY_STANDALONE || UNITY_EDITOR
            if (CurrentUSBBot.Connected)
            {
                toRet = CurrentUSBBot;
            }
#elif PLATFORM_ANDROID
            if (CurrentUSBBotAndroid.Connected)
            {
                toRet = CurrentUSBBotAndroid;
            }
#endif
            break;
        }
        return(toRet);
    }
Example #2
0
    public void ReadFromSourceUSBA()
    {
        uint offset = sbc.GetDefaultOffset();
        AutoInjector platformInjector;
#if UNITY_STANDALONE || UNITY_EDITOR
        platformInjector = usbInjector;
#else
        platformInjector = usbaInjector;
#endif
        platformInjector.SetWriteOffset(offset);
        platformInjector.ValidateEnabled = UI_Settings.GetValidateData();
        try
        {
            InjectionResult injectionResult = platformInjector.Read(true);
            if (injectionResult != InjectionResult.Success)
            {
                Debug.Log(injectionResult.ToString());
#if UNITY_STANDALONE || UNITY_EDITOR
                PopupHelper.CreateError(injectionResult.ToString(), 2f);
#endif
            }
        }
        catch (Exception ex)
        {
            Debug.LogError(ex.Message);
            UISB.ConnectedText.text = (ex.Message);
            UISB.SetConnected(false);
#if UNITY_STANDALONE || UNITY_EDITOR
            PopupHelper.CreateError(ex.Message, 2f);
#endif
        }
    }
    public void WriteToSource()
    {
        uint offset = sbc.GetDefaultOffset();

        injector.SetWriteOffset(offset);
        injector.ValidateEnabled = UI_Settings.GetValidateData();
        try
        {
            InjectionResult injectionResult = injector.Write(true);
            if (injectionResult == InjectionResult.Success)
            {
                PlayHappyParticles();
            }
            else
            {
                Debug.Log(injectionResult.ToString());
            }
        }
        catch (Exception ex)
        {
            Debug.LogError(ex.Message);
            UISB.ConnectedText.text = (ex.Message);
            UISB.SetConnected(val: false);
        }
    }
Example #4
0
    // Start is called before the first frame update
    void Start()
    {
        CurrentInstance = this;
        var cMode = UI_Settings.GetCatalogueMode();

        Execute(!cMode);
    }
Example #5
0
 public void UpdateUISettingsStatus()
 {
     UI_Settings.SetActive(!UI_Settings.activeInHierarchy);
     if (UI_Settings.activeInHierarchy == false)
     {
         UI_InfoPanel.SetActive(false);
     }
 }
Example #6
0
        public void UnFreezeBytes(uint offset)
        {
            lock (_sync)
            {
                SendInternal(SwitchCommand.UnFreeze(offset));

                // wait for freezes to clear and poll again
                Thread.Sleep(1 + UI_Settings.GetThreadSleepTime());
            }
        }
Example #7
0
        public void FreezeBytes(byte[] data, uint offset)
        {
            lock (_sync)
            {
                SendInternal(SwitchCommand.Freeze(offset, data));

                // wait for it to create freezers
                Thread.Sleep((data.Length / 256) + UI_Settings.GetThreadSleepTime());
            }
        }
Example #8
0
        public void Configure(string name, string value)
        {
            lock (_sync)
            {
                AndroidUSBUtils.CurrentInstance.WriteToEndpoint(SwitchCommand.Configure(name, value));

                // give it time to push data back
                Thread.Sleep(1 + UI_Settings.GetThreadSleepTime());
            }
        }
Example #9
0
        public void UnFreezeBytes(uint offset)
        {
            lock (_sync)
            {
                SendInternal(SwitchCommand.UnFreeze(offset));

                // give it time to push data back
                Thread.Sleep(1 + UI_Settings.GetThreadSleepTime());
            }
        }
Example #10
0
        public void Configure(string name, string value)
        {
            lock (_sync)
            {
                SendInternal(SwitchCommand.Configure(name, value));

                // give it time to push data back
                Thread.Sleep(1 + UI_Settings.GetThreadSleepTime());
            }
        }
Example #11
0
        public void FreezeBytes(byte[] data, uint offset)
        {
            lock (_sync)
            {
                SendInternal(SwitchCommand.Freeze(offset, data));

                // give it time to push data back
                Thread.Sleep((data.Length / 256) + UI_Settings.GetThreadSleepTime());
            }
        }
Example #12
0
        public void UnfreezeAll()
        {
            lock (_sync)
            {
                var cmd = SwitchCommand.FreezeClear();
                SendInternal(cmd);

                // give it time to push data back
                Thread.Sleep(1 + UI_Settings.GetThreadSleepTime());
            }
        }
Example #13
0
    private void Start()
    {
        SetConnected(val: false);
        DefaultIp     = PlayerPrefs.GetString(IPKEY, DefaultIp);
        DefaultSocket = PlayerPrefs.GetString(SOCKETKEY, DefaultSocket);
        IP.text       = (DefaultIp);
        Socket.text   = (DefaultSocket);

        SetInjectionProtocol(UI_Settings.GetInjectionProtocol());

        LastLoadedUI_Sysbot = this;
    }
Example #14
0
    public void GetCommandFromInventory(string commandName = "")
    {
        CommandPrefix = UI_Settings.GetPrefix();
        var items = UI_ACItemGrid.LastInstanceOfItemGrid.Items;

        if (!IsItemArrayInventorySafe(items.ToArray(), out var fail))
        {
            int failIndex = items.IndexOf(fail);
            PopupHelper.CreateError($"Item {failIndex} is a field item, these items cannot be in an inventory.", 3);
            return;
        }

        var  hexes        = new List <string>();
        int  count        = 0;
        bool tooManyItems = false;

        foreach (var item in items)
        {
            if (item.ItemId != Item.NONE)
            {
                if (count > 8 && commandName == "")
                {
                    tooManyItems = true;
                    break;
                }

                var itemAsHex = item.ToBytesClass();
                var asString  = BitConverter.ToString(itemAsHex).Replace("-", "");
                asString = flipEndianness(asString).TrimStart('0');
                hexes.Add(asString);
                count++;
            }
        }

        if (hexes.Count == 0)
        {
            PopupHelper.CreateError("No items in inventory squares. Search for an item and use the blue button to set it to an inventory square.", 3);
            return;
        }

        var itemshexSet = string.Join(" ", hexes.ToArray());
        var toCopy      = $"{CommandPrefix}{(commandName == "" ? "drop" : commandName)} {itemshexSet}";

        GUIUtility.systemCopyBuffer = toCopy;
        if (!tooManyItems || commandName != "")
        {
            UI_Popup.CurrentInstance.CreatePopupMessage(1.25f, $"Copied\r\n{toCopy}\r\nto clipboard.", () => {});
        }
        else
        {
            UI_Popup.CurrentInstance.CreatePopupMessage(5f, $"<color=red>You have too many items! Only the first 9 have been transferred to the command!</color>\r\n\r\nCopied\r\n{toCopy}\r\nto clipboard.", () => { });
        }
    }
Example #15
0
        public byte[] GetVersion()
        {
            lock (_sync)
            {
                var cmd = SwitchCommand.Version();
                AndroidUSBUtils.CurrentInstance.WriteToEndpoint(cmd);

                // give it time to push data back
                Thread.Sleep(1 + UI_Settings.GetThreadSleepTime());
                var buffer = AndroidUSBUtils.CurrentInstance.ReadEndpoint(9);
                return(Decoder.ConvertHexByteStringToBytes(buffer));
            }
        }
Example #16
0
        public byte[] PeekMainPointer(long[] jumps, int length)
        {
            lock (_sync)
            {
                var cmd = SwitchCommand.PeekMainPointer(jumps, length);
                SendInternal(cmd);

                // give it time to push data back
                Thread.Sleep((length / 256) + UI_Settings.GetThreadSleepTime());
                var buffer = new byte[(length * 2) + 1];
                var _      = ReadInternal(buffer);
                return(Decoder.ConvertHexByteStringToBytes(buffer));
            }
        }
Example #17
0
        public void WriteBytes(byte[] data, uint offset)
        {
            if (data.Length > MaximumTransferSize)
            {
                WriteBytesLarge(data, offset);
            }
            lock (_sync)
            {
                SendInternal(SwitchCommand.PokeRaw(offset, data));

                // give it time to push data back
                Thread.Sleep((data.Length / 256) + UI_Settings.GetThreadSleepTime());
            }
        }
Example #18
0
        public void WriteBytes(byte[] data, ulong offset, RWMethod method = RWMethod.Heap)
        {
            if (data.Length > MaximumTransferSize)
            {
                WriteBytesLarge(data, offset, method);
            }
            lock (_sync)
            {
                SendInternal(SwitchCommandMethodHelper.GetPokeCommand(offset, data, method, true));

                // give it time to push data back
                Thread.Sleep((data.Length / 256) + UI_Settings.GetThreadSleepTime());
            }
        }
Example #19
0
        public byte GetFreezeCount()
        {
            lock (_sync)
            {
                var cmd = SwitchCommand.FreezeCount();
                SendInternal(cmd);

                // give it time to push data back
                Thread.Sleep(1 + UI_Settings.GetThreadSleepTime());
                var buffer = new byte[3];
                var _      = ReadInternal(buffer);
                return(Decoder.ConvertHexByteStringToBytes(buffer)[0]);
            }
        }
Example #20
0
        public byte[] GetVersion()
        {
            lock (_sync)
            {
                var cmd = SwitchCommand.Version();
                SendInternal(cmd);

                // give it time to push data back
                Thread.Sleep(1 + UI_Settings.GetThreadSleepTime());
                var buffer = new byte[9];
                var _      = ReadInternal(buffer);
                return(buffer);
            }
        }
Example #21
0
        public ulong FollowMainPointer(long[] jumps)
        {
            lock (_sync)
            {
                var cmd = SwitchCommand.FollowMainPointer(jumps);
                SendInternal(cmd);

                // give it time to push data back
                Thread.Sleep(1 + UI_Settings.GetThreadSleepTime());
                var buffer = new byte[17];
                var _      = ReadInternal(buffer);
                var bytes  = Decoder.ConvertHexByteStringToBytes(buffer);
                return(BitConverter.ToUInt64(bytes, 0));
            }
        }
Example #22
0
        public void WriteBytes(byte[] data, ulong offset, RWMethod method = RWMethod.Heap)
        {
            if (data.Length > MaximumTransferSize)
            {
                WriteBytesLarge(data, offset, method);
            }
            else
            {
                lock (_sync)
                {
                    AndroidUSBUtils.CurrentInstance.WriteToEndpoint(SwitchCommandMethodHelper.GetPokeCommand(offset, data, method, true));

                    // give it time to push data back
                    Thread.Sleep((data.Length / 256) + UI_Settings.GetThreadSleepTime());
                }
            }
        }
Example #23
0
    public void FillAll()
    {
        if (SearchWindow.IsNoItemMode)
        {
            return;
        }
        bool isCatalogueMode = UI_Settings.GetCatalogueMode();

        for (int i = 0; i < 40; ++i)
        {
            lastItem = ItemGrid.GetItemAt(i);
            if (!(isCatalogueMode && !lastItem.IsNone))
            {
                FillSelected(i);
            }
        }
    }
        public void WriteBytes(byte[] data, uint offset)
        {
            if (data.Length > MaximumTransferSize)
            {
                WriteBytesLarge(data, offset);
            }
            else
            {
                lock (_sync)
                {
                    AndroidUSBUtils.CurrentInstance.WriteToEndpoint(SwitchCommand.PokeRaw(offset, data));

                    // give it time to push data back
                    Thread.Sleep((data.Length / 256) + UI_Settings.GetThreadSleepTime());
                }
            }
        }
Example #25
0
        public byte[] ReadBytes(ulong offset, int length, RWMethod method = RWMethod.Heap)
        {
            if (length > MaximumTransferSize)
            {
                return(ReadBytesLarge(offset, length, method));
            }
            lock (_sync)
            {
                byte[] cmd = SwitchCommandMethodHelper.GetPeekCommand(offset, length, method, true);
                AndroidUSBUtils.CurrentInstance.WriteToEndpoint(cmd);

                // give it time to push data back
                Thread.Sleep((length / 256) + UI_Settings.GetThreadSleepTime());

                byte[] buffer = AndroidUSBUtils.CurrentInstance.ReadEndpoint(length);
                return(buffer);
            }
        }
Example #26
0
        public byte[] ReadBytes(uint offset, int length)
        {
            if (length > MaximumTransferSize)
            {
                return(ReadBytesLarge(offset, length));
            }
            lock (_sync)
            {
                var cmd = SwitchCommand.Peek(offset, length);
                SendInternal(cmd);

                // give it time to push data back
                Thread.Sleep((length / 256) + UI_Settings.GetThreadSleepTime());
                var buffer = new byte[(length * 2) + 1];
                var _      = ReadInternal(buffer);
                return(Decoder.ConvertHexByteStringToBytes(buffer));
            }
        }
        public byte[] ReadBytes(uint offset, int length)
        {
            if (length > MaximumTransferSize)
            {
                return(ReadBytesLarge(offset, length));
            }
            lock (_sync)
            {
                byte[] cmd = SwitchCommand.PeekRaw(offset, length);
                AndroidUSBUtils.CurrentInstance.WriteToEndpoint(cmd);

                // give it time to push data back
                Thread.Sleep((length / 256) + UI_Settings.GetThreadSleepTime());

                byte[] buffer = AndroidUSBUtils.CurrentInstance.ReadEndpoint(length);
                return(buffer);
            }
        }
Example #28
0
    IEnumerator KeepAliveLoop(Func <Item, bool> processItem, ReferenceContainer <float> progress, Func <Item, bool> processItemLayer2 = null)
    {
        bool exitToken   = false;
        int  refreshRate = UI_Settings.GetThreadSleepTime();

        UI_Popup.CurrentInstance.CreatePopupChoice($"Your map is being continuously refreshed at minimum {refreshRate}ms per acre. You may decrease this value in settings, but the tradeoff may be stability.\r\nTo see replenished items, go in & out of a building.", "Stop refreshing", () => { exitToken = true; });
        while (!exitToken)
        {
            LastRefresherTime.text = $"Last refresher run:\r\n{DateTime.Now:dddd, dd MMMM yyyy HH:mm:ss}";
            StartCoroutine(functionTiles(processItem, progress, processItemLayer2, true));
            mapFunctionRunning = true;
            while (mapFunctionRunning && !exitToken)
            {
                yield return(new WaitForSeconds(1f));
            }
        }

        CancelCurrentFunction();
    }
Example #29
0
        public byte[] ReadBytes(ulong offset, int length, RWMethod method = RWMethod.Heap)
        {
            if (length > MaximumTransferSize)
            {
                return(ReadBytesLarge(offset, length, method));
            }
            lock (_sync)
            {
                var cmd = SwitchCommandMethodHelper.GetPeekCommand(offset, length, method, true);
                SendInternal(cmd);

                // give it time to push data back
                Thread.Sleep((length / 256) + UI_Settings.GetThreadSleepTime());

                var buffer = new byte[length];
                var _      = ReadInternal(buffer);
                //return Decoder.ConvertHexByteStringToBytes(buffer);
                return(buffer);
            }
        }
    public void ReadFromSourceUSBA()
    {
        uint offset = sbc.GetDefaultOffset();

        usbaInjector.SetWriteOffset(offset);
        usbaInjector.ValidateEnabled = UI_Settings.GetValidateData();
        try
        {
            InjectionResult injectionResult = usbaInjector.Read(true);
            if (injectionResult != InjectionResult.Success)
            {
                Debug.Log(injectionResult.ToString());
            }
        }
        catch (Exception ex)
        {
            Debug.LogError(ex.Message);
            UISB.ConnectedText.text = (ex.Message);
            UISB.SetConnected(val: false);
        }
    }