private void createIdleState() { _idleState = (fsm, gameObj) => { // GOAP planning // get the world state and the goal we want to plan for Dictionary <string, object> worldState = _dataProvider.GetWorldState(); Dictionary <Int64, Int64> resourceState = _dataProvider.GetResourceState(); Dictionary <string, object> goal = _dataProvider.CreateGoalState(); Dictionary <Int64, Int64> resourceGoal = _dataProvider.CreateResourceGoal(); loadActions(); // Plan Queue <GoapAction> plan = _planner.Plan(this, _availableActions, worldState, resourceState, goal, resourceGoal); if (plan != null) { // we have a plan, hooray! _currentActions = plan; _dataProvider.PlanFound(goal, plan); fsm.popState(); // move to PerformAction state fsm.pushState(_performActionState); } else { // ugh, we couldn't get a plan // Console.WriteLine("<color=orange>Failed Plan:</color>" + PrettyPrint(goal)); _dataProvider.PlanFailed(goal); fsm.popState(); // move back to IdleAction state fsm.pushState(_idleState); } }; }