void SelectPlan()
        {
            var activeGameObject = Selection.activeGameObject;

            if (EditorApplication.isPlayingOrWillChangePlaymode)
            {
                if (!activeGameObject)
                {
                    activeGameObject = FindPlannerObject();
                }

                if (activeGameObject)
                {
                    if (!GetPlanExecutor(activeGameObject, out var executor))
                    {
                        activeGameObject = FindPlannerObject();
                        GetPlanExecutor(activeGameObject, out executor);
                    }

                    if (executor != null)
                    {
                        m_PlanExecutor = executor;
                        m_Visualizer   = new PlanVisualizer(m_PlanExecutor);
                    }
                }
            }
            else
            {
                m_Visualizer   = null;
                m_PlanExecutor = null;
            }
        }
 protected BaseNode(IPlanExecutor planExecutor, string label, object content, bool expansion = false, float weight = 1, bool active = false)
     : base(content, weight, active)
 {
     m_PlanExecutor = planExecutor;
     Label          = label;
     ExpansionNode  = expansion;
 }
Esempio n. 3
0
        // etc.

        public AgentEnvironment(
            IGoalSelector goalSelector,
            IPlanner planner,
            IKnowledgeProvider knowledgeProvider,
            IPlanExecutor planExecutor,
            IReevaluationSensor reevaluationSensor = null
            )
        {
            this.GoalSelector       = PreconditionUtils.EnsureNotNull(goalSelector, "goalSelector");
            this.Planner            = PreconditionUtils.EnsureNotNull(planner, "planner");
            this.KnowledgeProvider  = PreconditionUtils.EnsureNotNull(knowledgeProvider, "knowledgeProvider");
            this.PlanExecutor       = PreconditionUtils.EnsureNotNull(planExecutor, "planExecutor");
            this.ReevaluationSensor = reevaluationSensor != null ? reevaluationSensor : new NullReevaluationSensor();
        }
Esempio n. 4
0
 private AgentConfiguration(
     IGoalSelector goalSelector,
     IPlanner planner,
     IKnowledgeProvider knowledgeProvider,
     IPlanExecutor planExecutor,
     IReevaluationSensor reevaluationSensor = null
     )
 {
     GoalSelector       = PreconditionUtils.EnsureNotNull(goalSelector, "goalSelector");
     Planner            = PreconditionUtils.EnsureNotNull(planner, "planner");
     KnowledgeProvider  = PreconditionUtils.EnsureNotNull(knowledgeProvider, "knowledgeProvider");
     PlanExecutor       = PreconditionUtils.EnsureNotNull(planExecutor, "planExecutor");
     ReevaluationSensor = reevaluationSensor ?? new NullReevaluationSensor();
 }
        static bool GetPlanExecutor(GameObject go, out IPlanExecutor executor)
        {
            executor = null;

            if (go == null)
            {
                return(false);
            }

            var decisionControllers = go.GetComponents <Unity.AI.Planner.Controller.DecisionController>();

            foreach (var decisionController in decisionControllers)
            {
                if (!decisionController.enabled || decisionController.m_PlanExecutor == null)
                {
                    continue;
                }

                executor = decisionController.m_PlanExecutor;
                return(true);
            }

            return(false);
        }
Esempio n. 6
0
 public PlanVisualizer(IPlanExecutor planExecutor)
 {
     m_PlanExecutor = planExecutor;
 }
Esempio n. 7
0
 public StateNode(IPlanExecutor planExecutor, IStateKey stateKey, bool expansion = false, float weight = 1, bool active = false, bool rootState = false)
     : base(planExecutor, stateKey.Label, stateKey, expansion, weight, active)
 {
     m_RootState = rootState;
 }
Esempio n. 8
0
 public Builder WithPlanExecutor(IPlanExecutor planExecutor)
 {
     this.planExecutor = PreconditionUtils.EnsureNotNull(planExecutor, "planExecutor");
     return(this);
 }