private Composite StateBehaviorPS_PathIngressing() { return(new PrioritySelector( // If no Ingress path exists, build it... new Decorator(context => Path_Ingress == null, new Action(context => { Path_Ingress = FollowPath.FindPath_Ingress(); })), // If we've consumed our Ingress path (or the one we initially built is empty), we're done... new Decorator(context => !Path_Ingress.Any(), new Action(context => { State_MainBehavior = StateType_MainBehavior.DestinationReached; })), // If Mob_ToAvoid is too close or we get in combat, abandon current ingress, and retreat back to safespot... new Decorator(context => Query.IsViable(Mob_ToAvoid) && ((Mob_ToAvoid.Distance < FollowPath.EgressDistance) || Me.Combat), new Action(context => { Path_Ingress = null; Path_Egress = null; State_MainBehavior = StateType_MainBehavior.PathRetreating; })), new Switch <SafePathType.StrategyType>(context => FollowPath.Strategy, new Action(context => // default case { var message = string.Format("FollowPathStrategyType({0}) is unhandled", FollowPath.Strategy); QBCLog.MaintenanceError(message); TreeRoot.Stop(); BehaviorDone(message); }), new SwitchArgument <SafePathType.StrategyType>(SafePathType.StrategyType.StalkMobAtAvoidDistance, new Decorator(context => Query.IsViable(Mob_ToAvoid) && (Mob_ToAvoid.Distance < AvoidDistance), new PrioritySelector( new ActionRunCoroutine(context => CommonCoroutines.StopMoving()), new ActionAlwaysSucceed() ))), new SwitchArgument <SafePathType.StrategyType>(SafePathType.StrategyType.WaitForAvoidDistance, new PrioritySelector( // No addition action needed to implement strategy for now )) ), // If we've arrived at the current ingress waypoint, dequeue it... new Decorator(context => Navigator.AtLocation(Path_Ingress.Peek().Location), new Action(context => { FollowPath.DismissPetIfNeeded(); Path_Ingress.Dequeue(); })), // Follow the prescribed ingress path, if its still safe to proceed... new Decorator(context => IsSafeToMoveToDestination(Mob_ToAvoid), new ActionRunCoroutine( context => UtilityCoroutine.MoveTo( Path_Ingress.Peek().Location, "follow ingress path", MovementBy))), // If mob is heading our direction, hold position... new Decorator(context => !IsSafeToMoveToDestination(Mob_ToAvoid), new Sequence( new Action(context => { TreeRoot.StatusText = string.Format("Holding position to evaluate {0}'s actions.", Mob_ToAvoid.SafeName); }), new ActionRunCoroutine(context => CommonCoroutines.StopMoving()) )) )); }
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") )) )) )); }