예제 #1
0
        // Token: 0x06000E01 RID: 3585 RVA: 0x00062450 File Offset: 0x00060850
        public static void getHeightmapVertices(Bounds worldBounds, Landscape.LandscapeGetHeightmapVerticesHandler callback)
        {
            if (callback == null)
            {
                return;
            }
            LandscapeBounds landscapeBounds = new LandscapeBounds(worldBounds);

            for (int i = landscapeBounds.min.x; i <= landscapeBounds.max.x; i++)
            {
                for (int j = landscapeBounds.min.y; j <= landscapeBounds.max.y; j++)
                {
                    LandscapeCoord landscapeCoord = new LandscapeCoord(i, j);
                    LandscapeTile  tile           = Landscape.getTile(landscapeCoord);
                    if (tile != null)
                    {
                        HeightmapBounds heightmapBounds = new HeightmapBounds(landscapeCoord, worldBounds);
                        for (int k = heightmapBounds.min.x; k <= heightmapBounds.max.x; k++)
                        {
                            for (int l = heightmapBounds.min.y; l <= heightmapBounds.max.y; l++)
                            {
                                HeightmapCoord heightmapCoord = new HeightmapCoord(k, l);
                                float          height         = tile.sourceHeightmap[k, l];
                                Vector3        worldPosition  = Landscape.getWorldPosition(landscapeCoord, heightmapCoord, height);
                                callback(landscapeCoord, heightmapCoord, worldPosition);
                            }
                        }
                    }
                }
            }
        }
예제 #2
0
        // Token: 0x06000DFE RID: 3582 RVA: 0x00061FD4 File Offset: 0x000603D4
        public static void readSplatmap(Bounds worldBounds, Landscape.LandscapeReadSplatmapHandler callback)
        {
            if (callback == null)
            {
                return;
            }
            LandscapeBounds landscapeBounds = new LandscapeBounds(worldBounds);

            for (int i = landscapeBounds.min.x; i <= landscapeBounds.max.x; i++)
            {
                for (int j = landscapeBounds.min.y; j <= landscapeBounds.max.y; j++)
                {
                    LandscapeCoord landscapeCoord = new LandscapeCoord(i, j);
                    LandscapeTile  tile           = Landscape.getTile(landscapeCoord);
                    if (tile != null)
                    {
                        SplatmapBounds splatmapBounds = new SplatmapBounds(landscapeCoord, worldBounds);
                        for (int k = splatmapBounds.min.x; k < splatmapBounds.max.x; k++)
                        {
                            for (int l = splatmapBounds.min.y; l < splatmapBounds.max.y; l++)
                            {
                                SplatmapCoord splatmapCoord = new SplatmapCoord(k, l);
                                for (int m = 0; m < Landscape.SPLATMAP_LAYERS; m++)
                                {
                                    Landscape.SPLATMAP_LAYER_BUFFER[m] = tile.sourceSplatmap[k, l, m];
                                }
                                Vector3 worldPosition = Landscape.getWorldPosition(landscapeCoord, splatmapCoord);
                                callback(landscapeCoord, splatmapCoord, worldPosition, Landscape.SPLATMAP_LAYER_BUFFER);
                            }
                        }
                    }
                }
            }
        }
예제 #3
0
 // Token: 0x06000E11 RID: 3601 RVA: 0x00062D18 File Offset: 0x00061118
 protected void handleGraphicsSettingsApplied()
 {
     foreach (KeyValuePair <LandscapeCoord, LandscapeTile> keyValuePair in Landscape.tiles)
     {
         LandscapeTile value = keyValuePair.Value;
         value.applyGraphicsSettings();
     }
 }
예제 #4
0
 // Token: 0x06000E03 RID: 3587 RVA: 0x0006267C File Offset: 0x00060A7C
 public static void applyLOD()
 {
     foreach (KeyValuePair <LandscapeCoord, LandscapeTile> keyValuePair in Landscape.tiles)
     {
         LandscapeTile value = keyValuePair.Value;
         value.terrain.ApplyDelayedHeightmapModification();
     }
 }
