private void CreatePerformActionState()
        {
            PerformActionState = (fsm, agent) =>
            {
                if (!HasActionPlan())
                {
                    fsm.PopState();
                    fsm.PushState(IdleState);
                    DataProvider.ActionsFinished();
                }

                GOAPAction action = CurrentActions.Peek();
                if (action.IsDone())
                {
                    AddThought("Completed action " + action.ToString(), Color.DarkOrange);
                    CurrentActions.Dequeue();
                }

                if (HasActionPlan())
                {
                    action = CurrentActions.Peek();
                    bool InRange = action.RequiresInRange() ? action.InRange : true;

                    if (InRange)
                    {
                        bool Success = action.Run(agent);

                        if (!Success)
                        {
                            fsm.PopState();
                            fsm.PushState(IdleState);
                            DataProvider.PlanAborted(action);
                        }
                    }
                    else
                    {
                        fsm.PushState(MoveToState);
                        AddThought("Moving to " + action.Target.Name, Color.DarkOliveGreen);
                    }
                }
                else
                {
                    fsm.PopState();
                    fsm.PushState(IdleState);
                    DataProvider.ActionsFinished();
                }
            };
        }
        private void CreateMoveToState()
        {
            MoveToState = (fsm, agent) =>
            {
                GOAPAction Action = CurrentActions.Peek();
                if (Action.RequiresInRange() && Action.Target == null)
                {
                    fsm.PopState();
                    fsm.PopState();
                    fsm.PushState(IdleState);
                    return;
                }

                if (DataProvider.MoveAgent(Action))
                {
                    fsm.PopState();
                    AddThought("Performing action " + Action.ToString(), Color.Blue);
                }
            };
        }