private void Stop(BehaviourTreeExecutor <TBlackboard> executor, BehaviourTreeExecutionData <TBlackboard> data, BehaviourTreeStatus status) { AbortRunningChildren(executor, data); executor.Stop(data, this, status); }
private static string GetColorByStatus(BehaviourTreeStatus status) { switch (status) { case BehaviourTreeStatus.Success: return("008800"); case BehaviourTreeStatus.Failure: return("880000"); case BehaviourTreeStatus.Running: return("000088"); case BehaviourTreeStatus.None: return("333333"); case BehaviourTreeStatus.Waiting: break; default: throw new ArgumentOutOfRangeException(); } return("ff00ff"); }
public void Update(GameTime gameTime) { if (Status == BehaviourTreeStatus.Running) { Status = internalUpdate(gameTime); } }
public override BehaviourTreeStatus Tick() { if (!condition()) { return(BehaviourTreeStatus.Success); } foreach (BaseNode node in inputNodes) { BehaviourTreeStatus result = node.Tick(); switch (result) { case BehaviourTreeStatus.Failure: return(BehaviourTreeStatus.Failure); case BehaviourTreeStatus.Running: return(BehaviourTreeStatus.Running); case BehaviourTreeStatus.Success: //only at succes it moves on to the next task break; default: break; } } return(BehaviourTreeStatus.Failure); }
public static IEnumerator <BehaviourTreeStatus> getStatus(BehaviourTreeStatus aStatus) { List <BehaviourTreeStatus> status = new List <BehaviourTreeStatus>(); status.Add(aStatus); return(status.GetEnumerator()); }
private void Close(BehaviourTreeContext context) { context.OpenedNodes.Remove(this); OnClose(context); LastStatus = BehaviourTreeStatus.Waiting; }
public override void SetStatusAll(BehaviourTreeStatus aStatus) { currentStatus = aStatus; foreach (var child in children) { child.SetStatusAll(aStatus); } }
public virtual int CountAllForStatus(BehaviourTreeStatus aStatus) { if (currentStatus == aStatus) { return(1); } else { return(0); } }
public void Stop(BehaviourTreeExecutionData <TBlackboard> data, BehaviourTreeNode <TBlackboard> node, BehaviourTreeStatus status) { RemoveNode(data, node); data.Statuses[node.Id] = status; if (node.Observer != null) { node.Observer.OnComplete(this, data, status); } }
public override int CountAllForStatus(BehaviourTreeStatus aStatus) { // return a count of the status for all nodes under the current node that have the // specified status value int numCount = 0; if (currentStatus == aStatus) { ++numCount; } numCount += childNode.CountAllForStatus(aStatus); return(numCount); }
public override BehaviourTreeStatus Tick(float Time) { foreach (BehaviorTreeNode node in Nodes) { BehaviourTreeStatus BTS = node.Tick(Time); if (BTS != BehaviourTreeStatus.Failed) { return(BTS); } } return(BehaviourTreeStatus.Failed); }
public BehaviourTreeStatus Tick(BehaviourTreeContext context, float delta) { if (!context.OpenedNodes.Contains(this)) { Open(context); } var status = OnTick(context, delta); if (status != BehaviourTreeStatus.Running) { Close(context); } LastStatus = status; return(status); }
private static BehaviourTreeStatus InvertStatus(BehaviourTreeStatus status) { switch (status) { case BehaviourTreeStatus.Failure: return(BehaviourTreeStatus.Success); case BehaviourTreeStatus.Success: return(BehaviourTreeStatus.Failure); case BehaviourTreeStatus.Uninitialized: case BehaviourTreeStatus.Running: case BehaviourTreeStatus.Aborted: return(status); default: throw new ArgumentOutOfRangeException(); } }
public RepeatUntilStatusReachedNode(string name, BehaviourTreeStatus status) : base(name) { _status = status; }
public virtual void SetStatusAll(BehaviourTreeStatus aStatus) { currentStatus = aStatus; }
public void SetStatus(BehaviourTreeNode <TBlackboard> node, BehaviourTreeStatus status) { Statuses[node.Id] = status; }
public override void SetStatusAll(BehaviourTreeStatus aStatus) { currentStatus = aStatus; childNode.SetStatusAll(aStatus); }
public BehaviourTreeStatus Tick(TimeData time) { Status = fn(time); return(Status); }
public RepeatWhileStatus(string name, BehaviourTreeStatus status) : base(name) { _status = status; }
public void OnComplete(BehaviourTreeExecutor <TBlackboard> executor, BehaviourTreeExecutionData <TBlackboard> execution, BehaviourTreeStatus status) { if (status != _status) { executor.Stop(execution, this, BehaviourTreeStatus.Success); } else { executor.Schedule(execution, Node, this); } }
public void OnComplete(BehaviourTreeExecutor <TBlackboard> executor, BehaviourTreeExecutionData <TBlackboard> execution, BehaviourTreeStatus status) { executor.Stop(execution, this, InvertStatus(status)); }
public void OnComplete(BehaviourTreeExecutor <TBlackboard> executor, BehaviourTreeExecutionData <TBlackboard> execution, BehaviourTreeStatus status) { if (status == BehaviourTreeStatus.Success) { ++execution.Variables[_succeededCountId]; if (SucceedPolicy == ParallelPolicy.RequireOne) { Stop(executor, execution, BehaviourTreeStatus.Success); return; } } else if (status == BehaviourTreeStatus.Failure) { ++execution.Variables[_failedCountId]; if (FailurePolicy == ParallelPolicy.RequireOne) { Stop(executor, execution, BehaviourTreeStatus.Failure); return; } } if (FailurePolicy == ParallelPolicy.RequireAll && execution.Variables[_failedCountId] == ChildrenCount) { Stop(executor, execution, BehaviourTreeStatus.Failure); } else if (SucceedPolicy == ParallelPolicy.RequireAll && execution.Variables[_succeededCountId] == ChildrenCount) { Stop(executor, execution, BehaviourTreeStatus.Success); } }
public void OnComplete(BehaviourTreeExecutor <TBlackboard> executor, BehaviourTreeExecutionData <TBlackboard> execution, BehaviourTreeStatus status) { var node = GetCurrentChild(execution); if (execution.Statuses[node.Id] == BehaviourTreeStatus.Success) { executor.Stop(execution, this, BehaviourTreeStatus.Success); return; } var currentChild = ++execution.Variables[_currentChildId]; if (currentChild == ChildrenCount) { executor.Stop(execution, this, BehaviourTreeStatus.Failure); } else { executor.Start(execution, GetCurrentChild(execution), this); } }
public virtual void OnTerminate(BehaviourTreeExecutionData <TBlackboard> behaviourTreeExecutor, BehaviourTreeStatus status) { }