Example #1
0
    public static void Main(string[] args)
    {
        string            s         = Console.ReadLine();
        Stack <int>       slopeinfo = new Stack <int>();
        Stack <WaterInfo> waterinfo = new Stack <WaterInfo>();

        for (int i = 0; i < s.Length; i++)
        {
            if (s[i] == '\\')
            {
                slopeinfo.Push(i);
            }
            if (s[i] == '/')
            {
                if (slopeinfo.Count == 0)
                {
                    continue;
                }
                int startPosition = slopeinfo.Pop();
                int area          = i - startPosition;
                while (waterinfo.Count > 0 && startPosition < waterinfo.Peek().startPosition)
                {
                    WaterInfo wi = waterinfo.Pop();
                    area += wi.area;
                }
                waterinfo.Push(new WaterInfo(area, startPosition));
            }
        }
        int[] areas = waterinfo.Select(x => x.area).Reverse().ToArray();
        if (areas.Length == 0)
        {
            Console.WriteLine("0");
            Console.WriteLine("0");
        }
        else
        {
            Console.WriteLine(areas.Sum());
            Console.Write("{0} ", areas.Length);
            for (int i = 0; i < areas.Length - 1; i++)
            {
                Console.Write("{0} ", areas[i]);
            }
            Console.WriteLine(areas[areas.Length - 1]);
        }
    }
Example #2
0
        private static WaterInfo[] CreateTypedRowsStartingAt(DateTime start, int rows)
        {
            var rng     = new Random();
            var regions = new[] { "west-eu", "north-eu", "west-us", "east-us", "asia" };

            var timestamp = start;
            var infos     = new WaterInfo[rows];

            for (var i = 0; i < rows; i++)
            {
                var waterLevel = rng.NextDouble();
                var region     = regions[rng.Next(regions.Length)];

                var info = new WaterInfo {
                    Timestamp = timestamp, WaterLevel = waterLevel, Region = region
                };
                infos[i] = info;

                timestamp = timestamp.AddSeconds(1);
            }

            return(infos);
        }
