public static void InvInterface_TargetAnywhere(InvInterface __instance, Vector2 myPos, bool pressedButton) { __instance.cursorTextString3.color = Color.white; bool debug = RogueFramework.IsDebugEnabled(DebugFlags.Items); InvItem invItem = __instance.mainGUI.targetItem; if (invItem != null) { CustomItem custom = invItem.GetHook <CustomItem>(); __instance.cursorHighlightTargetObjects = custom is IItemTargetable; if (custom is IItemTargetableAnywhere targetable) { if (debug && pressedButton) { RogueFramework.LogDebug($"Targeting {custom} ({invItem.invItemName}) anywhere:"); } bool filter = targetable.TargetFilter(myPos); __instance.cursorHighlight = filter; __instance.cursorHighlightTargetAnywhere = filter; __instance.mainGUI.agent.targetImage.tr.localScale = Vector3.one; CustomTooltip tooltip = targetable.TargetCursorText(myPos); __instance.cursorTextCanvas3.enabled = !string.IsNullOrEmpty(tooltip.Text); __instance.cursorTextString3.text = tooltip.Text ?? string.Empty; __instance.cursorTextString3.color = tooltip.Color ?? Color.white; if (pressedButton) { OnItemTargetingAnywhereArgs args = new OnItemTargetingAnywhereArgs(invItem, myPos, invItem.agent); if (InventoryChecks.onItemTargetingAnywhere.Raise(args, custom?.ItemInfo.IgnoredChecks)) { myPos = args.Target; using (AgentSwapper swapper = new AgentSwapper(invItem, args.User)) { bool success = targetable.TargetPosition(myPos); if (debug) { RogueFramework.LogDebug($"---- Targeting {(success ? "was successful" : "failed")}."); } if (success) { new ItemFunctions().UseItemAnim(invItem, invItem.agent); } if (custom.Count < 1 || !custom.Inventory.InvItemList.Contains(custom.Item) && InventoryChecks.IsCheckAllowed(custom, "StopOnZero")) { if (debug) { RogueFramework.LogDebug("---- Triggered \"StopOnZero\" inventory check."); } __instance.HideDraggedItem(); __instance.HideTarget(); } } } else { if (debug) { RogueFramework.LogDebug("---- Targeting was prevented by an inventory check."); } } } } } }