Example #1
0
        private void GenerateRivers()
        {
            Find.WorldPathGrid.RecalculateAllPerceivedPathCosts();
            List <int> coastalWaterTiles = this.GetCoastalWaterTiles();

            if (!coastalWaterTiles.Any <int>())
            {
                return;
            }
            List <int> neighbors = new List <int>();

            List <int>[] array = Find.WorldPathFinder.FloodPathsWithCostForTree(coastalWaterTiles, delegate(int st, int ed)
            {
                Tile tile  = Find.WorldGrid[ed];
                Tile tile2 = Find.WorldGrid[st];
                Find.WorldGrid.GetTileNeighbors(ed, neighbors);
                int num = neighbors[0];
                for (int j = 0; j < neighbors.Count; j++)
                {
                    if (WorldGenStep_Rivers.GetImpliedElevation(Find.WorldGrid[neighbors[j]]) < WorldGenStep_Rivers.GetImpliedElevation(Find.WorldGrid[num]))
                    {
                        num = neighbors[j];
                    }
                }
                float num2 = 1f;
                if (num != st)
                {
                    num2 = 2f;
                }
                return(Mathf.RoundToInt(num2 * WorldGenStep_Rivers.ElevationChangeCost.Evaluate(WorldGenStep_Rivers.GetImpliedElevation(tile2) - WorldGenStep_Rivers.GetImpliedElevation(tile))));
            }, (int tid) => Find.WorldGrid[tid].WaterCovered, null);
            float[] flow = new float[array.Length];
            for (int i = 0; i < coastalWaterTiles.Count; i++)
            {
                this.AccumulateFlow(flow, array, coastalWaterTiles[i]);
                this.CreateRivers(flow, array, coastalWaterTiles[i]);
            }
        }
            internal int <> m__0(int st, int ed)
            {
                Tile tile  = Find.WorldGrid[ed];
                Tile tile2 = Find.WorldGrid[st];

                Find.WorldGrid.GetTileNeighbors(ed, this.neighbors);
                int num = this.neighbors[0];

                for (int i = 0; i < this.neighbors.Count; i++)
                {
                    if (WorldGenStep_Rivers.GetImpliedElevation(Find.WorldGrid[this.neighbors[i]]) < WorldGenStep_Rivers.GetImpliedElevation(Find.WorldGrid[num]))
                    {
                        num = this.neighbors[i];
                    }
                }
                float num2 = 1f;

                if (num != st)
                {
                    num2 = 2f;
                }
                return(Mathf.RoundToInt(num2 * WorldGenStep_Rivers.ElevationChangeCost.Evaluate(WorldGenStep_Rivers.GetImpliedElevation(tile2) - WorldGenStep_Rivers.GetImpliedElevation(tile))));
            }