示例#1
0
 protected void RegisterActionFilter(string action, string controller, IActionFilter filter)
 {
     ActionFilters.Add(new DynamicActionFilter()
     {
         Action = action, Controller = controller, Filter = filter
     });
 }
示例#2
0
        public override bool Check(IGameContext context)
        {
            if (new RestState().Check(context))
            {
                return(false);
            }
            if (!context.API.Player.Status.Equals(Status.Standing))
            {
                return(false);
            }

            var trusts = context.Config.BattleLists["Trusts"].Actions
                         .Where(t => t.IsEnabled)
                         .Where(t => ActionFilters.BuffingFilter(context.API, t))
                         .ToList();

            var maxTrustPartySize = context.Config.TrustPartySize;

            foreach (var trust in trusts)
            {
                if (TrustNeedsDismissal(context, trust) ||
                    !TrustInParty(context, trust) && PartyHasSpace(context) && !MaxTrustsReached(context, maxTrustPartySize))
                {
                    return(true);
                }
            }

            return(false);
        }
示例#3
0
 /// <summary>
 /// Adds the action filter.
 /// </summary>
 /// <param name="filter">The filter.</param>
 protected virtual void AddActionFilter(IActionFilter filter)
 {
     if (!ActionFilters.Contains(filter))
     {
         ActionFilters.Add(filter);
     }
 }
示例#4
0
        /// <summary>
        ///     Use pulling moves if applicable to make the target
        ///     mob aggressive to us.
        /// </summary>
        public override void Run(IGameContext context)
        {
            var actions = context.Config.BattleLists["Pull"].Actions.ToList();
            var usable  = actions.Where(x => ActionFilters.TargetedFilter(context.API, x, context.Target)).ToList();

            context.Memory.Executor.UseTargetedActions(usable, context.Target);
        }
示例#5
0
        /// <summary>
        ///     Use pulling moves if applicable to make the target
        ///     mob aggressive to us.
        /// </summary>
        public override void Run()
        {
            var actions = Config.BattleLists["Pull"].Actions.ToList();
            var usable  = actions.Where(x => ActionFilters.TargetedFilter(EliteApi, x, Target)).ToList();

            Executor.UseTargetedActions(usable, Target);
        }
示例#6
0
        public override bool CheckComponent()
        {
            if (new RestState(fface).CheckComponent())
            {
                return(false);
            }

            // Target dead or null.
            if (!UnitFilters.MobFilter(fface, Target))
            {
                return(false);
            }

            // We should approach mobs that have aggroed or have been pulled.
            if (Target.Status.Equals(Status.Fighting))
            {
                return(true);
            }

            // Get usable abilities.
            var usable = Config.Instance.BattleLists["Pull"].Actions
                         .Where(x => ActionFilters.BuffingFilter(fface, x));

            // Approach when there are no pulling moves available.
            if (!usable.Any())
            {
                return(true);
            }

            // Approach mobs if their distance is close.
            return(Target.Distance < 8);
        }
示例#7
0
        public override void RunComponent()
        {
            // Check engaged
            // FIXED: no longer return on not engage but don't execute
            // these moves instead. Fixes the bot not attacking things
            // from move than 30 yalms problem.
            if (fface.Player.Status.Equals(Status.Fighting))
            {
                // Grab the first weaponskill or null.
                var weaponskill = Config.Instance.BattleLists["Weaponskill"]
                                  .Actions.FirstOrDefault();

                // See if they the user set a weaponskill.
                if (weaponskill == null)
                {
                    return;
                }

                // Perform the weaponskill if it is valid.
                if (ActionFilters.TargetedFilter(fface, weaponskill, Target))
                {
                    Executor.UseTargetedAction(weaponskill, Target);
                }
            }
        }
示例#8
0
            public void VerifyActionUsable()
            {
                var memoryAPI = FindMemoryApi();
                var result    = ActionFilters.BuffingFilter(memoryAPI, _battleAbility);

                Assert.True(result);
            }
示例#9
0
        /// <summary>
        ///     Use pulling moves if applicable to make the target
        ///     mob aggressive to us.
        /// </summary>
        public override void RunComponent()
        {
            var actions = Config.Instance.BattleLists["Pull"].Actions.ToList();
            var usable  = actions.Where(x => ActionFilters.TargetedFilter(fface, x, Target)).ToList();

            Executor.UseTargetedActions(usable, Target);
        }
