GetGridGraph() public static method

public static GetGridGraph ( uint graphIndex ) : LayerGridGraph
graphIndex uint
return LayerGridGraph
        // Token: 0x06002509 RID: 9481 RVA: 0x0019CDFC File Offset: 0x0019AFFC
        public override bool GetPortal(GraphNode other, List <Vector3> left, List <Vector3> right, bool backwards)
        {
            if (backwards)
            {
                return(true);
            }
            LayerGridGraph gridGraph = LevelGridNode.GetGridGraph(base.GraphIndex);

            int[]           neighbourOffsets = gridGraph.neighbourOffsets;
            LevelGridNode[] nodes            = gridGraph.nodes;
            int             nodeInGridIndex  = base.NodeInGridIndex;

            for (int i = 0; i < 4; i++)
            {
                int connectionValue = this.GetConnectionValue(i);
                if (connectionValue != 255 && other == nodes[nodeInGridIndex + neighbourOffsets[i] + gridGraph.lastScannedWidth * gridGraph.lastScannedDepth * connectionValue])
                {
                    Vector3 a      = (Vector3)(this.position + other.position) * 0.5f;
                    Vector3 vector = Vector3.Cross(gridGraph.collision.up, (Vector3)(other.position - this.position));
                    vector.Normalize();
                    vector *= gridGraph.nodeSize * 0.5f;
                    left.Add(a - vector);
                    right.Add(a + vector);
                    return(true);
                }
            }
            return(false);
        }
Ejemplo n.º 2
0
        public override void UpdateRecursiveG(Path path, PathNode pathNode, PathHandler handler)
        {
            handler.heap.Add(pathNode);
            base.UpdateG(path, pathNode);
            LayerGridGraph gridGraph = LevelGridNode.GetGridGraph(base.GraphIndex);

            int[]           neighbourOffsets = gridGraph.neighbourOffsets;
            LevelGridNode[] nodes            = gridGraph.nodes;
            int             nodeInGridIndex  = base.NodeInGridIndex;

            for (int i = 0; i < 4; i++)
            {
                int connectionValue = this.GetConnectionValue(i);
                if (connectionValue != 255)
                {
                    LevelGridNode levelGridNode = nodes[nodeInGridIndex + neighbourOffsets[i] + gridGraph.lastScannedWidth * gridGraph.lastScannedDepth * connectionValue];
                    PathNode      pathNode2     = handler.GetPathNode(levelGridNode);
                    if (pathNode2 != null && pathNode2.parent == pathNode && pathNode2.pathID == handler.PathID)
                    {
                        levelGridNode.UpdateRecursiveG(path, pathNode2, handler);
                    }
                }
            }
            base.UpdateRecursiveG(path, pathNode, handler);
        }
 // Token: 0x06002502 RID: 9474 RVA: 0x0019CBC4 File Offset: 0x0019ADC4
 public override GridNodeBase GetNeighbourAlongDirection(int direction)
 {
     if (this.GetConnection(direction))
     {
         LayerGridGraph gridGraph = LevelGridNode.GetGridGraph(base.GraphIndex);
         return(gridGraph.nodes[base.NodeInGridIndex + gridGraph.neighbourOffsets[direction] + gridGraph.lastScannedWidth * gridGraph.lastScannedDepth * this.GetConnectionValue(direction)]);
     }
     return(null);
 }
Ejemplo n.º 4
0
        public override void Open(Path path, PathNode pathNode, PathHandler handler)
        {
            LayerGridGraph gridGraph = LevelGridNode.GetGridGraph(base.GraphIndex);

            int[]           neighbourOffsets = gridGraph.neighbourOffsets;
            uint[]          neighbourCosts   = gridGraph.neighbourCosts;
            LevelGridNode[] nodes            = gridGraph.nodes;
            int             nodeInGridIndex  = base.NodeInGridIndex;

            for (int i = 0; i < 4; i++)
            {
                int connectionValue = this.GetConnectionValue(i);
                if (connectionValue != 255)
                {
                    GraphNode graphNode = nodes[nodeInGridIndex + neighbourOffsets[i] + gridGraph.lastScannedWidth * gridGraph.lastScannedDepth * connectionValue];
                    if (path.CanTraverse(graphNode))
                    {
                        PathNode pathNode2 = handler.GetPathNode(graphNode);
                        if (pathNode2.pathID != handler.PathID)
                        {
                            pathNode2.parent = pathNode;
                            pathNode2.pathID = handler.PathID;
                            pathNode2.cost   = neighbourCosts[i];
                            pathNode2.H      = path.CalculateHScore(graphNode);
                            graphNode.UpdateG(path, pathNode2);
                            handler.heap.Add(pathNode2);
                        }
                        else
                        {
                            uint num = neighbourCosts[i];
                            if (pathNode.G + num + path.GetTraversalCost(graphNode) < pathNode2.G)
                            {
                                pathNode2.cost   = num;
                                pathNode2.parent = pathNode;
                                graphNode.UpdateRecursiveG(path, pathNode2, handler);
                            }
                            else if (pathNode2.G + num + path.GetTraversalCost(this) < pathNode.G)
                            {
                                pathNode.parent = pathNode2;
                                pathNode.cost   = num;
                                this.UpdateRecursiveG(path, pathNode, handler);
                            }
                        }
                    }
                }
            }
            base.Open(path, pathNode, handler);
        }
