private static async Task <bool> SpellQueueMethod() { InSpellQueue = true; var spell = SpellQueue.Peek(); if (spell.Wait != null) { if (await Coroutine.Wait(spell.Wait.WaitTime, spell.Wait.Check)) { Logger.Write($"Spell Queue Wait: {spell.Wait.Name}"); } else { SpellQueue.Dequeue(); return(true); } } if (spell.Checks.Any(x => !x.Check.Invoke())) { SpellQueue.Dequeue(); Logger.Write($"Removing {spell.Spell.LocalizedName} from the Spell Queue because it failed it's checks."); foreach (var check in spell.Checks.Where(x => !x.Check.Invoke())) { Logger.Write($"Failed Check: {check.Name}"); } return(true); } var target = spell.Target(); if (target != null) { if (await spell.Spell.Cast(target)) { SpellQueue.Dequeue(); return(true); } } return(SpellQueue.Any()); }
public static async Task <bool> SpellQueueMethod() { if (!InSpellQueue) { Logger.WriteInfo("Starting Spell Queue"); Casting.LastSpell = null; } Debug.Instance.Queue = new AsyncObservableCollection <QueueSpell>(SpellQueue); InSpellQueue = true; if (CancelSpellQueue.Invoke()) { SpellQueueStop(); Logger.WriteInfo("Had To Cancel Spell Queue"); return(true); } var spell = SpellQueue.Peek(); if (NeedToDequeueSuccessfulCast) { if (Casting.LastSpell != null && Casting.LastSpell.Id == spell.Spell.Id) { SpellQueue.Dequeue(); NeedToDequeueSuccessfulCast = false; if (!SpellQueue.Any()) { Logger.WriteInfo("Spell Queue Complete"); SpellQueueStop(); } return(true); } } if (spell.SleepBefore) { await Coroutine.Sleep(spell.SleepMilliseconds); } if (spell.Wait != null) { if (await Coroutine.Wait(spell.Wait.WaitTime, spell.Wait.Check)) { Logger.Write($"Spell Queue Wait: {spell.Wait.Name}"); } else { SpellQueue.Dequeue(); Logger.Error($"Spell Wait Expired or Otherwise Unable to Cast: {spell.Wait.Name}"); return(true); } } if (spell.Checks.Any(x => !x.Check.Invoke())) { SpellQueue.Dequeue(); Logger.Write($"Removing {spell.Spell.LocalizedName} From The Spell Queue Because It Failed It's Checks."); foreach (var check in spell.Checks.Where(x => !x.Check.Invoke())) { if (!check.SilentMode) { Logger.Write($"Failed Check: {check.Name}"); } } return(true); } var target = spell.Target(); if (target == null) { return(SpellQueue.Any()); } if (!await spell.Spell.Cast(target)) { return(SpellQueue.Any()); } Logger.WriteInfo($@"Queue Cast: {spell.Spell.LocalizedName}"); NeedToDequeueSuccessfulCast = true; return(SpellQueue.Any()); }