public LandChunk GenerateLandChunk(IntRect area, int minAltitude, int maxAltitude) { LandChunk landChunk = new LandChunk(minAltitude, maxAltitude, area); int currentSeed = this.seed; currentSeed *= area.Left - area.Width * area.Width; foreach (ALandLayerGenerator generator in this.generatorsSortedList.Values) { currentSeed = generator.GenerateLandLayer(this, landChunk, area, currentSeed, minAltitude, maxAltitude); } return(landChunk); }
public void Run() { while (this.isRunning) { this.mainMutex.WaitOne(); IEnumerable <LandChunkContainer> containersToImport = this.pendingLandChunks.Values.ToList(); this.mainMutex.ReleaseMutex(); List <Tuple <LandChunkContainer, ILandChunk> > containerImported = new List <Tuple <LandChunkContainer, ILandChunk> >(); foreach (LandChunkContainer container in containersToImport) { // TODO: Add file importation this.worldGenerator.GenerateEpicenterChunk(container.Area); LandChunk landChunk = this.worldGenerator.GenerateLandChunk(container.Area, -ALTITUDE_RANGE, ALTITUDE_RANGE); containerImported.Add(new Tuple <LandChunkContainer, ILandChunk>(container, landChunk)); } this.NotifyLandChunkImported(containerImported); this.mainMutex.WaitOne(); foreach (LandChunkContainer container in containersToImport) { this.pendingLandChunks.Remove(container.Area); } this.mainMutex.ReleaseMutex(); Thread.Sleep(100); } }