Пример #1
0
        // Token: 0x060022C7 RID: 8903 RVA: 0x00195B0C File Offset: 0x00193D0C
        public PathNode Remove()
        {
            PathNode node = this.heap[0].node;

            node.heapIndex = ushort.MaxValue;
            this.numberOfItems--;
            if (this.numberOfItems == 0)
            {
                return(node);
            }
            BinaryHeap.Tuple tuple = this.heap[this.numberOfItems];
            uint             g     = tuple.node.G;
            int num = 0;

            for (;;)
            {
                int  num2 = num;
                uint num3 = tuple.F;
                int  num4 = num2 * 4 + 1;
                if (num4 <= this.numberOfItems)
                {
                    uint f  = this.heap[num4].F;
                    uint f2 = this.heap[num4 + 1].F;
                    uint f3 = this.heap[num4 + 2].F;
                    uint f4 = this.heap[num4 + 3].F;
                    if (num4 < this.numberOfItems && (f < num3 || (f == num3 && this.heap[num4].node.G < g)))
                    {
                        num3 = f;
                        num  = num4;
                    }
                    if (num4 + 1 < this.numberOfItems && (f2 < num3 || (f2 == num3 && this.heap[num4 + 1].node.G < ((num == num2) ? g : this.heap[num].node.G))))
                    {
                        num3 = f2;
                        num  = num4 + 1;
                    }
                    if (num4 + 2 < this.numberOfItems && (f3 < num3 || (f3 == num3 && this.heap[num4 + 2].node.G < ((num == num2) ? g : this.heap[num].node.G))))
                    {
                        num3 = f3;
                        num  = num4 + 2;
                    }
                    if (num4 + 3 < this.numberOfItems && (f4 < num3 || (f4 == num3 && this.heap[num4 + 3].node.G < ((num == num2) ? g : this.heap[num].node.G))))
                    {
                        num = num4 + 3;
                    }
                }
                if (num2 == num)
                {
                    break;
                }
                this.heap[num2] = this.heap[num];
                this.heap[num2].node.heapIndex = (ushort)num2;
            }
            this.heap[num]       = tuple;
            tuple.node.heapIndex = (ushort)num;
            return(node);
        }
Пример #2
0
        // Token: 0x060022C4 RID: 8900 RVA: 0x00195948 File Offset: 0x00193B48
        private void Expand()
        {
            int num = BinaryHeap.RoundUpToNextMultipleMod1(Math.Max(this.heap.Length + 4, Math.Min(65533, (int)Math.Round((double)((float)this.heap.Length * this.growthFactor)))));

            if (num > 65534)
            {
                throw new Exception("Binary Heap Size really large (>65534). A heap size this large is probably the cause of pathfinding running in an infinite loop. ");
            }
            BinaryHeap.Tuple[] array = new BinaryHeap.Tuple[num];
            this.heap.CopyTo(array, 0);
            this.heap = array;
        }
Пример #3
0
        public PathNode Remove()
        {
            this.numberOfItems--;
            PathNode node = this.heap[0].node;

            BinaryHeap.Tuple tuple = this.heap[this.numberOfItems];
            uint             g     = tuple.node.G;
            int num = 0;

            for (;;)
            {
                int  num2 = num;
                uint num3 = tuple.F;
                int  num4 = num2 * 4 + 1;
                if (num4 <= this.numberOfItems)
                {
                    uint f  = this.heap[num4].F;
                    uint f2 = this.heap[num4 + 1].F;
                    uint f3 = this.heap[num4 + 2].F;
                    uint f4 = this.heap[num4 + 3].F;
                    if (num4 < this.numberOfItems && (f < num3 || (f == num3 && this.heap[num4].node.G < g)))
                    {
                        num3 = f;
                        num  = num4;
                    }
                    if (num4 + 1 < this.numberOfItems && (f2 < num3 || (f2 == num3 && this.heap[num4 + 1].node.G < ((num != num2) ? this.heap[num].node.G : g))))
                    {
                        num3 = f2;
                        num  = num4 + 1;
                    }
                    if (num4 + 2 < this.numberOfItems && (f3 < num3 || (f3 == num3 && this.heap[num4 + 2].node.G < ((num != num2) ? this.heap[num].node.G : g))))
                    {
                        num3 = f3;
                        num  = num4 + 2;
                    }
                    if (num4 + 3 < this.numberOfItems && (f4 < num3 || (f4 == num3 && this.heap[num4 + 3].node.G < ((num != num2) ? this.heap[num].node.G : g))))
                    {
                        num = num4 + 3;
                    }
                }
                if (num2 == num)
                {
                    break;
                }
                this.heap[num2] = this.heap[num];
            }
            this.heap[num] = tuple;
            return(node);
        }
Пример #4
0
        private void Expand()
        {
            int num = BinaryHeap.RoundUpToNextMultipleMod1(Math.Max(this.heap.Length + 4, (int)Math.Round((double)((float)this.heap.Length * this.growthFactor))));

            if (num > 262144)
            {
                throw new Exception("Binary Heap Size really large (2^18). A heap size this large is probably the cause of pathfinding running in an infinite loop. \nRemove this check (in BinaryHeap.cs) if you are sure that it is not caused by a bug");
            }
            BinaryHeap.Tuple[] array = new BinaryHeap.Tuple[num];
            for (int i = 0; i < this.heap.Length; i++)
            {
                array[i] = this.heap[i];
            }
            this.heap = array;
        }
Пример #5
0
 public void Rebuild()
 {
     for (int i = 2; i < this.numberOfItems; i++)
     {
         int num = i;
         BinaryHeap.Tuple tuple = this.heap[i];
         uint             f     = tuple.F;
         while (num != 1)
         {
             int num2 = num / 4;
             if (f >= this.heap[num2].F)
             {
                 break;
             }
             this.heap[num]  = this.heap[num2];
             this.heap[num2] = tuple;
             num             = num2;
         }
     }
 }
Пример #6
0
        // Token: 0x060022C6 RID: 8902 RVA: 0x00195A38 File Offset: 0x00193C38
        private void DecreaseKey(BinaryHeap.Tuple node, ushort index)
        {
            int  num  = (int)index;
            uint num2 = node.F = node.node.F;
            uint g    = node.node.G;

            while (num != 0)
            {
                int num3 = (num - 1) / 4;
                if (num2 >= this.heap[num3].F && (num2 != this.heap[num3].F || g <= this.heap[num3].node.G))
                {
                    break;
                }
                this.heap[num] = this.heap[num3];
                this.heap[num].node.heapIndex = (ushort)num;
                num = num3;
            }
            this.heap[num]      = node;
            node.node.heapIndex = (ushort)num;
        }