コード例 #1
0
    private void createMoveToState()
    {
        moveToState = (fsm, gameObj) => {
            // move the game object

            GoapAction action = currentActions.Peek();
            if (action.requiresInRange() && action.target == null)
            {
                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()");
                fsm.popState();                 // move
                fsm.popState();                 // perform
                fsm.pushState(idleState);
                return;
            }

            // get the agent to go to action spot
            if (dataProvider.GoToAction(action))
            {
                fsm.popState();
            }
        };
    }