예제 #5
0
 // Token: 0x06000E12 RID: 3602 RVA: 0x00062D7C File Offset: 0x0006117C
 protected void handlePlanarReflectionPreRender()
 {
     foreach (KeyValuePair <LandscapeCoord, LandscapeTile> keyValuePair in Landscape.tiles)
     {
         LandscapeTile value = keyValuePair.Value;
         value.terrain.basemapDistance = 0f;
     }
 }
예제 #6
0
 // Token: 0x06000E07 RID: 3591 RVA: 0x00062A9C File Offset: 0x00060E9C
 protected static void clearTiles()
 {
     foreach (KeyValuePair <LandscapeCoord, LandscapeTile> keyValuePair in Landscape.tiles)
     {
         LandscapeTile value = keyValuePair.Value;
         value.disable();
     }
     Landscape.tiles.Clear();
 }
예제 #7
0
        // Token: 0x06000E13 RID: 3603 RVA: 0x00062DE8 File Offset: 0x000611E8
        protected void handlePlanarReflectionPostRender()
        {
            float basemapDistance = (float)((!GraphicsSettings.blend) ? 256 : 512);

            foreach (KeyValuePair <LandscapeCoord, LandscapeTile> keyValuePair in Landscape.tiles)
            {
                LandscapeTile value = keyValuePair.Value;
                value.terrain.basemapDistance = basemapDistance;
            }
        }
예제 #8
0
        // Token: 0x06000DEE RID: 3566 RVA: 0x00061AB0 File Offset: 0x0005FEB0
        public static bool getWorldHeight(LandscapeCoord tileCoord, HeightmapCoord heightmapCoord, out float height)
        {
            LandscapeTile tile = Landscape.getTile(tileCoord);

            if (tile != null)
            {
                height = tile.sourceHeightmap[heightmapCoord.x, heightmapCoord.y] * Landscape.TILE_HEIGHT - Landscape.TILE_HEIGHT / 2f;
                return(true);
            }
            height = 0f;
            return(false);
        }
예제 #9
0
        // Token: 0x06000DF5 RID: 3573 RVA: 0x00061C90 File Offset: 0x00060090
        public static bool getSplatmapLayer(LandscapeCoord tileCoord, SplatmapCoord splatmapCoord, out int layer)
        {
            LandscapeTile tile = Landscape.getTile(tileCoord);

            if (tile != null)
            {
                layer = Landscape.getSplatmapHighestWeightLayerIndex(splatmapCoord, tile.sourceSplatmap, -1);
                return(true);
            }
            layer = -1;
            return(false);
        }
예제 #10
0
        // Token: 0x06000DF0 RID: 3568 RVA: 0x00061B44 File Offset: 0x0005FF44
        public static bool getHeight01(LandscapeCoord tileCoord, HeightmapCoord heightmapCoord, out float height)
        {
            LandscapeTile tile = Landscape.getTile(tileCoord);

            if (tile != null)
            {
                height = tile.sourceHeightmap[heightmapCoord.x, heightmapCoord.y];
                return(true);
            }
            height = 0f;
            return(false);
        }
예제 #11
0
 // Token: 0x06000E0F RID: 3599 RVA: 0x00062C80 File Offset: 0x00061080
 public override void write(IFormattedFileWriter writer)
 {
     writer.beginObject();
     writer.beginArray("Tiles");
     foreach (KeyValuePair <LandscapeCoord, LandscapeTile> keyValuePair in Landscape.tiles)
     {
         LandscapeTile value = keyValuePair.Value;
         writer.writeValue <LandscapeTile>(value);
     }
     writer.endArray();
     writer.endObject();
 }
예제 #12
0
        // Token: 0x06000DEF RID: 3567 RVA: 0x00061B04 File Offset: 0x0005FF04
        public static bool getHeight01(Vector3 position, out float height)
        {
            LandscapeCoord coord = new LandscapeCoord(position);
            LandscapeTile  tile  = Landscape.getTile(coord);

            if (tile != null)
            {
                height = tile.terrain.SampleHeight(position) / Landscape.TILE_HEIGHT;
                return(true);
            }
            height = 0f;
            return(false);
        }
