Last active
February 12, 2023 09:15
-
-
Save Schroedi/bae705b8ca5c635fb7b7705ee6ce3c7b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static async Task<bool> FastMoveFromDevice(int itemId) | |
{ | |
// get the generic control, regardless of whether we have a 4 or 5 slot device | |
var inventoryControlWrapper = MapDevice.InventoryControl; | |
// accessing the items works on both | |
var itemCount = inventoryControlWrapper.Inventory.Items.Count; | |
var item = inventoryControlWrapper.Inventory.FindItemById(itemId); | |
if (item == null) | |
{ | |
GlobalLog.Error($"[FastMoveFromDevice] Fail to find item {itemId} in Map Device."); | |
return false; | |
} | |
var itemName = item.FullName; | |
GlobalLog.Debug($"[FastMoveFromDevice] Fast moving \"{itemName}\" (id:{itemId}) from Map Device."); | |
var moved = FastMoveResult.Failed; | |
if (LokiPoe.InGameState.MasterDeviceUi.IsFiveSlotDevice) | |
{ | |
foreach (var ctrl in LokiPoe.InGameState.MasterDeviceUi.FiveSlotInventoryControl) | |
{ | |
if (ctrl.CustomTabItem?.LocalId != itemId) | |
continue; | |
moved = ctrl.FastMove(); | |
break; | |
} | |
} | |
else | |
{ | |
moved = inventoryControlWrapper.FastMove(item.LocalId); | |
} | |
if (moved != FastMoveResult.None) | |
{ | |
GlobalLog.Error($"[FastMoveFromDevice] Fast move error: \"{moved}\"."); | |
return false; | |
} | |
if (await Wait.For(() => inventoryControlWrapper.Inventory.Items.Count == itemCount - 1, "fast move")) | |
{ | |
GlobalLog.Debug( | |
$"[FastMoveFromDevice] \"{itemName}\" {itemId} has been successfully fast moved from Map Device."); | |
return true; | |
} | |
GlobalLog.Error($"[FastMoveFromDevice] Fast move timeout for \"{itemName}\" {itemId} in Map Device."); | |
return false; | |
} | |
private static class MapDevice | |
{ | |
public static bool IsOpen => World.CurrentArea.IsHideoutArea | |
? LokiPoe.InGameState.MasterDeviceUi.IsOpened | |
: LokiPoe.InGameState.MapDeviceUi.IsOpened; | |
public static InventoryControlWrapper InventoryControl => World.CurrentArea.IsHideoutArea | |
? LokiPoe.InGameState.MasterDeviceUi.InventoryControl | |
: LokiPoe.InGameState.MapDeviceUi.InventoryControl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment