private void ConstructMountainArea(WorldGenerator worldGenerator, IntRect area) { ALandLayerGenerator altitudeLandLayerGenerator = worldGenerator.Generators["altitude"]; ALandLayerGenerator groundLandLayerGenerator = worldGenerator.Generators["ground"]; this.mountainArea = new int[area.Height + 4, area.Width + 4]; for (int i = -2; i < area.Height + 2; i++) { for (int j = -2; j < area.Width + 2; j++) { int altitude = altitudeLandLayerGenerator.GetComputedPowerAt(j, i); int power = groundLandLayerGenerator.GetComputedPowerAt(j, i); int currentValue = -1; int mountainType = (int)this.GetMountainTypeFromPower(power); if (altitude > 22) { currentValue = -1; } else if (altitude > 18) { if (mountainType == 0) { currentValue = 1; } else { currentValue = mountainType; } } else if (altitude > 8) { currentValue = mountainType; } else if (altitude > 6) { if (mountainType == 1) { currentValue = -1; } else { currentValue = mountainType; } } else { currentValue = -1; } this.mountainArea[i + 2, j + 2] = currentValue; } } for (int i = 0; i < area.Height + 2; i++) { for (int j = 0; j < area.Width + 2; j++) { this.powerArea[i + 1, j + 1] = LandCreationHelper.NeedToFillLandAt(this.mountainArea, area, i - 1, j - 1); //this.powerArea[i + 1, j + 1] = this.NeedToFillMountainAt(area, i - 1, j - 1); } } }
public override int GenerateLandLayer(WorldGenerator worldGenerator, ILandChunk landChunk, IntRect area, int seed, int minAltitude, int maxAltitude) { ALandLayerGenerator altitudeLandLayerGenerator = worldGenerator.Generators["altitude"]; ALandLayerGenerator cliffLandLayerGenerator = worldGenerator.Generators["cliff"]; bool[,] subArea = new bool[3, 3]; bool isThereMountain = false; this.ConstructMountainArea(worldGenerator, area); for (int i = 0; i < area.Height; i++) { for (int j = 0; j < area.Width; j++) { int altitude = altitudeLandLayerGenerator.GetComputedPowerAt(j, i); int altitudeOffset = cliffLandLayerGenerator.GetComputedPowerAt(j, i); if ((altitude > 6 || (altitude == 6 && altitudeOffset > 0)) && altitude < 23) { LandCreationHelper.GetComputedLandType(this, area, i, j, out int mountainTypeInt, out int secondTypeInt, out LandTransition landTransition, out LandTransition secondLandTransition); //this.GetComputedLandType(area, i, j, out MountainType mountainType, out MountainType secondType, out LandTransition landTransition, out LandTransition secondLandTransition); MountainType mountainType = (MountainType)mountainTypeInt; MountainType secondType = (MountainType)secondTypeInt; MountainLandObject groundLandObject = null; MountainLandObject secondGroundLandObject = null; if (mountainType != MountainType.NONE) { groundLandObject = new MountainLandObject(area.Left + j, area.Top + i, altitude, mountainType); groundLandObject.SetTransition(landTransition); isThereMountain = true; } if (secondType != mountainType && secondType != MountainType.NONE) { secondGroundLandObject = new MountainLandObject(area.Left + j, area.Top + i, 0, secondType); secondGroundLandObject.SetTransition(secondLandTransition); isThereMountain = true; } bool onlyGround = altitude == 22 && altitudeOffset > 0; AssignGround(landChunk, i, j, altitude, altitudeOffset, groundLandObject, secondGroundLandObject, onlyGround); } } } if (isThereMountain) { landChunk.AddTypeInChunk(typeof(MountainLandObject)); } return(seed); }