예제 #13
0
        // Token: 0x06000DF1 RID: 3569 RVA: 0x00061B84 File Offset: 0x0005FF84
        public static bool getNormal(Vector3 position, out Vector3 normal)
        {
            LandscapeCoord coord = new LandscapeCoord(position);
            LandscapeTile  tile  = Landscape.getTile(coord);

            if (tile != null)
            {
                normal = tile.data.GetInterpolatedNormal((position.x - (float)coord.x * Landscape.TILE_SIZE) / Landscape.TILE_SIZE, (position.z - (float)coord.y * Landscape.TILE_SIZE) / Landscape.TILE_SIZE);
                return(true);
            }
            normal = Vector3.up;
            return(false);
        }
예제 #14
0
        // Token: 0x06000E06 RID: 3590 RVA: 0x00062A48 File Offset: 0x00060E48
        public static LandscapeTile addTile(LandscapeCoord coord)
        {
            if (Landscape.instance == null)
            {
                return(null);
            }
            if (Landscape.tiles.ContainsKey(coord))
            {
                return(null);
            }
            LandscapeTile landscapeTile = new LandscapeTile(coord);

            landscapeTile.enable();
            landscapeTile.applyGraphicsSettings();
            Landscape.tiles.Add(coord, landscapeTile);
            return(landscapeTile);
        }
예제 #15
0
 // Token: 0x06000E04 RID: 3588 RVA: 0x000626E4 File Offset: 0x00060AE4
 public static void linkNeighbors()
 {
     foreach (KeyValuePair <LandscapeCoord, LandscapeTile> keyValuePair in Landscape.tiles)
     {
         LandscapeTile value  = keyValuePair.Value;
         LandscapeTile tile   = Landscape.getTile(new LandscapeCoord(value.coord.x - 1, value.coord.y));
         LandscapeTile tile2  = Landscape.getTile(new LandscapeCoord(value.coord.x, value.coord.y + 1));
         LandscapeTile tile3  = Landscape.getTile(new LandscapeCoord(value.coord.x + 1, value.coord.y));
         LandscapeTile tile4  = Landscape.getTile(new LandscapeCoord(value.coord.x, value.coord.y - 1));
         Terrain       left   = (tile != null) ? tile.terrain : null;
         Terrain       top    = (tile2 != null) ? tile2.terrain : null;
         Terrain       right  = (tile3 != null) ? tile3.terrain : null;
         Terrain       bottom = (tile4 != null) ? tile4.terrain : null;
         value.terrain.SetNeighbors(left, top, right, bottom);
         value.terrain.Flush();
     }
 }
예제 #16
0
 public static void linkNeighbors()
 {
     foreach (KeyValuePair <LandscapeCoord, LandscapeTile> keyValuePair in Landscape.tiles)
     {
         LandscapeTile value    = keyValuePair.Value;
         LandscapeTile tile     = Landscape.getTile(new LandscapeCoord(value.coord.x - 1, value.coord.y));
         LandscapeTile tile2    = Landscape.getTile(new LandscapeCoord(value.coord.x, value.coord.y + 1));
         LandscapeTile tile3    = Landscape.getTile(new LandscapeCoord(value.coord.x + 1, value.coord.y));
         LandscapeTile tile4    = Landscape.getTile(new LandscapeCoord(value.coord.x, value.coord.y - 1));
         Terrain       terrain  = (tile != null) ? tile.terrain : null;
         Terrain       terrain2 = (tile2 != null) ? tile2.terrain : null;
         Terrain       terrain3 = (tile3 != null) ? tile3.terrain : null;
         Terrain       terrain4 = (tile4 != null) ? tile4.terrain : null;
         value.terrain.SetNeighbors(terrain, terrain2, terrain3, terrain4);
         value.terrain.Flush();
     }
 }
