コード例 #1
0
        public static NodeState Tick(int index, INodeBlob blob, IBlackboard blackboard)
        {
            var childState = blob.TickChildren(index, blackboard).FirstOrDefault();

            if (childState == 0)
            {
                blob.ResetChildren(index, blackboard);
                childState = blob.TickChildren(index, blackboard).FirstOrDefault();
            }
            ref var data = ref blob.GetNodeData <RepeatTimesNode>(index);
コード例 #2
0
        public NodeState Tick(int index, INodeBlob blob, IBlackboard blackboard)
        {
            var childState = blob.TickChildren(index, blackboard).FirstOrDefault();

            if (childState == 0)
            {
                blob.ResetChildren(index, blackboard);
                childState = blob.TickChildren(index, blackboard).FirstOrDefault();
            }
            return(BreakStates.HasFlagFast(childState) ? childState : NodeState.Running);
        }
コード例 #3
0
        public static NodeState Tick(int index, INodeBlob blob, IBlackboard bb)
        {
            if (!bb.HasData <IsRunOnMainThread>())
            {
                return(blob.TickChildren(index, bb).FirstOrDefault());
            }

            ref var isRunOnMainThread = ref bb.GetDataRef <IsRunOnMainThread>();
コード例 #4
0
        public NodeState Tick(int index, INodeBlob blob, IBlackboard blackboard)
        {
            var childState = blob.TickChildren(index, blackboard).FirstOrDefault();

            if (childState == 0)
            {
                blob.ResetChildren(index, blackboard);
                childState = blob.TickChildren(index, blackboard).FirstOrDefault();
            }
            if (BreakStates.HasFlag(childState))
            {
                return(childState);
            }

            TickTimes--;
            return(TickTimes <= 0 ? NodeState.Success : NodeState.Running);
        }
コード例 #5
0
        public NodeState Tick(int index, INodeBlob blob, IBlackboard bb)
        {
            var childState = blob.TickChildren(index, bb).FirstOrDefault();

            if (childState == 0)
            {
                blob.ResetChildren(index, bb);
                childState = blob.TickChildren(index, bb).FirstOrDefault();
            }
            if (BreakStates.HasFlag(childState))
            {
                return(childState);
            }

            CountdownSeconds -= bb.GetData <BehaviorTreeTickDeltaTime>().Value;
            return(CountdownSeconds <= 0 ? NodeState.Success : NodeState.Running);
        }
コード例 #6
0
ファイル: TimerNode.cs プロジェクト: Hengle/EntitiesBT
        public NodeState Tick(int index, INodeBlob blob, IBlackboard blackboard)
        {
            var childState = blob.TickChildren(index, blackboard, state => state.IsCompleted()).FirstOrDefault();

            CountdownSeconds -= blackboard.GetData <BehaviorTreeTickDeltaTime>().Value;
            if (CountdownSeconds <= 0f)
            {
                return(childState.IsCompleted() ? childState : BreakReturnState);
            }
            return(NodeState.Running);
        }
コード例 #7
0
        public NodeState Tick(int index, INodeBlob blob, IBlackboard bb)
        {
            if (bb.HasData <ForceRunOnMainThreadTag>() || bb.HasData <ForceRunOnJobTag>())
            {
                return(blob.TickChildren(index, bb).FirstOrDefault());
            }

            var isRunOnMainThread = bb.HasData <RunOnMainThreadTag>();

            if (!isRunOnMainThread)
            {
                bb.GetData <IEntityCommand>().AddComponent <RunOnMainThreadTag>();
                return(NodeState.Running);
            }
            var state = blob.TickChildren(index, bb).FirstOrDefault();

            if (state != NodeState.Running)
            {
                bb.GetData <IEntityCommand>().RemoveComponent <RunOnMainThreadTag>();
            }
            return(state);
        }
コード例 #8
0
        public static NodeState Tick(int index, INodeBlob blob, IBlackboard bb)
        {
            var endIndex   = blob.GetEndIndex(index);
            var childIndex = index + 1;

            for (var i = childIndex + 1 /* always reset directly child */; i < endIndex; i++)
            {
                if (blob.GetState(i) == NodeState.Running)
                {
                    endIndex = i;
                    break;
                }
            }
            var count = endIndex - childIndex;

            // count will be 0 if there's no child
            blob.ResetStates(childIndex, count);
            return(blob.TickChildren(index, bb).FirstOrDefault());
        }
コード例 #9
0
        public static NodeState Tick(int index, INodeBlob blob, IBlackboard blackboard)
        {
            var flags = blob.TickChildren(index, blackboard)
                        .Aggregate((NodeState)0, (childStateFlags, childState) => {
                childStateFlags |= childState;
                return(childStateFlags);
            });

            if (flags.HasFlagFast(NodeState.Running))
            {
                return(NodeState.Running);
            }
            if (flags.HasFlagFast(NodeState.Failure))
            {
                return(NodeState.Failure);
            }
            if (flags.HasFlagFast(NodeState.Success))
            {
                return(NodeState.Success);
            }
            return(0);
        }
コード例 #10
0
 public static NodeState Tick(int index, INodeBlob blob, IBlackboard blackboard)
 {
     var     childState = blob.TickChildren(index, blackboard, state => state.IsCompleted()).FirstOrDefault();
     ref var data       = ref blob.GetNodeData <TimerNode>(index);
コード例 #11
0
 public NodeState Tick(int index, INodeBlob blob, IBlackboard blackboard)
 {
     return(blob.TickChildren(index, blackboard, breakCheck: state => state.IsRunningOrFailure()).LastOrDefault());
 }