internal static void SubscribeChecks() { InventoryChecks.AddItemUsingCheck("Ghost", GhostCheck); InventoryChecks.AddItemUsingCheck("PeaBrained", PeaBrainedCheck); InventoryChecks.AddItemUsingCheck("OnlyOil", OnlyOilCheck); InventoryChecks.AddItemUsingCheck("OnlyOilMedicine", OnlyOilMedicineCheck); InventoryChecks.AddItemUsingCheck("OnlyBlood", OnlyBloodCheck); InventoryChecks.AddItemUsingCheck("OnlyBloodMedicine", OnlyBloodMedicineCheck); InventoryChecks.AddItemUsingCheck("OnlyCharge", OnlyChargeCheck); InventoryChecks.AddItemUsingCheck("OnlyChargeMedicine", OnlyChargeMedicineCheck); InventoryChecks.AddItemUsingCheck("OnlyHumanFlesh", OnlyHumanFleshCheck); InventoryChecks.AddItemUsingCheck("FullHealth", FullHealthCheck); }
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."); } } } } } }
public static bool InvItem_TargetObject(InvItem __instance, PlayfieldObject otherObject, string combineType, ref bool __result) { bool debug = RogueFramework.IsDebugEnabled(DebugFlags.Items); bool actualCombining = combineType == "Combine"; CustomItem custom = __instance.GetHook <CustomItem>(); if (debug && actualCombining) { RogueFramework.LogDebug($"Targeting {custom} ({__instance.invItemName}) on {otherObject.objectName}:"); } if (Vector2.Distance(__instance.agent.curPosition, otherObject.curPosition) > 15f && InventoryChecks.IsCheckAllowed(custom, "Distance")) { if (debug && actualCombining) { RogueFramework.LogDebug("---- Triggered \"Distance\" inventory check."); RogueFramework.LogDebug("---- Targeting was prevented by an inventory check."); } __result = false; return(false); } if ((otherObject as Agent)?.butlerBot == true && InventoryChecks.IsCheckAllowed(custom, "ButlerBot")) { if (debug && actualCombining) { RogueFramework.LogDebug("---- Triggered \"ButlerBot\" inventory check."); RogueFramework.LogDebug("---- Targeting was prevented by an inventory check."); } __result = false; return(false); } if ((otherObject as Agent)?.mechEmpty == true && InventoryChecks.IsCheckAllowed(custom, "EmptyMech")) { if (debug && actualCombining) { RogueFramework.LogDebug("---- Triggered \"EmptyMech\" inventory check."); RogueFramework.LogDebug("---- Targeting was prevented by an inventory check."); } __result = false; return(false); } __result = custom is IItemTargetable targetable ? targetable.TargetFilter(otherObject) : new ItemFunctions().TargetObject(__instance, __instance.agent, otherObject, string.Empty); if (actualCombining) { OnItemTargetingArgs args = new OnItemTargetingArgs(__instance, otherObject, __instance.agent); if (InventoryChecks.onItemTargeting.Raise(args, custom?.ItemInfo.IgnoredChecks)) { otherObject = args.Target; using (AgentSwapper swapper = new AgentSwapper(__instance, args.User)) { if (custom is IItemTargetable targetable2) { bool success = targetable2.TargetObject(otherObject); if (debug) { RogueFramework.LogDebug($"---- Targeting {(success ? "was successful" : "failed")}."); } if (success) { new ItemFunctions().UseItemAnim(__instance, __instance.agent); } } else { if (debug) { RogueFramework.LogDebug("---- Running the original method."); } new ItemFunctions().TargetObject(__instance, __instance.agent, otherObject, "Combine"); } if (__instance.invItemCount < 1 || !__instance.database.InvItemList.Contains(__instance) && InventoryChecks.IsCheckAllowed(custom, "StopOnZero")) { if (debug) { RogueFramework.LogDebug("---- Triggered \"StopOnZero\" inventory check."); } __instance.agent.mainGUI.invInterface.HideDraggedItem(); __instance.agent.mainGUI.invInterface.HideTarget(); } } } else { if (debug) { RogueFramework.LogDebug("---- Targeting was prevented by an inventory check."); } } } return(false); }
public static bool InvItem_CombineItems(InvItem __instance, InvItem otherItem, int slotNum, Agent myAgent, string combineType, ref bool __result) { bool debug = RogueFramework.IsDebugEnabled(DebugFlags.Items); bool actualCombining = combineType == "Combine"; CustomItem custom = __instance.GetHook <CustomItem>(); if (debug && actualCombining) { RogueFramework.LogDebug($"Combining {custom} ({__instance.invItemName}) with {otherItem.invItemName}:"); } if (__instance.stackable && __instance.invItemName == otherItem.invItemName && InventoryChecks.IsCheckAllowed(custom, "AutoStacking")) { if (__instance.invItemName == VanillaItems.Syringe && __instance.contents[0] != otherItem.contents[0]) { __result = false; return(false); } if (actualCombining) { if (debug) { RogueFramework.LogDebug("---- Triggered \"AutoStacking\" inventory check."); RogueFramework.LogDebug("---- Combining was prevented by an inventory check."); } if (myAgent.controllerType != "Keyboard") { myAgent.gc.audioHandler.Play(myAgent, VanillaAudio.BeginCombine); } otherItem.agent.mainGUI.invInterface.PutDraggedItemBack(); } __result = true; return(false); } if (custom is IItemCombinable combinable) { using (AgentSwapper swapper = new AgentSwapper(__instance, myAgent)) __result = combinable.CombineFilter(otherItem); } else { __result = new ItemFunctions().CombineItems(__instance, myAgent, otherItem, slotNum, string.Empty); } if (actualCombining) { OnItemsCombiningArgs args = new OnItemsCombiningArgs(__instance, otherItem, myAgent); if (InventoryChecks.onItemsCombining.Raise(args, custom?.ItemInfo.IgnoredChecks)) { myAgent = args.Combiner; otherItem = args.OtherItem; if (custom is IItemCombinable combinable2) { using (AgentSwapper swapper = new AgentSwapper(__instance, myAgent)) { bool success = combinable2.CombineItems(otherItem); if (debug) { RogueFramework.LogDebug($"---- Combining {(success ? "was successful" : "failed")}."); } if (success) { new ItemFunctions().UseItemAnim(__instance, myAgent); } } } else { if (debug) { RogueFramework.LogDebug("---- Running the original method."); } new ItemFunctions().CombineItems(__instance, myAgent, otherItem, slotNum, "Combine"); } if (__instance.invItemCount < 1 || !__instance.database.InvItemList.Contains(__instance) && InventoryChecks.IsCheckAllowed(custom, "StopOnZero")) { if (debug) { RogueFramework.LogDebug("---- Triggered \"StopOnZero\" inventory check."); } myAgent.mainGUI.invInterface.HideDraggedItem(); myAgent.mainGUI.invInterface.HideTarget(); } } else { if (debug) { RogueFramework.LogDebug("---- Combining was prevented by an inventory check."); } } } return(false); }