Example #3
0
        private void GenerateRiverLookupTexture(Map map, RiverMaker riverMaker)
        {
            int num  = Mathf.CeilToInt(DefDatabase <RiverDef> .AllDefs.Select((RiverDef rd) => rd.widthOnMap / 2f + 8f).Max());
            int num2 = Mathf.Max(4, num) * 2;
            Dictionary <int, GRLT_Entry> dictionary  = new Dictionary <int, GRLT_Entry>();
            Dictionary <int, GRLT_Entry> dictionary2 = new Dictionary <int, GRLT_Entry>();
            Dictionary <int, GRLT_Entry> dictionary3 = new Dictionary <int, GRLT_Entry>();

            for (int i = -num2; i < map.Size.z + num2; i++)
            {
                for (int j = -num2; j < map.Size.x + num2; j++)
                {
                    IntVec3 intVec  = new IntVec3(j, 0, i);
                    Vector3 vector  = riverMaker.WaterCoordinateAt(intVec);
                    int     entryId = Mathf.FloorToInt(vector.z / 4f);
                    UpdateRiverAnchorEntry(dictionary, intVec, entryId, (vector.z + Mathf.Abs(vector.x)) / 4f);
                    UpdateRiverAnchorEntry(dictionary2, intVec, entryId, (vector.z + Mathf.Abs(vector.x - (float)num)) / 4f);
                    UpdateRiverAnchorEntry(dictionary3, intVec, entryId, (vector.z + Mathf.Abs(vector.x + (float)num)) / 4f);
                }
            }
            int num3 = Mathf.Max(dictionary.Keys.Min(), dictionary2.Keys.Min(), dictionary3.Keys.Min());
            int num4 = Mathf.Min(dictionary.Keys.Max(), dictionary2.Keys.Max(), dictionary3.Keys.Max());

            for (int k = num3; k < num4; k++)
            {
                WaterInfo waterInfo = map.waterInfo;
                if (dictionary2.ContainsKey(k) && dictionary2.ContainsKey(k + 1))
                {
                    waterInfo.riverDebugData.Add(dictionary2[k].bestNode.ToVector3Shifted());
                    waterInfo.riverDebugData.Add(dictionary2[k + 1].bestNode.ToVector3Shifted());
                }
                if (dictionary.ContainsKey(k) && dictionary.ContainsKey(k + 1))
                {
                    waterInfo.riverDebugData.Add(dictionary[k].bestNode.ToVector3Shifted());
                    waterInfo.riverDebugData.Add(dictionary[k + 1].bestNode.ToVector3Shifted());
                }
                if (dictionary3.ContainsKey(k) && dictionary3.ContainsKey(k + 1))
                {
                    waterInfo.riverDebugData.Add(dictionary3[k].bestNode.ToVector3Shifted());
                    waterInfo.riverDebugData.Add(dictionary3[k + 1].bestNode.ToVector3Shifted());
                }
                if (dictionary2.ContainsKey(k) && dictionary.ContainsKey(k))
                {
                    waterInfo.riverDebugData.Add(dictionary2[k].bestNode.ToVector3Shifted());
                    waterInfo.riverDebugData.Add(dictionary[k].bestNode.ToVector3Shifted());
                }
                if (dictionary.ContainsKey(k) && dictionary3.ContainsKey(k))
                {
                    waterInfo.riverDebugData.Add(dictionary[k].bestNode.ToVector3Shifted());
                    waterInfo.riverDebugData.Add(dictionary3[k].bestNode.ToVector3Shifted());
                }
            }
            CellRect cellRect = new CellRect(-2, -2, map.Size.x + 4, map.Size.z + 4);

            float[] array = new float[cellRect.Area * 2];
            int     num5  = 0;

            for (int l = cellRect.minZ; l <= cellRect.maxZ; l++)
            {
                for (int m = cellRect.minX; m <= cellRect.maxX; m++)
                {
                    IntVec3 a    = new IntVec3(m, 0, l);
                    bool    flag = true;
                    for (int n = 0; n < GenAdj.AdjacentCellsAndInside.Length; n++)
                    {
                        if (riverMaker.TerrainAt(a + GenAdj.AdjacentCellsAndInside[n]) != null)
                        {
                            flag = false;
                            break;
                        }
                    }
                    if (!flag)
                    {
                        Vector2 p       = a.ToIntVec2.ToVector2();
                        int     num6    = int.MinValue;
                        Vector2 vector2 = Vector2.zero;
                        for (int num7 = num3; num7 < num4; num7++)
                        {
                            if (dictionary2.ContainsKey(num7) && dictionary2.ContainsKey(num7 + 1) && dictionary.ContainsKey(num7) && dictionary.ContainsKey(num7 + 1) && dictionary3.ContainsKey(num7) && dictionary3.ContainsKey(num7 + 1))
                            {
                                Vector2 p2      = dictionary2[num7].bestNode.ToIntVec2.ToVector2();
                                Vector2 p3      = dictionary2[num7 + 1].bestNode.ToIntVec2.ToVector2();
                                Vector2 p4      = dictionary[num7].bestNode.ToIntVec2.ToVector2();
                                Vector2 p5      = dictionary[num7 + 1].bestNode.ToIntVec2.ToVector2();
                                Vector2 p6      = dictionary3[num7].bestNode.ToIntVec2.ToVector2();
                                Vector2 p7      = dictionary3[num7 + 1].bestNode.ToIntVec2.ToVector2();
                                Vector2 vector3 = GenGeo.InverseQuadBilinear(p, p4, p2, p5, p3);
                                if (vector3.x >= -0.0001f && vector3.x <= 1.0001f && vector3.y >= -0.0001f && vector3.y <= 1.0001f)
                                {
                                    vector2 = new Vector2((0f - vector3.x) * (float)num, (vector3.y + (float)num7) * 4f);
                                    num6    = num7;
                                    break;
                                }
                                Vector2 vector4 = GenGeo.InverseQuadBilinear(p, p4, p6, p5, p7);
                                if (vector4.x >= -0.0001f && vector4.x <= 1.0001f && vector4.y >= -0.0001f && vector4.y <= 1.0001f)
                                {
                                    vector2 = new Vector2(vector4.x * (float)num, (vector4.y + (float)num7) * 4f);
                                    num6    = num7;
                                    break;
                                }
                            }
                        }
                        if (num6 == int.MinValue)
                        {
                            Log.ErrorOnce("Failed to find all necessary river flow data", 5273133);
                        }
                        array[num5]     = vector2.x;
                        array[num5 + 1] = vector2.y;
                    }
                    num5 += 2;
                }
            }
            float[] array2 = new float[cellRect.Area * 2];
            float[] array3 = new float[9]
            {
                0.123317f,
                0.123317f,
                0.123317f,
                0.123317f,
                0.077847f,
                0.077847f,
                0.077847f,
                0.077847f,
                0.195346f
            };
            int num8 = 0;

            for (int num9 = cellRect.minZ; num9 <= cellRect.maxZ; num9++)
            {
                for (int num10 = cellRect.minX; num10 <= cellRect.maxX; num10++)
                {
                    IntVec3 a2    = new IntVec3(num10, 0, num9);
                    float   num11 = 0f;
                    float   num12 = 0f;
                    float   num13 = 0f;
                    for (int num14 = 0; num14 < GenAdj.AdjacentCellsAndInside.Length; num14++)
                    {
                        IntVec3 c = a2 + GenAdj.AdjacentCellsAndInside[num14];
                        if (cellRect.Contains(c))
                        {
                            int num15 = num8 + (GenAdj.AdjacentCellsAndInside[num14].x + GenAdj.AdjacentCellsAndInside[num14].z * cellRect.Width) * 2;
                            if (array[num15] != 0f || array[num15 + 1] != 0f)
                            {
                                num11 += array[num15] * array3[num14];
                                num12 += array[num15 + 1] * array3[num14];
                                num13 += array3[num14];
                            }
                        }
                    }
                    if (num13 > 0f)
                    {
                        array2[num8]     = num11 / num13;
                        array2[num8 + 1] = num12 / num13;
                    }
                    num8 += 2;
                }
            }
            array = array2;
            for (int num16 = 0; num16 < array.Length; num16 += 2)
            {
                if (array[num16] != 0f || array[num16 + 1] != 0f)
                {
                    Vector2 vector5 = Rand.InsideUnitCircle * 0.4f;
                    array[num16]     += vector5.x;
                    array[num16 + 1] += vector5.y;
                }
            }
            byte[] array4 = new byte[array.Length * 4];
            Buffer.BlockCopy(array, 0, array4, 0, array.Length * 4);
            map.waterInfo.riverOffsetMap = array4;
            map.waterInfo.GenerateRiverFlowMap();
        }
