示例#1
0
 public void CreateTileTypesFromGraph()
 {
     RecastGraph.NavmeshTile[] tiles = this.graph.GetTiles();
     if (tiles == null || tiles.Length != this.graph.tileXCount * this.graph.tileZCount)
     {
         throw new InvalidOperationException("Graph tiles are invalid (either null or number of tiles is not equal to width*depth of the graph");
     }
     for (int i = 0; i < this.graph.tileZCount; i++)
     {
         for (int j = 0; j < this.graph.tileXCount; j++)
         {
             RecastGraph.NavmeshTile navmeshTile = tiles[j + i * this.graph.tileXCount];
             VInt3 vInt     = (VInt3)this.graph.GetTileBounds(j, i, 1, 1).min;
             VInt3 tileSize = new VInt3(this.graph.tileSizeX, 1, this.graph.tileSizeZ) * (1000f * this.graph.cellSize);
             vInt += new VInt3(tileSize.x * navmeshTile.w / 2, 0, tileSize.z * navmeshTile.d / 2);
             vInt  = -vInt;
             SGameTileHandler.TileType tileType = new SGameTileHandler.TileType(navmeshTile.verts, navmeshTile.tris, tileSize, vInt, navmeshTile.w, navmeshTile.d);
             this.tileTypes.Add(tileType);
             int num = j + i * this.graph.tileXCount;
             this.activeTileTypes[num]     = tileType;
             this.activeTileRotations[num] = 0;
             this.activeTileOffsets[num]   = 0;
         }
     }
 }
示例#2
0
        public void LoadTile(ListView <NavmeshCut> navmeshCuts, SGameTileHandler.TileType tile, int x, int z, int rotation, int yoffset)
        {
            if (tile == null)
            {
                throw new ArgumentNullException("tile");
            }
            int num = x + z * this.graph.tileXCount;

            rotation %= 4;
            if (this.isBatching && this.reloadedInBatch[num] && this.activeTileOffsets[num] == yoffset && this.activeTileRotations[num] == rotation && this.activeTileTypes[num] == tile)
            {
                return;
            }
            if (this.isBatching)
            {
                this.reloadedInBatch[num] = true;
            }
            this.activeTileOffsets[num]   = yoffset;
            this.activeTileRotations[num] = rotation;
            this.activeTileTypes[num]     = tile;
            if (this.activeTileOffsets[num] != yoffset || this.activeTileRotations[num] != rotation || this.activeTileTypes[num] != tile)
            {
                return;
            }
            GraphModifier.TriggerEvent(GraphModifier.EventType.PreUpdate);
            VInt3[] verts;
            int[]   tris;
            tile.Load(out verts, out tris, rotation, yoffset);
            Bounds tileBounds = this.graph.GetTileBounds(x, z, tile.Width, tile.Depth);
            VInt3  vInt       = (VInt3)tileBounds.min;

            vInt = -vInt;
            VInt3[] array  = null;
            int[]   array2 = null;
            int     num2;
            int     num3;

            this.CutPoly(navmeshCuts, verts, tris, ref array, ref array2, out num2, out num3, null, vInt, tileBounds, (SGameTileHandler.CutMode) 3, 0);
            this.DelaunayRefinement(array, array2, ref num2, ref num3, true, false, -vInt);
            if (num3 != array2.Length)
            {
                array2 = SGameTileHandler.ShrinkArray <int>(array2, num3);
            }
            if (num2 != array.Length)
            {
                array = SGameTileHandler.ShrinkArray <VInt3>(array, num2);
            }
            int w = (rotation % 2 != 0) ? tile.Depth : tile.Width;
            int d = (rotation % 2 != 0) ? tile.Width : tile.Depth;

            this.graph.ReplaceTile(x, z, w, d, array, array2, false);
            GraphModifier.TriggerEvent(GraphModifier.EventType.PostUpdate);
        }
示例#3
0
 public SGameTileHandler.TileType RegisterTileType(Mesh source, VInt3 centerOffset, int width = 1, int depth = 1)
 {
     SGameTileHandler.TileType tileType = new SGameTileHandler.TileType(source, new VInt3(this.graph.tileSizeX, 1, this.graph.tileSizeZ) * (1000f * this.graph.cellSize), centerOffset, width, depth);
     this.tileTypes.Add(tileType);
     return(tileType);
 }