public async Task CloseGate(uint Offset, CancellationToken token)
        {
            // Navigate through dialog with Dodo to close the gate, then inject empty dodo bytes
            await Task.Delay(0_500, token).ConfigureAwait(false);

            var Hold = SwitchCommand.Hold(SwitchButton.L);
            await Connection.SendAsync(Hold, token).ConfigureAwait(false);

            await Task.Delay(0_700, token).ConfigureAwait(false);

            await BotRunner.Click(SwitchButton.A, 3_000, token).ConfigureAwait(false);

            await BotRunner.Click(SwitchButton.A, 1_000, token).ConfigureAwait(false);

            await BotRunner.Click(SwitchButton.A, 2_000, token).ConfigureAwait(false);

            await BotRunner.Click(SwitchButton.A, 3_000, token).ConfigureAwait(false);

            for (int i = 0; i < 5; ++i)
            {
                await BotRunner.Click(SwitchButton.B, 1_000, token).ConfigureAwait(false);
            }

            await Task.Delay(0_500, token).ConfigureAwait(false);

            var Release = SwitchCommand.Release(SwitchButton.L);
            await Connection.SendAsync(Release, token).ConfigureAwait(false);

            await Connection.WriteBytesAsync(new byte[5], Offset, token).ConfigureAwait(false);

            DodoCode = string.Empty;
        }
Exemplo n.º 2
0
    public async Task DoSocketQueue(bool isNetwork, CancellationToken token)
    {
        while (!token.IsCancellationRequested)
        {
            if (ExecutionQueue.TryDequeue(out var item))
            {
                byte[] command = Array.Empty <byte>();
                switch (item.PType)
                {
                case PressType.ButtonPress: command = SwitchCommand.Hold(item.ButtonToPress, isNetwork); break;

                case PressType.ButtonRelease: command = SwitchCommand.Release(item.ButtonToPress, isNetwork); break;

                case PressType.Joystick: command = SwitchCommand.SetStick(item.StickToMove, item.X, item.Y); break;
                }
                try { Connection.CurrentConnection.SendBytes(command); } catch { }
            }

            await Task.Delay(1, token).ConfigureAwait(false);
        }
    }
        public async Task GetDodoCode(ulong CoordinateAddress, uint Offset, bool isRetry, CancellationToken token)
        {
            // Navigate through dialog with Dodo to open gates and to get Dodo code.
            await Task.Delay(0_500, token).ConfigureAwait(false);

            var Hold = SwitchCommand.Hold(SwitchButton.L);
            await Connection.SendAsync(Hold, token).ConfigureAwait(false);

            await Task.Delay(0_700, token).ConfigureAwait(false);

            await BotRunner.Click(SwitchButton.A, 4_000, token).ConfigureAwait(false);

            await BotRunner.Click(SwitchButton.A, 2_000, token).ConfigureAwait(false);

            if (!isRetry)
            {
                await BotRunner.Click(SwitchButton.A, 2_100, token).ConfigureAwait(false);
            }
            await BotRunner.Click(SwitchButton.DDOWN, 0_500, token).ConfigureAwait(false);

            await BotRunner.Click(SwitchButton.A, 2_500, token).ConfigureAwait(false);

            await BotRunner.Click(SwitchButton.A, 1_000, token).ConfigureAwait(false);

            await BotRunner.Click(SwitchButton.DDOWN, 0_500, token).ConfigureAwait(false);

            await BotRunner.Click(SwitchButton.A, 2_000, token).ConfigureAwait(false);

            await BotRunner.Click(SwitchButton.A, 1_000, token).ConfigureAwait(false);

            await BotRunner.Click(SwitchButton.A, 20_000, token).ConfigureAwait(false);

            await BotRunner.Click(SwitchButton.A, 1_500, token).ConfigureAwait(false);

            await BotRunner.Click(SwitchButton.DUP, 0_500, token).ConfigureAwait(false);

            await BotRunner.Click(SwitchButton.DUP, 0_500, token).ConfigureAwait(false);

            await BotRunner.Click(SwitchButton.A, 1_500, token).ConfigureAwait(false);

            await BotRunner.Click(SwitchButton.A, 1_000, token).ConfigureAwait(false);

            await BotRunner.Click(SwitchButton.DUP, 0_500, token).ConfigureAwait(false);

            await BotRunner.Click(SwitchButton.A, 2_500, token).ConfigureAwait(false);

            await BotRunner.Click(SwitchButton.A, 1_000, token).ConfigureAwait(false);

            await BotRunner.Click(SwitchButton.A, 1_500, token).ConfigureAwait(false);

            await BotRunner.Click(SwitchButton.A, 2_500, token).ConfigureAwait(false);

            await BotRunner.Click(SwitchButton.A, 3_000, token).ConfigureAwait(false);

            await BotRunner.Click(SwitchButton.A, 2_000, token).ConfigureAwait(false);

            await BotRunner.Click(SwitchButton.A, 2_000, token).ConfigureAwait(false);

            await Task.Delay(0_500, token).ConfigureAwait(false);

            var Release = SwitchCommand.Release(SwitchButton.L);
            await Connection.SendAsync(Release, token).ConfigureAwait(false);

            // Clear incase opening the gate took too long
            for (int i = 0; i < 6; ++i)
            {
                await BotRunner.Click(SwitchButton.B, 1_000, token).ConfigureAwait(false);
            }

            // Obtain Dodo code from offset and store it.
            byte[] bytes = await Connection.ReadBytesAsync(Offset, 0x5, token).ConfigureAwait(false);

            DodoCode = Encoding.UTF8.GetString(bytes, 0, 5);
            LogUtil.LogInfo($"Retrieved Dodo code: {DodoCode}.", Config.IP);

            // Wait for loading screen.
            while (await GetOverworldState(CoordinateAddress, token).ConfigureAwait(false) != OverworldState.Overworld)
            {
                await Task.Delay(0_500, token).ConfigureAwait(false);
            }
        }