| using System; |
| using System; |
| using System.Collections.Generic; |
| using System.Collections.Generic; |
| using System.Threading; |
| using System.Threading; |
| using UnityEngine; |
| using UnityEngine; |
| |
| |
| public class WorldGenerator |
| public class WorldGenerator |
| { |
| { |
| public static void Initialize(World world) |
| public static void Initialize(World world) |
| { |
| { |
| WorldGenerator.m_instance = new WorldGenerator(world); |
| WorldGenerator.m_instance = new WorldGenerator(world); |
| } |
| } |
| |
| |
| public static void Deitialize() |
| public static void Deitialize() |
| { |
| { |
| WorldGenerator.m_instance = null; |
| WorldGenerator.m_instance = null; |
| } |
| } |
| |
| |
| public static WorldGenerator instance |
| public static WorldGenerator instance |
| { |
| { |
| get |
| get |
| { |
| { |
| return WorldGenerator.m_instance; |
| return WorldGenerator.m_instance; |
| } |
| } |
| } |
| } |
| |
| |
| private WorldGenerator(World world) |
| private WorldGenerator(World world) |
| { |
| { |
| this.m_world = world; |
| this.m_world = world; |
| this.m_version = this.m_world.m_worldGenVersion; |
| this.m_version = this.m_world.m_worldGenVersion; |
| this.VersionSetup(this.m_version); |
| this.VersionSetup(this.m_version); |
| UnityEngine.Random.State state = UnityEngine.Random.state; |
| UnityEngine.Random.State state = UnityEngine.Random.state; |
| UnityEngine.Random.InitState(this.m_world.m_seed); |
| UnityEngine.Random.InitState(this.m_world.m_seed); |
| . | |
| if (WorldGenerator.m_noiseGen == null) |
| |
| { |
| |
| WorldGenerator.m_noiseGen = new FastNoise(this.m_world.m_seed); |
| |
| WorldGenerator.m_noiseGen.SetNoiseType(FastNoise.NoiseType.Cellular); |
| |
| WorldGenerator.m_noiseGen.SetCellularDistanceFunction(FastNoise.CellularDistanceFunction.Euclidean); |
| |
| WorldGenerator.m_noiseGen.SetCellularReturnType(FastNoise.CellularReturnType.Distance); |
| |
| WorldGenerator.m_noiseGen.SetFractalOctaves(2); |
| |
| } |
| this.m_offset0 = (float)UnityEngine.Random.Range(-10000, 10000); |
| this.m_offset0 = (float)UnityEngine.Random.Range(-10000, 10000); |
| this.m_offset1 = (float)UnityEngine.Random.Range(-10000, 10000); |
| this.m_offset1 = (float)UnityEngine.Random.Range(-10000, 10000); |
| this.m_offset2 = (float)UnityEngine.Random.Range(-10000, 10000); |
| this.m_offset2 = (float)UnityEngine.Random.Range(-10000, 10000); |
| this.m_offset3 = (float)UnityEngine.Random.Range(-10000, 10000); |
| this.m_offset3 = (float)UnityEngine.Random.Range(-10000, 10000); |
| this.m_riverSeed = UnityEngine.Random.Range(int.MinValue, int.MaxValue); |
| this.m_riverSeed = UnityEngine.Random.Range(int.MinValue, int.MaxValue); |
| this.m_streamSeed = UnityEngine.Random.Range(int.MinValue, int.MaxValue); |
| this.m_streamSeed = UnityEngine.Random.Range(int.MinValue, int.MaxValue); |
| this.m_offset4 = (float)UnityEngine.Random.Range(-10000, 10000); |
| this.m_offset4 = (float)UnityEngine.Random.Range(-10000, 10000); |
| if (!this.m_world.m_menu) |
| if (!this.m_world.m_menu) |
| { |
| { |
| this.Pregenerate(); |
| this.Pregenerate(); |
| } |
| } |
| UnityEngine.Random.state = state; |
| UnityEngine.Random.state = state; |
| } |
| } |
| |
| |
| private void VersionSetup(int version) |
| private void VersionSetup(int version) |
| { |
| { |
| ZLog.Log("Worldgenerator version setup:" + version.ToString()); |
| ZLog.Log("Worldgenerator version setup:" + version.ToString()); |
| if (version <= 0) |
| if (version <= 0) |
| { |
| { |
| this.m_minMountainDistance = 1500f; |
| this.m_minMountainDistance = 1500f; |
| } |
| } |
| if (version <= 1) |
| if (version <= 1) |
| { |
| { |
| this.minDarklandNoise = 0.5f; |
| this.minDarklandNoise = 0.5f; |
| this.maxMarshDistance = 8000f; |
| this.maxMarshDistance = 8000f; |
| } |
| } |
| } |
| } |
| |
| |
| private void Pregenerate() |
| private void Pregenerate() |
| { |
| { |
| this.FindLakes(); |
| this.FindLakes(); |
| this.m_rivers = this.PlaceRivers(); |
| this.m_rivers = this.PlaceRivers(); |
| this.m_streams = this.PlaceStreams(); |
| this.m_streams = this.PlaceStreams(); |
| } |
| } |
| |
| |
| public List<Vector2> GetLakes() |
| public List<Vector2> GetLakes() |
| { |
| { |
| return this.m_lakes; |
| return this.m_lakes; |
| } |
| } |
| |
| |
| public List<WorldGenerator.River> GetRivers() |
| public List<WorldGenerator.River> GetRivers() |
| { |
| { |
| return this.m_rivers; |
| return this.m_rivers; |
| } |
| } |
| |
| |
| public List<WorldGenerator.River> GetStreams() |
| public List<WorldGenerator.River> GetStreams() |
| { |
| { |
| return this.m_streams; |
| return this.m_streams; |
| } |
| } |
| |
| |
| private void FindLakes() |
| private void FindLakes() |
| { |
| { |
| DateTime now = DateTime.Now; |
| DateTime now = DateTime.Now; |
| List<Vector2> list = new List<Vector2>(); |
| List<Vector2> list = new List<Vector2>(); |
| for (float num = -10000f; num <= 10000f; num = (float)((double)num + 128.0)) |
| for (float num = -10000f; num <= 10000f; num = (float)((double)num + 128.0)) |
| { |
| { |
| for (float num2 = -10000f; num2 <= 10000f; num2 = (float)((double)num2 + 128.0)) |
| for (float num2 = -10000f; num2 <= 10000f; num2 = (float)((double)num2 + 128.0)) |
| { |
| { |
| if (new Vector2(num2, num).magnitude <= 10000f && this.GetBaseHeight(num2, num, false) < 0.05f) |
| if (new Vector2(num2, num).magnitude <= 10000f && this.GetBaseHeight(num2, num, false) < 0.05f) |
| { |
| { |
| list.Add(new Vector2(num2, num)); |
| list.Add(new Vector2(num2, num)); |
| } |
| } |
| } |
| } |
| } |
| } |
| this.m_lakes = this.MergePoints(list, 800f); |
| this.m_lakes = this.MergePoints(list, 800f); |
| DateTime.Now - now; |
| DateTime.Now - now; |
| } |
| } |
| |
| |
| private List<Vector2> MergePoints(List<Vector2> points, float range) |
| private List<Vector2> MergePoints(List<Vector2> points, float range) |
| { |
| { |
| List<Vector2> list = new List<Vector2>(); |
| List<Vector2> list = new List<Vector2>(); |
| while (points.Count > 0) |
| while (points.Count > 0) |
| { |
| { |
| Vector2 vector = points[0]; |
| Vector2 vector = points[0]; |
| points.RemoveAt(0); |
| points.RemoveAt(0); |
| while (points.Count > 0) |
| while (points.Count > 0) |
| { |
| { |
| int num = this.FindClosest(points, vector, range); |
| int num = this.FindClosest(points, vector, range); |
| if (num == -1) |
| if (num == -1) |
| { |
| { |
| break; |
| break; |
| } |
| } |
| vector = (vector + points[num]) * 0.5f; |
| vector = (vector + points[num]) * 0.5f; |
| points[num] = points[points.Count - 1]; |
| points[num] = points[points.Count - 1]; |
| points.RemoveAt(points.Count - 1); |
| points.RemoveAt(points.Count - 1); |
| } |
| } |
| list.Add(vector); |
| list.Add(vector); |
| } |
| } |
| return list; |
| return list; |
| } |
| } |
| |
| |
| private int FindClosest(List<Vector2> points, Vector2 p, float maxDistance) |
| private int FindClosest(List<Vector2> points, Vector2 p, float maxDistance) |
| { |
| { |
| int num = -1; |
| int num = -1; |
| float num2 = 99999f; |
| float num2 = 99999f; |
| for (int i = 0; i < points.Count; i++) |
| for (int i = 0; i < points.Count; i++) |
| { |
| { |
| if (!(points[i] == p)) |
| if (!(points[i] == p)) |
| { |
| { |
| float num3 = Vector2.Distance(p, points[i]); |
| float num3 = Vector2.Distance(p, points[i]); |
| if (num3 < maxDistance && num3 < num2) |
| if (num3 < maxDistance && num3 < num2) |
| { |
| { |
| num = i; |
| num = i; |
| num2 = num3; |
| num2 = num3; |
| } |
| } |
| } |
| } |
| } |
| } |
| return num; |
| return num; |
| } |
| } |
| |
| |
| private List<WorldGenerator.River> PlaceStreams() |
| private List<WorldGenerator.River> PlaceStreams() |
| { |
| { |
| UnityEngine.Random.State state = UnityEngine.Random.state; |
| UnityEngine.Random.State state = UnityEngine.Random.state; |
| UnityEngine.Random.InitState(this.m_streamSeed); |
| UnityEngine.Random.InitState(this.m_streamSeed); |
| List<WorldGenerator.River> list = new List<WorldGenerator.River>(); |
| List<WorldGenerator.River> list = new List<WorldGenerator.River>(); |
| int num = 0; |
| int num = 0; |
| DateTime now = DateTime.Now; |
| DateTime now = DateTime.Now; |
| for (int i = 0; i < 3000; i++) |
| for (int i = 0; i < 3000; i++) |
| { |
| { |
| Vector2 vector; |
| Vector2 vector; |
| float num2; |
| float num2; |
| Vector2 vector2; |
| Vector2 vector2; |
| if (this.FindStreamStartPoint(100, 26f, 31f, out vector, out num2) && this.FindStreamEndPoint(100, 36f, 44f, vector, 80f, 200f, out vector2)) |
| if (this.FindStreamStartPoint(100, 26f, 31f, out vector, out num2) && this.FindStreamEndPoint(100, 36f, 44f, vector, 80f, 200f, out vector2)) |
| { |
| { |
| Vector2 vector3 = (vector + vector2) * 0.5f; |
| Vector2 vector3 = (vector + vector2) * 0.5f; |
| float pregenerationHeight = this.GetPregenerationHeight(vector3.x, vector3.y); |
| float pregenerationHeight = this.GetPregenerationHeight(vector3.x, vector3.y); |
| if (pregenerationHeight >= 26f && pregenerationHeight <= 44f) |
| if (pregenerationHeight >= 26f && pregenerationHeight <= 44f) |
| { |
| { |
| WorldGenerator.River river = new WorldGenerator.River(); |
| WorldGenerator.River river = new WorldGenerator.River(); |
| river.p0 = vector; |
| river.p0 = vector; |
| river.p1 = vector2; |
| river.p1 = vector2; |
| river.center = vector3; |
| river.center = vector3; |
| river.widthMax = 20f; |
| river.widthMax = 20f; |
| river.widthMin = 20f; |
| river.widthMin = 20f; |
| float num3 = Vector2.Distance(river.p0, river.p1); |
| float num3 = Vector2.Distance(river.p0, river.p1); |
| river.curveWidth = (float)((double)num3 / 15.0); |
| river.curveWidth = (float)((double)num3 / 15.0); |
| river.curveWavelength = (float)((double)num3 / 20.0); |
| river.curveWavelength = (float)((double)num3 / 20.0); |
| list.Add(river); |
| list.Add(river); |
| num++; |
| num++; |
| } |
| } |
| } |
| } |
| } |
| } |
| this.RenderRivers(list); |
| this.RenderRivers(list); |
| UnityEngine.Random.state = state; |
| UnityEngine.Random.state = state; |
| DateTime.Now - now; |
| DateTime.Now - now; |
| return list; |
| return list; |
| } |
| } |
| |
| |
| private bool FindStreamEndPoint(int iterations, float minHeight, float maxHeight, Vector2 start, float minLength, float maxLength, out Vector2 end) |
| private bool FindStreamEndPoint(int iterations, float minHeight, float maxHeight, Vector2 start, float minLength, float maxLength, out Vector2 end) |
| { |
| { |
| float num = (float)(((double)maxLength - (double)minLength) / (double)iterations); |
| float num = (float)(((double)maxLength - (double)minLength) / (double)iterations); |
| float num2 = maxLength; |
| float num2 = maxLength; |
| for (int i = 0; i < iterations; i++) |
| for (int i = 0; i < iterations; i++) |
| { |
| { |
| num2 = (float)((double)num2 - (double)num); |
| num2 = (float)((double)num2 - (double)num); |
| float num3 = UnityEngine.Random.Range(0f, 6.2831855f); |
| float num3 = UnityEngine.Random.Range(0f, 6.2831855f); |
| Vector2 vector = start + new Vector2(Mathf.Sin(num3), Mathf.Cos(num3)) * num2; |
| Vector2 vector = start + new Vector2(Mathf.Sin(num3), Mathf.Cos(num3)) * num2; |
| float pregenerationHeight = this.GetPregenerationHeight(vector.x, vector.y); |
| float pregenerationHeight = this.GetPregenerationHeight(vector.x, vector.y); |
| if (pregenerationHeight > minHeight && pregenerationHeight < maxHeight) |
| if (pregenerationHeight > minHeight && pregenerationHeight < maxHeight) |
| { |
| { |
| end = vector; |
| end = vector; |
| return true; |
| return true; |
| } |
| } |
| } |
| } |
| end = Vector2.zero; |
| end = Vector2.zero; |
| return false; |
| return false; |
| } |
| } |
| |
| |
| private bool FindStreamStartPoint(int iterations, float minHeight, float maxHeight, out Vector2 p, out float starth) |
| private bool FindStreamStartPoint(int iterations, float minHeight, float maxHeight, out Vector2 p, out float starth) |
| { |
| { |
| for (int i = 0; i < iterations; i++) |
| for (int i = 0; i < iterations; i++) |
| { |
| { |
| float num = UnityEngine.Random.Range(-10000f, 10000f); |
| float num = UnityEngine.Random.Range(-10000f, 10000f); |
| float num2 = UnityEngine.Random.Range(-10000f, 10000f); |
| float num2 = UnityEngine.Random.Range(-10000f, 10000f); |
| float pregenerationHeight = this.GetPregenerationHeight(num, num2); |
| float pregenerationHeight = this.GetPregenerationHeight(num, num2); |
| if (pregenerationHeight > minHeight && pregenerationHeight < maxHeight) |
| if (pregenerationHeight > minHeight && pregenerationHeight < maxHeight) |
| { |
| { |
| p = new Vector2(num, num2); |
| p = new Vector2(num, num2); |
| starth = pregenerationHeight; |
| starth = pregenerationHeight; |
| return true; |
| return true; |
| } |
| } |
| } |
| } |
| p = Vector2.zero; |
| p = Vector2.zero; |
| starth = 0f; |
| starth = 0f; |
| return false; |
| return false; |
| } |
| } |
| |
| |
| private List<WorldGenerator.River> PlaceRivers() |
| private List<WorldGenerator.River> PlaceRivers() |
| { |
| { |
| UnityEngine.Random.State state = UnityEngine.Random.state; |
| UnityEngine.Random.State state = UnityEngine.Random.state; |
| UnityEngine.Random.InitState(this.m_riverSeed); |
| UnityEngine.Random.InitState(this.m_riverSeed); |
| DateTime now = DateTime.Now; |
| DateTime now = DateTime.Now; |
| List<WorldGenerator.River> list = new List<WorldGenerator.River>(); |
| List<WorldGenerator.River> list = new List<WorldGenerator.River>(); |
| List<Vector2> list2 = new List<Vector2>(this.m_lakes); |
| List<Vector2> list2 = new List<Vector2>(this.m_lakes); |
| while (list2.Count > 1) |
| while (list2.Count > 1) |
| { |
| { |
| Vector2 vector = list2[0]; |
| Vector2 vector = list2[0]; |
| int num = this.FindRandomRiverEnd(list, this.m_lakes, vector, 2000f, 0.4f, 128f); |
| int num = this.FindRandomRiverEnd(list, this.m_lakes, vector, 2000f, 0.4f, 128f); |
| if (num == -1 && !this.HaveRiver(list, vector)) |
| if (num == -1 && !this.HaveRiver(list, vector)) |
| { |
| { |
| num = this.FindRandomRiverEnd(list, this.m_lakes, vector, 5000f, 0.4f, 128f); |
| num = this.FindRandomRiverEnd(list, this.m_lakes, vector, 5000f, 0.4f, 128f); |
| } |
| } |
| if (num != -1) |
| if (num != -1) |
| { |
| { |
| WorldGenerator.River river = new WorldGenerator.River(); |
| WorldGenerator.River river = new WorldGenerator.River(); |
| river.p0 = vector; |
| river.p0 = vector; |
| river.p1 = this.m_lakes[num]; |
| river.p1 = this.m_lakes[num]; |
| river.center = (river.p0 + river.p1) * 0.5f; |
| river.center = (river.p0 + river.p1) * 0.5f; |
| river.widthMax = UnityEngine.Random.Range(60f, 100f); |
| river.widthMax = UnityEngine.Random.Range(60f, 100f); |
| river.widthMin = UnityEngine.Random.Range(60f, river.widthMax); |
| river.widthMin = UnityEngine.Random.Range(60f, river.widthMax); |
| float num2 = Vector2.Distance(river.p0, river.p1); |
| float num2 = Vector2.Distance(river.p0, river.p1); |
| river.curveWidth = (float)((double)num2 / 15.0); |
| river.curveWidth = (float)((double)num2 / 15.0); |
| river.curveWavelength = (float)((double)num2 / 20.0); |
| river.curveWavelength = (float)((double)num2 / 20.0); |
| list.Add(river); |
| list.Add(river); |
| } |
| } |
| else |
| else |
| { |
| { |
| list2.RemoveAt(0); |
| list2.RemoveAt(0); |
| } |
| } |
| } |
| } |
| this.RenderRivers(list); |
| this.RenderRivers(list); |
| DateTime.Now - now; |
| DateTime.Now - now; |
| UnityEngine.Random.state = state; |
| UnityEngine.Random.state = state; |
| return list; |
| return list; |
| } |
| } |
| |
| |
| private int FindClosestRiverEnd(List<WorldGenerator.River> rivers, List<Vector2> points, Vector2 p, float maxDistance, float heightLimit, float checkStep) |
| private int FindClosestRiverEnd(List<WorldGenerator.River> rivers, List<Vector2> points, Vector2 p, float maxDistance, float heightLimit, float checkStep) |
| { |
| { |
| int num = -1; |
| int num = -1; |
| float num2 = 99999f; |
| float num2 = 99999f; |
| for (int i = 0; i < points.Count; i++) |
| for (int i = 0; i < points.Count; i++) |
| { |
| { |
| if (!(points[i] == p)) |
| if (!(points[i] == p)) |
| { |
| { |
| float num3 = Vector2.Distance(p, points[i]); |
| float num3 = Vector2.Distance(p, points[i]); |
| if (num3 < maxDistance && num3 < num2 && !this.HaveRiver(rivers, p, points[i]) && this.IsRiverAllowed(p, points[i], checkStep, heightLimit)) |
| if (num3 < maxDistance && num3 < num2 && !this.HaveRiver(rivers, p, points[i]) && this.IsRiverAllowed(p, points[i], checkStep, heightLimit)) |
| { |
| { |
| num = i; |
| num = i; |
| num2 = num3; |
| num2 = num3; |
| } |
| } |
| } |
| } |
| } |
| } |
| return num; |
| return num; |
| } |
| } |
| |
| |
| private int FindRandomRiverEnd(List<WorldGenerator.River> rivers, List<Vector2> points, Vector2 p, float maxDistance, float heightLimit, float checkStep) |
| private int FindRandomRiverEnd(List<WorldGenerator.River> rivers, List<Vector2> points, Vector2 p, float maxDistance, float heightLimit, float checkStep) |
| { |
| { |
| List<int> list = new List<int>(); |
| List<int> list = new List<int>(); |
| for (int i = 0; i < points.Count; i++) |
| for (int i = 0; i < points.Count; i++) |
| { |
| { |
| if (!(points[i] == p) && Vector2.Distance(p, points[i]) < maxDistance && !this.HaveRiver(rivers, p, points[i]) && this.IsRiverAllowed(p, points[i], checkStep, heightLimit)) |
| if (!(points[i] == p) && Vector2.Distance(p, points[i]) < maxDistance && !this.HaveRiver(rivers, p, points[i]) && this.IsRiverAllowed(p, points[i], checkStep, heightLimit)) |
| { |
| { |
| list.Add(i); |
| list.Add(i); |
| } |
| } |
| } |
| } |
| if (list.Count == 0) |
| if (list.Count == 0) |
| { |
| { |
| return -1; |
| return -1; |
| } |
| } |
| return list[UnityEngine.Random.Range(0, list.Count)]; |
| return list[UnityEngine.Random.Range(0, list.Count)]; |
| } |
| } |
| |
| |
| private bool HaveRiver(List<WorldGenerator.River> rivers, Vector2 p0) |
| private bool HaveRiver(List<WorldGenerator.River> rivers, Vector2 p0) |
| { |
| { |
| foreach (WorldGenerator.River river in rivers) |
| foreach (WorldGenerator.River river in rivers) |
| { |
| { |
| if (river.p0 == p0 || river.p1 == p0) |
| if (river.p0 == p0 || river.p1 == p0) |
| { |
| { |
| return true; |
| return true; |
| } |
| } |
| } |
| } |
| return false; |
| return false; |
| } |
| } |
| |
| |
| private bool HaveRiver(List<WorldGenerator.River> rivers, Vector2 p0, Vector2 p1) |
| private bool HaveRiver(List<WorldGenerator.River> rivers, Vector2 p0, Vector2 p1) |
| { |
| { |
| foreach (WorldGenerator.River river in rivers) |
| foreach (WorldGenerator.River river in rivers) |
| { |
| { |
| if ((river.p0 == p0 && river.p1 == p1) || (river.p0 == p1 && river.p1 == p0)) |
| if ((river.p0 == p0 && river.p1 == p1) || (river.p0 == p1 && river.p1 == p0)) |
| { |
| { |
| return true; |
| return true; |
| } |
| } |
| } |
| } |
| return false; |
| return false; |
| } |
| } |
| |
| |
| private bool IsRiverAllowed(Vector2 p0, Vector2 p1, float step, float heightLimit) |
| private bool IsRiverAllowed(Vector2 p0, Vector2 p1, float step, float heightLimit) |
| { |
| { |
| float num = Vector2.Distance(p0, p1); |
| float num = Vector2.Distance(p0, p1); |
| Vector2 normalized = (p1 - p0).normalized; |
| Vector2 normalized = (p1 - p0).normalized; |
| bool flag = true; |
| bool flag = true; |
| for (float num2 = step; num2 <= (float)((double)num - (double)step); num2 = (float)((double)num2 + (double)step)) |
| for (float num2 = step; num2 <= (float)((double)num - (double)step); num2 = (float)((double)num2 + (double)step)) |
| { |
| { |
| Vector2 vector = p0 + normalized * num2; |
| Vector2 vector = p0 + normalized * num2; |
| float baseHeight = this.GetBaseHeight(vector.x, vector.y, false); |
| float baseHeight = this.GetBaseHeight(vector.x, vector.y, false); |
| if (baseHeight > heightLimit) |
| if (baseHeight > heightLimit) |
| { |
| { |
| return false; |
| return false; |
| } |
| } |
| if (baseHeight > 0.05f) |
| if (baseHeight > 0.05f) |
| { |
| { |
| flag = false; |
| flag = false; |
| } |
| } |
| } |
| } |
| return !flag; |
| return !flag; |
| } |
| } |
| |
| |
| private void RenderRivers(List<WorldGenerator.River> rivers) |
| private void RenderRivers(List<WorldGenerator.River> rivers) |
| { |
| { |
| DateTime now = DateTime.Now; |
| DateTime now = DateTime.Now; |
| Dictionary<Vector2i, List<WorldGenerator.RiverPoint>> dictionary = new Dictionary<Vector2i, List<WorldGenerator.RiverPoint>>(); |
| Dictionary<Vector2i, List<WorldGenerator.RiverPoint>> dictionary = new Dictionary<Vector2i, List<WorldGenerator.RiverPoint>>(); |
| foreach (WorldGenerator.River river in rivers) |
| foreach (WorldGenerator.River river in rivers) |
| { |
| { |
| float num = (float)((double)river.widthMin / 8.0); |
| float num = (float)((double)river.widthMin / 8.0); |
| Vector2 normalized = (river.p1 - river.p0).normalized; |
| Vector2 normalized = (river.p1 - river.p0).normalized; |
| Vector2 vector = new Vector2(-normalized.y, normalized.x); |
| Vector2 vector = new Vector2(-normalized.y, normalized.x); |
| float num2 = Vector2.Distance(river.p0, river.p1); |
| float num2 = Vector2.Distance(river.p0, river.p1); |
| for (float num3 = 0f; num3 <= num2; num3 = (float)((double)num3 + (double)num)) |
| for (float num3 = 0f; num3 <= num2; num3 = (float)((double)num3 + (double)num)) |
| { |
| { |
| float num4 = (float)((double)num3 / (double)river.curveWavelength); |
| float num4 = (float)((double)num3 / (double)river.curveWavelength); |
| float num5 = (float)(Math.Sin((double)num4) * Math.Sin((double)num4 * 0.634119987487793) * Math.Sin((double)num4 * 0.3341200053691864) * (double)river.curveWidth); |
| float num5 = (float)(Math.Sin((double)num4) * Math.Sin((double)num4 * 0.634119987487793) * Math.Sin((double)num4 * 0.3341200053691864) * (double)river.curveWidth); |
| float num6 = UnityEngine.Random.Range(river.widthMin, river.widthMax); |
| float num6 = UnityEngine.Random.Range(river.widthMin, river.widthMax); |
| Vector2 vector2 = river.p0 + normalized * num3 + vector * num5; |
| Vector2 vector2 = river.p0 + normalized * num3 + vector * num5; |
| this.AddRiverPoint(dictionary, vector2, num6, river); |
| this.AddRiverPoint(dictionary, vector2, num6, river); |
| } |
| } |
| } |
| } |
| foreach (KeyValuePair<Vector2i, List<WorldGenerator.RiverPoint>> keyValuePair in dictionary) |
| foreach (KeyValuePair<Vector2i, List<WorldGenerator.RiverPoint>> keyValuePair in dictionary) |
| { |
| { |
| WorldGenerator.RiverPoint[] array; |
| WorldGenerator.RiverPoint[] array; |
| if (this.m_riverPoints.TryGetValue(keyValuePair.Key, out array)) |
| if (this.m_riverPoints.TryGetValue(keyValuePair.Key, out array)) |
| { |
| { |
| List<WorldGenerator.RiverPoint> list = new List<WorldGenerator.RiverPoint>(array); |
| List<WorldGenerator.RiverPoint> list = new List<WorldGenerator.RiverPoint>(array); |
| list.AddRange(keyValuePair.Value); |
| list.AddRange(keyValuePair.Value); |
| this.m_riverPoints[keyValuePair.Key] = list.ToArray(); |
| this.m_riverPoints[keyValuePair.Key] = list.ToArray(); |
| } |
| } |
| else |
| else |
| { |
| { |
| WorldGenerator.RiverPoint[] array2 = keyValuePair.Value.ToArray(); |
| WorldGenerator.RiverPoint[] array2 = keyValuePair.Value.ToArray(); |
| this.m_riverPoints.Add(keyValuePair.Key, array2); |
| this.m_riverPoints.Add(keyValuePair.Key, array2); |
| } |
| } |
| } |
| } |
| DateTime.Now - now; |
| DateTime.Now - now; |
| } |
| } |
| |
| |
| private void AddRiverPoint(Dictionary<Vector2i, List<WorldGenerator.RiverPoint>> riverPoints, Vector2 p, float r, WorldGenerator.River river) |
| private void AddRiverPoint(Dictionary<Vector2i, List<WorldGenerator.RiverPoint>> riverPoints, Vector2 p, float r, WorldGenerator.River river) |
| { |
| { |
| Vector2i riverGrid = this.GetRiverGrid(p.x, p.y); |
| Vector2i riverGrid = this.GetRiverGrid(p.x, p.y); |
| int num = Mathf.CeilToInt((float)((double)r / 64.0)); |
| int num = Mathf.CeilToInt((float)((double)r / 64.0)); |
| for (int i = riverGrid.y - num; i <= riverGrid.y + num; i++) |
| for (int i = riverGrid.y - num; i <= riverGrid.y + num; i++) |
| { |
| { |
| for (int j = riverGrid.x - num; j <= riverGrid.x + num; j++) |
| for (int j = riverGrid.x - num; j <= riverGrid.x + num; j++) |
| { |
| { |
| Vector2i vector2i = new Vector2i(j, i); |
| Vector2i vector2i = new Vector2i(j, i); |
| if (this.InsideRiverGrid(vector2i, p, r)) |
| if (this.InsideRiverGrid(vector2i, p, r)) |
| { |
| { |
| this.AddRiverPoint(riverPoints, vector2i, p, r, river); |
| this.AddRiverPoint(riverPoints, vector2i, p, r, river); |
| } |
| } |
| } |
| } |
| } |
| } |
| } |
| } |
| |
| |
| private void AddRiverPoint(Dictionary<Vector2i, List<WorldGenerator.RiverPoint>> riverPoints, Vector2i grid, Vector2 p, float r, WorldGenerator.River river) |
| private void AddRiverPoint(Dictionary<Vector2i, List<WorldGenerator.RiverPoint>> riverPoints, Vector2i grid, Vector2 p, float r, WorldGenerator.River river) |
| { |
| { |
| List<WorldGenerator.RiverPoint> list; |
| List<WorldGenerator.RiverPoint> list; |
| if (riverPoints.TryGetValue(grid, out list)) |
| if (riverPoints.TryGetValue(grid, out list)) |
| { |
| { |
| list.Add(new WorldGenerator.RiverPoint(p, r)); |
| list.Add(new WorldGenerator.RiverPoint(p, r)); |
| return; |
| return; |
| } |
| } |
| list = new List<WorldGenerator.RiverPoint>(); |
| list = new List<WorldGenerator.RiverPoint>(); |
| list.Add(new WorldGenerator.RiverPoint(p, r)); |
| list.Add(new WorldGenerator.RiverPoint(p, r)); |
| riverPoints.Add(grid, list); |
| riverPoints.Add(grid, list); |
| } |
| } |
| |
| |
| public bool InsideRiverGrid(Vector2i grid, Vector2 p, float r) |
| public bool InsideRiverGrid(Vector2i grid, Vector2 p, float r) |
| { |
| { |
| Vector2 vector = new Vector2((float)((double)grid.x * 64.0), (float)((double)grid.y * 64.0)); |
| Vector2 vector = new Vector2((float)((double)grid.x * 64.0), (float)((double)grid.y * 64.0)); |
| Vector2 vector2 = p - vector; |
| Vector2 vector2 = p - vector; |
| return Math.Abs(vector2.x) < (float)((double)r + 32.0) && Math.Abs(vector2.y) < (float)((double)r + 32.0); |
| return Math.Abs(vector2.x) < (float)((double)r + 32.0) && Math.Abs(vector2.y) < (float)((double)r + 32.0); |
| } |
| } |
| |
| |
| public Vector2i GetRiverGrid(float wx, float wy) |
| public Vector2i GetRiverGrid(float wx, float wy) |
| { |
| { |
| int num = Mathf.FloorToInt((float)(((double)wx + 32.0) / 64.0)); |
| int num = Mathf.FloorToInt((float)(((double)wx + 32.0) / 64.0)); |
| int num2 = Mathf.FloorToInt((float)(((double)wy + 32.0) / 64.0)); |
| int num2 = Mathf.FloorToInt((float)(((double)wy + 32.0) / 64.0)); |
| return new Vector2i(num, num2); |
| return new Vector2i(num, num2); |
| } |
| } |
| |
| |
| private void GetRiverWeight(float wx, float wy, out float weight, out float width) |
| private void GetRiverWeight(float wx, float wy, out float weight, out float width) |
| { |
| { |
| Vector2i riverGrid = this.GetRiverGrid(wx, wy); |
| Vector2i riverGrid = this.GetRiverGrid(wx, wy); |
| this.m_riverCacheLock.EnterReadLock(); |
| this.m_riverCacheLock.EnterReadLock(); |
| if (riverGrid == this.m_cachedRiverGrid) |
| if (riverGrid == this.m_cachedRiverGrid) |
| { |
| { |
| if (this.m_cachedRiverPoints != null) |
| if (this.m_cachedRiverPoints != null) |
| { |
| { |
| this.GetWeight(this.m_cachedRiverPoints, wx, wy, out weight, out width); |
| this.GetWeight(this.m_cachedRiverPoints, wx, wy, out weight, out width); |
| this.m_riverCacheLock.ExitReadLock(); |
| this.m_riverCacheLock.ExitReadLock(); |
| return; |
| return; |
| } |
| } |
| weight = 0f; |
| weight = 0f; |
| width = 0f; |
| width = 0f; |
| this.m_riverCacheLock.ExitReadLock(); |
| this.m_riverCacheLock.ExitReadLock(); |
| return; |
| return; |
| } |
| } |
| else |
| else |
| { |
| { |
| this.m_riverCacheLock.ExitReadLock(); |
| this.m_riverCacheLock.ExitReadLock(); |
| WorldGenerator.RiverPoint[] array; |
| WorldGenerator.RiverPoint[] array; |
| if (this.m_riverPoints.TryGetValue(riverGrid, out array)) |
| if (this.m_riverPoints.TryGetValue(riverGrid, out array)) |
| { |
| { |
| this.GetWeight(array, wx, wy, out weight, out width); |
| this.GetWeight(array, wx, wy, out weight, out width); |
| this.m_riverCacheLock.EnterWriteLock(); |
| this.m_riverCacheLock.EnterWriteLock(); |
| this.m_cachedRiverGrid = riverGrid; |
| this.m_cachedRiverGrid = riverGrid; |
| this.m_cachedRiverPoints = array; |
| this.m_cachedRiverPoints = array; |
| this.m_riverCacheLock.ExitWriteLock(); |
| this.m_riverCacheLock.ExitWriteLock(); |
| return; |
| return; |
| } |
| } |
| this.m_riverCacheLock.EnterWriteLock(); |
| this.m_riverCacheLock.EnterWriteLock(); |
| this.m_cachedRiverGrid = riverGrid; |
| this.m_cachedRiverGrid = riverGrid; |
| this.m_cachedRiverPoints = null; |
| this.m_cachedRiverPoints = null; |
| this.m_riverCacheLock.ExitWriteLock(); |
| this.m_riverCacheLock.ExitWriteLock(); |
| weight = 0f; |
| weight = 0f; |
| width = 0f; |
| width = 0f; |
| return; |
| return; |
| } |
| } |
| } |
| } |
| |
| |
| private void GetWeight(WorldGenerator.RiverPoint[] points, float wx, float wy, out float weight, out float width) |
| private void GetWeight(WorldGenerator.RiverPoint[] points, float wx, float wy, out float weight, out float width) |
| { |
| { |
| Vector2 vector = new Vector2(wx, wy); |
| Vector2 vector = new Vector2(wx, wy); |
| weight = 0f; |
| weight = 0f; |
| width = 0f; |
| width = 0f; |
| float num = 0f; |
| float num = 0f; |
| float num2 = 0f; |
| float num2 = 0f; |
| foreach (WorldGenerator.RiverPoint riverPoint in points) |
| foreach (WorldGenerator.RiverPoint riverPoint in points) |
| { |
| { |
| float num3 = Vector2.SqrMagnitude(riverPoint.p - vector); |
| float num3 = Vector2.SqrMagnitude(riverPoint.p - vector); |
| if (num3 < riverPoint.w2) |
| if (num3 < riverPoint.w2) |
| { |
| { |
| float num4 = (float)Math.Sqrt((double)num3); |
| float num4 = (float)Math.Sqrt((double)num3); |
| float num5 = (float)(1.0 - (double)num4 / (double)riverPoint.w); |
| float num5 = (float)(1.0 - (double)num4 / (double)riverPoint.w); |
| if (num5 > weight) |
| if (num5 > weight) |
| { |
| { |
| weight = num5; |
| weight = num5; |
| } |
| } |
| num = (float)((double)num + (double)riverPoint.w * (double)num5); |
| num = (float)((double)num + (double)riverPoint.w * (double)num5); |
| num2 = (float)((double)num2 + (double)num5); |
| num2 = (float)((double)num2 + (double)num5); |
| } |
| } |
| } |
| } |
| if (num2 > 0f) |
| if (num2 > 0f) |
| { |
| { |
| width = (float)((double)num / (double)num2); |
| width = (float)((double)num / (double)num2); |
| } |
| } |
| } |
| } |
| |
| |
| private void GenerateBiomes() |
| private void GenerateBiomes() |
| { |
| { |
| this.m_biomes = new List<Heightmap.Biome>(); |
| this.m_biomes = new List<Heightmap.Biome>(); |
| int num = 400000000; |
| int num = 400000000; |
| for (int i = 0; i < num; i++) |
| for (int i = 0; i < num; i++) |
| { |
| { |
| this.m_biomes[i] = Heightmap.Biome.Meadows; |
| this.m_biomes[i] = Heightmap.Biome.Meadows; |
| } |
| } |
| } |
| } |
| |
| |
| public Heightmap.BiomeArea GetBiomeArea(Vector3 point) |
| public Heightmap.BiomeArea GetBiomeArea(Vector3 point) |
| { |
| { |
| Heightmap.Biome biome = this.GetBiome(point); |
| Heightmap.Biome biome = this.GetBiome(point); |
| Heightmap.Biome biome2 = this.GetBiome(point - new Vector3(-64f, 0f, -64f)); |
| Heightmap.Biome biome2 = this.GetBiome(point - new Vector3(-64f, 0f, -64f)); |
| Heightmap.Biome biome3 = this.GetBiome(point - new Vector3(64f, 0f, -64f)); |
| Heightmap.Biome biome3 = this.GetBiome(point - new Vector3(64f, 0f, -64f)); |
| Heightmap.Biome biome4 = this.GetBiome(point - new Vector3(64f, 0f, 64f)); |
| Heightmap.Biome biome4 = this.GetBiome(point - new Vector3(64f, 0f, 64f)); |
| Heightmap.Biome biome5 = this.GetBiome(point - new Vector3(-64f, 0f, 64f)); |
| Heightmap.Biome biome5 = this.GetBiome(point - new Vector3(-64f, 0f, 64f)); |
| Heightmap.Biome biome6 = this.GetBiome(point - new Vector3(-64f, 0f, 0f)); |
| Heightmap.Biome biome6 = this.GetBiome(point - new Vector3(-64f, 0f, 0f)); |
| Heightmap.Biome biome7 = this.GetBiome(point - new Vector3(64f, 0f, 0f)); |
| Heightmap.Biome biome7 = this.GetBiome(point - new Vector3(64f, 0f, 0f)); |
| Heightmap.Biome biome8 = this.GetBiome(point - new Vector3(0f, 0f, -64f)); |
| Heightmap.Biome biome8 = this.GetBiome(point - new Vector3(0f, 0f, -64f)); |
| Heightmap.Biome biome9 = this.GetBiome(point - new Vector3(0f, 0f, 64f)); |
| Heightmap.Biome biome9 = this.GetBiome(point - new Vector3(0f, 0f, 64f)); |
| if (biome == biome2 && biome == biome3 && biome == biome4 && biome == biome5 && biome == biome6 && biome == biome7 && biome == biome8 && biome == biome9) |
| if (biome == biome2 && biome == biome3 && biome == biome4 && biome == biome5 && biome == biome6 && biome == biome7 && biome == biome8 && biome == biome9) |
| { |
| { |
| return Heightmap.BiomeArea.Median; |
| return Heightmap.BiomeArea.Median; |
| } |
| } |
| return Heightmap.BiomeArea.Edge; |
| return Heightmap.BiomeArea.Edge; |
| } |
| } |
| |
| |
| public Heightmap.Biome GetBiome(Vector3 point) |
| public Heightmap.Biome GetBiome(Vector3 point) |
| { |
| { |
| . | return this.GetBiome(point.x, point.z); |
| return this.GetBiome(point.x, point.z, 0.02f, false); |
| |
| } |
| |
| |
| |
| public static bool IsAshlands(float x, float y) |
| |
| { |
| |
| double num = (double)WorldGenerator.WorldAngle(x, y) * 100.0; |
| |
| return (double)DUtils.Length(x, (float)((double)y + (double)WorldGenerator.ashlandsYOffset)) > (double)WorldGenerator.ashlandsMinDistance + num; |
| |
| } |
| |
| |
| |
| public static float GetAshlandsOceanGradient(float x, float y) |
| |
| { |
| |
| double num = (double)WorldGenerator.WorldAngle(x, y + WorldGenerator.ashlandsYOffset) * 100.0; |
| |
| return (float)(((double)DUtils.Length(x, y + WorldGenerator.ashlandsYOffset) - ((double)WorldGenerator.ashlandsMinDistance + num)) / 300.0); |
| } |
| } |
| |
| |
| . | public Heightmap.Biome GetBiome(float wx, float wy) |
| public static float GetAshlandsOceanGradient(Vector2 pos) |
| |
| { |
| |
| return WorldGenerator.GetAshlandsOceanGradient(pos.x, pos.y); |
| |
| } |
| |
| |
| |
| public static float GetAshlandsOceanGradient(Vector3 pos) |
| |
| { |
| |
| return WorldGenerator.GetAshlandsOceanGradient(pos.x, pos.z); |
| |
| } |
| |
| |
| |
| public static bool IsDeepnorth(float x, float y) |
| |
| { |
| |
| float num = (float)((double)WorldGenerator.WorldAngle(x, y) * 100.0); |
| |
| return new Vector2(x, (float)((double)y + 4000.0)).magnitude > (float)(12000.0 + (double)num); |
| |
| } |
| |
| |
| |
| public Heightmap.Biome GetBiome(float wx, float wy, float oceanLevel = 0.02f, bool waterAlwaysOcean = false) |
| { |
| { |
| if (this.m_world.m_menu) |
| if (this.m_world.m_menu) |
| { |
| { |
| if (this.GetBaseHeight(wx, wy, true) >= 0.4f) |
| if (this.GetBaseHeight(wx, wy, true) >= 0.4f) |
| { |
| { |
| return Heightmap.Biome.Mountain; |
| return Heightmap.Biome.Mountain; |
| } |
| } |
| return Heightmap.Biome.BlackForest; |
| return Heightmap.Biome.BlackForest; |
| } |
| } |
| else |
| else |
| { |
| { |
| . | float magnitude = new Vector2(wx, wy).magnitude; |
| float num = DUtils.Length(wx, wy); |
| float baseHeight = this.GetBaseHeight(wx, wy, false); |
| float baseHeight = this.GetBaseHeight(wx, wy, false); |
| . | float num = (float)((double)this.WorldAngle(wx, wy) * 100.0); |
| float num2 = (float)((double)WorldGenerator.WorldAngle(wx, wy) * 100.0); |
| if (new Vector2(wx, (float)((double)wy + -4000.0)).magnitude > (float)(12000.0 + (double)num)) |
| if (waterAlwaysOcean && this.GetHeight(wx, wy) <= oceanLevel) |
| |
| { |
| |
| return Heightmap.Biome.Ocean; |
| |
| } |
| |
| if (WorldGenerator.IsAshlands(wx, wy)) |
| { |
| { |
| return Heightmap.Biome.AshLands; |
| return Heightmap.Biome.AshLands; |
| } |
| } |
| . | if ((double)baseHeight <= 0.02) |
| if (!waterAlwaysOcean && baseHeight <= oceanLevel) |
| { |
| { |
| return Heightmap.Biome.Ocean; |
| return Heightmap.Biome.Ocean; |
| } |
| } |
| . | if (new Vector2(wx, (float)((double)wy + 4000.0)).magnitude > (float)(12000.0 + (double)num)) |
| if (WorldGenerator.IsDeepnorth(wx, wy)) |
| { |
| { |
| if (baseHeight > 0.4f) |
| if (baseHeight > 0.4f) |
| { |
| { |
| return Heightmap.Biome.Mountain; |
| return Heightmap.Biome.Mountain; |
| } |
| } |
| return Heightmap.Biome.DeepNorth; |
| return Heightmap.Biome.DeepNorth; |
| } |
| } |
| else |
| else |
| { |
| { |
| if (baseHeight > 0.4f) |
| if (baseHeight > 0.4f) |
| { |
| { |
| return Heightmap.Biome.Mountain; |
| return Heightmap.Biome.Mountain; |
| } |
| } |
| . | if (DUtils.PerlinNoise((double)((float)((double)this.m_offset0 + (double)wx)) * 0.0010000000474974513, (double)((float)((double)this.m_offset0 + (double)wy)) * 0.0010000000474974513) > 0.6f && magnitude > 2000f && magnitude < this.maxMarshDistance && baseHeight > 0.05f && baseHeight < 0.25f) |
| if (DUtils.PerlinNoise((double)((float)((double)this.m_offset0 + (double)wx)) * 0.0010000000474974513, (double)((float)((double)this.m_offset0 + (double)wy)) * 0.0010000000474974513) > 0.6f && num > 2000f && num < this.maxMarshDistance && baseHeight > 0.05f && baseHeight < 0.25f) |
| { |
| { |
| return Heightmap.Biome.Swamp; |
| return Heightmap.Biome.Swamp; |
| } |
| } |
| . | if (DUtils.PerlinNoise((double)((float)((double)this.m_offset4 + (double)wx)) * 0.0010000000474974513, (double)((float)((double)this.m_offset4 + (double)wy)) * 0.0010000000474974513) > this.minDarklandNoise && magnitude > (float)(6000.0 + (double)num) && magnitude < 10000f) |
| if (DUtils.PerlinNoise((double)((float)((double)this.m_offset4 + (double)wx)) * 0.0010000000474974513, (double)((float)((double)this.m_offset4 + (double)wy)) * 0.0010000000474974513) > this.minDarklandNoise && num > (float)(6000.0 + (double)num2) && num < 10000f) |
| { |
| { |
| return Heightmap.Biome.Mistlands; |
| return Heightmap.Biome.Mistlands; |
| } |
| } |
| . | if (DUtils.PerlinNoise((double)((float)((double)this.m_offset1 + (double)wx)) * 0.0010000000474974513, (double)((float)((double)this.m_offset1 + (double)wy)) * 0.0010000000474974513) > 0.4f && magnitude > (float)(3000.0 + (double)num) && magnitude < 8000f) |
| if (DUtils.PerlinNoise((double)((float)((double)this.m_offset1 + (double)wx)) * 0.0010000000474974513, (double)((float)((double)this.m_offset1 + (double)wy)) * 0.0010000000474974513) > 0.4f && num > (float)(3000.0 + (double)num2) && num < 8000f) |
| { |
| { |
| return Heightmap.Biome.Plains; |
| return Heightmap.Biome.Plains; |
| } |
| } |
| . | if (DUtils.PerlinNoise((double)((float)((double)this.m_offset2 + (double)wx)) * 0.0010000000474974513, (double)((float)((double)this.m_offset2 + (double)wy)) * 0.0010000000474974513) > 0.4f && magnitude > (float)(600.0 + (double)num) && magnitude < 6000f) |
| if (DUtils.PerlinNoise((double)((float)((double)this.m_offset2 + (double)wx)) * 0.0010000000474974513, (double)((float)((double)this.m_offset2 + (double)wy)) * 0.0010000000474974513) > 0.4f && num > (float)(600.0 + (double)num2) && num < 6000f) |
| { |
| { |
| return Heightmap.Biome.BlackForest; |
| return Heightmap.Biome.BlackForest; |
| } |
| } |
| . | if (magnitude > (float)(5000.0 + (double)num)) |
| if (num > (float)(5000.0 + (double)num2)) |
| { |
| { |
| return Heightmap.Biome.BlackForest; |
| return Heightmap.Biome.BlackForest; |
| } |
| } |
| return Heightmap.Biome.Meadows; |
| return Heightmap.Biome.Meadows; |
| } |
| } |
| } |
| } |
| } |
| } |
| |
| |
| . | private float WorldAngle(float wx, float wy) |
| public static float WorldAngle(float wx, float wy) |
| { |
| { |
| return (float)Math.Sin((double)((float)((double)((float)Math.Atan2((double)wx, (double)wy)) * 20.0))); |
| return (float)Math.Sin((double)((float)((double)((float)Math.Atan2((double)wx, (double)wy)) * 20.0))); |
| } |
| } |
| |
| |
| private float GetBaseHeight(float wx, float wy, bool menuTerrain) |
| private float GetBaseHeight(float wx, float wy, bool menuTerrain) |
| { |
| { |
| if (menuTerrain) |
| if (menuTerrain) |
| { |
| { |
| double num = (double)wx; |
| double num = (double)wx; |
| double num2 = (double)wy; |
| double num2 = (double)wy; |
| num += 100000.0 + (double)this.m_offset0; |
| num += 100000.0 + (double)this.m_offset0; |
| num2 += 100000.0 + (double)this.m_offset1; |
| num2 += 100000.0 + (double)this.m_offset1; |
| float num3 = 0f; |
| float num3 = 0f; |
| num3 = (float)((double)num3 + (double)DUtils.PerlinNoise(num * 0.0020000000949949026 * 0.5, num2 * 0.0020000000949949026 * 0.5) * (double)DUtils.PerlinNoise(num * 0.003000000026077032 * 0.5, num2 * 0.003000000026077032 * 0.5) * 1.0); |
| num3 = (float)((double)num3 + (double)DUtils.PerlinNoise(num * 0.0020000000949949026 * 0.5, num2 * 0.0020000000949949026 * 0.5) * (double)DUtils.PerlinNoise(num * 0.003000000026077032 * 0.5, num2 * 0.003000000026077032 * 0.5) * 1.0); |
| num3 = (float)((double)num3 + (double)DUtils.PerlinNoise(num * 0.0020000000949949026 * 1.0, num2 * 0.0020000000949949026 * 1.0) * (double)DUtils.PerlinNoise(num * 0.003000000026077032 * 1.0, num2 * 0.003000000026077032 * 1.0) * (double)num3 * 0.8999999761581421); |
| num3 = (float)((double)num3 + (double)DUtils.PerlinNoise(num * 0.0020000000949949026 * 1.0, num2 * 0.0020000000949949026 * 1.0) * (double)DUtils.PerlinNoise(num * 0.003000000026077032 * 1.0, num2 * 0.003000000026077032 * 1.0) * (double)num3 * 0.8999999761581421); |
| num3 = (float)((double)num3 + (double)DUtils.PerlinNoise(num * 0.004999999888241291 * 1.0, num2 * 0.004999999888241291 * 1.0) * (double)DUtils.PerlinNoise(num * 0.009999999776482582 * 1.0, num2 * 0.009999999776482582 * 1.0) * 0.5 * (double)num3); |
| num3 = (float)((double)num3 + (double)DUtils.PerlinNoise(num * 0.004999999888241291 * 1.0, num2 * 0.004999999888241291 * 1.0) * (double)DUtils.PerlinNoise(num * 0.009999999776482582 * 1.0, num2 * 0.009999999776482582 * 1.0) * 0.5 * (double)num3); |
| return (float)((double)num3 - 0.07000000029802322); |
| return (float)((double)num3 - 0.07000000029802322); |
| } |
| } |
| float num4 = DUtils.Length(wx, wy); |
| float num4 = DUtils.Length(wx, wy); |
| double num5 = (double)wx; |
| double num5 = (double)wx; |
| double num6 = (double)wy; |
| double num6 = (double)wy; |
| num5 += 100000.0 + (double)this.m_offset0; |
| num5 += 100000.0 + (double)this.m_offset0; |
| num6 += 100000.0 + (double)this.m_offset1; |
| num6 += 100000.0 + (double)this.m_offset1; |
| float num7 = 0f; |
| float num7 = 0f; |
| num7 = (float)((double)num7 + (double)DUtils.PerlinNoise(num5 * 0.0020000000949949026 * 0.5, num6 * 0.0020000000949949026 * 0.5) * (double)DUtils.PerlinNoise(num5 * 0.003000000026077032 * 0.5, num6 * 0.003000000026077032 * 0.5) * 1.0); |
| num7 = (float)((double)num7 + (double)DUtils.PerlinNoise(num5 * 0.0020000000949949026 * 0.5, num6 * 0.0020000000949949026 * 0.5) * (double)DUtils.PerlinNoise(num5 * 0.003000000026077032 * 0.5, num6 * 0.003000000026077032 * 0.5) * 1.0); |
| num7 = (float)((double)num7 + (double)DUtils.PerlinNoise(num5 * 0.0020000000949949026 * 1.0, num6 * 0.0020000000949949026 * 1.0) * (double)DUtils.PerlinNoise(num5 * 0.003000000026077032 * 1.0, num6 * 0.003000000026077032 * 1.0) * (double)num7 * 0.8999999761581421); |
| num7 = (float)((double)num7 + (double)DUtils.PerlinNoise(num5 * 0.0020000000949949026 * 1.0, num6 * 0.0020000000949949026 * 1.0) * (double)DUtils.PerlinNoise(num5 * 0.003000000026077032 * 1.0, num6 * 0.003000000026077032 * 1.0) * (double)num7 * 0.8999999761581421); |
| num7 = (float)((double)num7 + (double)DUtils.PerlinNoise(num5 * 0.004999999888241291 * 1.0, num6 * 0.004999999888241291 * 1.0) * (double)DUtils.PerlinNoise(num5 * 0.009999999776482582 * 1.0, num6 * 0.009999999776482582 * 1.0) * 0.5 * (double)num7); |
| num7 = (float)((double)num7 + (double)DUtils.PerlinNoise(num5 * 0.004999999888241291 * 1.0, num6 * 0.004999999888241291 * 1.0) * (double)DUtils.PerlinNoise(num5 * 0.009999999776482582 * 1.0, num6 * 0.009999999776482582 * 1.0) * 0.5 * (double)num7); |
| num7 = (float)((double)num7 - 0.07000000029802322); |
| num7 = (float)((double)num7 - 0.07000000029802322); |
| double num8 = (double)DUtils.PerlinNoise(num5 * 0.0020000000949949026 * 0.25 + 0.12300000339746475, num6 * 0.0020000000949949026 * 0.25 + 0.15123000741004944); |
| double num8 = (double)DUtils.PerlinNoise(num5 * 0.0020000000949949026 * 0.25 + 0.12300000339746475, num6 * 0.0020000000949949026 * 0.25 + 0.15123000741004944); |
| float num9 = DUtils.PerlinNoise(num5 * 0.0020000000949949026 * 0.25 + 0.32100000977516174, num6 * 0.0020000000949949026 * 0.25 + 0.23100000619888306); |
| float num9 = DUtils.PerlinNoise(num5 * 0.0020000000949949026 * 0.25 + 0.32100000977516174, num6 * 0.0020000000949949026 * 0.25 + 0.23100000619888306); |
| float num10 = Mathf.Abs((float)(num8 - (double)num9)); |
| float num10 = Mathf.Abs((float)(num8 - (double)num9)); |
| float num11 = (float)(1.0 - (double)DUtils.LerpStep(0.02f, 0.12f, num10)); |
| float num11 = (float)(1.0 - (double)DUtils.LerpStep(0.02f, 0.12f, num10)); |
| num11 = (float)((double)num11 * (double)DUtils.SmoothStep(744f, 1000f, num4)); |
| num11 = (float)((double)num11 * (double)DUtils.SmoothStep(744f, 1000f, num4)); |
| num7 = (float)((double)num7 * (1.0 - (double)num11)); |
| num7 = (float)((double)num7 * (1.0 - (double)num11)); |
| if (num4 > 10000f) |
| if (num4 > 10000f) |
| { |
| { |
| float num12 = DUtils.LerpStep(10000f, 10500f, num4); |
| float num12 = DUtils.LerpStep(10000f, 10500f, num4); |
| num7 = DUtils.Lerp(num7, -0.2f, num12); |
| num7 = DUtils.Lerp(num7, -0.2f, num12); |
| float num13 = 10490f; |
| float num13 = 10490f; |
| if (num4 > num13) |
| if (num4 > num13) |
| { |
| { |
| float num14 = Utils.LerpStep(num13, 10500f, num4); |
| float num14 = Utils.LerpStep(num13, 10500f, num4); |
| num7 = DUtils.Lerp(num7, -2f, num14); |
| num7 = DUtils.Lerp(num7, -2f, num14); |
| } |
| } |
| . | |
| return num7; |
| } |
| } |
| if (num4 < this.m_minMountainDistance && num7 > 0.28f) |
| if (num4 < this.m_minMountainDistance && num7 > 0.28f) |
| { |
| { |
| float num15 = (float)DUtils.Clamp01(((double)num7 - 0.2800000011920929) / 0.09999999403953552); |
| float num15 = (float)DUtils.Clamp01(((double)num7 - 0.2800000011920929) / 0.09999999403953552); |
| num7 = DUtils.Lerp(DUtils.Lerp(0.28f, 0.38f, num15), num7, DUtils.LerpStep((float)((double)this.m_minMountainDistance - 400.0), this.m_minMountainDistance, num4)); |
| num7 = DUtils.Lerp(DUtils.Lerp(0.28f, 0.38f, num15), num7, DUtils.LerpStep((float)((double)this.m_minMountainDistance - 400.0), this.m_minMountainDistance, num4)); |
| } |
| } |
| return num7; |
| return num7; |
| } |
| } |
| |
| |
| private float AddRivers(float wx, float wy, float h) |
| private float AddRivers(float wx, float wy, float h) |
| { |
| { |
| float num; |
| float num; |
| float num2; |
| float num2; |
| this.GetRiverWeight(wx, wy, out num, out num2); |
| this.GetRiverWeight(wx, wy, out num, out num2); |
| if (num <= 0f) |
| if (num <= 0f) |
| { |
| { |
| return h; |
| return h; |
| } |
| } |
| float num3 = DUtils.LerpStep(20f, 60f, num2); |
| float num3 = DUtils.LerpStep(20f, 60f, num2); |
| float num4 = DUtils.Lerp(0.14f, 0.12f, num3); |
| float num4 = DUtils.Lerp(0.14f, 0.12f, num3); |
| float num5 = DUtils.Lerp(0.139f, 0.128f, num3); |
| float num5 = DUtils.Lerp(0.139f, 0.128f, num3); |
| if (h > num4) |
| if (h > num4) |
| { |
| { |
| h = DUtils.Lerp(h, num4, num); |
| h = DUtils.Lerp(h, num4, num); |
| } |
| } |
| if (h > num5) |
| if (h > num5) |
| { |
| { |
| float num6 = DUtils.LerpStep(0.85f, 1f, num); |
| float num6 = DUtils.LerpStep(0.85f, 1f, num); |
| h = DUtils.Lerp(h, num5, num6); |
| h = DUtils.Lerp(h, num5, num6); |
| } |
| } |
| return h; |
| return h; |
| } |
| } |
| |
| |
| public float GetHeight(float wx, float wy) |
| public float GetHeight(float wx, float wy) |
| { |
| { |
| . | Heightmap.Biome biome = this.GetBiome(wx, wy); |
| Heightmap.Biome biome = this.GetBiome(wx, wy, 0.02f, false); |
| Color color; |
| Color color; |
| return this.GetBiomeHeight(biome, wx, wy, out color, false); |
| return this.GetBiomeHeight(biome, wx, wy, out color, false); |
| } |
| } |
| |
| |
| . | |
| public float GetHeight(float wx, float wy, out Color mask) |
| |
| { |
| |
| Heightmap.Biome biome = this.GetBiome(wx, wy, 0.02f, false); |
| |
| return this.GetBiomeHeight(biome, wx, wy, out mask, false); |
| |
| } |
| |
| |
| public float GetPregenerationHeight(float wx, float wy) |
| public float GetPregenerationHeight(float wx, float wy) |
| { |
| { |
| . | Heightmap.Biome biome = this.GetBiome(wx, wy); |
| Heightmap.Biome biome = this.GetBiome(wx, wy, 0.02f, false); |
| Color color; |
| Color color; |
| return this.GetBiomeHeight(biome, wx, wy, out color, true); |
| return this.GetBiomeHeight(biome, wx, wy, out color, true); |
| } |
| } |
| |
| |
| public float GetBiomeHeight(Heightmap.Biome biome, float wx, float wy, out Color mask, bool preGeneration = false) |
| public float GetBiomeHeight(Heightmap.Biome biome, float wx, float wy, out Color mask, bool preGeneration = false) |
| { |
| { |
| . | |
| float num; |
| |
| if (preGeneration) |
| |
| { |
| |
| num = WorldGenerator.GetHeightMultiplier(); |
| |
| } |
| |
| else |
| |
| { |
| |
| num = (float)((double)WorldGenerator.GetHeightMultiplier() * this.CreateAshlandsGap(wx, wy) * this.CreateDeepNorthGap(wx, wy)); |
| |
| } |
| mask = Color.black; |
| mask = Color.black; |
| . | if (!this.m_world.m_menu) |
| if (this.m_world.m_menu) |
| |
| { |
| |
| if (biome == Heightmap.Biome.Mountain) |
| |
| { |
| |
| return (float)((double)this.GetSnowMountainHeight(wx, wy, true) * (double)num); |
| |
| } |
| |
| return (float)((double)this.GetMenuHeight(wx, wy) * (double)num); |
| |
| } |
| |
| else |
| { |
| { |
| . | |
| if (DUtils.Length(wx, wy) > 10500f) |
| |
| { |
| |
| return -2f * WorldGenerator.GetHeightMultiplier(); |
| |
| } |
| if (biome <= Heightmap.Biome.Plains) |
| if (biome <= Heightmap.Biome.Plains) |
| { |
| { |
| switch (biome) |
| switch (biome) |
| { |
| { |
| case Heightmap.Biome.Meadows: |
| case Heightmap.Biome.Meadows: |
| . | return (float)((double)this.GetMeadowsHeight(wx, wy) * 200.0); |
| return (float)((double)this.GetMeadowsHeight(wx, wy) * (double)num); |
| case Heightmap.Biome.Swamp: |
| case Heightmap.Biome.Swamp: |
| . | return (float)((double)this.GetMarshHeight(wx, wy) * 200.0); |
| return (float)((double)this.GetMarshHeight(wx, wy) * (double)num); |
| case Heightmap.Biome.Meadows | Heightmap.Biome.Swamp: |
| case Heightmap.Biome.Meadows | Heightmap.Biome.Swamp: |
| break; |
| break; |
| case Heightmap.Biome.Mountain: |
| case Heightmap.Biome.Mountain: |
| . | return (float)((double)this.GetSnowMountainHeight(wx, wy, false) * 200.0); |
| return (float)((double)this.GetSnowMountainHeight(wx, wy, false) * (double)num); |
| default: |
| default: |
| if (biome == Heightmap.Biome.BlackForest) |
| if (biome == Heightmap.Biome.BlackForest) |
| { |
| { |
| . | return (float)((double)this.GetForestHeight(wx, wy) * 200.0); |
| return (float)((double)this.GetForestHeight(wx, wy) * (double)num); |
| } |
| } |
| if (biome == Heightmap.Biome.Plains) |
| if (biome == Heightmap.Biome.Plains) |
| { |
| { |
| . | return (float)((double)this.GetPlainsHeight(wx, wy) * 200.0); |
| return (float)((double)this.GetPlainsHeight(wx, wy) * (double)num); |
| } |
| } |
| break; |
| break; |
| } |
| } |
| } |
| } |
| else if (biome <= Heightmap.Biome.DeepNorth) |
| else if (biome <= Heightmap.Biome.DeepNorth) |
| { |
| { |
| . | if (biome == Heightmap.Biome.AshLands) |
| if (biome != Heightmap.Biome.AshLands) |
| { |
| { |
| . | return (float)((double)this.GetAshlandsHeight(wx, wy) * 200.0); |
| if (biome == Heightmap.Biome.DeepNorth) |
| |
| { |
| |
| return (float)((double)this.GetDeepNorthHeight(wx, wy) * (double)num); |
| |
| } |
| } |
| } |
| . | if (biome == Heightmap.Biome.DeepNorth) |
| else |
| { |
| { |
| . | return (float)((double)this.GetDeepNorthHeight(wx, wy) * 200.0); |
| if (preGeneration) |
| |
| { |
| |
| return (float)((double)this.GetAshlandsHeightPregenerate(wx, wy) * (double)num); |
| |
| } |
| |
| return (float)((double)this.GetAshlandsHeight(wx, wy, out mask, false) * (double)num); |
| } |
| } |
| } |
| } |
| else |
| else |
| { |
| { |
| if (biome == Heightmap.Biome.Ocean) |
| if (biome == Heightmap.Biome.Ocean) |
| { |
| { |
| . | return (float)((double)this.GetOceanHeight(wx, wy) * 200.0); |
| return (float)((double)this.GetOceanHeight(wx, wy) * (double)num); |
| } |
| } |
| if (biome == Heightmap.Biome.Mistlands) |
| if (biome == Heightmap.Biome.Mistlands) |
| { |
| { |
| if (preGeneration) |
| if (preGeneration) |
| { |
| { |
| . | return (float)((double)this.GetForestHeight(wx, wy) * 200.0); |
| return (float)((double)this.GetForestHeight(wx, wy) * (double)num); |
| } |
| } |
| . | return (float)((double)this.GetMistlandsHeight(wx, wy, out mask) * 200.0); |
| return (float)((double)this.GetMistlandsHeight(wx, wy, out mask) * (double)num); |
| } |
| } |
| } |
| } |
| return 0f; |
| return 0f; |
| } |
| } |
| . | if (biome == Heightmap.Biome.Mountain) |
| |
| { |
| |
| return (float)((double)this.GetSnowMountainHeight(wx, wy, true) * 200.0); |
| |
| } |
| |
| return (float)((double)this.GetMenuHeight(wx, wy) * 200.0); |
| |
| } |
| } |
| |
| |
| private float GetMarshHeight(float wx, float wy) |
| private float GetMarshHeight(float wx, float wy) |
| { |
| { |
| float num = wx; |
| float num = wx; |
| float num2 = wy; |
| float num2 = wy; |
| float num3 = 0.137f; |
| float num3 = 0.137f; |
| wx = (float)((double)wx + 100000.0); |
| wx = (float)((double)wx + 100000.0); |
| wy = (float)((double)wy + 100000.0); |
| wy = (float)((double)wy + 100000.0); |
| double num4 = (double)wx; |
| double num4 = (double)wx; |
| double num5 = (double)wy; |
| double num5 = (double)wy; |
| float num6 = (float)((double)DUtils.PerlinNoise(num4 * 0.03999999910593033, num5 * 0.03999999910593033) * (double)DUtils.PerlinNoise(num4 * 0.07999999821186066, num5 * 0.07999999821186066)); |
| float num6 = (float)((double)DUtils.PerlinNoise(num4 * 0.03999999910593033, num5 * 0.03999999910593033) * (double)DUtils.PerlinNoise(num4 * 0.07999999821186066, num5 * 0.07999999821186066)); |
| num3 = (float)((double)num3 + (double)num6 * 0.029999999329447746); |
| num3 = (float)((double)num3 + (double)num6 * 0.029999999329447746); |
| num3 = this.AddRivers(num, num2, num3); |
| num3 = this.AddRivers(num, num2, num3); |
| num3 = (float)((double)num3 + (double)DUtils.PerlinNoise(num4 * 0.10000000149011612, num5 * 0.10000000149011612) * 0.009999999776482582); |
| num3 = (float)((double)num3 + (double)DUtils.PerlinNoise(num4 * 0.10000000149011612, num5 * 0.10000000149011612) * 0.009999999776482582); |
| return (float)((double)num3 + (double)DUtils.PerlinNoise(num4 * 0.4000000059604645, num5 * 0.4000000059604645) * 0.003000000026077032); |
| return (float)((double)num3 + (double)DUtils.PerlinNoise(num4 * 0.4000000059604645, num5 * 0.4000000059604645) * 0.003000000026077032); |
| } |
| } |
| |
| |
| private float GetMeadowsHeight(float wx, float wy) |
| private float GetMeadowsHeight(float wx, float wy) |
| { |
| { |
| float num = wx; |
| float num = wx; |
| float num2 = wy; |
| float num2 = wy; |
| float baseHeight = this.GetBaseHeight(wx, wy, false); |
| float baseHeight = this.GetBaseHeight(wx, wy, false); |
| wx = (float)((double)wx + 100000.0 + (double)this.m_offset3); |
| wx = (float)((double)wx + 100000.0 + (double)this.m_offset3); |
| wy = (float)((double)wy + 100000.0 + (double)this.m_offset3); |
| wy = (float)((double)wy + 100000.0 + (double)this.m_offset3); |
| double num3 = (double)wx; |
| double num3 = (double)wx; |
| double num4 = (double)wy; |
| double num4 = (double)wy; |
| float num5 = (float)((double)DUtils.PerlinNoise(num3 * 0.009999999776482582, num4 * 0.009999999776482582) * (double)DUtils.PerlinNoise(num3 * 0.019999999552965164, num4 * 0.019999999552965164)); |
| float num5 = (float)((double)DUtils.PerlinNoise(num3 * 0.009999999776482582, num4 * 0.009999999776482582) * (double)DUtils.PerlinNoise(num3 * 0.019999999552965164, num4 * 0.019999999552965164)); |
| num5 = (float)((double)num5 + (double)DUtils.PerlinNoise(num3 * 0.05000000074505806, num4 * 0.05000000074505806) * (double)DUtils.PerlinNoise(num3 * 0.10000000149011612, num4 * 0.10000000149011612) * (double)num5 * 0.5); |
| num5 = (float)((double)num5 + (double)DUtils.PerlinNoise(num3 * 0.05000000074505806, num4 * 0.05000000074505806) * (double)DUtils.PerlinNoise(num3 * 0.10000000149011612, num4 * 0.10000000149011612) * (double)num5 * 0.5); |
| float num6 = baseHeight; |
| float num6 = baseHeight; |
| num6 = (float)((double)num6 + (double)num5 * 0.10000000149011612); |
| num6 = (float)((double)num6 + (double)num5 * 0.10000000149011612); |
| float num7 = 0.15f; |
| float num7 = 0.15f; |
| float num8 = (float)((double)num6 - (double)num7); |
| float num8 = (float)((double)num6 - (double)num7); |
| float num9 = (float)DUtils.Clamp01((double)baseHeight / 0.4000000059604645); |
| float num9 = (float)DUtils.Clamp01((double)baseHeight / 0.4000000059604645); |
| if (num8 > 0f) |
| if (num8 > 0f) |
| { |
| { |
| num6 = (float)((double)num6 - (double)num8 * ((1.0 - (double)num9) * 0.75)); |
| num6 = (float)((double)num6 - (double)num8 * ((1.0 - (double)num9) * 0.75)); |
| } |
| } |
| num6 = this.AddRivers(num, num2, num6); |
| num6 = this.AddRivers(num, num2, num6); |
| num6 = (float)((double)num6 + (double)DUtils.PerlinNoise(num3 * 0.10000000149011612, num4 * 0.10000000149011612) * 0.009999999776482582); |
| num6 = (float)((double)num6 + (double)DUtils.PerlinNoise(num3 * 0.10000000149011612, num4 * 0.10000000149011612) * 0.009999999776482582); |
| return (float)((double)num6 + (double)DUtils.PerlinNoise(num3 * 0.4000000059604645, num4 * 0.4000000059604645) * 0.003000000026077032); |
| return (float)((double)num6 + (double)DUtils.PerlinNoise(num3 * 0.4000000059604645, num4 * 0.4000000059604645) * 0.003000000026077032); |
| } |
| } |
| |
| |
| private float GetForestHeight(float wx, float wy) |
| private float GetForestHeight(float wx, float wy) |
| { |
| { |
| float num = wx; |
| float num = wx; |
| float num2 = wy; |
| float num2 = wy; |
| float num3 = this.GetBaseHeight(wx, wy, false); |
| float num3 = this.GetBaseHeight(wx, wy, false); |
| wx = (float)((double)wx + 100000.0 + (double)this.m_offset3); |
| wx = (float)((double)wx + 100000.0 + (double)this.m_offset3); |
| wy = (float)((double)wy + 100000.0 + (double)this.m_offset3); |
| wy = (float)((double)wy + 100000.0 + (double)this.m_offset3); |
| double num4 = (double)wx; |
| double num4 = (double)wx; |
| double num5 = (double)wy; |
| double num5 = (double)wy; |
| float num6 = (float)((double)DUtils.PerlinNoise(num4 * 0.009999999776482582, num5 * 0.009999999776482582) * (double)DUtils.PerlinNoise(num4 * 0.019999999552965164, num5 * 0.019999999552965164)); |
| float num6 = (float)((double)DUtils.PerlinNoise(num4 * 0.009999999776482582, num5 * 0.009999999776482582) * (double)DUtils.PerlinNoise(num4 * 0.019999999552965164, num5 * 0.019999999552965164)); |
| num6 = (float)((double)num6 + (double)DUtils.PerlinNoise(num4 * 0.05000000074505806, num5 * 0.05000000074505806) * (double)DUtils.PerlinNoise(num4 * 0.10000000149011612, num5 * 0.10000000149011612) * (double)num6 * 0.5); |
| num6 = (float)((double)num6 + (double)DUtils.PerlinNoise(num4 * 0.05000000074505806, num5 * 0.05000000074505806) * (double)DUtils.PerlinNoise(num4 * 0.10000000149011612, num5 * 0.10000000149011612) * (double)num6 * 0.5); |
| num3 = (float)((double)num3 + (double)num6 * 0.10000000149011612); |
| num3 = (float)((double)num3 + (double)num6 * 0.10000000149011612); |
| num3 = this.AddRivers(num, num2, num3); |
| num3 = this.AddRivers(num, num2, num3); |
| num3 = (float)((double)num3 + (double)DUtils.PerlinNoise(num4 * 0.10000000149011612, num5 * 0.10000000149011612) * 0.009999999776482582); |
| num3 = (float)((double)num3 + (double)DUtils.PerlinNoise(num4 * 0.10000000149011612, num5 * 0.10000000149011612) * 0.009999999776482582); |
| return (float)((double)num3 + (double)DUtils.PerlinNoise(num4 * 0.4000000059604645, num5 * 0.4000000059604645) * 0.003000000026077032); |
| return (float)((double)num3 + (double)DUtils.PerlinNoise(num4 * 0.4000000059604645, num5 * 0.4000000059604645) * 0.003000000026077032); |
| } |
| } |
| |
| |
| private float GetMistlandsHeight(float wx, float wy, out Color mask) |
| private float GetMistlandsHeight(float wx, float wy, out Color mask) |
| { |
| { |
| float num = wx; |
| float num = wx; |
| float num2 = wy; |
| float num2 = wy; |
| float num3 = this.GetBaseHeight(wx, wy, false); |
| float num3 = this.GetBaseHeight(wx, wy, false); |
| wx = (float)((double)wx + 100000.0 + (double)this.m_offset3); |
| wx = (float)((double)wx + 100000.0 + (double)this.m_offset3); |
| wy = (float)((double)wy + 100000.0 + (double)this.m_offset3); |
| wy = (float)((double)wy + 100000.0 + (double)this.m_offset3); |
| double num4 = (double)wx; |
| double num4 = (double)wx; |
| double num5 = (double)wy; |
| double num5 = (double)wy; |
| float num6 = DUtils.PerlinNoise(num4 * 0.019999999552965164 * 0.699999988079071, num5 * 0.019999999552965164 * 0.699999988079071) * DUtils.PerlinNoise(num4 * 0.03999999910593033 * 0.699999988079071, num5 * 0.03999999910593033 * 0.699999988079071); |
| float num6 = DUtils.PerlinNoise(num4 * 0.019999999552965164 * 0.699999988079071, num5 * 0.019999999552965164 * 0.699999988079071) * DUtils.PerlinNoise(num4 * 0.03999999910593033 * 0.699999988079071, num5 * 0.03999999910593033 * 0.699999988079071); |
| num6 = (float)((double)num6 + (double)DUtils.PerlinNoise(num4 * 0.029999999329447746 * 0.699999988079071, num5 * 0.029999999329447746 * 0.699999988079071) * (double)DUtils.PerlinNoise(num4 * 0.05000000074505806 * 0.699999988079071, num5 * 0.05000000074505806 * 0.699999988079071) * (double)num6 * 0.5); |
| num6 = (float)((double)num6 + (double)DUtils.PerlinNoise(num4 * 0.029999999329447746 * 0.699999988079071, num5 * 0.029999999329447746 * 0.699999988079071) * (double)DUtils.PerlinNoise(num4 * 0.05000000074505806 * 0.699999988079071, num5 * 0.05000000074505806 * 0.699999988079071) * (double)num6 * 0.5); |
| num6 = ((num6 > 0f) ? ((float)Math.Pow((double)num6, 1.5)) : num6); |
| num6 = ((num6 > 0f) ? ((float)Math.Pow((double)num6, 1.5)) : num6); |
| num3 = (float)((double)num3 + (double)num6 * 0.4000000059604645); |
| num3 = (float)((double)num3 + (double)num6 * 0.4000000059604645); |
| num3 = this.AddRivers(num, num2, num3); |
| num3 = this.AddRivers(num, num2, num3); |
| float num7 = (float)DUtils.Clamp01((double)num6 * 7.0); |
| float num7 = (float)DUtils.Clamp01((double)num6 * 7.0); |
| num3 = (float)((double)num3 + (double)DUtils.PerlinNoise(num4 * 0.10000000149011612, num5 * 0.10000000149011612) * 0.029999999329447746 * (double)num7); |
| num3 = (float)((double)num3 + (double)DUtils.PerlinNoise(num4 * 0.10000000149011612, num5 * 0.10000000149011612) * 0.029999999329447746 * (double)num7); |
| num3 = (float)((double)num3 + (double)DUtils.PerlinNoise(num4 * 0.4000000059604645, num5 * 0.4000000059604645) * 0.009999999776482582 * (double)num7); |
| num3 = (float)((double)num3 + (double)DUtils.PerlinNoise(num4 * 0.4000000059604645, num5 * 0.4000000059604645) * 0.009999999776482582 * (double)num7); |
| float num8 = (float)(1.0 - (double)num7 * 1.2000000476837158); |
| float num8 = (float)(1.0 - (double)num7 * 1.2000000476837158); |
| num8 = (float)((double)num8 - (1.0 - (double)DUtils.LerpStep(0.1f, 0.3f, num7))); |
| num8 = (float)((double)num8 - (1.0 - (double)DUtils.LerpStep(0.1f, 0.3f, num7))); |
| float num9 = (float)((double)num3 + (double)DUtils.PerlinNoise(num4 * 0.4000000059604645, num5 * 0.4000000059604645) * 0.0020000000949949026); |
| float num9 = (float)((double)num3 + (double)DUtils.PerlinNoise(num4 * 0.4000000059604645, num5 * 0.4000000059604645) * 0.0020000000949949026); |
| float num10 = num3; |
| float num10 = num3; |
| num10 = (float)((double)num10 * 400.0); |
| num10 = (float)((double)num10 * 400.0); |
| num10 = Mathf.Ceil(num10); |
| num10 = Mathf.Ceil(num10); |
| num10 = (float)((double)num10 / 400.0); |
| num10 = (float)((double)num10 / 400.0); |
| num3 = DUtils.Lerp(num9, num10, num7); |
| num3 = DUtils.Lerp(num9, num10, num7); |
| mask = new Color(0f, 0f, 0f, num8); |
| mask = new Color(0f, 0f, 0f, num8); |
| return num3; |
| return num3; |
| } |
| } |
| |
| |
| private float GetPlainsHeight(float wx, float wy) |
| private float GetPlainsHeight(float wx, float wy) |
| { |
| { |
| float num = wx; |
| float num = wx; |
| float num2 = wy; |
| float num2 = wy; |
| float baseHeight = this.GetBaseHeight(wx, wy, false); |
| float baseHeight = this.GetBaseHeight(wx, wy, false); |
| wx = (float)((double)wx + 100000.0 + (double)this.m_offset3); |
| wx = (float)((double)wx + 100000.0 + (double)this.m_offset3); |
| wy = (float)((double)wy + 100000.0 + (double)this.m_offset3); |
| wy = (float)((double)wy + 100000.0 + (double)this.m_offset3); |
| double num3 = (double)wx; |
| double num3 = (double)wx; |
| double num4 = (double)wy; |
| double num4 = (double)wy; |
| float num5 = (float)((double)DUtils.PerlinNoise(num3 * 0.009999999776482582, num4 * 0.009999999776482582) * (double)DUtils.PerlinNoise(num3 * 0.019999999552965164, num4 * 0.019999999552965164)); |
| float num5 = (float)((double)DUtils.PerlinNoise(num3 * 0.009999999776482582, num4 * 0.009999999776482582) * (double)DUtils.PerlinNoise(num3 * 0.019999999552965164, num4 * 0.019999999552965164)); |
| num5 = (float)((double)num5 + (double)DUtils.PerlinNoise(num3 * 0.05000000074505806, num4 * 0.05000000074505806) * (double)DUtils.PerlinNoise(num3 * 0.10000000149011612, num4 * 0.10000000149011612) * (double)num5 * 0.5); |
| num5 = (float)((double)num5 + (double)DUtils.PerlinNoise(num3 * 0.05000000074505806, num4 * 0.05000000074505806) * (double)DUtils.PerlinNoise(num3 * 0.10000000149011612, num4 * 0.10000000149011612) * (double)num5 * 0.5); |
| float num6 = baseHeight; |
| float num6 = baseHeight; |
| num6 = (float)((double)num6 + (double)num5 * 0.10000000149011612); |
| num6 = (float)((double)num6 + (double)num5 * 0.10000000149011612); |
| float num7 = 0.15f; |
| float num7 = 0.15f; |
| float num8 = num6 - num7; |
| float num8 = num6 - num7; |
| float num9 = (float)DUtils.Clamp01((double)baseHeight / 0.4000000059604645); |
| float num9 = (float)DUtils.Clamp01((double)baseHeight / 0.4000000059604645); |
| if (num8 > 0f) |
| if (num8 > 0f) |
| { |
| { |
| num6 = (float)((double)num6 - (double)num8 * (1.0 - (double)num9) * 0.75); |
| num6 = (float)((double)num6 - (double)num8 * (1.0 - (double)num9) * 0.75); |
| } |
| } |
| num6 = this.AddRivers(num, num2, num6); |
| num6 = this.AddRivers(num, num2, num6); |
| num6 = (float)((double)num6 + (double)DUtils.PerlinNoise(num3 * 0.10000000149011612, num4 * 0.10000000149011612) * 0.009999999776482582); |
| num6 = (float)((double)num6 + (double)DUtils.PerlinNoise(num3 * 0.10000000149011612, num4 * 0.10000000149011612) * 0.009999999776482582); |
| return (float)((double)num6 + (double)DUtils.PerlinNoise(num3 * 0.4000000059604645, num4 * 0.4000000059604645) * 0.003000000026077032); |
| return (float)((double)num6 + (double)DUtils.PerlinNoise(num3 * 0.4000000059604645, num4 * 0.4000000059604645) * 0.003000000026077032); |
| } |
| } |
| |
| |
| private float GetMenuHeight(float wx, float wy) |
| private float GetMenuHeight(float wx, float wy) |
| { |
| { |
| double baseHeight = (double)this.GetBaseHeight(wx, wy, true); |
| double baseHeight = (double)this.GetBaseHeight(wx, wy, true); |
| wx = (float)((double)wx + 100000.0 + (double)this.m_offset3); |
| wx = (float)((double)wx + 100000.0 + (double)this.m_offset3); |
| wy = (float)((double)wy + 100000.0 + (double)this.m_offset3); |
| wy = (float)((double)wy + 100000.0 + (double)this.m_offset3); |
| double num = (double)wx; |
| double num = (double)wx; |
| double num2 = (double)wy; |
| double num2 = (double)wy; |
| float num3 = DUtils.PerlinNoise(num * 0.009999999776482582, num2 * 0.009999999776482582) * DUtils.PerlinNoise(num * 0.019999999552965164, num2 * 0.019999999552965164); |
| float num3 = DUtils.PerlinNoise(num * 0.009999999776482582, num2 * 0.009999999776482582) * DUtils.PerlinNoise(num * 0.019999999552965164, num2 * 0.019999999552965164); |
| num3 = (float)((double)num3 + (double)DUtils.PerlinNoise(num * 0.05000000074505806, num2 * 0.05000000074505806) * (double)DUtils.PerlinNoise(num * 0.10000000149011612, num2 * 0.10000000149011612) * (double)num3 * 0.5); |
| num3 = (float)((double)num3 + (double)DUtils.PerlinNoise(num * 0.05000000074505806, num2 * 0.05000000074505806) * (double)DUtils.PerlinNoise(num * 0.10000000149011612, num2 * 0.10000000149011612) * (double)num3 * 0.5); |
| return (float)((double)((float)((double)((float)(baseHeight + (double)num3 * 0.10000000149011612)) + (double)DUtils.PerlinNoise(num * 0.10000000149011612, num2 * 0.10000000149011612) * 0.009999999776482582)) + (double)DUtils.PerlinNoise(num * 0.4000000059604645, num2 * 0.4000000059604645) * 0.003000000026077032); |
| return (float)((double)((float)((double)((float)(baseHeight + (double)num3 * 0.10000000149011612)) + (double)DUtils.PerlinNoise(num * 0.10000000149011612, num2 * 0.10000000149011612) * 0.009999999776482582)) + (double)DUtils.PerlinNoise(num * 0.4000000059604645, num2 * 0.4000000059604645) * 0.003000000026077032); |
| } |
| } |
| |
| |
| . | private float GetAshlandsHeight(float wx, float wy) |
| private float GetAshlandsHeightPregenerate(float wx, float wy) |
| { |
| { |
| float num = wx; |
| float num = wx; |
| float num2 = wy; |
| float num2 = wy; |
| float num3 = this.GetBaseHeight(wx, wy, false); |
| float num3 = this.GetBaseHeight(wx, wy, false); |
| wx = (float)((double)wx + 100000.0 + (double)this.m_offset3); |
| wx = (float)((double)wx + 100000.0 + (double)this.m_offset3); |
| wy = (float)((double)wy + 100000.0 + (double)this.m_offset3); |
| wy = (float)((double)wy + 100000.0 + (double)this.m_offset3); |
| double num4 = (double)wx; |
| double num4 = (double)wx; |
| double num5 = (double)wy; |
| double num5 = (double)wy; |
| float num6 = (float)((double)DUtils.PerlinNoise(num4 * 0.009999999776482582, num5 * 0.009999999776482582) * (double)DUtils.PerlinNoise(num4 * 0.019999999552965164, num5 * 0.019999999552965164)); |
| float num6 = (float)((double)DUtils.PerlinNoise(num4 * 0.009999999776482582, num5 * 0.009999999776482582) * (double)DUtils.PerlinNoise(num4 * 0.019999999552965164, num5 * 0.019999999552965164)); |
| num6 = (float)((double)num6 + (double)DUtils.PerlinNoise(num4 * 0.05000000074505806, num5 * 0.05000000074505806) * (double)DUtils.PerlinNoise(num4 * 0.10000000149011612, num5 * 0.10000000149011612) * (double)num6 * 0.5); |
| num6 = (float)((double)num6 + (double)DUtils.PerlinNoise(num4 * 0.05000000074505806, num5 * 0.05000000074505806) * (double)DUtils.PerlinNoise(num4 * 0.10000000149011612, num5 * 0.10000000149011612) * (double)num6 * 0.5); |
| num3 = (float)((double)num3 + (double)num6 * 0.10000000149011612); |
| num3 = (float)((double)num3 + (double)num6 * 0.10000000149011612); |
| num3 = (float)((double)num3 + 0.10000000149011612); |
| num3 = (float)((double)num3 + 0.10000000149011612); |
| num3 = (float)((double)num3 + (double)DUtils.PerlinNoise(num4 * 0.10000000149011612, num5 * 0.10000000149011612) * 0.009999999776482582); |
| num3 = (float)((double)num3 + (double)DUtils.PerlinNoise(num4 * 0.10000000149011612, num5 * 0.10000000149011612) * 0.009999999776482582); |
| num3 = (float)((double)num3 + (double)DUtils.PerlinNoise(num4 * 0.4000000059604645, num5 * 0.4000000059604645) * 0.003000000026077032); |
| num3 = (float)((double)num3 + (double)DUtils.PerlinNoise(num4 * 0.4000000059604645, num5 * 0.4000000059604645) * 0.003000000026077032); |
| return this.AddRivers(num, num2, num3); |
| return this.AddRivers(num, num2, num3); |
| } |
| } |
| |
| |
| . | |
| public float GetAshlandsHeight(float wx, float wy, out Color mask, bool cheap = false) |
| |
| { |
| |
| double num = (double)wx; |
| |
| double num2 = (double)wy; |
| |
| double num3 = (double)this.GetBaseHeight((float)num, (float)num2, false); |
| |
| double num4 = (double)WorldGenerator.WorldAngle((float)num, (float)num2) * 100.0; |
| |
| double num5 = DUtils.Length(num, num2 + (double)WorldGenerator.ashlandsYOffset - (double)WorldGenerator.ashlandsYOffset * 0.3) - ((double)WorldGenerator.ashlandsMinDistance + num4); |
| |
| num5 = Math.Abs(num5) / 1000.0; |
| |
| num5 = 1.0 - DUtils.Clamp01(num5); |
| |
| num5 = DUtils.MathfLikeSmoothStep(0.1, 1.0, num5); |
| |
| double num6 = Math.Abs(num); |
| |
| num6 = 1.0 - DUtils.Clamp01(num6 / 7500.0); |
| |
| num5 *= num6; |
| |
| double num7 = DUtils.Length(num, num2) - 10150.0; |
| |
| num7 = 1.0 - DUtils.Clamp01(num7 / 600.0); |
| |
| num += (double)(100000f + this.m_offset3); |
| |
| num2 += (double)(100000f + this.m_offset3); |
| |
| double num8 = 0.0; |
| |
| double num9 = 1.0; |
| |
| double num10 = 0.33000001311302185; |
| |
| int num11 = (cheap ? 2 : 5); |
| |
| for (int i = 0; i < num11; i++) |
| |
| { |
| |
| num8 += num9 * DUtils.MathfLikeSmoothStep(0.0, 1.0, WorldGenerator.m_noiseGen.GetCellular(num * num10, num2 * num10)); |
| |
| num10 *= 2.0; |
| |
| num9 *= 0.5; |
| |
| } |
| |
| num8 = DUtils.Remap(num8, -1.0, 1.0, 0.0, 1.0); |
| |
| double num12 = DUtils.Lerp(num5, DUtils.BlendOverlay(num5, num8), 0.5); |
| |
| double num13 = (double)(DUtils.PerlinNoise(num * 0.009999999776482582, num2 * 0.009999999776482582) * DUtils.PerlinNoise(num * 0.019999999552965164, num2 * 0.019999999552965164)); |
| |
| num13 += (double)(DUtils.PerlinNoise(num * 0.05000000074505806, num2 * 0.05000000074505806) * DUtils.PerlinNoise(num * 0.10000000149011612, num2 * 0.10000000149011612)) * num13 * 0.5; |
| |
| double num14 = DUtils.Lerp(num3, 0.15000000596046448, 0.75); |
| |
| num14 += num12 * 0.5; |
| |
| num14 = DUtils.Lerp(-1.0, num14, DUtils.MathfLikeSmoothStep(0.0, 1.0, num7)); |
| |
| double num15 = 0.15; |
| |
| double num16 = 0.0; |
| |
| double num17 = 1.0; |
| |
| double num18 = 8.0; |
| |
| int num19 = (cheap ? 2 : 3); |
| |
| for (int j = 0; j < num19; j++) |
| |
| { |
| |
| num16 += num17 * WorldGenerator.m_noiseGen.GetCellular(num * num18, num2 * num18); |
| |
| num18 *= 2.0; |
| |
| num17 *= 0.5; |
| |
| } |
| |
| num16 = DUtils.Remap(num16, -1.0, 1.0, 0.0, 1.0); |
| |
| num16 = DUtils.Clamp01(Math.Pow(num16, 4.0) * 2.0); |
| |
| double num20 = WorldGenerator.m_noiseGen.GetSimplexFractal(num * 0.075, num2 * 0.075); |
| |
| num20 = DUtils.Remap(num20, -1.0, 1.0, 0.0, 1.0); |
| |
| num20 = Math.Pow(num20, 1.399999976158142); |
| |
| num14 *= num20; |
| |
| double num21 = DUtils.Fbm(new Vector2((float)(num * 0.009999999776482582), (float)(num2 * 0.009999999776482582)), 3, 2.0, 0.5); |
| |
| num21 *= DUtils.Clamp01(DUtils.Remap(num5, 0.0, 0.5, 0.5, 1.0)); |
| |
| num21 = DUtils.LerpStep(0.699999988079071, 1.0, num21); |
| |
| num21 = Math.Pow(num21, 2.0); |
| |
| double num22 = DUtils.BlendOverlay(num21, num16); |
| |
| num22 *= DUtils.Clamp01((num14 - num15 - 0.02) / 0.01); |
| |
| double num23 = (double)DUtils.PerlinNoise(num * 0.05 + 5124.0, num2 * 0.05 + 5000.0); |
| |
| num23 = Math.Pow(num23, 2.0); |
| |
| num23 = DUtils.Remap(num23, 0.0, 1.0, 0.009999999776482582, 0.054999999701976776); |
| |
| double num24 = (double)Mathf.Clamp((float)(num14 - num23), (float)(num15 + 0.009999999776482582), 5000f); |
| |
| num14 = DUtils.Lerp(num14, num24, num22); |
| |
| mask = new Color(0f, 0f, 0f, (float)num22); |
| |
| return (float)num14; |
| |
| } |
| |
| |
| private float GetEdgeHeight(float wx, float wy) |
| private float GetEdgeHeight(float wx, float wy) |
| { |
| { |
| . | float magnitude = new Vector2(wx, wy).magnitude; |
| float num = DUtils.Length(wx, wy); |
| float num = 10490f; |
| float num2 = 10490f; |
| if (magnitude > num) |
| if (num > num2) |
| { |
| { |
| float num2 = DUtils.LerpStep(num, 10500f, magnitude); |
| float num3 = DUtils.LerpStep(num2, 10500f, num); |
| return (float)(-2.0 * (double)num2); |
| return (float)(-2.0 * (double)num3); |
| } |
| } |
| float num3 = DUtils.LerpStep(10000f, 10100f, magnitude); |
| float num4 = DUtils.LerpStep(10000f, 10100f, num); |
| float num4 = this.GetBaseHeight(wx, wy, false); |
| float num5 = this.GetBaseHeight(wx, wy, false); |
| num4 = DUtils.Lerp(num4, 0f, num3); |
| num5 = DUtils.Lerp(num5, 0f, num4); |
| return this.AddRivers(wx, wy, num4); |
| return this.AddRivers(wx, wy, num5); |
| } |
| } |
| |
| |
| private float GetOceanHeight(float wx, float wy) |
| private float GetOceanHeight(float wx, float wy) |
| { |
| { |
| return this.GetBaseHeight(wx, wy, false); |
| return this.GetBaseHeight(wx, wy, false); |
| } |
| } |
| |
| |
| private float BaseHeightTilt(float wx, float wy) |
| private float BaseHeightTilt(float wx, float wy) |
| { |
| { |
| float baseHeight = this.GetBaseHeight((float)((double)wx - 1.0), wy, false); |
| float baseHeight = this.GetBaseHeight((float)((double)wx - 1.0), wy, false); |
| double baseHeight2 = (double)this.GetBaseHeight((float)((double)wx + 1.0), wy, false); |
| double baseHeight2 = (double)this.GetBaseHeight((float)((double)wx + 1.0), wy, false); |
| float baseHeight3 = this.GetBaseHeight(wx, (float)((double)wy - 1.0), false); |
| float baseHeight3 = this.GetBaseHeight(wx, (float)((double)wy - 1.0), false); |
| float baseHeight4 = this.GetBaseHeight(wx, (float)((double)wy + 1.0), false); |
| float baseHeight4 = this.GetBaseHeight(wx, (float)((double)wy + 1.0), false); |
| return (float)((double)Mathf.Abs((float)(baseHeight2 - (double)baseHeight)) + (double)Mathf.Abs((float)((double)baseHeight3 - (double)baseHeight4))); |
| return (float)((double)Mathf.Abs((float)(baseHeight2 - (double)baseHeight)) + (double)Mathf.Abs((float)((double)baseHeight3 - (double)baseHeight4))); |
| } |
| } |
| |
| |
| private float GetSnowMountainHeight(float wx, float wy, bool menu) |
| private float GetSnowMountainHeight(float wx, float wy, bool menu) |
| { |
| { |
| float num = wx; |
| float num = wx; |
| float num2 = wy; |
| float num2 = wy; |
| float num3 = this.GetBaseHeight(wx, wy, menu); |
| float num3 = this.GetBaseHeight(wx, wy, menu); |
| float num4 = this.BaseHeightTilt(wx, wy); |
| float num4 = this.BaseHeightTilt(wx, wy); |
| wx = (float)((double)wx + 100000.0 + (double)this.m_offset3); |
| wx = (float)((double)wx + 100000.0 + (double)this.m_offset3); |
| wy = (float)((double)wy + 100000.0 + (double)this.m_offset3); |
| wy = (float)((double)wy + 100000.0 + (double)this.m_offset3); |
| double num5 = (double)wx; |
| double num5 = (double)wx; |
| double num6 = (double)wy; |
| double num6 = (double)wy; |
| float num7 = (float)((double)num3 - 0.4000000059604645); |
| float num7 = (float)((double)num3 - 0.4000000059604645); |
| num3 = (float)((double)num3 + (double)num7); |
| num3 = (float)((double)num3 + (double)num7); |
| float num8 = (float)((double)DUtils.PerlinNoise(num5 * 0.009999999776482582, num6 * 0.009999999776482582) * (double)DUtils.PerlinNoise(num5 * 0.019999999552965164, num6 * 0.019999999552965164)); |
| float num8 = (float)((double)DUtils.PerlinNoise(num5 * 0.009999999776482582, num6 * 0.009999999776482582) * (double)DUtils.PerlinNoise(num5 * 0.019999999552965164, num6 * 0.019999999552965164)); |
| num8 = (float)((double)num8 + (double)DUtils.PerlinNoise(num5 * 0.05000000074505806, num6 * 0.05000000074505806) * (double)DUtils.PerlinNoise(num5 * 0.10000000149011612, num6 * 0.10000000149011612) * (double)num8 * 0.5); |
| num8 = (float)((double)num8 + (double)DUtils.PerlinNoise(num5 * 0.05000000074505806, num6 * 0.05000000074505806) * (double)DUtils.PerlinNoise(num5 * 0.10000000149011612, num6 * 0.10000000149011612) * (double)num8 * 0.5); |
| num3 = (float)((double)num3 + (double)num8 * 0.20000000298023224); |
| num3 = (float)((double)num3 + (double)num8 * 0.20000000298023224); |
| num3 = this.AddRivers(num, num2, num3); |
| num3 = this.AddRivers(num, num2, num3); |
| num3 = (float)((double)num3 + (double)DUtils.PerlinNoise(num5 * 0.10000000149011612, num6 * 0.10000000149011612) * 0.009999999776482582); |
| num3 = (float)((double)num3 + (double)DUtils.PerlinNoise(num5 * 0.10000000149011612, num6 * 0.10000000149011612) * 0.009999999776482582); |
| num3 = (float)((double)num3 + (double)DUtils.PerlinNoise(num5 * 0.4000000059604645, num6 * 0.4000000059604645) * 0.003000000026077032); |
| num3 = (float)((double)num3 + (double)DUtils.PerlinNoise(num5 * 0.4000000059604645, num6 * 0.4000000059604645) * 0.003000000026077032); |
| return (float)((double)num3 + (double)DUtils.PerlinNoise(num5 * 0.20000000298023224, num6 * 0.20000000298023224) * 2.0 * (double)num4); |
| return (float)((double)num3 + (double)DUtils.PerlinNoise(num5 * 0.20000000298023224, num6 * 0.20000000298023224) * 2.0 * (double)num4); |
| } |
| } |
| |
| |
| private float GetDeepNorthHeight(float wx, float wy) |
| private float GetDeepNorthHeight(float wx, float wy) |
| { |
| { |
| float num = wx; |
| float num = wx; |
| float num2 = wy; |
| float num2 = wy; |
| float num3 = this.GetBaseHeight(wx, wy, false); |
| float num3 = this.GetBaseHeight(wx, wy, false); |
| wx = (float)((double)wx + 100000.0 + (double)this.m_offset3); |
| wx = (float)((double)wx + 100000.0 + (double)this.m_offset3); |
| wy = (float)((double)wy + 100000.0 + (double)this.m_offset3); |
| wy = (float)((double)wy + 100000.0 + (double)this.m_offset3); |
| double num4 = (double)wx; |
| double num4 = (double)wx; |
| double num5 = (double)wy; |
| double num5 = (double)wy; |
| float num6 = Mathf.Max(0f, (float)((double)num3 - 0.4000000059604645)); |
| float num6 = Mathf.Max(0f, (float)((double)num3 - 0.4000000059604645)); |
| num3 = (float)((double)num3 + (double)num6); |
| num3 = (float)((double)num3 + (double)num6); |
| float num7 = (float)((double)DUtils.PerlinNoise(num4 * 0.009999999776482582, num5 * 0.009999999776482582) * (double)DUtils.PerlinNoise(num4 * 0.019999999552965164, num5 * 0.019999999552965164)); |
| float num7 = (float)((double)DUtils.PerlinNoise(num4 * 0.009999999776482582, num5 * 0.009999999776482582) * (double)DUtils.PerlinNoise(num4 * 0.019999999552965164, num5 * 0.019999999552965164)); |
| num7 = (float)((double)num7 + (double)DUtils.PerlinNoise(num4 * 0.05000000074505806, num5 * 0.05000000074505806) * (double)DUtils.PerlinNoise(num4 * 0.10000000149011612, num5 * 0.10000000149011612) * (double)num7 * 0.5); |
| num7 = (float)((double)num7 + (double)DUtils.PerlinNoise(num4 * 0.05000000074505806, num5 * 0.05000000074505806) * (double)DUtils.PerlinNoise(num4 * 0.10000000149011612, num5 * 0.10000000149011612) * (double)num7 * 0.5); |
| num3 = (float)((double)num3 + (double)num7 * 0.20000000298023224); |
| num3 = (float)((double)num3 + (double)num7 * 0.20000000298023224); |
| num3 = (float)((double)num3 * 1.2000000476837158); |
| num3 = (float)((double)num3 * 1.2000000476837158); |
| num3 = this.AddRivers(num, num2, num3); |
| num3 = this.AddRivers(num, num2, num3); |
| num3 = (float)((double)num3 + (double)DUtils.PerlinNoise((double)(wx * 0.1f), (double)(wy * 0.1f)) * 0.009999999776482582); |
| num3 = (float)((double)num3 + (double)DUtils.PerlinNoise((double)(wx * 0.1f), (double)(wy * 0.1f)) * 0.009999999776482582); |
| return (float)((double)num3 + (double)DUtils.PerlinNoise((double)(wx * 0.4f), (double)(wy * 0.4f)) * 0.003000000026077032); |
| return (float)((double)num3 + (double)DUtils.PerlinNoise((double)(wx * 0.4f), (double)(wy * 0.4f)) * 0.003000000026077032); |
| } |
| } |
| |
| |
| . | |
| private double CreateAshlandsGap(float wx, float wy) |
| |
| { |
| |
| double num = (double)WorldGenerator.WorldAngle(wx, wy) * 100.0; |
| |
| double num2 = (double)DUtils.Length(wx, wy + WorldGenerator.ashlandsYOffset) - ((double)WorldGenerator.ashlandsMinDistance + num); |
| |
| num2 = DUtils.Clamp01(Math.Abs(num2) / 400.0); |
| |
| return DUtils.MathfLikeSmoothStep(0.0, 1.0, (double)((float)num2)); |
| |
| } |
| |
| |
| |
| private double CreateDeepNorthGap(float wx, float wy) |
| |
| { |
| |
| double num = (double)WorldGenerator.WorldAngle(wx, wy) * 100.0; |
| |
| double num2 = (double)DUtils.Length(wx, wy + 4000f) - (12000.0 + num); |
| |
| num2 = DUtils.Clamp01(Math.Abs(num2) / 400.0); |
| |
| return DUtils.MathfLikeSmoothStep(0.0, 1.0, (double)((float)num2)); |
| |
| } |
| |
| |
| public static bool InForest(Vector3 pos) |
| public static bool InForest(Vector3 pos) |
| { |
| { |
| return WorldGenerator.GetForestFactor(pos) < 1.15f; |
| return WorldGenerator.GetForestFactor(pos) < 1.15f; |
| } |
| } |
| |
| |
| public static float GetForestFactor(Vector3 pos) |
| public static float GetForestFactor(Vector3 pos) |
| { |
| { |
| float num = 0.4f; |
| float num = 0.4f; |
| return DUtils.Fbm(pos * 0.01f * num, 3, 1.6f, 0.7f); |
| return DUtils.Fbm(pos * 0.01f * num, 3, 1.6f, 0.7f); |
| } |
| } |
| |
| |
| public void GetTerrainDelta(Vector3 center, float radius, out float delta, out Vector3 slopeDirection) |
| public void GetTerrainDelta(Vector3 center, float radius, out float delta, out Vector3 slopeDirection) |
| { |
| { |
| int num = 10; |
| int num = 10; |
| float num2 = -999999f; |
| float num2 = -999999f; |
| float num3 = 999999f; |
| float num3 = 999999f; |
| Vector3 vector = center; |
| Vector3 vector = center; |
| Vector3 vector2 = center; |
| Vector3 vector2 = center; |
| for (int i = 0; i < num; i++) |
| for (int i = 0; i < num; i++) |
| { |
| { |
| Vector2 vector3 = UnityEngine.Random.insideUnitCircle * radius; |
| Vector2 vector3 = UnityEngine.Random.insideUnitCircle * radius; |
| Vector3 vector4 = center + new Vector3(vector3.x, 0f, vector3.y); |
| Vector3 vector4 = center + new Vector3(vector3.x, 0f, vector3.y); |
| float height = this.GetHeight(vector4.x, vector4.z); |
| float height = this.GetHeight(vector4.x, vector4.z); |
| if (height < num3) |
| if (height < num3) |
| { |
| { |
| num3 = height; |
| num3 = height; |
| vector2 = vector4; |
| vector2 = vector4; |
| } |
| } |
| if (height > num2) |
| if (height > num2) |
| { |
| { |
| num2 = height; |
| num2 = height; |
| vector = vector4; |
| vector = vector4; |
| } |
| } |
| } |
| } |
| delta = (float)((double)num2 - (double)num3); |
| delta = (float)((double)num2 - (double)num3); |
| slopeDirection = Vector3.Normalize(vector2 - vector); |
| slopeDirection = Vector3.Normalize(vector2 - vector); |
| } |
| } |
| |
| |
| public int GetSeed() |
| public int GetSeed() |
| { |
| { |
| return this.m_world.m_seed; |
| return this.m_world.m_seed; |
| } |
| } |
| |
| |
| public static float GetHeightMultiplier() |
| public static float GetHeightMultiplier() |
| { |
| { |
| return 200f; |
| return 200f; |
| } |
| } |
| |
| |
| private const float m_waterTreshold = 0.05f; |
| private const float m_waterTreshold = 0.05f; |
| |
| |
| . | private static WorldGenerator m_instance; |
| private static WorldGenerator m_instance = null; |
| |
| |
| private World m_world; |
| private World m_world; |
| |
| |
| private int m_version; |
| private int m_version; |
| |
| |
| private float m_offset0; |
| private float m_offset0; |
| |
| |
| private float m_offset1; |
| private float m_offset1; |
| |
| |
| private float m_offset2; |
| private float m_offset2; |
| |
| |
| private float m_offset3; |
| private float m_offset3; |
| |
| |
| private float m_offset4; |
| private float m_offset4; |
| |
| |
| private int m_riverSeed; |
| private int m_riverSeed; |
| |
| |
| private int m_streamSeed; |
| private int m_streamSeed; |
| |
| |
| private List<Vector2> m_lakes; |
| private List<Vector2> m_lakes; |
| |
| |
| private List<WorldGenerator.River> m_rivers = new List<WorldGenerator.River>(); |
| private List<WorldGenerator.River> m_rivers = new List<WorldGenerator.River>(); |
| |
| |
| private List<WorldGenerator.River> m_streams = new List<WorldGenerator.River>(); |
| private List<WorldGenerator.River> m_streams = new List<WorldGenerator.River>(); |
| |
| |
| private Dictionary<Vector2i, WorldGenerator.RiverPoint[]> m_riverPoints = new Dictionary<Vector2i, WorldGenerator.RiverPoint[]>(); |
| private Dictionary<Vector2i, WorldGenerator.RiverPoint[]> m_riverPoints = new Dictionary<Vector2i, WorldGenerator.RiverPoint[]>(); |
| |
| |
| private WorldGenerator.RiverPoint[] m_cachedRiverPoints; |
| private WorldGenerator.RiverPoint[] m_cachedRiverPoints; |
| |
| |
| private Vector2i m_cachedRiverGrid = new Vector2i(-999999, -999999); |
| private Vector2i m_cachedRiverGrid = new Vector2i(-999999, -999999); |
| |
| |
| private ReaderWriterLockSlim m_riverCacheLock = new ReaderWriterLockSlim(); |
| private ReaderWriterLockSlim m_riverCacheLock = new ReaderWriterLockSlim(); |
| |
| |
| private List<Heightmap.Biome> m_biomes = new List<Heightmap.Biome>(); |
| private List<Heightmap.Biome> m_biomes = new List<Heightmap.Biome>(); |
| |
| |
| . | private const float heightMultiplier = 200f; |
| private static FastNoise m_noiseGen; |
| |
| |
| |
| private const float c_HeightMultiplier = 200f; |
| |
| |
| private const float riverGridSize = 64f; |
| private const float riverGridSize = 64f; |
| |
| |
| private const float minRiverWidth = 60f; |
| private const float minRiverWidth = 60f; |
| |
| |
| private const float maxRiverWidth = 100f; |
| private const float maxRiverWidth = 100f; |
| |
| |
| private const float minRiverCurveWidth = 50f; |
| private const float minRiverCurveWidth = 50f; |
| |
| |
| private const float maxRiverCurveWidth = 80f; |
| private const float maxRiverCurveWidth = 80f; |
| |
| |
| private const float minRiverCurveWaveLength = 50f; |
| private const float minRiverCurveWaveLength = 50f; |
| |
| |
| private const float maxRiverCurveWaveLength = 70f; |
| private const float maxRiverCurveWaveLength = 70f; |
| |
| |
| private const int streams = 3000; |
| private const int streams = 3000; |
| |
| |
| private const float streamWidth = 20f; |
| private const float streamWidth = 20f; |
| |
| |
| private const float meadowsMaxDistance = 5000f; |
| private const float meadowsMaxDistance = 5000f; |
| |
| |
| private const float minDeepForestNoise = 0.4f; |
| private const float minDeepForestNoise = 0.4f; |
| |
| |
| private const float minDeepForestDistance = 600f; |
| private const float minDeepForestDistance = 600f; |
| |
| |
| private const float maxDeepForestDistance = 6000f; |
| private const float maxDeepForestDistance = 6000f; |
| |
| |
| private const float deepForestForestFactorMax = 0.9f; |
| private const float deepForestForestFactorMax = 0.9f; |
| |
| |
| private const float marshBiomeScale = 0.001f; |
| private const float marshBiomeScale = 0.001f; |
| |
| |
| private const float minMarshNoise = 0.6f; |
| private const float minMarshNoise = 0.6f; |
| |
| |
| private const float minMarshDistance = 2000f; |
| private const float minMarshDistance = 2000f; |
| |
| |
| private float maxMarshDistance = 6000f; |
| private float maxMarshDistance = 6000f; |
| |
| |
| private const float minMarshHeight = 0.05f; |
| private const float minMarshHeight = 0.05f; |
| |
| |
| private const float maxMarshHeight = 0.25f; |
| private const float maxMarshHeight = 0.25f; |
| |
| |
| private const float heathBiomeScale = 0.001f; |
| private const float heathBiomeScale = 0.001f; |
| |
| |
| private const float minHeathNoise = 0.4f; |
| private const float minHeathNoise = 0.4f; |
| |
| |
| private const float minHeathDistance = 3000f; |
| private const float minHeathDistance = 3000f; |
| |
| |
| private const float maxHeathDistance = 8000f; |
| private const float maxHeathDistance = 8000f; |
| |
| |
| private const float darklandBiomeScale = 0.001f; |
| private const float darklandBiomeScale = 0.001f; |
| |
| |
| private float minDarklandNoise = 0.4f; |
| private float minDarklandNoise = 0.4f; |
| |
| |
| private const float minDarklandDistance = 6000f; |
| private const float minDarklandDistance = 6000f; |
| |
| |
| private const float maxDarklandDistance = 10000f; |
| private const float maxDarklandDistance = 10000f; |
| |
| |
| private const float oceanBiomeScale = 0.0005f; |
| private const float oceanBiomeScale = 0.0005f; |
| |
| |
| private const float oceanBiomeMinNoise = 0.4f; |
| private const float oceanBiomeMinNoise = 0.4f; |
| |
| |
| private const float oceanBiomeMaxNoise = 0.6f; |
| private const float oceanBiomeMaxNoise = 0.6f; |
| |
| |
| private const float oceanBiomeMinDistance = 1000f; |
| private const float oceanBiomeMinDistance = 1000f; |
| |
| |
| private const float oceanBiomeMinDistanceBuffer = 256f; |
| private const float oceanBiomeMinDistanceBuffer = 256f; |
| |
| |
| private float m_minMountainDistance = 1000f; |
| private float m_minMountainDistance = 1000f; |
| |
| |
| private const float mountainBaseHeightMin = 0.4f; |
| private const float mountainBaseHeightMin = 0.4f; |
| |
| |
| private const float deepNorthMinDistance = 12000f; |
| private const float deepNorthMinDistance = 12000f; |
| |
| |
| private const float deepNorthYOffset = 4000f; |
| private const float deepNorthYOffset = 4000f; |
| |
| |
| . | private const float ashlandsMinDistance = 12000f; |
| public static readonly float ashlandsMinDistance = 12000f; |
| |
| |
| . | private const float ashlandsYOffset = -4000f; |
| public static readonly float ashlandsYOffset = -4000f; |
| |
| |
| public const float worldSize = 10000f; |
| public const float worldSize = 10000f; |
| |
| |
| public const float waterEdge = 10500f; |
| public const float waterEdge = 10500f; |
| |
| |
| public class River |
| public class River |
| { |
| { |
| public Vector2 p0; |
| public Vector2 p0; |
| |
| |
| public Vector2 p1; |
| public Vector2 p1; |
| |
| |
| public Vector2 center; |
| public Vector2 center; |
| |
| |
| public float widthMin; |
| public float widthMin; |
| |
| |
| public float widthMax; |
| public float widthMax; |
| |
| |
| public float curveWidth; |
| public float curveWidth; |
| |
| |
| public float curveWavelength; |
| public float curveWavelength; |
| } |
| } |
| |
| |
| public struct RiverPoint |
| public struct RiverPoint |
| { |
| { |
| public RiverPoint(Vector2 p_p, float p_w) |
| public RiverPoint(Vector2 p_p, float p_w) |
| { |
| { |
| this.p = p_p; |
| this.p = p_p; |
| this.w = p_w; |
| this.w = p_w; |
| this.w2 = (float)((double)p_w * (double)p_w); |
| this.w2 = (float)((double)p_w * (double)p_w); |
| } |
| } |
| |
| |
| public Vector2 p; |
| public Vector2 p; |
| |
| |
| public float w; |
| public float w; |
| |
| |
| public float w2; |
| public float w2; |
| } |
| } |
| } |
| } |
| |
| |