예제 #17
0
        // Token: 0x06000E00 RID: 3584 RVA: 0x00062290 File Offset: 0x00060690
        public static void writeSplatmap(Bounds worldBounds, Landscape.LandscapeWriteSplatmapHandler callback)
        {
            if (callback == null)
            {
                return;
            }
            LandscapeBounds landscapeBounds = new LandscapeBounds(worldBounds);

            for (int i = landscapeBounds.min.x; i <= landscapeBounds.max.x; i++)
            {
                for (int j = landscapeBounds.min.y; j <= landscapeBounds.max.y; j++)
                {
                    LandscapeCoord landscapeCoord = new LandscapeCoord(i, j);
                    LandscapeTile  tile           = Landscape.getTile(landscapeCoord);
                    if (tile != null)
                    {
                        if (!Landscape.splatmapTransactions.ContainsKey(landscapeCoord))
                        {
                            LandscapeSplatmapTransaction landscapeSplatmapTransaction = new LandscapeSplatmapTransaction(tile);
                            DevkitTransactionManager.recordTransaction(landscapeSplatmapTransaction);
                            Landscape.splatmapTransactions.Add(landscapeCoord, landscapeSplatmapTransaction);
                        }
                        SplatmapBounds splatmapBounds = new SplatmapBounds(landscapeCoord, worldBounds);
                        for (int k = splatmapBounds.min.x; k <= splatmapBounds.max.x; k++)
                        {
                            for (int l = splatmapBounds.min.y; l <= splatmapBounds.max.y; l++)
                            {
                                SplatmapCoord splatmapCoord = new SplatmapCoord(k, l);
                                for (int m = 0; m < Landscape.SPLATMAP_LAYERS; m++)
                                {
                                    Landscape.SPLATMAP_LAYER_BUFFER[m] = tile.sourceSplatmap[k, l, m];
                                }
                                Vector3 worldPosition = Landscape.getWorldPosition(landscapeCoord, splatmapCoord);
                                callback(landscapeCoord, splatmapCoord, worldPosition, Landscape.SPLATMAP_LAYER_BUFFER);
                                for (int n = 0; n < Landscape.SPLATMAP_LAYERS; n++)
                                {
                                    tile.sourceSplatmap[k, l, n] = Mathf.Clamp01(Landscape.SPLATMAP_LAYER_BUFFER[n]);
                                }
                            }
                        }
                        tile.data.SetAlphamaps(0, 0, tile.sourceSplatmap);
                    }
                }
            }
        }
예제 #18
0
        // Token: 0x06000E05 RID: 3589 RVA: 0x00062870 File Offset: 0x00060C70
        public static void reconcileNeighbors(LandscapeTile tile)
        {
            LandscapeTile tile2 = Landscape.getTile(new LandscapeCoord(tile.coord.x - 1, tile.coord.y));

            if (tile2 != null)
            {
                for (int i = 0; i < Landscape.HEIGHTMAP_RESOLUTION; i++)
                {
                    tile.sourceHeightmap[i, 0] = tile2.sourceHeightmap[i, Landscape.HEIGHTMAP_RESOLUTION - 1];
                }
            }
            LandscapeTile tile3 = Landscape.getTile(new LandscapeCoord(tile.coord.x, tile.coord.y - 1));

            if (tile3 != null)
            {
                for (int j = 0; j < Landscape.HEIGHTMAP_RESOLUTION; j++)
                {
                    tile.sourceHeightmap[0, j] = tile3.sourceHeightmap[Landscape.HEIGHTMAP_RESOLUTION - 1, j];
                }
            }
            LandscapeTile tile4 = Landscape.getTile(new LandscapeCoord(tile.coord.x + 1, tile.coord.y));

            if (tile4 != null)
            {
                for (int k = 0; k < Landscape.HEIGHTMAP_RESOLUTION; k++)
                {
                    tile.sourceHeightmap[k, Landscape.HEIGHTMAP_RESOLUTION - 1] = tile4.sourceHeightmap[k, 0];
                }
            }
            LandscapeTile tile5 = Landscape.getTile(new LandscapeCoord(tile.coord.x, tile.coord.y + 1));

            if (tile5 != null)
            {
                for (int l = 0; l < Landscape.HEIGHTMAP_RESOLUTION; l++)
                {
                    tile.sourceHeightmap[Landscape.HEIGHTMAP_RESOLUTION - 1, l] = tile5.sourceHeightmap[0, l];
                }
            }
            tile.data.SetHeightsDelayLOD(0, 0, tile.sourceHeightmap);
        }
