Example #1
0
        protected AgentAction AddBindableAction(IAsyncExecutableAction action)
        {
            var agentAction = new AgentAction(this, action);

            _actions.Add(agentAction);

            return(agentAction);
        }
Example #2
0
        private async Task ExecuteAction(IAsyncExecutableAction action, DomainState currentState, CancellationToken token)
        {
            OnActionStarting(action);
            CurrentAction = action;

            try
            {
                var actionSucceeded = await action.ExecuteAsync(currentState, token);

                if (actionSucceeded)
                {
                    OnActionCompleted(action);
                }
                else
                {
                    OnActionFailed(action);
                }
            }
            catch (OperationCanceledException)
            {
                CurrentAction = null;
            }
        }
Example #3
0
 public AgentAction(Agent agent, IAsyncExecutableAction action)
 {
     _action = action;
     _agent  = agent;
 }