private static void SendInput(Hotkey hotkey, int repeat = 1) { for (int i = repeat; i > 0; i--) { UICommunicator.UpdateStatus2("Sending \"" + hotkey.ToString() + "\""); KeyInputEngine.SendKeysToGame(hotkey.KeyCode, hotkey.ModKeyCodes); SleepThread(hotkey.TimerInMiliseconds); } }
private static void SendMacroInput(Hotkey hotkey, int macroNumber) { if (hotkey == null) { return; } Logger.Write("Sending Macro " + macroNumber); // UI message: MACRO NUMBER macroNumber UICommunicator.UpdateMacroUIInfo(macroNumber, hotkey.TimerInMiliseconds, VerifyFinalMacro(macroNumber)); SendInput(hotkey); }
private static void SendCollectableConfirmationInput() { if (Settings.CollectableCraft == false) { return; } Logger.Write("Accepting Collectable Craft"); UICommunicator.UpdateStatus("Accepting Collectable Craft..."); Break(STANDARD_MENU_DELAY); SendInput(HotkeySet[HKType.Confirm]); SendInput(HotkeySet[HKType.Confirm]); }
private static void RunCraftProgressBar() { int totalTime = HotkeySet[HKType.Macro1].TimerInMiliseconds; if (HotkeySet[HKType.Macro2] != null) { totalTime += HotkeySet[HKType.Macro2].TimerInMiliseconds; } if (HotkeySet[HKType.Macro3] != null) { totalTime += HotkeySet[HKType.Macro3].TimerInMiliseconds; } UICommunicator.BeginCraftTimer(totalTime); }
public static void CancelCrafting() { if (!CraftingActive) { return; } if (!CraftPrimedToCancel) { CraftPrimedToCancel = true; UICommunicator.UpdateStatus("Finishing this craft...", true); return; } UICommunicator.UpdateStatus("Ending Craft..."); Cts.Cancel(); }
private static void EndCraftingProcess() { // ALL CLEANUP UICommunicator.EndAllProgress(); UICommunicator.UpdateStatus("Crafting Finished!"); var craftCompleted = "Completed "; craftCompleted += Settings.CraftCount > 0 ? $"{TotalCount}/{Settings.CraftCount}" : $"{TotalCount}"; UICommunicator.UpdateStatus2(craftCompleted); CraftingActive = false; var foodRemaining = (int)(NextFoodUse - DateTime.Now).TotalMinutes; var syrupRemaining = (int)(NextSyrupUse - DateTime.Now).TotalMinutes; SetFoodAndSyrupTimings.Invoke(foodRemaining, syrupRemaining); EndCraftCallback.Invoke(); }
private static void PrepareNextCraftInput() { if (CraftingComplete()) { return; } UICommunicator.UpdateStatus("Preparing Next Craft..."); Logger.Write("Resetting Craft Cycle"); try { ProcessManager.DisableInputs(); Break(50); SendInput(HotkeySet[HKType.Confirm], 3); Break(50); } finally { ProcessManager.EnableInputs(); } }
private static void SendFoodAndSyrupInput() { if (CraftingComplete()) { return; } // check if timers is passed bool useFood = (HotkeySet[HKType.Food] != null && DateTime.Compare(NextFoodUse, DateTime.Now) <= 0); bool useSyrup = (HotkeySet[HKType.Syrup] != null && DateTime.Compare(NextSyrupUse, DateTime.Now) <= 0); // leave if neither are to be used if (!useFood && !useSyrup) { return; } UICommunicator.UpdateStatus("Refreshing Consumables..."); Logger.Write("Refreshing Consumables"); // enter a craft and leave it out Break(500); try { ProcessManager.DisableInputs(); Break(50); SendInput(HotkeySet[HKType.Confirm], 3); SendInput(HotkeySet[HKType.Cancel]); Break(50); } finally { ProcessManager.EnableInputs(); } Break(1500); try { ProcessManager.DisableInputs(); Break(100); SendInput(HotkeySet[HKType.Confirm]); SendInput(HotkeySet[HKType.Cancel]); SendInput(HotkeySet[HKType.Confirm]); Break(50); } finally { ProcessManager.EnableInputs(); } Break(2000); // use food and syrup as needed if (useFood) { UICommunicator.UpdateStatus("Using Food..."); Logger.Write("Using Food"); SendInput(HotkeySet[HKType.Food]); NextFoodUse = CalculateNextConsumableUse(Settings.FoodDuration); UICommunicator.UpdateFood(NextFoodUse); } if (useSyrup) { UICommunicator.UpdateStatus("Using Syrup..."); Logger.Write("Using Syrup"); SendInput(HotkeySet[HKType.Syrup]); NextSyrupUse = CalculateNextConsumableUse(STANDARD_SYRUP_TIME); UICommunicator.UpdateSyrup(NextSyrupUse); } }
private static void RunCraftingEngine(CancellationToken token) { // PROCESS: // set queue parameters // calcualte overall time for full process // macro 1 // macro 2 // macro 3 // collectable if needed // food if needed // pot if needed // begin next craft try { // Set crafting parameters UICommunicator.ResetValues(); UICommunicator.ErrorMessageHandler = ErrorMessageHandler; UICommunicator.UpdateStatus("Setting up for Crafting..."); UICommunicator.StartTimedProgressBarUpdates(); UICommunicator.UpdateCompletedUIInfo(0, Settings.CraftCount); CraftCount = 1; TotalCount = 0; if (HotkeySet[HKType.Food] != null) { NextFoodUse = CalculateNextConsumableUse(Settings.StartingFoodTime); UICommunicator.UpdateFood(NextFoodUse); } if (HotkeySet[HKType.Syrup] != null) { NextSyrupUse = CalculateNextConsumableUse(Settings.StartingSyrupTime); UICommunicator.UpdateSyrup(NextSyrupUse); } // If crafts remaining was 0, loop infinitley // If not, craft until quota is met while (!CraftingComplete()) { // UI MESSAGE: Set timer for overall craft UICommunicator.UpdateCraftUIInfo(CraftCount, Settings.CraftCount); // Add requested delay Break(Settings.StartingDelay); // Begin Craft Timer: RunCraftProgressBar(); // Initiate Macro 1 SendMacroInput(HotkeySet[HKType.Macro1], 1); // Initiate Macro 2 SendMacroInput(HotkeySet[HKType.Macro2], 2); // Initiate Macro 3 SendMacroInput(HotkeySet[HKType.Macro3], 3); // Update UI Message TotalCount = CraftCount; UICommunicator.UpdateCompletedUIInfo(TotalCount, Settings.CraftCount); // Collectable Menu Option SendCollectableConfirmationInput(); // Standard delay for menus Break(STANDARD_MENU_DELAY); // Use Food and Syrup SendFoodAndSyrupInput(); // Prepare next craft if crafting is not finished PrepareNextCraftInput(); Break(STANDARD_ANIMATION_DELAY); CraftCount += 1; } } catch (Exception e) when(!(e is CraftCancelRequest)) { ErrorMessageHandler(e); } finally { EndCraftingProcess(); } }