Пример #1
0
    public bool NodeContainsAnyExcept(GraphNode node, List <SingleNodeBlocker> selector)
    {
        List <SingleNodeBlocker> list;

        if (!this.blocked.TryGetValue(node, out list))
        {
            return(false);
        }
        for (int i = 0; i < list.Count; i++)
        {
            SingleNodeBlocker objA = list[i];
            bool flag = false;
            for (int j = 0; j < selector.Count; j++)
            {
                if (object.ReferenceEquals(objA, selector[j]))
                {
                    flag = true;
                    break;
                }
            }
            if (!flag)
            {
                return(true);
            }
        }
        return(false);
    }
Пример #2
0
        private void SetupNodeBlocker()
        {
            if (this.blocker != null)
            {
                return;
            }

            this.blocker         = GetComponent <SingleNodeBlocker>();
            this.blocker.manager = Pathfinder.Instance.BlockManager;
        }
Пример #3
0
    protected virtual void Awake()
    {
        isNotAffectedByCondition = true;

        blockManager      = GameObject.Find("AStarManager").GetComponent <BlockManager>();
        blocker           = GetComponent <SingleNodeBlocker>();
        traversalProvider = new BlockManager.TraversalProvider(blockManager, BlockManager.BlockMode.AllExceptSelector, new List <SingleNodeBlocker>()
        {
            blocker
        });
    }
Пример #4
0
    /** Register \a blocker as being present at the specified node.
     * Calling this method multiple times will add multiple instances of the blocker to the node.
     *
     * \note The node will not be blocked immediately. Instead the pathfinding
     * threads will be paused and then the update will be applied. It is however
     * guaranteed to be applied before the next path request is started.
     */
    public void InternalBlock(GraphNode node, SingleNodeBlocker blocker)
    {
        AstarPath.active.AddWorkItem(new AstarWorkItem(() => {
            List <SingleNodeBlocker> blockersInNode;
            if (!blocked.TryGetValue(node, out blockersInNode))
            {
                blockersInNode = blocked[node] = ListPool <SingleNodeBlocker> .Claim();
            }

            blockersInNode.Add(blocker);
        }));
    }
Пример #5
0
    private void Start()
    {
        GameController.instance.AddEnemyToList(this);

        blocker = GetComponent <SingleNodeBlocker>();

        blocker.BlockAtCurrentPosition();

        movingToPoint.parent = null;

        CalculateObstacles();
    }
Пример #6
0
 public void InternalBlock(GraphNode node, SingleNodeBlocker blocker)
 {
     AstarPath.active.AddWorkItem(new AstarWorkItem(delegate
     {
         List <SingleNodeBlocker> list;
         if (!this.blocked.TryGetValue(node, out list))
         {
             list = (this.blocked[node] = ListPool <SingleNodeBlocker> .Claim());
         }
         list.Add(blocker);
     }, null));
 }
Пример #7
0
    /** Remove \a blocker from the specified node.
     * Will only remove a single instance, calling this method multiple
     * times will remove multiple instances of the blocker from the node.
     *
     * \note The node will not be unblocked immediately. Instead the pathfinding
     * threads will be paused and then the update will be applied. It is however
     * guaranteed to be applied before the next path request is started.
     */
    public void InternalUnblock(GraphNode node, SingleNodeBlocker blocker)
    {
        AstarPath.active.AddWorkItem(new AstarWorkItem(() => {
            List <SingleNodeBlocker> blockersInNode;
            if (blocked.TryGetValue(node, out blockersInNode))
            {
                blockersInNode.Remove(blocker);

                if (blockersInNode.Count == 0)
                {
                    blocked.Remove(node);
                    ListPool <SingleNodeBlocker> .Release(blockersInNode);
                }
            }
        }));
    }
Пример #8
0
 public void InternalUnblock(GraphNode node, SingleNodeBlocker blocker)
 {
     AstarPath.active.AddWorkItem(new AstarWorkItem(delegate
     {
         List <SingleNodeBlocker> list;
         if (this.blocked.TryGetValue(node, out list))
         {
             list.Remove(blocker);
             if (list.Count == 0)
             {
                 this.blocked.Remove(node);
                 ListPool <SingleNodeBlocker> .Release(list);
             }
         }
     }, null));
 }
Пример #9
0
    public bool NodeContainsAnyOf(GraphNode node, List <SingleNodeBlocker> selector)
    {
        List <SingleNodeBlocker> list;

        if (!this.blocked.TryGetValue(node, out list))
        {
            return(false);
        }
        for (int i = 0; i < list.Count; i++)
        {
            SingleNodeBlocker singleNodeBlocker = list[i];
            for (int j = 0; j < selector.Count; j++)
            {
                if (singleNodeBlocker == selector[j])
                {
                    return(true);
                }
            }
        }
        return(false);
    }
Пример #10
0
 void Start()
 {
     blocker = GetComponent <SingleNodeBlocker>();
     blocker.BlockAtCurrentPosition();
 }
Пример #11
0
 private void Start()
 {
     blocker         = GetComponent <SingleNodeBlocker>();
     blocker.manager = FindObjectOfType <BlockManager>();
     UpdateBlocker();
 }
Пример #12
0
 void Awake()
 {
     animator = GetComponent <Animator>();
     blocker  = GetComponent <SingleNodeBlocker>();
 }