private async Task DropItem(Item item, bool first, CancellationToken token) { // Exit out of any menus. if (first) { for (int i = 0; i < 3; i++) { await Click(SwitchButton.B, 0_400, token).ConfigureAwait(false); } } var itemName = GameInfo.Strings.GetItemName(item); LogUtil.LogInfo($"Injecting Item: {item.DisplayItemId:X4} ({itemName}).", Config.IP); // Inject item. var data = item.ToBytesClass(); var poke = SwitchCommand.Poke(Config.Offset, data); await Connection.SendAsync(poke, token); await Task.Delay(0_300, token).ConfigureAwait(false); // Open player inventory and open the currently selected item slot -- assumed to be the config offset. await Click(SwitchButton.X, 1_100, token).ConfigureAwait(false); await Click(SwitchButton.A, 0_500, token).ConfigureAwait(false); // Navigate down to the "drop item" option. var downCount = item.GetItemDropOption(); for (int i = 0; i < downCount; i++) { await Click(SwitchButton.DDOWN, 0_400, token).ConfigureAwait(false); } // Drop item, close menu. await Click(SwitchButton.A, 0_400, token).ConfigureAwait(false); await Click(SwitchButton.X, 0_400, token).ConfigureAwait(false); // Exit out of any menus (fail-safe) for (int i = 0; i < 2; i++) { await Click(SwitchButton.B, 0_400, token).ConfigureAwait(false); } }
private async Task CleanUp(CancellationToken token) { LogUtil.LogInfo("Picking up leftover items during idle time.", Config.IP); // Exit out of any menus. for (int i = 0; i < 3; i++) { await Click(SwitchButton.B, 0_400, token).ConfigureAwait(false); } // Pick up and delete. for (int i = 0; i < PickupCount; i++) { await Click(SwitchButton.Y, 2_000, token).ConfigureAwait(false); var poke = SwitchCommand.Poke(Config.Offset, Item.NONE.ToBytes()); await Connection.SendAsync(poke, token); await Task.Delay(1_000, token).ConfigureAwait(false); } }