public void AddParentBehavior(StratusAIBehavior behavior, BehaviorNode child) { if (behavior != null) { this.tree.AddParentElement(behavior, child); } }
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); }
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); }
public StratusAIBehavior AddParentBehavior(Type behaviorType, BehaviorNode child) { StratusAIBehavior behavior = StratusAIBehavior.Instantiate(behaviorType); AddParentBehavior(behavior, child); return(behavior); }
public void AddBehavior(StratusAIBehavior behavior, BehaviorNode parent) { if (behavior != null) { this.tree.AddChildElement(behavior, parent); } }
public override void OnBehaviorEnded(StratusAIBehavior behavior, StratusAIBehavior.Status status) { stack.RemoveLast(); //Trace.Script($"Removing {behavior}"); if (stack.Empty()) { this.OnReset(); } }
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(); }
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);
//------------------------------------------------------------------------/ // Method //------------------------------------------------------------------------/ public void Set(StratusAIBehavior child) { this.child = child; }
protected abstract void OnBehaviorAdded(StratusAIBehavior behavior);
public abstract void OnBehaviorStarted(StratusAIBehavior behavior);
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); }
public override void OnBehaviorStarted(StratusAIBehavior behavior) { //Trace.Script($"Adding {behavior}"); stack.Add(behavior); }
protected override void OnBehaviorAdded(StratusAIBehavior behavior) { this.tree.AddElement(behavior); }
protected override void OnBehaviorsCleared() { this.tree.Clear(); this.tree.root.data = StratusAIBehavior.Instantiate(typeof(StratusAISequence)); }
public void ReplaceBehavior(BehaviorNode original, Type replacementBehaviorType) { StratusAIBehavior replacementBehavior = StratusAIBehavior.Instantiate(replacementBehaviorType); this.tree.ReplaceElement(original, replacementBehavior); }
//------------------------------------------------------------------------/ // Messages: Behaviors //------------------------------------------------------------------------/ protected override void OnBehaviorAdded(StratusAIBehavior behavior) { throw new NotImplementedException(); }