コード例 #1
0
        private Composite StateBehaviorPS_PathRetreating()
        {
            return(new PrioritySelector(
                       // If no Egress path, build it...
                       new Decorator(context => Path_Egress == null,
                                     new Action(context =>
            {
                Path_Egress = FollowPath.FindPath_Egress(Mob_ToAvoid);
                QBCLog.Info("Retreating back to safespot due to {0}.",
                            Me.Combat
                            ? "combat"
                            : string.Format("{0} too close (dist: {1:F1})", Mob_ToAvoid.SafeName, Mob_ToAvoid.Distance));
            })),

                       // If we've come to the end of our egress path, move back to safe spot...
                       new Decorator(context => !Path_Egress.Any(),
                                     new Action(context =>
            {
                Path_Ingress = null;
                Path_Egress = null;
                State_MainBehavior = StateType_MainBehavior.MovingToSafespot;
            })),

                       // If we've arrived at the current waypoint, dequeue it...
                       new Decorator(context => Navigator.AtLocation(Path_Egress.Peek().Location),
                                     new Action(context => { Path_Egress.Dequeue(); })),

                       new ActionRunCoroutine(
                           context => UtilityCoroutine.MoveTo(
                               Path_Egress.Peek().Location,
                               "retreat",
                               MovementBy))
                       ));
        }
コード例 #2
0
        protected override Composite CreateBehavior_CombatMain()
        {
            return(new PrioritySelector(
                       // If we are following the path to the destination...
                       new Decorator(context => State_MainBehavior == StateType_MainBehavior.FollowingPathToDestination,
                                     new PrioritySelector(
                                         // If no path specified, we're done...
                                         new Decorator(context => !FollowPath.Waypoints.Any(),
                                                       new Action(context => { State_MainBehavior = StateType_MainBehavior.BehaviorDone; })),

                                         // If Mob_ToAvoid is too close, abandon current ingress, and find egress path back to safespot...
                                         new Decorator(context => Mob_ToAvoid != null,
                                                       new Decorator(context => ((Mob_ToAvoid.Distance < FollowPath.EgressDistance) || Me.Combat) &&
                                                                     (Path_Egress == null),
                                                                     new Action(context =>
            {
                LogInfo("Moving back to safespot due to {0}.",
                        Me.Combat
                                        ? "combat"
                                        : string.Format("{0} too close (dist: {1:F1})", Mob_ToAvoid.Name, Mob_ToAvoid.Distance));
                Path_Ingress = null;
                Path_Egress = FollowPath.FindPath_Egress(Mob_ToAvoid);
            }))
                                                       ),

                                         // If we are egressing, follow the Yellow Brick Road...
                                         new Decorator(context => Path_Egress != null,
                                                       new PrioritySelector(
                                                           // If we've come to the end of our egress path, move back to safe spot...
                                                           new Decorator(context => !Path_Egress.Any(),
                                                                         new Action(context => { State_MainBehavior = StateType_MainBehavior.MovingToSafespot; })),

                                                           // If we've arriaved at the current waypoint, dequeue it...
                                                           new Decorator(context => Me.Location.Distance(Path_Egress.Peek().Location) <= Navigator.PathPrecision,
                                                                         new Action(context => { Path_Egress.Dequeue(); })),

                                                           UtilityBehaviorPS_MoveTo(context => Path_Egress.Peek().Location, context => "safe spot")
                                                           )),

                                         // If we don't have a current ingress path to follow, build it...
                                         new Decorator(context => ((Mob_ToAvoid == null) || (Mob_ToAvoid.Distance > AvoidDistance)) &&
                                                       (Path_Ingress == null),
                                                       new Action(context =>
            {
                Path_Egress = null;
                Path_Ingress = FollowPath.FindPath_Ingress();
                FollowPath.DismissPetIfNeeded();
            })),

                                         // If we've an Ingress path to follow, use it...
                                         new Decorator(context => Path_Ingress != null,
                                                       new PrioritySelector(
                                                           // If we've consumed our ingress path, we're done...
                                                           new Decorator(context => !Path_Ingress.Any(),
                                                                         new Action(context => { State_MainBehavior = StateType_MainBehavior.BehaviorDone; })),

                                                           new Switch <SafePathType.StrategyType>(context => FollowPath.Strategy,
                                                                                                  #region State: DEFAULT
                                                                                                  new Action(context => // default case
            {
                LogMaintenanceError("FollowPathStrategyType({0}) is unhandled", FollowPath.Strategy);
                TreeRoot.Stop();
                State_MainBehavior = StateType_MainBehavior.BehaviorDone;
            }),
                                                                                                  #endregion


                                                                                                  #region Strategy: Stalk Mob at Avoid Distance Strategy
                                                                                                  new SwitchArgument <SafePathType.StrategyType>(SafePathType.StrategyType.StalkMobAtAvoidDistance,
                                                                                                                                                 new Decorator(context => (Mob_ToAvoid != null) && (Mob_ToAvoid.Distance < AvoidDistance),
                                                                                                                                                               new PrioritySelector(
                                                                                                                                                                   new Decorator(context => Me.IsMoving,
                                                                                                                                                                                 new Action(context => { WoWMovement.MoveStop(); })),
                                                                                                                                                                   new ActionAlwaysSucceed()
                                                                                                                                                                   ))),
                                                                                                  #endregion


                                                                                                  #region Strategy: Wait for Avoid Distance
                                                                                                  new SwitchArgument <SafePathType.StrategyType>(SafePathType.StrategyType.WaitForAvoidDistance,
                                                                                                                                                 new PrioritySelector(
                                                                                                                                                     // No addition action needed to implement strategy for now
                                                                                                                                                     ))
                                                                                                  #endregion
                                                                                                  ),

                                                           // If we've arrived at the current ingress waypoint, dequeue it...
                                                           new Decorator(context => Me.Location.Distance(Path_Ingress.Peek().Location) <= Navigator.PathPrecision,
                                                                         new Action(context => { Path_Ingress.Dequeue(); })),

                                                           // Follow the prescribed ingress path...
                                                           UtilityBehaviorPS_MoveTo(context => Path_Ingress.Peek().Location, context => "follow ingress path")
                                                           ))
                                         ))
                       ));
        }