Exemplo n.º 1
0
        /// <summary>
        /// Implementation of <see cref="IAction"/> interface. Calls the MoveAgent of the <see cref="IGoap"/> interface.
        /// </summary>
        public void Execute()
        {
            // get the action we need to move to
            var action = _agent.PeekNextAction();

            // get the agent to move itself
            _dataProvider.MoveAgent(action);
            if (action.RequiresInRange() == false || action.Target != null)
            {
                return;
            }

            // something went wrong. we need a new plan
            Debug.Log("<color=red>Fatal error:</color> Action requires a target but has none. Planning failed. You did not assign the target in your Action.checkProceduralPrecondition()");

            _agent.GetCurrentActions().Clear(); // set state to PlanState
        }