//Clears the hotbar after using a map and before the map is actually consumed static void Prefix(ui_mouseFrame_DragAndDrop __instance) { for (int i = 0; i < dmUtilities.theGame.theUIFrames.hotbarArrayLength(); i++) { dmItem hotBarItem = dmUtilities.theGame.theUIFrames.GetHeldItemFromHotbar(i); if (hotBarItem != null && hotBarItem.ArchetypeName == "adventure_map" && hotBarItem.bRemove == true) { dmUtilities.theGame.theUIFrames.RemoveHeldItemFromHotbar(i); dmUtilities.theGame.theUIFrames.ClearHotbarSlot(i); } } }
//On the function consumables don't set the containedItem, so here we set it so the map isn't consumed when clicked on the hotbar static bool Prefix(ui_mouseFrame_DragAndDrop __instance) { dmItem aux = Traverse.Create(__instance).Field("theInput").GetValue <dmInput>().mouseHeldItem; if (aux != null) { if (aux.ArchetypeName == "adventure_map") { __instance.containedItem = aux; } } return(true); }
//Fixes when a map is activated in the hotbar using the keyboard, so it doesn't remove it from the inventory just because it is a consumable static bool Prefix(dmGame __instance) { if (__instance.dungeonMans.iCurrentAP > 0 && !__instance.bShowMasteriesMode && !__instance.bInventoryMode && !__instance.bSelectPowerMode) { for (int j = 0; j < 10; j++) { if (!__instance.theInput.ExecutedActions.Contains((ActionButton)(53 + j))) { continue; } int num = j; if (__instance.theInput.bCtrlIsDown) { num += 10; } else if (__instance.theInput.bShiftIsDown) { num += 20; } else if (__instance.theInput.bAltIsDown) { num += 30; } dmItem swapItem = __instance.theUIFrames.GetHeldItemFromHotbar(num); if (swapItem != null) { if (swapItem is dmConsumable && __instance.dungeonMans.iCurrentAP >= 100 && __instance.gamePhase == GameTurnPhase.WaitForHeroAction) { __instance.dungeonMans.UseConsumable(swapItem as dmConsumable, __instance); return(false); } } } } return(true); }