public async Task <GoapGoal?> GetAction() { if (playerReader.HealthPercent > 1 && blacklist.IsTargetBlacklisted()) { logger.LogWarning($"{GetType().Name}: Target is blacklisted - StopAttack & ClearTarget"); await input.TapStopAttack(""); await input.TapClearTarget(""); UpdateWorldState(); } var goal = new HashSet <KeyValuePair <GoapKey, GoapPreCondition> >(); //Plan Queue <GoapGoal> plan = planner.Plan(AvailableGoals, WorldState, goal); if (plan != null && plan.Count > 0) { if (CurrentGoal == plan.Peek() && !CurrentGoal.Repeatable) { logger.LogInformation($"Plan= {CurrentGoal.GetType().Name} is not Repeatable!"); CurrentGoal = null; } else { CurrentGoal = plan.Peek(); } } else { if (CurrentGoal != null && !CurrentGoal.Repeatable) { logger.LogInformation($"Plan= {CurrentGoal.GetType().Name} is not Repeatable!"); CurrentGoal = null; await stopMoving.Stop(); } } return(CurrentGoal); }
public async Task MountUp() { if (playerReader.Level >= minLevelToMount) { if (playerReader.Class == PlayerClassEnum.Druid) { classConfig.Form .Where(s => s.FormEnum == Form.Druid_Travel) .ToList() .ForEach(async k => await input.KeyPress(k.ConsoleKey, 50)); } else { if (playerReader.Bits.IsFalling) { (bool notfalling, double fallingElapsedMs) = await wait.InterruptTask(10000, () => !playerReader.Bits.IsFalling); logger.LogInformation($"{GetType().Name}: waited for landing interrupted: {!notfalling} - {fallingElapsedMs}ms"); } await stopMoving.Stop(); await wait.Update(1); await input.TapMount(); (bool notStartedCasted, double castStartElapsedMs) = await wait.InterruptTask(400, () => playerReader.Bits.IsMounted || playerReader.IsCasting); logger.LogInformation($"{GetType().Name}: casting: {!notStartedCasted} | Mounted: {playerReader.Bits.IsMounted} | Delay: {castStartElapsedMs}ms"); if (!playerReader.Bits.IsMounted) { (bool notmounted, double elapsedMs) = await wait.InterruptTask(mountCastTimeMs, () => playerReader.Bits.IsMounted || !playerReader.IsCasting); logger.LogInformation($"{GetType().Name}: interrupted: {!notmounted} | Mounted: {playerReader.Bits.IsMounted} | Delay: {elapsedMs}ms"); } } } }