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