public bool ExecuteStep()
    {
        //predicate is executed separately from targetfinder predicate
        //this way we can select one target, then check which spell to cast on the target
        //as opposed to finding a target to cast a specific spell on (not the desired result)
        Func <WoWUnit, bool> targetFinderPredicate = CheckRange ? (Func <WoWUnit, bool>)((u) => u.GetDistance <= Action.Range()) : ((u) => true);
        WoWUnit target = TargetFinder(targetFinderPredicate);

        if (target != null && Predicate(Action, target))
        {
            return(Action.Execute(target, Force));
        }
        return(false);
    }
Beispiel #2
0
        public bool ExecuteStep(bool globalActive)
        {
            //can't execute this, because global is still active
            //can't execute this because we can't stop the current cast to execute this
            if ((globalActive && !_action.IgnoresGlobal()) || (RotationFramework.IsCast && !_forceCast))
            {
                return(false);
            }

            //predicate is executed separately from targetfinder predicate
            //this way we can select one target, then check which spell to cast on the target
            //as opposed to finding a target to cast a specific spell on (not the desired result)
            Func <WoWUnit, bool> targetFinderPredicate = _checkRange ? (Func <WoWUnit, bool>)((u) => u.GetDistance <= _action.Range()) : ((u) => true);

            var    watch     = System.Diagnostics.Stopwatch.StartNew();
            string spellName = "<noname>";

            if (_action.GetType() == typeof(RotationSpell))
            {
                RotationSpell spell = (RotationSpell)_action;
                spellName = spell.FullName();
            }

            WoWUnit target = _targetFinder(targetFinderPredicate);

            watch.Stop();
            RotationLogger.Trace($"({spellName}) targetFinder ({_targetFinder.Method.Name}) - {target?.Name}: {watch.ElapsedMilliseconds} ms");

            watch.Restart();
            if (target != null && _predicate(_action, target))
            {
                watch.Stop();
                RotationLogger.Trace($"({spellName}) predicate ({_targetFinder.Method.Name}): on {target.Name} {watch.ElapsedMilliseconds} ms");

                watch.Restart();
                var returnValue = _action.Execute(target, _forceCast);

                watch.Stop();
                RotationLogger.Trace($"action ({spellName}): {watch.ElapsedMilliseconds} ms");

                return(returnValue);
            }

            return(false);
        }