ResetAllGridConnections() public method

public ResetAllGridConnections ( ) : void
return void
        // Token: 0x06002544 RID: 9540 RVA: 0x001A1D88 File Offset: 0x0019FF88
        public void CalculateConnections(int x, int z, int layerIndex)
        {
            LevelGridNode levelGridNode = this.nodes[z * this.width + x + this.width * this.depth * layerIndex];

            if (levelGridNode == null)
            {
                return;
            }
            levelGridNode.ResetAllGridConnections();
            if (!levelGridNode.Walkable)
            {
                return;
            }
            Vector3 vector = (Vector3)levelGridNode.position;
            Vector3 rhs    = base.transform.WorldUpAtGraphPosition(vector);
            float   num    = Vector3.Dot(vector, rhs);
            float   num2;

            if (layerIndex == this.layerCount - 1 || this.nodes[levelGridNode.NodeInGridIndex + this.width * this.depth * (layerIndex + 1)] == null)
            {
                num2 = float.PositiveInfinity;
            }
            else
            {
                num2 = Math.Abs(num - Vector3.Dot((Vector3)this.nodes[levelGridNode.NodeInGridIndex + this.width * this.depth * (layerIndex + 1)].position, rhs));
            }
            for (int i = 0; i < 4; i++)
            {
                int num3 = x + this.neighbourXOffsets[i];
                int num4 = z + this.neighbourZOffsets[i];
                if (num3 >= 0 && num4 >= 0 && num3 < this.width && num4 < this.depth)
                {
                    int num5  = num4 * this.width + num3;
                    int value = 255;
                    for (int j = 0; j < this.layerCount; j++)
                    {
                        GraphNode graphNode = this.nodes[num5 + this.width * this.depth * j];
                        if (graphNode != null && graphNode.Walkable)
                        {
                            float num6 = Vector3.Dot((Vector3)graphNode.position, rhs);
                            float num7;
                            if (j == this.layerCount - 1 || this.nodes[num5 + this.width * this.depth * (j + 1)] == null)
                            {
                                num7 = float.PositiveInfinity;
                            }
                            else
                            {
                                num7 = Math.Abs(num6 - Vector3.Dot((Vector3)this.nodes[num5 + this.width * this.depth * (j + 1)].position, rhs));
                            }
                            float num8 = Mathf.Max(num6, num);
                            if (Mathf.Min(num6 + num7, num + num2) - num8 >= this.characterHeight && Mathf.Abs(num6 - num) <= this.maxClimb)
                            {
                                value = j;
                            }
                        }
                    }
                    levelGridNode.SetConnectionValue(i, value);
                }
            }
        }
Ejemplo n.º 2
0
        public void CalculateConnections(GraphNode[] nodes, GraphNode node, int x, int z, int layerIndex)
        {
            if (node == null)
            {
                return;
            }
            LevelGridNode levelGridNode = (LevelGridNode)node;

            levelGridNode.ResetAllGridConnections();
            if (!node.Walkable)
            {
                return;
            }
            float num;

            if (layerIndex == this.layerCount - 1 || nodes[levelGridNode.NodeInGridIndex + this.width * this.depth * (layerIndex + 1)] == null)
            {
                num = float.PositiveInfinity;
            }
            else
            {
                num = (float)Math.Abs(levelGridNode.position.y - nodes[levelGridNode.NodeInGridIndex + this.width * this.depth * (layerIndex + 1)].position.y) * 0.001f;
            }
            for (int i = 0; i < 4; i++)
            {
                int num2 = x + this.neighbourXOffsets[i];
                int num3 = z + this.neighbourZOffsets[i];
                if (num2 >= 0 && num3 >= 0 && num2 < this.width && num3 < this.depth)
                {
                    int num4  = num3 * this.width + num2;
                    int value = 255;
                    for (int j = 0; j < this.layerCount; j++)
                    {
                        GraphNode graphNode = nodes[num4 + this.width * this.depth * j];
                        if (graphNode != null && graphNode.Walkable)
                        {
                            float num5;
                            if (j == this.layerCount - 1 || nodes[num4 + this.width * this.depth * (j + 1)] == null)
                            {
                                num5 = float.PositiveInfinity;
                            }
                            else
                            {
                                num5 = (float)Math.Abs(graphNode.position.y - nodes[num4 + this.width * this.depth * (j + 1)].position.y) * 0.001f;
                            }
                            float num6 = Mathf.Max((float)graphNode.position.y * 0.001f, (float)levelGridNode.position.y * 0.001f);
                            float num7 = Mathf.Min((float)graphNode.position.y * 0.001f + num5, (float)levelGridNode.position.y * 0.001f + num);
                            float num8 = num7 - num6;
                            if (num8 >= this.characterHeight && (float)Mathf.Abs(graphNode.position.y - levelGridNode.position.y) * 0.001f <= this.maxClimb)
                            {
                                value = j;
                            }
                        }
                    }
                    levelGridNode.SetConnectionValue(i, value);
                }
            }
        }