Example #4
0
    /// <summary>
    /// 获取水位信息
    /// </summary>
    /// <param name="type"></param>
    /// <returns></returns>
    public static List <WaterInfo> getWaterInfos(string type)
    {
        SqlConnection conn = new SqlConnection(ConfigurationManager.AppSettings["GXSLSql"]);        //数据库连接对象

        ConnectSQL(conn);
        List <WaterInfo> List_WaterInfos = new List <WaterInfo>();
        string           starSql         = "";

        switch (type)
        {
        case "Rver":
        {
            starSql = "select st_rsvr_r.STCD , st_rsvr_r.RZ, st_rsvr_r.INQ,st_rsvr_r.OTQ,st_rsvr_r.W,st_rsvr_r.TM,st_sitinfo_b.站名,st_sitinfo_b.东经,st_sitinfo_b.北纬, st_sitinfo_b.地址 from st_rsvr_r  INNER JOIN st_sitinfo_b on st_rsvr_r.STCD=st_sitinfo_b.站码 where (st_rsvr_r.RZ>0 and st_rsvr_r.TM='2006-05-10 08:00:00.000')";
            try
            {
                SqlCommand     cmd = null;
                SqlDataAdapter da  = null;
                DataSet        ds  = null;
                DataTable      dt  = null;
                cmd = new SqlCommand(starSql, conn);
                da  = new SqlDataAdapter(cmd);
                ds  = new DataSet();
                da.Fill(ds, "ds");
                dt = ds.Tables[0];
                WaterInfo tmp;
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    tmp = new WaterInfo();
                    DataRow row = dt.Rows[i];
                    tmp.SiteNum     = (Convert.IsDBNull(row["STCD"])) ? 0 : (int)row["STCD"];
                    tmp.SiteName    = (Convert.IsDBNull(row["站名"])) ? "" : (string)row["站名"];
                    tmp.SitePntX    = (Convert.IsDBNull(row["东经"])) ? "0" : (string)(row["东经"]);     // Convert.ToDouble(row["东经"]);
                    tmp.SitePntY    = (Convert.IsDBNull(row["北纬"])) ? "0" : (string)(row["北纬"]);
                    tmp.TM          = (Convert.IsDBNull(row["TM"])) ? DateTime.Now : (DateTime)row["TM"];
                    tmp.tm          = (Convert.IsDBNull(row["TM"])) ? DateTime.Now.ToLongDateString().ToString() : ((DateTime)row["TM"]).ToLongDateString().ToString();
                    tmp.WaterPos    = (Convert.IsDBNull(row["RZ"])) ? "0" : (row["RZ"]).ToString();
                    tmp.FlowNum     = (Convert.IsDBNull(row["INQ"])) ? "0" : (row["INQ"]).ToString();
                    tmp.NorNum      = (Convert.IsDBNull(row["OTQ"])) ? "0" : (row["OTQ"]).ToString();
                    tmp.WarnNum     = (Convert.IsDBNull(row["W"])) ? "0" : (row["W"]).ToString();
                    tmp.SiteAddress = (Convert.IsDBNull(row["地址"])) ? "" : (string)row["地址"];
                    List_WaterInfos.Add(tmp);
                }
            }
            catch
            {
                conn.Close();
            }
            finally
            {
                conn.Close();
            }
            break;
        }

        case "river":
        {
            starSql = "select st_river_r.STCD , st_river_r.Z, st_river_r.Q,st_river_r.TM,st_sitinfo_b.站名,st_sitinfo_b.东经,st_sitinfo_b.北纬, st_sitinfo_b.地址 from st_river_r  INNER JOIN st_sitinfo_b on st_river_r.STCD=st_sitinfo_b.站码 where (st_river_r.Z>0 and st_river_r.TM='2006-05-08  08:00:00.000')";
            try
            {
                SqlCommand     cmd = null;
                SqlDataAdapter da  = null;
                DataSet        ds  = null;
                DataTable      dt  = null;
                cmd = new SqlCommand(starSql, conn);
                da  = new SqlDataAdapter(cmd);
                ds  = new DataSet();
                da.Fill(ds, "ds");
                dt = ds.Tables[0];
                WaterInfo tmp;
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    tmp = new WaterInfo();
                    DataRow row = dt.Rows[i];
                    tmp.SiteNum  = (Convert.IsDBNull(row["STCD"])) ? 0 : (int)row["STCD"];
                    tmp.SiteName = (Convert.IsDBNull(row["站名"])) ? "" : (string)row["站名"];
                    tmp.SitePntX = (Convert.IsDBNull(row["东经"])) ? "0" : (string)(row["东经"]);        // Convert.ToDouble(row["东经"]);
                    tmp.SitePntY = (Convert.IsDBNull(row["北纬"])) ? "0" : (string)(row["北纬"]);
                    tmp.TM       = (Convert.IsDBNull(row["TM"])) ? DateTime.Now : (DateTime)row["TM"];
                    tmp.tm       = (Convert.IsDBNull(row["TM"])) ? DateTime.Now.ToLongDateString().ToString() : ((DateTime)row["TM"]).ToLongDateString().ToString();
                    tmp.WaterPos = (Convert.IsDBNull(row["Z"])) ? "0" : (row["Z"]).ToString();
                    //   tmp.FlowNum = (Convert.IsDBNull(row["Q"])) ? "0" : (row["Q"]).ToString();
                    tmp.NorNum = (Convert.IsDBNull(row["Q"])) ? "0" : (row["Q"]).ToString();
                    // tmp.WarnNum = (Convert.IsDBNull(row["W"])) ? "0" : (row["W"]).ToString();
                    tmp.SiteAddress = (Convert.IsDBNull(row["地址"])) ? "" : (string)row["地址"];
                    List_WaterInfos.Add(tmp);
                }
            }
            catch
            {
                conn.Close();
            }
            finally
            {
                conn.Close();
            }
            break;
        }
        }
        return(List_WaterInfos);
    }
