// Token: 0x060005DF RID: 1503 RVA: 0x00035EB4 File Offset: 0x000342B4 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]; Int3 @int = (Int3)this.graph.GetTileBounds(j, i).min; Int3 tileSize = new Int3(this.graph.tileSizeX, 1, this.graph.tileSizeZ) * (1000f * this.graph.cellSize); @int += new Int3(tileSize.x * navmeshTile.w / 2, 0, tileSize.z * navmeshTile.d / 2); @int = -@int; TileHandler.TileType tileType = new TileHandler.TileType(navmeshTile.verts, navmeshTile.tris, tileSize, @int, 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; } } }
// Token: 0x060005EB RID: 1515 RVA: 0x00037D0C File Offset: 0x0003610C public void LoadTile(TileHandler.TileType tile, int x, int z, int rotation, int yoffset) { if (tile == null) { throw new ArgumentNullException("tile"); } if (AstarPath.active == null) { return; } int index = x + z * this.graph.tileXCount; rotation %= 4; if (this.isBatching && this.reloadedInBatch[index] && this.activeTileOffsets[index] == yoffset && this.activeTileRotations[index] == rotation && this.activeTileTypes[index] == tile) { return; } if (this.isBatching) { this.reloadedInBatch[index] = true; } this.activeTileOffsets[index] = yoffset; this.activeTileRotations[index] = rotation; this.activeTileTypes[index] = tile; AstarPath.active.AddWorkItem(new AstarPath.AstarWorkItem(delegate(bool force) { if (this.activeTileOffsets[index] != yoffset || this.activeTileRotations[index] != rotation || this.activeTileTypes[index] != tile) { return(true); } GraphModifier.TriggerEvent(GraphModifier.EventType.PreUpdate); Int3[] verts; int[] tris; tile.Load(out verts, out tris, rotation, yoffset); Bounds tileBounds = this.graph.GetTileBounds(x, z, tile.Width, tile.Depth); Int3 @int = (Int3)tileBounds.min; @int = -@int; Int3[] array = null; int[] array2 = null; int num; int num2; this.CutPoly(verts, tris, ref array, ref array2, out num, out num2, null, @int, tileBounds, (TileHandler.CutMode) 3, 0); this.DelaunayRefinement(array, array2, ref num, ref num2, true, false, -@int); if (num2 != array2.Length) { array2 = TileHandler.ShrinkArray <int>(array2, num2); } if (num != array.Length) { array = TileHandler.ShrinkArray <Int3>(array, num); } 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); AstarPath.active.QueueWorkItemFloodFill(); return(true); })); }
// Token: 0x060029BC RID: 10684 RVA: 0x001C4000 File Offset: 0x001C2200 public void LoadTile(TileHandler.TileType tile, int x, int z, int rotation, int yoffset) { if (tile == null) { throw new ArgumentNullException("tile"); } if (AstarPath.active == null) { return; } int index = x + z * this.tileXCount; rotation %= 4; if (this.isBatching && this.reloadedInBatch[index] && this.activeTileOffsets[index] == yoffset && this.activeTileRotations[index] == rotation && this.activeTileTypes[index] == tile) { return; } this.reloadedInBatch[index] |= this.isBatching; this.activeTileOffsets[index] = yoffset; this.activeTileRotations[index] = rotation; this.activeTileTypes[index] = tile; AstarPath.active.AddWorkItem(new AstarWorkItem(delegate(IWorkItemContext context, bool force) { if (this.activeTileOffsets[index] != yoffset || this.activeTileRotations[index] != rotation || this.activeTileTypes[index] != tile) { return(true); } GraphModifier.TriggerEvent(GraphModifier.EventType.PreUpdate); Int3[] verts; int[] tris; tile.Load(out verts, out tris, rotation, yoffset); TileHandler.CuttingResult cuttingResult = this.CutPoly(verts, tris, null, this.graph.transform, new IntRect(x, z, x + tile.Width - 1, z + tile.Depth - 1), TileHandler.CutMode.CutAll | TileHandler.CutMode.CutDual, -1); int num = cuttingResult.tris.Length; this.DelaunayRefinement(cuttingResult.verts, cuttingResult.tris, ref num, true, false); if (num != cuttingResult.tris.Length) { cuttingResult.tris = Memory.ShrinkArray <int>(cuttingResult.tris, num); } int num2 = (rotation % 2 == 0) ? tile.Width : tile.Depth; int num3 = (rotation % 2 == 0) ? tile.Depth : tile.Width; if (num2 != 1 || num3 != 1) { throw new Exception("Only tiles of width = depth = 1 are supported at this time"); } this.graph.ReplaceTile(x, z, cuttingResult.verts, cuttingResult.tris); if (!this.isBatching) { GraphModifier.TriggerEvent(GraphModifier.EventType.PostUpdate); } context.QueueFloodFill(); return(true); })); }
private void UpdateTileType(NavmeshTile tile) { int x = tile.x; int z = tile.z; Int3 tileSize = (Int3) new Vector3(this.graph.TileWorldSizeX, 0f, this.graph.TileWorldSizeZ); Int3 centerOffset = -((Int3)this.graph.GetTileBoundsInGraphSpace(x, z, 1, 1).min + new Int3(tileSize.x * tile.w / 2, 0, tileSize.z * tile.d / 2)); TileHandler.TileType tileType = new TileHandler.TileType(tile.vertsInGraphSpace, tile.tris, tileSize, centerOffset, tile.w, tile.d); int num = x + z * this.tileXCount; this.activeTileTypes[num] = tileType; this.activeTileRotations[num] = 0; this.activeTileOffsets[num] = 0; }
// Token: 0x060005DE RID: 1502 RVA: 0x00035E5C File Offset: 0x0003425C public TileHandler.TileType RegisterTileType(Mesh source, Int3 centerOffset, int width = 1, int depth = 1) { TileHandler.TileType tileType = new TileHandler.TileType(source, new Int3(this.graph.tileSizeX, 1, this.graph.tileSizeZ) * (1000f * this.graph.cellSize), centerOffset, width, depth); this.tileTypes.Add(tileType); return(tileType); }