示例#1
0
 public override void StartBehaviourTreeUpdate(BehaviourTreeRoot root)
 {
     Preconditions.Assert(_rootSnapshot == null, "RootSnapshotNotNull");
     Preconditions.Assert(_snapshotsStack == null, "SnapshotStack not null");
     _rootSnapshot   = CreateBaseTaskSnapshot(root.Child);
     _snapshotsStack = new Stack <AiRegistryTaskSnapshot>();
 }
示例#2
0
        private AiRegistryTaskSnapshot CreateBaseTaskSnapshot(AITask task)
        {
            var snapshot = new AiRegistryTaskSnapshot()
            {
                TaskWithStatus = new AiRegistryTaskWithStatus()
                {
                    Status = task.TaskStatus,
                    Task   = task
                }
            };

            snapshot.Children   = task.Children.Select(CreateBaseTaskSnapshot).ToList();
            snapshot.ChildCalls = new List <AiRegistryChildCall>();
            return(snapshot);
        }
示例#3
0
 public override void OnRunCompleted(AITask aiTask, AIOneRunStatus result)
 {
     _snapshotsStack.Pop();
     if (_snapshotsStack.Any())
     {
         var parent = _snapshotsStack.Peek();
         parent.ChildCalls.Add(new AiRegistryChildCall()
         {
             CallStatus    = result,
             TaskAfterCall = new AiRegistryTaskWithStatus()
             {
                 Status = aiTask.TaskStatus,
                 Task   = aiTask
             }
         });
     }
     else
     {
         _recorder.RecordSnapshot(new AiBehaviourTreeFrameSnapshot()
         {
             Owner    = _owner,
             RootCall = new AiRegistryChildCall()
             {
                 TaskAfterCall = new AiRegistryTaskWithStatus()
                 {
                     Task   = aiTask,
                     Status = aiTask.TaskStatus
                 },
                 CallStatus = result
             },
             RootChild = _rootSnapshot
         });
         _snapshotsStack = null;
         _rootSnapshot   = null;
     }
 }