示例#10
0
        public override bool Check()
        {
            if (new RestState(Memory).Check())
            {
                return(false);
            }
            if (!EliteApi.Player.Status.Equals(Status.Standing))
            {
                return(false);
            }

            var trusts = Config.Instance.BattleLists["Trusts"].Actions
                         .Where(t => t.IsEnabled)
                         .Where(t => ActionFilters.BuffingFilter(EliteApi, t))
                         .ToList();

            var maxTrustPartySize = Config.Instance.TrustPartySize;

            foreach (var trust in trusts)
            {
                if (TrustNeedsDismissal(trust) ||
                    !TrustInParty(trust) && PartyHasSpace() && !MaxTrustsReached(maxTrustPartySize))
                {
                    return(true);
                }
            }

            return(false);
        }
        private void AddFilter(Filter filter)
        {
            if (filter == null)
            {
                throw new ArgumentNullException(nameof(filter));
            }

            var instance = filter.Instance;

            if (instance is IAuthenticationFilter authentication)
            {
                AuthenticationFilters.Add(new FilterInfo <IAuthenticationFilter>
                {
                    Filter = authentication,
                    Scope  = filter.Scope,
                    Order  = filter.Order
                });
            }

            if (instance is IAuthorizationFilter authorization)
            {
                AuthorizationFilters.Add(new FilterInfo <IAuthorizationFilter>
                {
                    Filter = authorization,
                    Scope  = filter.Scope,
                    Order  = filter.Order
                });
            }

            if (instance is IActionFilter action)
            {
                ActionFilters.Add(new FilterInfo <IActionFilter>
                {
                    Filter = action,
                    Scope  = filter.Scope,
                    Order  = filter.Order
                });
            }

            if (instance is IResultFilter result)
            {
                ResultFilters.Add(new FilterInfo <IResultFilter>
                {
                    Filter = result,
                    Scope  = filter.Scope,
                    Order  = filter.Order
                });
            }

            if (instance is IExceptionFilter exception)
            {
                ExceptionFilters.Add(new FilterInfo <IExceptionFilter>
                {
                    Filter = exception,
                    Scope  = filter.Scope,
                    Order  = filter.Order
                });
            }
        }
示例#12
0
            public void VerifyActionUsable()
            {
                GlobalFactory.BuildUnitService = x => new TestUnitService();
                var memory = FindMemoryApi();
                var result = ActionFilters.BuffingFilter(memory, _battleAbility);

                Assert.True(result);
            }
示例#13
0
        public override void Run()
        {
            var usable = Config.Instance.BattleLists["Start"]
                         .Actions.Where(x => ActionFilters.BuffingFilter(fface, x));

            // Execute moves at target.
            Executor.UseBuffingActions(usable);
        }
示例#14
0
        public override void Run(IGameContext context)
        {
            var usable = context.Config.BattleLists["Start"]
                         .Actions.Where(x => ActionFilters.BuffingFilter(context.API, x));

            // Execute moves at target.
            context.Memory.Executor.UseBuffingActions(usable);
        }
示例#15
0
        public override bool Check(IGameContext context)
        {
            if (new RestState().Check(context))
            {
                return(false);
            }

            return(context.Config.BattleLists["Healing"].Actions
                   .Any(x => ActionFilters.BuffingFilter(context.API, x)));
        }
示例#16
0
            public void VerifyActionNotUsable()
            {
                var memoryAPI = FindMemoryApi();
                var result    = ActionFilters.ValidateBuffingAction(memoryAPI, _battleAbility, new List <IUnit>
                {
                    new FakeUnit()
                }).ToList();

                Assert.NotEmpty(result);
            }
示例#17
0
        public override bool Check()
        {
            if (new RestState(Memory).Check())
            {
                return(false);
            }

            return(Config.Instance.BattleLists["Healing"].Actions
                   .Any(x => ActionFilters.BuffingFilter(EliteApi, x)));
        }
示例#18
0
        public override void RunComponent()
        {
            // Cast only one action to prevent blocking curing.
            var action = Config.Instance.BattleLists["Battle"].Actions
                         .FirstOrDefault(x => ActionFilters.TargetedFilter(fface, x, Target));

            if (action != null)
            {
                _executor.UseTargetedAction(action, Target);
            }
        }
 /// <summary>
 /// Used For Queueing Actions Inside AllyActionQueueController
 /// </summary>
 /// <param name="actionToPerform">From IGBPI_Action Struct.</param>
 /// <param name="canPerformAction">From IGBPI_Action Struct. Only Needed For Testing Action Condition Inside AllyTacticsController Script. Use (_ally) => true If No Additional Condition is Needed</param>
 /// <param name="actionFilter">From IGBPI_Action Struct.</param>
 /// <param name="stopPerformingTask">Optional Action That Will Stop The Execution Of A Task. Use (_ally) => {} if Stopping Isn't Needed</param>
 public RTSActionItem(
     System.Action <AllyMember, AllyAIController, AllyMember> actionToPerform,
     System.Func <AllyMember, AllyAIController, AllyMember, bool> canPerformAction,
     ActionFilters actionFilter,
     System.Action <AllyMember, AllyAIController, AllyMember> stopPerformingTask
     )
 {
     this.actionToPerform    = actionToPerform;
     this.canPerformAction   = canPerformAction;
     this.actionFilter       = actionFilter;
     this.stopPerformingTask = stopPerformingTask;
 }
