예제 #1
0
        /// <summary>
        ///   Creates the ensure movement stopped behavior. if no range specified, will stop immediately.  if range given, will stop if within range yds of current target
        /// </summary>
        /// <remarks>
        ///   Created 5/1/2011.
        /// </remarks>
        /// <returns>.</returns>
        public static Composite CreateEnsureMovementStoppedBehavior(float range = float.MaxValue, UnitSelectionDelegate onUnit = null, string reason = null)
        {
            if (range == float.MaxValue)
            {
                return(new Decorator(
                           ret => StyxWoW.Me.IsMoving,
                           new Sequence(
                               new Action(ret => Logging.WriteDiagnostic("EnsureMovementStopped: stopping! {0}", reason ?? "")),
                               //Logger.WriteDebug(Color.White, "EnsureMovementStopped: stopping! {0}", reason ?? "")),
                               new Action(ret => StopMoving.Now())
                               )
                           ));
            }

            if (onUnit == null)
            {
                onUnit = del => StyxWoW.Me.CurrentTarget;
            }

            return(new Decorator(
                       ret => StyxWoW.Me.IsMoving &&
                       (onUnit(ret) == null || onUnit(ret).Distance < range),
                       new Sequence(
                           new Action(ret => Logging.WriteDiagnostic("EnsureMovementStopped: stopping because {0}", onUnit(ret) == null ? "No CurrentTarget" : string.Format("target @ {0:F1} yds, stop range: {1:F1}", onUnit(ret).Distance, range))),
                           //Logger.WriteDebug(Color.White, "EnsureMovementStopped: stopping because {0}", onUnit(ret) == null ? "No CurrentTarget" : string.Format("target @ {0:F1} yds, stop range: {1:F1}", onUnit(ret).Distance, range))),
                           new Action(ret => StopMoving.Now())
                           )
                       ));
        }
예제 #2
0
 /// <summary>
 /// Creates ensure movement stopped if within melee range behavior.
 /// </summary>
 /// <returns></returns>
 public static Composite CreateEnsureMovementStoppedWithinMelee()
 {
     return(new Decorator(
                ret => StyxWoW.Me.IsMoving &&
                InMoveToMeleeStopRange(StyxWoW.Me.CurrentTarget),
                new Sequence(
                    new Action(ret => Logging.WriteDiagnostic("EnsureMovementStoppedWithinMelee: stopping because {0}", !StyxWoW.Me.GotTarget ? "No CurrentTarget" : string.Format("target at {0:F1} yds", StyxWoW.Me.CurrentTarget.Distance))),
                    //Logger.WriteDebug(Color.White, "EnsureMovementStoppedWithinMelee: stopping because {0}", !StyxWoW.Me.GotTarget ? "No CurrentTarget" : string.Format("target at {0:F1} yds", StyxWoW.Me.CurrentTarget.Distance))),
                    new Action(ret => StopMoving.Now())
                    )
                ));
 }