Exemple #1
0
        public NodeState Tick(int index, INodeBlob blob, IBlackboard bb)
        {
            var deltaTime = bb.GetData <BehaviorTreeTickDeltaTime>().Value;
            var transform = bb.GetData <Transform>();
            var deltaMove = Velocity * deltaTime;

            transform.position += deltaMove;
            return(NodeState.Running);
        }
        public static NodeState Tick(int index, INodeBlob blob, IBlackboard bb)
        {
            var controller = bb.GetData <CharacterController>();

            if (controller == null)
            {
                return(NodeState.Failure);
            }
            controller.SimpleMove(bb.GetData <BTCharacterSimpleMoveVelocity>().Value);
            return(NodeState.Success);
        }
        public NodeState Tick(int index, INodeBlob blob, IBlackboard bb)
        {
            var input  = bb.GetData <InputActionAssetComponent>().Value;
            var action = input.FindAction(ActionId);

            return(action != null && action.phase == Phase ? NodeState.Success : NodeState.Failure);
        }
        public static NodeState Tick(int index, INodeBlob blob, IBlackboard blackboard)
        {
            var animator = blackboard.GetData <Animator>();

            animator.SetTrigger(blob.GetNodeData <SetAnimatorTriggerNode>(index).Value);
            return(NodeState.Success);
        }
        public static NodeState Tick(int index, INodeBlob blob, IBlackboard bb)
        {
            var look      = bb.GetData <BTInputLookData>().Value;
            var direction = quaternion.LookRotation(new float3(look.x, 0, look.y), math.up());

            bb.GetDataRef <BTTransformRotationData>().Value = direction;
            return(NodeState.Success);
        }
Exemple #6
0
        public static NodeState Tick(int index, INodeBlob blob, IBlackboard bb)
        {
            var input  = bb.GetData <InputActionAssetComponent>().Value;
            var data   = blob.GetNodeData <CheckInputActionPhaseNode>(index);
            var action = input.FindAction(data.ActionId);

            return(action != null && action.phase == data.Phase ? NodeState.Success : NodeState.Failure);
        }
        public static InputAction GetInputAction <TNodeData>(this IBlackboard bb, int index, INodeBlob blob)
            where TNodeData : struct, IInputActionNodeData
        {
            var input = bb.GetData <InputActionAssetComponent>().Value;
            var data  = blob.GetNodeData <TNodeData>(index);

            return(input.FindAction(data.ActionId));
        }
        public static NodeState Tick(int index, INodeBlob blob, IBlackboard bb)
        {
            var input     = bb.GetData <BTInputMoveData>();
            var direction = new Vector3(input.Value.x, 0, input.Value.y).normalized;
            var speed     = blob.GetNodeData <InputMoveToCharacterVelocityNode>(index).Speed;

            bb.GetDataRef <BTCharacterSimpleMoveVelocity>().Value = direction * speed;
            return(NodeState.Success);
        }
        public static NodeState Tick(int index, INodeBlob blob, IBlackboard bb)
        {
            var controller = bb.GetData <CharacterController>();

            if (controller == null)
            {
                return(NodeState.Failure);
            }
            ref var data     = ref blob.GetNodeData <CharacterSimpleMoveNode>(index);
        public static NodeState Tick(int index, INodeBlob blob, IBlackboard bb)
        {
            var controller = bb.GetData <UnityEngine.CharacterController>();

            if (controller == null)
            {
                return(NodeState.Failure);
            }
            controller.SimpleMove(blob.GetNodeData <CharacterSimpleMoveWithCustomGlobalVelocityNode>(index).Velocity);
            return(NodeState.Success);
        }
Exemple #11
0
        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);
        }
Exemple #12
0
        public NodeState Tick(int index, INodeBlob blob, IBlackboard bb)
        {
            var controller = bb.GetData <CharacterController>();

            if (controller == null)
            {
                return(NodeState.Failure);
            }
            Vector3 velocity = Velocity.GetData(index, blob, bb);

            controller.SimpleMove(IsLocal ? controller.transform.localToWorldMatrix.MultiplyVector(velocity) : velocity);
            return(NodeState.Success);
        }
Exemple #13
0
        public NodeState Tick(int index, INodeBlob blob, IBlackboard bb)
        {
            var transform = bb.GetData <Transform>();

            if (transform == null)
            {
                return(NodeState.Failure);
            }
            var rotation = RotationProperty.GetData(index, blob, bb);

            transform.rotation = rotation;
            return(NodeState.Success);
        }
Exemple #14
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);
        }
Exemple #15
0
        public static NodeState Tick(int index, INodeBlob blob, IBlackboard bb)
        {
            var move = bb.GetData <BTInputMoveData>().Value;

            if (math.lengthsq(move) <= math.FLT_MIN_NORMAL)
            {
                return(NodeState.Success);
            }

            var direction = quaternion.LookRotationSafe(new float3(move.x, 0, move.y), math.up());

            bb.GetDataRef <BTTransformRotationData>().Value = direction;
            return(NodeState.Success);
        }
        public static NodeState Tick(int index, INodeBlob blob, IBlackboard bb)
        {
            var controller = bb.GetData <CharacterController>();

            if (controller == null)
            {
                return(NodeState.Failure);
            }
            var velocity = blob.GetNodeData <CharacterSimpleMoveWithCustomLocalVelocityNode>(index).Velocity;

            velocity = controller.transform.localToWorldMatrix.MultiplyVector(velocity);
            controller.SimpleMove(velocity);
            return(NodeState.Success);
        }
Exemple #17
0
    public NodeState Tick(int index, INodeBlob blob, IBlackboard bb)
    {
        NodeState ret = NodeState.Running;

        if (bb.HasData <ClosestEnemy>())
        {
            var comp = bb.GetData <ClosestEnemy>();
            Debug.Log($"closestEnemy: {comp.entity}, pos: {comp.position}");
            ret = NodeState.Success;
        }
        else
        {
            ret = NodeState.Failure;
        }

        return(ret);
    }
        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);
        }
Exemple #19
0
 public NodeState Tick(int index, INodeBlob blob, IBlackboard bb)
 {
     TimerSeconds -= bb.GetData <BehaviorTreeTickDeltaTime>().Value;
     return(TimerSeconds <= 0 ? NodeState.Success : NodeState.Running);
 }
Exemple #20
0
        public NodeState Tick(int index, INodeBlob blob, IBlackboard bb)
        {
            var translation = bb.GetData <Translation>();

            return(Bounds.Contains(translation.Value) ? NodeState.Success : NodeState.Failure);
        }
Exemple #21
0
 public NodeState Tick(int index, INodeBlob blob, IBlackboard bb)
 {
     bb.GetData <InputActionAssetComponent>().Value.Enable();
     return(NodeState.Success);
 }
Exemple #22
0
 public static NodeState Tick(int index, INodeBlob blob, IBlackboard bb)
 {
     var     deltaTime = bb.GetData <BehaviorTreeTickDeltaTime>().Value;
     ref var data      = ref blob.GetNodeData <Data>(index);