Ejemplo n.º 1
0
    private void CreateIdleState()
    {
        idleState = (fsm, gameObj) => {
            // GOAP Planning

            Dictionary <string, object> worldState = agent.WorldState();
            Dictionary <string, object> goal       = agent.CreateGoalState();

            Queue <GoapAction> plan = GoapPlanner.Plan(gameObject, availableActions, worldState, goal);

            if (plan != null)
            {
                currentPlan = plan;
                agent.PlanFound(goal, plan);

                fsm.PopState();
                fsm.PushState(performActionState);
            }
            else
            {
                Debug.Log("<color=orange>Failed Plan:</color>" + goal);
                agent.PlanFailed(goal);
                fsm.PopState();
                fsm.PushState(idleState);
            }
        };
    }