コード例 #1
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>();
コード例 #2
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);
        }
コード例 #3
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);
    }