private IEnumerator FindItemToPick() { if (!GameController.Window.IsForeground()) { yield break; } var window = GameController.Window.GetWindowRectangleTimeCache; var playerPos = GameController.Player.GridPos; List <CustomItem> currentLabels; var morphPath = "Metadata/MiscellaneousObjects/Metamorphosis/MetamorphosisMonsterMarker"; if (Settings.UseWeight) { currentLabels = GameController.Game.IngameState.IngameUi.ItemsOnGroundLabelsVisible .Where(x => x.Address != 0 && x.ItemOnGround?.Path != null && x.ItemOnGround.HasComponent <WorldItem>() && x.IsVisible && x.Label.GetClientRectCache.Center.PointInRectangle(window) && x.CanPickUp && (x.MaxTimeForPickUp.TotalSeconds <= 0) || x.ItemOnGround?.Path == morphPath) .Select(x => new CustomItem(x, GameController.Files, x.ItemOnGround.DistancePlayer, _weightsRules, x.ItemOnGround?.Path == morphPath)) .OrderByDescending(x => x.Weight).ThenBy(x => x.Distance).ToList(); } else { currentLabels = GameController.Game.IngameState.IngameUi.ItemsOnGroundLabelsVisible .Where(x => x.Address != 0 && x.ItemOnGround?.Path != null && x.ItemOnGround.HasComponent <WorldItem>() && x.IsVisible && x.Label.GetClientRectCache.Center.PointInRectangle(window) && x.CanPickUp && (x.MaxTimeForPickUp.TotalSeconds <= 0) || x.ItemOnGround?.Path == morphPath) .Select(x => new CustomItem(x, GameController.Files, x.ItemOnGround.DistancePlayer, _weightsRules, x.ItemOnGround?.Path == morphPath)) .OrderBy(x => x.Distance).ToList(); } GameController.Debug["PickIt"] = currentLabels; var rectangleOfGameWindow = GameController.Window.GetWindowRectangleTimeCache; rectangleOfGameWindow.Inflate(-36, -36); var pickUpThisItem = currentLabels.FirstOrDefault(x => DoWePickThis(x) && x.Distance < Settings.PickupRange && x.GroundItem != null && rectangleOfGameWindow.Intersects(new RectangleF(x.LabelOnGround.Label.GetClientRectCache.Center.X, x.LabelOnGround.Label.GetClientRectCache.Center.Y, 3, 3)) && Misc.CanFitInventory(x)); if (Input.GetKeyState(Settings.PickUpKey.Value) || CanLazyLoot() && ShouldLazyLoot(pickUpThisItem)) { yield return(TryToPickV2(pickUpThisItem)); FullWork = true; } }
private IEnumerator FindItemToPick() { if (!GameController.Window.IsForeground()) { yield break; } if (UpdateCacheList.Value == null) { yield break; } var window = GameController.Window.GetWindowRectangleTimeCache; var rect = new RectangleF(window.X, window.X, window.X + window.Width, window.Y + window.Height); var playerPos = GameController.Player.GridPos; GameController.Debug["PickIt"] = UpdateCacheList?.Value; var rectangleOfGameWindow = GameController.Window.GetWindowRectangleTimeCache; rectangleOfGameWindow.Inflate(-36, -36); var pickUpThisItem = UpdateCacheList?.Value.FirstOrDefault(x => DoWePickThis(x) && x.Distance < Settings.PickupRange && x.GroundItem != null && rectangleOfGameWindow.Intersects(new RectangleF(x.LabelOnGround.Label.GetClientRectCache.Center.X, x.LabelOnGround.Label.GetClientRectCache.Center.Y, 3, 3)) && Misc.CanFitInventory(x)); if (Input.GetKeyState(Settings.PickUpKey.Value) || CanLazyLoot() && ShouldLazyLoot(pickUpThisItem)) { yield return(TryToPickV2(pickUpThisItem)); FullWork = true; } }