public void BuildRain(RainMethod pm, Benchmark bench = null) { Benchmark.Start(bench, "Rain"); // etc if (pm == RainMethod.Equal) { BuildRainByEqual(); } else if (pm == RainMethod.Noise) { BuildRainByNoise(); } else if (pm == RainMethod.Wind) { WindSpawn ws = WindSpawn.TradeLinear; WindRainType rt = WindRainType.HeatBasedContinuous; WindEvaporationType et = WindEvaporationType.WaterAndHeat; WindTurnType wt = WindTurnType.TerrainBased; BuildRainByWind(1000, ws, rt, et, wt, bench); MapUtil.TransformMapMinMax(ref Rain, MapUtil.dNormalize); } if (bench != null) { bench.EndBenchmark("Rain"); } }
private void BuildRainByWindWorkhorse(ref List <Wind> winds, WindSpawn windSpawn, WindRainType rainType, WindEvaporationType evapType, WindTurnType windTurnType) { // Combine Winds at the same location CombineWinds(ref winds, windSpawn); // Add to WindFlow foreach (Wind w in winds) { WindVectorsList[w.approxMapLoc.x, w.approxMapLoc.y].Add(new Vec(w.velocity.x, w.velocity.y)); } // Move wind in the direction vector foreach (Wind w in winds) { w.Blow(Elevation, Temperature); } // If the wind moves off the map, remove it RemoveOffWindMaps(ref winds); // Rain foreach (Wind w in winds) { w.Rain(rainType, ref Rain, Elevation, seaLevel); } // Evaporate foreach (Wind w in winds) { w.Evaporate(evapType, Elevation, Temperature, seaLevel); } // Turn Wind foreach (Wind w in winds) { w.TurnWind(windTurnType, Elevation, seaLevel); } }
private void CombineWinds(ref List <Wind> winds, WindSpawn ws, bool addNewWinds = false) { List <Wind>[,] stackedWindsList = new List <Wind> [xDim, yDim]; for (int x = 0; x < xDim; x++) { for (int y = 0; y < yDim; y++) { stackedWindsList[x, y] = new List <Wind>(); } } foreach (Wind w in winds) { stackedWindsList[w.approxMapLoc.x, w.approxMapLoc.y].Add(w); } List <Wind> newWinds = new List <Wind>(); for (int x = 0; x < xDim; x++) { for (int y = 0; y < yDim; y++) { if (addNewWinds) { stackedWindsList[x, y].Add(new Wind(x, y, Elevation, ws)); } if (stackedWindsList[x, y].Count > 0) { newWinds.Add(CombineWindsAtMapLocation(stackedWindsList[x, y])); } } } winds = newWinds; }
private void BuildRainByWind(int maxIter, WindSpawn windSpawn, WindRainType rainType, WindEvaporationType evapType, WindTurnType windTurnType, Benchmark bench = null) { if (bench != null) { bench.StartBenchmark("Wind"); } List <Wind> winds = new List <Wind>(); for (int x = 0; x < xDim; x++) { for (int y = 0; y < yDim; y++) { WindVectorsList[x, y] = new List <Vec>(); Wind w = new Wind(x, y, Elevation, windSpawn); WindVectorsList[x, y].Add(new Vec(w.velocity.x, w.velocity.y)); winds.Add(w); } } int iter = 0; int numberOfWinds = winds.Count; while (iter < maxIter) { numberOfWinds = winds.Count; if (numberOfWinds == 0) { break; } else { BuildRainByWindWorkhorse(ref winds, windSpawn, rainType, evapType, windTurnType); } iter++; } MapUtil.TransformMap(ref Rain, MapUtil.dExponentiate, 0.125f); TabulateWindflow(); if (bench != null) { bench.EndBenchmark("Wind"); } }
public Wind(float _x, float _y, float[,] Elevation, WindSpawn ws) { Water = 0.1f; deltaHeight = 0f; deltaTemp = 0f; actualMapLoc = new Vec(_x, _y); approxMapLoc = new MapLoc((int)_x, (int)_y); WindOnMap = true; xDim = Elevation.GetLength(0); yDim = Elevation.GetLength(1); if (ws == WindSpawn.Easterly) { velocity = new Vec(1, 0); } else if (ws == WindSpawn.TradeSine) { velocity = TradeWindSine(); } else if (ws == WindSpawn.TradeLinear) { velocity = TradeWindLinear(); } }