//------------------------------------------------------------------------/
        // Behavior
        //------------------------------------------------------------------------/
        /// <summary>
        /// Adds a behaviour to the system
        /// </summary>
        /// <param name="behaviorType"></param>
        public StratusAIBehavior AddBehavior(Type behaviorType)
        {
            StratusAIBehavior behavior = StratusAIBehavior.Instantiate(behaviorType);

            this.AddBehavior(behavior);
            return(behavior);
        }
        /// <summary>
        /// Adds a behaviour to the system
        /// </summary>
        /// <param name="behaviorType"></param>
        public T AddBehavior <T>() where T : StratusAIBehavior
        {
            T behavior = StratusAIBehavior.Instantiate <T>();

            this.AddBehavior(behavior);
            return(behavior);
        }
Пример #3
0
            protected override void OnAssert()
            {
                if (this.tree == null)
                {
                    this.tree           = new StratusSerializedTree <BehaviorNode, StratusAIBehavior>();
                    this.tree.root.data = StratusAIBehavior.Instantiate(typeof(StratusAISequence));
                }

                try
                {
                    this.tree.Assert();
                }
                catch (Exception e)
                {
                    StratusDebug.Log($"The tree {name} is damaged: '{e.Message}'. Attempting to repair...");
                    this.tree.Repair();

                    // Try again

                    try
                    {
                        this.tree.Assert();
                    }
                    catch (Exception e2)
                    {
                        StratusDebug.Log($"The tree {name} is damaged: '{e.Message}'");
                        throw e2;
                    }
                }
            }
Пример #4
0
            public StratusAIBehavior AddParentBehavior(Type behaviorType, BehaviorNode child)
            {
                StratusAIBehavior behavior = StratusAIBehavior.Instantiate(behaviorType);

                AddParentBehavior(behavior, child);
                return(behavior);
            }
Пример #5
0
            public StratusAIBehavior AddBehavior(Type behaviorType, BehaviorNode parent)
            {
                StratusAIBehavior behavior = StratusAIBehavior.Instantiate(behaviorType);

                AddBehavior(behavior, parent);
                return(behavior);
            }
Пример #6
0
 protected override void OnBehaviorsCleared()
 {
     this.tree.Clear();
     this.tree.root.data = StratusAIBehavior.Instantiate(typeof(StratusAISequence));
 }
Пример #7
0
            public void ReplaceBehavior(BehaviorNode original, Type replacementBehaviorType)
            {
                StratusAIBehavior replacementBehavior = StratusAIBehavior.Instantiate(replacementBehaviorType);

                this.tree.ReplaceElement(original, replacementBehavior);
            }