示例#20
0
        public override void Run()
        {
            // Cast only one action to prevent blocking curing.
            var action = Config.Instance.BattleLists["Battle"].Actions
                         .FirstOrDefault(x => ActionFilters.TargetedFilter(EliteApi, x, Target));

            if (action == null)
            {
                return;
            }
            Executor.UseTargetedActions(new[] { action }, Target);
        }
示例#21
0
        /// <summary>
        ///     Use pulling moves if applicable to make the target
        ///     mob aggressive to us.
        /// </summary>
        public override void Run(IGameContext context)
        {
            // Has the user decided we should engage in battle.
            if (context.Target.Distance <= 25 && context.Config.IsEngageEnabled)
            {
                Player.Engage(context.API);
            }

            var actions = context.Config.BattleLists["Pull"].Actions.ToList();
            var usable  = actions.Where(x => ActionFilters.TargetedFilter(context.API, x, context.Target)).ToList();

            context.Memory.Executor.UseTargetedActions(context, usable, context.Target);
        }
示例#22
0
        public override void Run(IGameContext context)
        {
            // Execute moves.
            var usable = context.Config.BattleLists["End"].Actions
                         .Where(x => ActionFilters.BuffingFilter(context.API, x));

            context.Memory.Executor.UseBuffingActions(usable, context.API.Player.Position);

            // Reset all usage data to begin a new battle.
            foreach (var action in context.Config.BattleLists.Actions)
            {
                action.Usages = 0;
            }
        }
示例#23
0
        public override void Run()
        {
            // Execute moves.
            var usable = Config.Instance.BattleLists["End"].Actions
                         .Where(x => ActionFilters.BuffingFilter(fface, x));

            _executor.UseBuffingActions(usable);

            // Reset all usage data to begin a new battle.
            foreach (var action in Config.Instance.BattleLists.Actions)
            {
                action.Usages = 0;
            }
        }
示例#24
0
        public ActionFilters NavPreviousAction()
        {
            var _filters = Enum.GetValues(typeof(ActionFilters));

            if ((int)actionFilter > 0)
            {
                actionFilter--;
            }
            else
            {
                actionFilter = (ActionFilters)_filters.Length - 1;
            }
            return(actionFilter);
        }
示例#25
0
        public ActionFilters NavForwardAction()
        {
            var _filters = Enum.GetValues(typeof(ActionFilters));

            if ((int)actionFilter < _filters.Length - 1)
            {
                actionFilter++;
            }
            else
            {
                actionFilter = (ActionFilters)0;
            }
            return(actionFilter);
        }
示例#26
0
        public override void Run(IGameContext context)
        {
            ShouldRecycleBattleStateCheck(context);

            // Cast only one action to prevent blocking curing.
            var action = context.Config.BattleLists["Battle"].Actions
                         .FirstOrDefault(x => ActionFilters.TargetedFilter(context.API, x, context.Target));

            if (action == null)
            {
                return;
            }
            context.Memory.Executor.UseTargetedActions(new[] { action }, context.Target);
        }
示例#27
0
        public override void Run()
        {
            // Get the list of healing abilities that can be used.
            var healingMoves = Config.Instance.BattleLists["Healing"].Actions
                               .Where(x => ActionFilters.BuffingFilter(EliteApi, x))
                               .ToList();

            if (healingMoves.Count <= 0)
            {
                return;
            }
            var healingMove = healingMoves.First();

            Executor.UseBuffingActions(new[] { healingMove });
        }
示例#28
0
        public override bool Check()
        {
            if (new RestState(fface).Check())
            {
                return(false);
            }

            if (!Config.Instance.BattleLists["Healing"].Actions
                .Any(x => ActionFilters.BuffingFilter(fface, x)))
            {
                return(false);
            }

            return(true);
        }
示例#29
0
        public override void Run(IGameContext context)
        {
            // Get the list of healing abilities that can be used.
            var healingMoves = context.Config.BattleLists["Healing"].Actions
                               .Where(x => ActionFilters.BuffingFilter(context.API, x))
                               .ToList();

            if (healingMoves.Count <= 0)
            {
                return;
            }
            var healingMove = healingMoves.First();

            context.Memory.Executor.UseBuffingActions(new[] { healingMove }, context.API.Player.Position);
        }
示例#30
0
        /// <summary>
        ///     Use pulling moves if applicable to make the target
        ///     mob aggressive to us.
        /// </summary>
        public override void RunComponent()
        {
            // Do not pull if we've done so already.
            if (CombatBaseState.IsFighting)
            {
                return;
            }

            // Only pull if we have moves.
            if (Config.Instance.BattleLists["Pull"]
                .Actions.Any(x => x.IsEnabled))
            {
                var usable = Config.Instance.BattleLists["Pull"]
                             .Actions.Where(x => ActionFilters.TargetedFilter(fface, x, Target));

                Executor.UseTargetedActions(usable, Target);
            }
        }