예제 #19
0
        // Token: 0x06000DFF RID: 3583 RVA: 0x00062118 File Offset: 0x00060518
        public static void writeHeightmap(Bounds worldBounds, Landscape.LandscapeWriteHeightmapHandler callback)
        {
            if (callback == null)
            {
                return;
            }
            LandscapeBounds landscapeBounds = new LandscapeBounds(worldBounds);

            for (int i = landscapeBounds.min.x; i <= landscapeBounds.max.x; i++)
            {
                for (int j = landscapeBounds.min.y; j <= landscapeBounds.max.y; j++)
                {
                    LandscapeCoord landscapeCoord = new LandscapeCoord(i, j);
                    LandscapeTile  tile           = Landscape.getTile(landscapeCoord);
                    if (tile != null)
                    {
                        if (!Landscape.heightmapTransactions.ContainsKey(landscapeCoord))
                        {
                            LandscapeHeightmapTransaction landscapeHeightmapTransaction = new LandscapeHeightmapTransaction(tile);
                            DevkitTransactionManager.recordTransaction(landscapeHeightmapTransaction);
                            Landscape.heightmapTransactions.Add(landscapeCoord, landscapeHeightmapTransaction);
                        }
                        HeightmapBounds heightmapBounds = new HeightmapBounds(landscapeCoord, worldBounds);
                        for (int k = heightmapBounds.min.x; k <= heightmapBounds.max.x; k++)
                        {
                            for (int l = heightmapBounds.min.y; l <= heightmapBounds.max.y; l++)
                            {
                                HeightmapCoord heightmapCoord = new HeightmapCoord(k, l);
                                float          num            = tile.sourceHeightmap[k, l];
                                Vector3        worldPosition  = Landscape.getWorldPosition(landscapeCoord, heightmapCoord, num);
                                tile.sourceHeightmap[k, l] = Mathf.Clamp01(callback(landscapeCoord, heightmapCoord, worldPosition, num));
                            }
                        }
                        tile.data.SetHeightsDelayLOD(0, 0, tile.sourceHeightmap);
                    }
                }
            }
        }
예제 #20
0
        // Token: 0x06000E66 RID: 3686 RVA: 0x00063A64 File Offset: 0x00061E64
        protected void findTerrainColliders()
        {
            this.terrainColliders.Clear();
            Bounds          bounds          = base.box.bounds;
            LandscapeBounds landscapeBounds = new LandscapeBounds(bounds);

            for (int i = landscapeBounds.min.x; i <= landscapeBounds.max.x; i++)
            {
                for (int j = landscapeBounds.min.y; j <= landscapeBounds.max.y; j++)
                {
                    LandscapeCoord coord = new LandscapeCoord(i, j);
                    LandscapeTile  tile  = Landscape.getTile(coord);
                    if (tile != null)
                    {
                        this.terrainColliders.Add(tile.collider);
                    }
                }
            }
            if (LevelGround.terrain != null)
            {
                this.terrainColliders.Add(LevelGround.terrain.transform.GetComponent <TerrainCollider>());
            }
        }
예제 #21
0
        // Token: 0x06000E0E RID: 3598 RVA: 0x00062BD8 File Offset: 0x00060FD8
        public override void read(IFormattedFileReader reader)
        {
            reader = reader.readObject();
            int num = reader.readArrayLength("Tiles");

            for (int i = 0; i < num; i++)
            {
                reader.readArrayIndex(i);
                LandscapeTile landscapeTile = new LandscapeTile(LandscapeCoord.ZERO);
                landscapeTile.enable();
                landscapeTile.applyGraphicsSettings();
                landscapeTile.read(reader);
                if (Landscape.tiles.ContainsKey(landscapeTile.coord))
                {
                    Debug.LogError("Duplicate landscape coord read: " + landscapeTile.coord);
                }
                else
                {
                    Landscape.tiles.Add(landscapeTile.coord, landscapeTile);
                }
            }
            Landscape.linkNeighbors();
            Landscape.applyLOD();
        }
 public LandscapeHeightmapTransaction(LandscapeTile newTile)
 {
     this.tile = newTile;
 }