public Action FindAction(ActionName actionName, IntPtr handle, CancellationTokenSource tokenSource) { if (!actionName.IsCancelable()) { throw new Exception($"Tried to recive non cancelable Macro {actionName} as a cancellable Macro."); } switch (actionName) { case ActionName.CubeConverterDualSlot: var speed = settingsService.MacroSettings.ConvertingSpeed; return(() => actionService.CubeConverterDualSlot(handle, tokenSource, speed)); case ActionName.CubeConverterSingleSlot: speed = settingsService.MacroSettings.ConvertingSpeed; return(() => actionService.CubeConverterSingleSlot(handle, tokenSource, speed)); case ActionName.UpgradeGem: var key = settingsService.GetKeybinding(CommandKeybinding.TeleportToTown); var isEmpowered = settingsService.MacroSettings.Empowered; var pickYourself = settingsService.MacroSettings.PickGemYourself; return(() => actionService.UpgradeGem(handle, tokenSource, isEmpowered, pickYourself, key)); case ActionName.SkillCastLoop: var configuration = settingsService.SkillCastSettings.SelectedSkillCastConfiguration; var keybindings = settingsService.Settings.SkillKeybindings; if (configuration == default) { logService.AddEntry(this, "SelectedSkillCastConfiguration was null", LogLevel.Warning); return(() => { }); } return(() => actionService.SkillCastLoop(handle, tokenSource, configuration, keybindings)); default: throw new NotImplementedException($"Cancellable Macro not implemented for {actionName}"); } }
public Action FindAction(ActionName actionName, IntPtr handle) { if (actionName.IsCancelable()) { throw new Exception($"Tried to recive Macro {actionName} as a non cancellable Macro."); } switch (actionName) { case ActionName.RightClick: return(() => actionService.RightClick(handle)); case ActionName.LeftClick: return(() => actionService.LeftClick(handle)); case ActionName.DropInventory: var columns = settingsService.MacroSettings.SpareColumns; var key = settingsService.GetKeybinding(CommandKeybinding.OpenInventory); return(() => actionService.DropInventory(handle, columns, key)); case ActionName.Salvage: return(() => actionService.Salvage(handle, settingsService.MacroSettings.SpareColumns)); case ActionName.OpenGrift: return(() => actionService.OpenGrift(handle)); case ActionName.LeaveGame: return(() => actionService.LeaveGame(handle)); case ActionName.Reforge: return(() => actionService.Reforge(handle, settingsService.MacroSettings.ConvertingSpeed)); case ActionName.TravelAct1: return(() => actionService.TravelTown(handle, 1, settingsService.GetKeybinding(CommandKeybinding.OpenMap))); case ActionName.TravelAct2: return(() => actionService.TravelTown(handle, 2, settingsService.GetKeybinding(CommandKeybinding.OpenMap))); case ActionName.TravelAct34: return(() => actionService.TravelTown(handle, 3, settingsService.GetKeybinding(CommandKeybinding.OpenMap))); case ActionName.TravelAct5: return(() => actionService.TravelTown(handle, 5, settingsService.GetKeybinding(CommandKeybinding.OpenMap))); case ActionName.TravelPool: return(() => actionService.TravelPool(handle)); case ActionName.NormalizeDifficulty: return(() => actionService.LowerDifficulty(handle)); case ActionName.SwapArmour: key = settingsService.GetKeybinding(CommandKeybinding.OpenInventory); var swapItemAmount = settingsService.MacroSettings.SwapItemsAmount; return(() => actionService.SwapArmour(handle, key, swapItemAmount)); case ActionName.Gamble: return(() => actionService.Gamble(handle, settingsService.MacroSettings.SelectedGambleItem)); default: throw new NotImplementedException(); } }