internal override void GeneratePartial(IServerChunk[] chunks, int intoChunkX, int intoChunkZ, int fromChunkdX, int fromChunkdZ) { for (int i = 0; i < deposits.variants.Length; i++) { DepositVariant variant = deposits.variants[i]; float quantityFactor = 1; int originChunkX = intoChunkX + fromChunkdX; int originChunkZ = intoChunkZ + fromChunkdZ; if (variant.WithOreMap) { IMapRegion originMapRegion = api.WorldManager.GetMapRegion((originChunkX * chunksize) / regionSize, (originChunkZ * chunksize) / regionSize); if (originMapRegion == null) { continue; } int lx = (originChunkX * chunksize + chunksize / 2) % regionSize; int lz = (originChunkZ * chunksize + chunksize / 2) % regionSize; IntMap map = null; originMapRegion.OreMaps.TryGetValue(variant.Code, out map); if (map != null) { float posXInRegionOre = GameMath.Clamp((float)lx / regionSize * noiseSizeOre, 0, noiseSizeOre - 1); float posZInRegionOre = GameMath.Clamp((float)lz / regionSize * noiseSizeOre, 0, noiseSizeOre - 1); int oreDist = originMapRegion.OreMaps[variant.Code].GetUnpaddedColorLerped(posXInRegionOre, posZInRegionOre); quantityFactor = (oreDist & 0xff) / 255f; } } float qModified = variant.Quantity * quantityFactor; int quantity = (int)qModified; quantity += chunkRand.NextInt(100) < 100 * (qModified - quantity) ? 1 : 0; while (quantity-- > 0) { int offsetX = chunksize * fromChunkdX + chunkRand.NextInt(chunksize); int offsetZ = chunksize * fromChunkdZ + chunkRand.NextInt(chunksize); depositRand.SetWorldSeed(chunkRand.NextInt(10000000)); depositRand.InitPositionSeed(intoChunkX + fromChunkdX, intoChunkZ + fromChunkdZ); Dictionary <Vec3i, DepositVariant> SubDepositsToPlace = GenDeposit(chunks, intoChunkX, intoChunkZ, offsetX, offsetZ, variant); foreach (var val in SubDepositsToPlace) { depositRand.SetWorldSeed(chunkRand.NextInt(10000000)); depositRand.InitPositionSeed(intoChunkX + fromChunkdX, intoChunkZ + fromChunkdZ); GenDeposit(chunks, intoChunkX, intoChunkZ, val.Key.X, val.Key.Z, val.Value, val.Key.Y); } } } }
internal override void GeneratePartial(IServerChunk[] chunks, int chunkX, int chunkZ, int cdx, int cdz) { int quantityCaves = chunkRand.NextInt(81) / 60; while (quantityCaves-- > 0) { int posX = cdx * chunksize + chunkRand.NextInt(chunksize); int posY = chunkRand.NextInt(worldheight - 20) + 8; int posZ = cdz * chunksize + chunkRand.NextInt(chunksize); float horAngle = chunkRand.NextFloat() * GameMath.TWOPI; float vertAngle = (chunkRand.NextFloat() - 0.5f) * 0.25f; float horizontalSize = chunkRand.NextFloat() * 2 + chunkRand.NextFloat(); int maxIterations = chunkRange * chunksize - chunksize / 2; maxIterations = maxIterations - chunkRand.NextInt(maxIterations / 4); caveRand.SetWorldSeed(chunkRand.NextInt(10000000)); caveRand.InitPositionSeed(chunkX + cdx, chunkZ + cdz); CarveTunnel(chunks, chunkX, chunkZ, posX, posY, posZ, horAngle, vertAngle, horizontalSize, 1f, 0, maxIterations, 0); } }