public void LoadAdjacentSims(Vec3d pos) { int regSize = api.World.BlockAccessor.RegionSize; int hereRegX = (int)pos.X / regSize; int hereRegZ = (int)pos.Z / regSize; int topLeftRegX = (int)Math.Round(pos.X / regSize) - 1; int topLeftRegZ = (int)Math.Round(pos.Z / regSize) - 1; int i = 0; for (int dx = 0; dx <= 1; dx++) { for (int dz = 0; dz <= 1; dz++) { int regX = topLeftRegX + dx; int regZ = topLeftRegZ + dz; WeatherSimulationRegion weatherSim = ws.getOrCreateWeatherSimForRegion(regX, regZ); if (weatherSim == null) { weatherSim = ws.dummySim; } AdjacentSims[i++] = weatherSim; if (regX == hereRegX && regZ == hereRegZ) { hereMapRegion = weatherSim.MapRegion; } } } }
private void onThreadTick() { while (!isShuttingDown) { Thread.Sleep(5); int i = 0; while (chunkColsstoCheckQueue.Count > 0 && i++ < 10) { Vec2i chunkCoord; lock (chunkstoCheckQueueLock) { chunkCoord = chunkColsstoCheckQueue.Dequeue(); } int regionX = (chunkCoord.X * chunksize) / regionsize; int regionZ = (chunkCoord.Y * chunksize) / regionsize; WeatherSimulationRegion sim = ws.getOrCreateWeatherSimForRegion(regionX, regionZ); IServerMapChunk mc = sapi.WorldManager.GetMapChunk(chunkCoord.X, chunkCoord.Y); if (mc != null && sim != null) { UpdateSnowLayerOffThread(sim, mc, chunkCoord); } } } }
private void Event_ChunkColumnLoaded(Vec2i chunkCoord, IWorldChunk[] chunks) { if (!ProcessChunks) { return; } int regionX = (chunkCoord.X * chunksize) / regionsize; int regionZ = (chunkCoord.Y * chunksize) / regionsize; WeatherSimulationRegion simregion = ws.getOrCreateWeatherSimForRegion(regionX, regionZ); IServerMapChunk mc = sapi.WorldManager.GetMapChunk(chunkCoord.X, chunkCoord.Y); if (mc != null && simregion != null) { lock (chunkColsstoCheckQueue) { chunkColsstoCheckQueue.Enqueue(chunkCoord); } } }