/// <summary> /// Returns the highest priority Tuple entry /// </summary> /// <param name="context"></param> /// <returns></returns> public Tuple <SpellManager.SpellInformation, CastAction> GetHighestPriorityTuple(Actor context) { var ability = _priorityDictionary.Where(u => { if (!u.Item2(context)) { return(false); } SpellManager.SpellInformation spell = SpellManager.GetSpell(u.Item1); if (spell != null) { // That's all. If we can cast it, go ahead and cast it. return(spell.CanCast); } return(false); }).FirstOrDefault(); if (ability == null) { return(null); } return(new Tuple <SpellManager.SpellInformation, CastAction>(SpellManager.GetSpell(ability.Item1), ability.Item3)); }
public override async Task Rest() { SpellManager.SpellInformation restAbility = Routine.Rest.ToValidAbilityList(GameManager.LocalPlayer).FirstOrDefault(); if (restAbility != null) { await SpellCastBehaviors.CastSimple(restAbility); } }
/// <summary> /// Turns this AbilityPriority collection into a prioritized list of castable spells. /// </summary> /// <param name="context"></param> /// <returns></returns> public List <SpellManager.SpellInformation> ToValidAbilityList(Actor context) { return(_priorityDictionary.Where(u => { if (!u.Item2(context)) { return false; } SpellManager.SpellInformation spell = SpellManager.GetSpell(u.Item1); if (spell != null) { // That's all. If we can cast it, go ahead and cast it. return spell.CanCast; } return false; }).Select(s => SpellManager.GetSpell(s.Item1)).ToList()); }
public override async Task Pull(object target) { var pullTarget = (target as Actor); if (pullTarget == null) { return; } Targeting.PullTarget = pullTarget; if (pullTarget.Distance > Routine.PullRange) { Logger.Debug(string.Format("[MoveWithin] {0} -> {1} (Distance {2})", GameManager.ControlledUnit.Position, pullTarget.Position, pullTarget.Distance)); // Stop within pull range, also stop early if we happen to body pull something. if (await CommonBehaviors.MoveWithin(pullTarget.Position, Routine.PullRange, true, true) == CommonBehaviors.BehaviorResult.CombatStop) { // Return only if we body pulled. Chances are, we pulled something we don't actually want. return; } // NOTE: Do not "return" after moving within range. //return; } SpellManager.SpellInformation pullAbility = Routine.Pull.ToValidAbilityList(pullTarget).FirstOrDefault(); if (pullAbility == null) { throw new Exception("Could not find a usable pull ability. Is pull not implemented for this class?"); } Logger.Debug(string.Format("[PULL] FaceCast [Name {0}, SpellBarIndex {1}]", pullAbility.Name, pullAbility.SpellBarIndex)); if (WindowSettings.EnableMovement) { pullTarget.Face(); } await SpellCastBehaviors.CastSimple(pullAbility, () => pullTarget, true); }
protected bool CanCast(string spellName) { SpellManager.SpellInformation spell = SpellManager.GetSpell(spellName); return(spell != null && spell.CanCast); }