Ejemplo n.º 5
0
        public override void GetConnections(GraphNodeDelegate del)
        {
            int            num       = this.NodeInGridIndex;
            LayerGridGraph gridGraph = LevelGridNode.GetGridGraph(base.GraphIndex);

            int[]           neighbourOffsets = gridGraph.neighbourOffsets;
            LevelGridNode[] nodes            = gridGraph.nodes;
            for (int i = 0; i < 4; i++)
            {
                int connectionValue = this.GetConnectionValue(i);
                if (connectionValue != 255)
                {
                    LevelGridNode levelGridNode = nodes[num + neighbourOffsets[i] + gridGraph.lastScannedWidth * gridGraph.lastScannedDepth * connectionValue];
                    if (levelGridNode != null)
                    {
                        del(levelGridNode);
                    }
                }
            }
        }
        // Token: 0x06002505 RID: 9477 RVA: 0x0019CD10 File Offset: 0x0019AF10
        public override void FloodFill(Stack <GraphNode> stack, uint region)
        {
            int            nodeInGridIndex = base.NodeInGridIndex;
            LayerGridGraph gridGraph       = LevelGridNode.GetGridGraph(base.GraphIndex);

            int[]           neighbourOffsets = gridGraph.neighbourOffsets;
            LevelGridNode[] nodes            = gridGraph.nodes;
            for (int i = 0; i < 4; i++)
            {
                int connectionValue = this.GetConnectionValue(i);
                if (connectionValue != 255)
                {
                    LevelGridNode levelGridNode = nodes[nodeInGridIndex + neighbourOffsets[i] + gridGraph.lastScannedWidth * gridGraph.lastScannedDepth * connectionValue];
                    if (levelGridNode != null && levelGridNode.Area != region)
                    {
                        levelGridNode.Area = region;
                        stack.Push(levelGridNode);
                    }
                }
            }
        }
 // Token: 0x06002503 RID: 9475 RVA: 0x0019CC14 File Offset: 0x0019AE14
 public override void ClearConnections(bool alsoReverse)
 {
     if (alsoReverse)
     {
         LayerGridGraph  gridGraph        = LevelGridNode.GetGridGraph(base.GraphIndex);
         int[]           neighbourOffsets = gridGraph.neighbourOffsets;
         LevelGridNode[] nodes            = gridGraph.nodes;
         for (int i = 0; i < 4; i++)
         {
             int connectionValue = this.GetConnectionValue(i);
             if (connectionValue != 255)
             {
                 LevelGridNode levelGridNode = nodes[base.NodeInGridIndex + neighbourOffsets[i] + gridGraph.lastScannedWidth * gridGraph.lastScannedDepth * connectionValue];
                 if (levelGridNode != null)
                 {
                     levelGridNode.SetConnectionValue((i + 2) % 4, 255);
                 }
             }
         }
     }
     this.ResetAllGridConnections();
 }
Ejemplo n.º 8
0
        public override void GetConnections(Action <GraphNode> action)
        {
            LayerGridGraph gridGraph = LevelGridNode.GetGridGraph(base.GraphIndex);

            int[]           neighbourOffsets = gridGraph.neighbourOffsets;
            LevelGridNode[] nodes            = gridGraph.nodes;
            int             nodeInGridIndex  = base.NodeInGridIndex;

            for (int i = 0; i < 4; i++)
            {
                int connectionValue = this.GetConnectionValue(i);
                if (connectionValue != 255)
                {
                    LevelGridNode levelGridNode = nodes[nodeInGridIndex + neighbourOffsets[i] + gridGraph.lastScannedWidth * gridGraph.lastScannedDepth * connectionValue];
                    if (levelGridNode != null)
                    {
                        action(levelGridNode);
                    }
                }
            }
            base.GetConnections(action);
        }