Example #5
0
    /// <summary>
    /// 获取站点水位信息
    /// </summary>
    /// <param name="SiteNum"></param>
    /// <returns></returns>
    public static List <WaterInfo> getWaterHisInfo(string type, int SiteNum)
    {
        List <WaterInfo> lst_HisInfos = new List <WaterInfo>();
        SqlConnection    conn         = new SqlConnection(ConfigurationManager.AppSettings["GXSLSql"]); //数据库连接对象

        ConnectSQL(conn);
        string starSql = "";

        switch (type)
        {
        case "river":
        {
            starSql = "select  st_river_r.STCD , st_river_r.Z, st_river_r.TM,st_sitinfo_b.站名, st_sitinfo_b.地址 from st_river_r  INNER JOIN st_sitinfo_b on st_river_r.STCD=st_sitinfo_b.站码 where (st_river_r.STCD=" + SiteNum + " and st_river_r.TM>='2006-05-08  00:00:00.000' and st_river_r.TM<='2006-05-08  23:00:00.000') ORDER BY st_river_r.TM ";
            try
            {
                SqlCommand     cmd = null;
                SqlDataAdapter da  = null;
                DataSet        ds  = null;
                DataTable      dt  = null;
                cmd = new SqlCommand(starSql, conn);
                da  = new SqlDataAdapter(cmd);
                ds  = new DataSet();
                da.Fill(ds, "ds");
                dt = ds.Tables[0];
                WaterInfo tmp;
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    tmp = new WaterInfo();
                    DataRow row = dt.Rows[i];
                    tmp.SiteNum     = (Convert.IsDBNull(row["STCD"])) ? 0 : Convert.ToInt32(row["STCD"]);
                    tmp.SiteName    = (Convert.IsDBNull(row["站名"])) ? "" : (string)row["站名"];
                    tmp.SiteAddress = (Convert.IsDBNull(row["地址"])) ? "" : (string)row["地址"];
                    tmp.WaterPos    = (Convert.IsDBNull(row["Z"])) ? "0" : (row["Z"]).ToString();
                    tmp.TM          = (Convert.IsDBNull(row["TM"])) ? DateTime.Now : (DateTime)row["TM"];
                    tmp.tm          = (Convert.IsDBNull(row["TM"])) ? DateTime.Now.ToLongDateString().ToString() : ((DateTime)row["TM"]).ToLongTimeString();
                    lst_HisInfos.Add(tmp);
                }
            }
            catch
            {
                conn.Close();
            }
            finally
            {
                conn.Close();
            }
            break;
        }

        case "Rver":
        {
            starSql = "select st_rsvr_r.STCD , st_rsvr_r.RZ, st_rsvr_r.TM,st_sitinfo_b.站名, st_sitinfo_b.地址 from st_rsvr_r  INNER JOIN st_sitinfo_b on st_rsvr_r.STCD=st_sitinfo_b.站码 where (st_rsvr_r.STCD=" + SiteNum + " and st_rsvr_r.TM>='2006-05-10 00:00:00.000' and st_rsvr_r.TM<='2006-05-10  23:00:00.000') ORDER BY st_rsvr_r.TM";
            try
            {
                SqlCommand     cmd = null;
                SqlDataAdapter da  = null;
                DataSet        ds  = null;
                DataTable      dt  = null;
                cmd = new SqlCommand(starSql, conn);
                da  = new SqlDataAdapter(cmd);
                ds  = new DataSet();
                da.Fill(ds, "ds");
                dt = ds.Tables[0];
                WaterInfo tmp;
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    tmp = new WaterInfo();
                    DataRow row = dt.Rows[i];
                    tmp.SiteNum     = (Convert.IsDBNull(row["STCD"])) ? 0 : Convert.ToInt32(row["STCD"]);
                    tmp.SiteName    = (Convert.IsDBNull(row["站名"])) ? "" : (string)row["站名"];
                    tmp.SiteAddress = (Convert.IsDBNull(row["地址"])) ? "" : (string)row["地址"];
                    tmp.WaterPos    = (Convert.IsDBNull(row["RZ"])) ? "0" : (row["RZ"]).ToString();
                    tmp.TM          = (Convert.IsDBNull(row["TM"])) ? DateTime.Now : (DateTime)row["TM"];
                    tmp.tm          = (Convert.IsDBNull(row["TM"])) ? DateTime.Now.ToLongDateString().ToString() : ((DateTime)row["TM"]).ToLongTimeString().ToString();
                    lst_HisInfos.Add(tmp);
                }
            }
            catch
            {
                conn.Close();
            }
            finally
            {
                conn.Close();
            }
            break;
        }
        }
        return(lst_HisInfos);
    }
        private void GenerateRiverLookupTexture(Map map, RiverMaker riverMaker)
        {
            int num = Mathf.CeilToInt((from rd in DefDatabase <RiverDef> .AllDefs
                                       select(float)(rd.widthOnMap / 2.0 + 5.0)).Max());
            int num2 = Mathf.Max(4, num) * 2;
            Dictionary <int, GRLT_Entry> dictionary  = new Dictionary <int, GRLT_Entry>();
            Dictionary <int, GRLT_Entry> dictionary2 = new Dictionary <int, GRLT_Entry>();
            Dictionary <int, GRLT_Entry> dictionary3 = new Dictionary <int, GRLT_Entry>();
            int num3 = -num2;

            while (true)
            {
                int     num4 = num3;
                IntVec3 size = map.Size;
                if (num4 < size.z + num2)
                {
                    int num5 = -num2;
                    while (true)
                    {
                        int     num6  = num5;
                        IntVec3 size2 = map.Size;
                        if (num6 < size2.x + num2)
                        {
                            IntVec3 intVec  = new IntVec3(num5, 0, num3);
                            Vector3 vector  = riverMaker.WaterCoordinateAt(intVec);
                            int     entryId = Mathf.FloorToInt((float)(vector.z / 4.0));
                            this.UpdateRiverAnchorEntry(dictionary, intVec, entryId, (float)((vector.z + Mathf.Abs(vector.x)) / 4.0));
                            this.UpdateRiverAnchorEntry(dictionary2, intVec, entryId, (float)((vector.z + Mathf.Abs(vector.x - (float)num)) / 4.0));
                            this.UpdateRiverAnchorEntry(dictionary3, intVec, entryId, (float)((vector.z + Mathf.Abs(vector.x + (float)num)) / 4.0));
                            num5++;
                            continue;
                        }
                        break;
                    }
                    num3++;
                    continue;
                }
                break;
            }
            int num7 = Mathf.Max(dictionary.Keys.Min(), dictionary2.Keys.Min(), dictionary3.Keys.Min());
            int num8 = Mathf.Min(dictionary.Keys.Max(), dictionary2.Keys.Max(), dictionary3.Keys.Max());

            for (int i = num7; i < num8; i++)
            {
                WaterInfo waterInfo = map.waterInfo;
                if (dictionary2.ContainsKey(i) && dictionary2.ContainsKey(i + 1))
                {
                    List <Vector3> riverDebugData = waterInfo.riverDebugData;
                    GRLT_Entry     gRLT_Entry     = dictionary2[i];
                    riverDebugData.Add(gRLT_Entry.bestNode.ToVector3Shifted());
                    List <Vector3> riverDebugData2 = waterInfo.riverDebugData;
                    GRLT_Entry     gRLT_Entry2     = dictionary2[i + 1];
                    riverDebugData2.Add(gRLT_Entry2.bestNode.ToVector3Shifted());
                }
                if (dictionary.ContainsKey(i) && dictionary.ContainsKey(i + 1))
                {
                    List <Vector3> riverDebugData3 = waterInfo.riverDebugData;
                    GRLT_Entry     gRLT_Entry3     = dictionary[i];
                    riverDebugData3.Add(gRLT_Entry3.bestNode.ToVector3Shifted());
                    List <Vector3> riverDebugData4 = waterInfo.riverDebugData;
                    GRLT_Entry     gRLT_Entry4     = dictionary[i + 1];
                    riverDebugData4.Add(gRLT_Entry4.bestNode.ToVector3Shifted());
                }
                if (dictionary3.ContainsKey(i) && dictionary3.ContainsKey(i + 1))
                {
                    List <Vector3> riverDebugData5 = waterInfo.riverDebugData;
                    GRLT_Entry     gRLT_Entry5     = dictionary3[i];
                    riverDebugData5.Add(gRLT_Entry5.bestNode.ToVector3Shifted());
                    List <Vector3> riverDebugData6 = waterInfo.riverDebugData;
                    GRLT_Entry     gRLT_Entry6     = dictionary3[i + 1];
                    riverDebugData6.Add(gRLT_Entry6.bestNode.ToVector3Shifted());
                }
                if (dictionary2.ContainsKey(i) && dictionary.ContainsKey(i))
                {
                    List <Vector3> riverDebugData7 = waterInfo.riverDebugData;
                    GRLT_Entry     gRLT_Entry7     = dictionary2[i];
                    riverDebugData7.Add(gRLT_Entry7.bestNode.ToVector3Shifted());
                    List <Vector3> riverDebugData8 = waterInfo.riverDebugData;
                    GRLT_Entry     gRLT_Entry8     = dictionary[i];
                    riverDebugData8.Add(gRLT_Entry8.bestNode.ToVector3Shifted());
                }
                if (dictionary.ContainsKey(i) && dictionary3.ContainsKey(i))
                {
                    List <Vector3> riverDebugData9 = waterInfo.riverDebugData;
                    GRLT_Entry     gRLT_Entry9     = dictionary[i];
                    riverDebugData9.Add(gRLT_Entry9.bestNode.ToVector3Shifted());
                    List <Vector3> riverDebugData10 = waterInfo.riverDebugData;
                    GRLT_Entry     gRLT_Entry10     = dictionary3[i];
                    riverDebugData10.Add(gRLT_Entry10.bestNode.ToVector3Shifted());
                }
            }
            IntVec3  size3    = map.Size;
            int      width    = size3.x + 4;
            IntVec3  size4    = map.Size;
            CellRect cellRect = new CellRect(-2, -2, width, size4.z + 4);

            float[] array = new float[cellRect.Area * 2];
            int     num9  = 0;

            for (int j = cellRect.minZ; j <= cellRect.maxZ; j++)
            {
                for (int k = cellRect.minX; k <= cellRect.maxX; k++)
                {
                    IntVec3 a     = new IntVec3(k, 0, j);
                    bool    flag  = true;
                    int     num10 = 0;
                    while (num10 < GenAdj.AdjacentCellsAndInside.Length)
                    {
                        if (riverMaker.TerrainAt(a + GenAdj.AdjacentCellsAndInside[num10], false) == null)
                        {
                            num10++;
                            continue;
                        }
                        flag = false;
                        break;
                    }
                    if (!flag)
                    {
                        Vector2 p       = a.ToIntVec2.ToVector2();
                        int     num11   = -2147483648;
                        Vector2 vector2 = Vector2.zero;
                        for (int l = num7; l < num8; l++)
                        {
                            GRLT_Entry gRLT_Entry11 = dictionary2[l];
                            Vector2    p2           = gRLT_Entry11.bestNode.ToIntVec2.ToVector2();
                            GRLT_Entry gRLT_Entry12 = dictionary2[l + 1];
                            Vector2    p3           = gRLT_Entry12.bestNode.ToIntVec2.ToVector2();
                            GRLT_Entry gRLT_Entry13 = dictionary[l];
                            Vector2    p4           = gRLT_Entry13.bestNode.ToIntVec2.ToVector2();
                            GRLT_Entry gRLT_Entry14 = dictionary[l + 1];
                            Vector2    p5           = gRLT_Entry14.bestNode.ToIntVec2.ToVector2();
                            GRLT_Entry gRLT_Entry15 = dictionary3[l];
                            Vector2    p6           = gRLT_Entry15.bestNode.ToIntVec2.ToVector2();
                            GRLT_Entry gRLT_Entry16 = dictionary3[l + 1];
                            Vector2    p7           = gRLT_Entry16.bestNode.ToIntVec2.ToVector2();
                            Vector2    vector3      = GenGeo.InverseQuadBilinear(p, p4, p2, p5, p3);
                            if (vector3.x >= -9.9999997473787516E-05 && vector3.x <= 1.0001000165939331 && vector3.y >= -9.9999997473787516E-05 && vector3.y <= 1.0001000165939331)
                            {
                                vector2 = new Vector2((float)((0.0 - vector3.x) * (float)num), (float)((vector3.y + (float)l) * 4.0));
                                num11   = l;
                                break;
                            }
                            Vector2 vector4 = GenGeo.InverseQuadBilinear(p, p4, p6, p5, p7);
                            if (vector4.x >= -9.9999997473787516E-05 && vector4.x <= 1.0001000165939331 && vector4.y >= -9.9999997473787516E-05 && vector4.y <= 1.0001000165939331)
                            {
                                vector2 = new Vector2(vector4.x * (float)num, (float)((vector4.y + (float)l) * 4.0));
                                num11   = l;
                                break;
                            }
                        }
                        if (num11 == -2147483648)
                        {
                            Log.ErrorOnce("Failed to find all necessary river flow data", 5273133);
                        }
                        array[num9]     = vector2.x;
                        array[num9 + 1] = vector2.y;
                    }
                    num9 += 2;
                }
            }
            float[] array2 = new float[cellRect.Area * 2];
            float[] array3 = new float[9]
            {
                0.123317f,
                0.123317f,
                0.123317f,
                0.123317f,
                0.077847f,
                0.077847f,
                0.077847f,
                0.077847f,
                0.195346f
            };
            int num12 = 0;

            for (int m = cellRect.minZ; m <= cellRect.maxZ; m++)
            {
                for (int n = cellRect.minX; n <= cellRect.maxX; n++)
                {
                    IntVec3 a2    = new IntVec3(n, 0, m);
                    float   num13 = 0f;
                    float   num14 = 0f;
                    float   num15 = 0f;
                    for (int num16 = 0; num16 < GenAdj.AdjacentCellsAndInside.Length; num16++)
                    {
                        IntVec3 c = a2 + GenAdj.AdjacentCellsAndInside[num16];
                        if (cellRect.Contains(c))
                        {
                            int num17 = num12 + (GenAdj.AdjacentCellsAndInside[num16].x + GenAdj.AdjacentCellsAndInside[num16].z * cellRect.Width) * 2;
                            if (array.Length <= num17 + 1 || num17 < 0)
                            {
                                Log.Message("you wut");
                            }
                            if (array[num17] != 0.0 || array[num17 + 1] != 0.0)
                            {
                                num13 += array[num17] * array3[num16];
                                num14 += array[num17 + 1] * array3[num16];
                                num15 += array3[num16];
                            }
                        }
                    }
                    if (num15 > 0.0)
                    {
                        array2[num12]     = num13 / num15;
                        array2[num12 + 1] = num14 / num15;
                    }
                    num12 += 2;
                }
            }
            array = array2;
            for (int num18 = 0; num18 < array.Length; num18 += 2)
            {
                if (array[num18] != 0.0 || array[num18 + 1] != 0.0)
                {
                    Vector3 vector5 = Rand.PointOnDisc * 0.4f;
                    array[num18]     += vector5.x;
                    array[num18 + 1] += vector5.z;
                }
            }
            byte[] array4 = new byte[array.Length * 4];
            Buffer.BlockCopy(array, 0, array4, 0, array.Length * 4);
            map.waterInfo.riverOffsetMap = array4;
            map.waterInfo.GenerateRiverFlowMap();
        }