示例#1
0
 public void AddParentBehavior(StratusAIBehavior behavior, BehaviorNode child)
 {
     if (behavior != null)
     {
         this.tree.AddParentElement(behavior, child);
     }
 }
示例#2
0
            public StratusAIBehavior AddBehavior(Type behaviorType, BehaviorNode parent)
            {
                StratusAIBehavior behavior = StratusAIBehavior.Instantiate(behaviorType);

                AddBehavior(behavior, parent);
                return(behavior);
            }
        //------------------------------------------------------------------------/
        // 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);
        }
示例#4
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;
                    }
                }
            }
        /// <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);
        }
示例#6
0
            public StratusAIBehavior AddParentBehavior(Type behaviorType, BehaviorNode child)
            {
                StratusAIBehavior behavior = StratusAIBehavior.Instantiate(behaviorType);

                AddParentBehavior(behavior, child);
                return(behavior);
            }
示例#7
0
 public void AddBehavior(StratusAIBehavior behavior, BehaviorNode parent)
 {
     if (behavior != null)
     {
         this.tree.AddChildElement(behavior, parent);
     }
 }
示例#8
0
 public override void OnBehaviorEnded(StratusAIBehavior behavior, StratusAIBehavior.Status status)
 {
     stack.RemoveLast();
     //Trace.Script($"Removing {behavior}");
     if (stack.Empty())
     {
         this.OnReset();
     }
 }
示例#9
0
 public override void OnBehaviorEnded(StratusAIBehavior behavior, StratusAIBehavior.Status status)
 {
     // Modify the current world state due to the previous action
     // We already have a reference to the current action so
     // don't really use the behavior here (it wouldn't know its
     // part of a stateful action anyway)
     this.state.Merge(currentAction.effects);
     ContinuePlan();
 }
示例#10
0
        private void AddNode(StratusAIBehavior behavior, BehaviorTree.BehaviorNode parent = null)
        {
            if (parent != null)
            {
                this.behaviorTree.AddBehavior(behavior, parent);
            }
            else
            {
                this.behaviorTree.AddBehavior(behavior);
            }

            this.Save();
        }
 public abstract void OnBehaviorEnded(StratusAIBehavior behavior, StratusAIBehavior.Status status);
示例#12
0
 //------------------------------------------------------------------------/
 // Method
 //------------------------------------------------------------------------/
 public void Set(StratusAIBehavior child)
 {
     this.child = child;
 }
 protected abstract void OnBehaviorAdded(StratusAIBehavior behavior);
 public abstract void OnBehaviorStarted(StratusAIBehavior behavior);
示例#15
0
 public override void OnBehaviorStarted(StratusAIBehavior behavior)
 {
 }
 /// <summary>
 /// Adds a behaviour to the system
 /// </summary>
 /// <param name="type"></param>
 public void AddBehavior(StratusAIBehavior behavior)
 {
     this.OnBehaviorAdded(behavior);
 }
示例#17
0
 public override void OnBehaviorStarted(StratusAIBehavior behavior)
 {
     //Trace.Script($"Adding {behavior}");
     stack.Add(behavior);
 }
示例#18
0
 protected override void OnBehaviorAdded(StratusAIBehavior behavior)
 {
     this.tree.AddElement(behavior);
 }
示例#19
0
 protected override void OnBehaviorsCleared()
 {
     this.tree.Clear();
     this.tree.root.data = StratusAIBehavior.Instantiate(typeof(StratusAISequence));
 }
示例#20
0
            public void ReplaceBehavior(BehaviorNode original, Type replacementBehaviorType)
            {
                StratusAIBehavior replacementBehavior = StratusAIBehavior.Instantiate(replacementBehaviorType);

                this.tree.ReplaceElement(original, replacementBehavior);
            }
示例#21
0
 //------------------------------------------------------------------------/
 // Messages: Behaviors
 //------------------------------------------------------------------------/
 protected override void OnBehaviorAdded(StratusAIBehavior behavior)
 {
     throw new NotImplementedException();
 }