public override int GenerateLandLayer(WorldGenerator worldGenerator, ILandChunk landChunk, IntRect area, int seed, int minAltitude, int maxAltitude) { ALandLayerGenerator altitudeLandLayerGenerator = worldGenerator.Generators["altitude"]; bool[,] subArea = new bool[3, 3]; this.powerArea = new int[area.Height + 4, area.Width + 4]; for (int i = 0; i < area.Height; i++) { for (int j = 0; j < area.Width; j++) { int[,] subAreaInt = new int[3, 3]; int maxLocalAltitude = int.MinValue; maxLocalAltitude = this.GetComputedMatrix(altitudeLandLayerGenerator, i, j, ref subAreaInt); int diffAltitude = maxLocalAltitude - subAreaInt[1, 1]; this.powerArea[i + 2, j + 2] = diffAltitude; for (int offset = 0; offset < diffAltitude; offset++) { this.GetComputedLandType(area, ref subAreaInt, maxLocalAltitude, out LandTransition landTransition); if (landTransition != LandTransition.NONE) { AltitudeLandObject altitudeLandObject = new AltitudeLandObject(area.Left + j, area.Top + i, subAreaInt[1, 1], LandType.GRASS); landChunk.InitializeLandCase(i, j, subAreaInt[1, 1]); landChunk.GetLandCase(i, j, subAreaInt[1, 1]).LandWall = altitudeLandObject; altitudeLandObject.SetLandTransition(landTransition); } subAreaInt[1, 1]++; } } } landChunk.AddTypeInChunk(typeof(AltitudeLandObject)); return(seed); }
public override int GenerateLandLayer(WorldGenerator worldGenerator, ILandChunk landChunk, IntRect area, int seed, int minAltitude, int maxAltitude) { ALandLayerGenerator altitudeLandLayerGenerator = worldGenerator.Generators["altitude"]; bool isThereWater = false; this.ConstructAltitudeArea(worldGenerator, area); for (int i = 0; i < area.Height; i++) { for (int j = 0; j < area.Width; j++) { int altitude = this.powerArea[i + 1, j + 1]; int[,] subAreaInt = new int[3, 3]; int maxLocalAltitude = int.MinValue; maxLocalAltitude = this.GetComputedMatrix(i, j, ref subAreaInt); for (int z = altitude; z <= 0; z++) { this.GetComputedLandType(area, ref subAreaInt, maxLocalAltitude, out LandTransition landTransition); WaterLandObject waterLandObject = new WaterLandObject(area.Left + j, area.Top + i, z); waterLandObject.SetLandTransition(landTransition); landChunk.InitializeLandCase(i, j, z); landChunk.GetLandCase(i, j, z).LandWater = waterLandObject; isThereWater = true; subAreaInt[1, 1]++; } } } if (isThereWater) { landChunk.AddTypeInChunk(typeof(WaterLandObject)); } return(seed); }
protected static void AssignGround( ILandChunk landChunk, int i, int j, int altitude, int altitudeOffset, ILandObject mainLandObject, ILandObject secondLandObject, bool onlyGround = false) { if (mainLandObject != null || secondLandObject != null) { if (altitudeOffset == 0) { landChunk.InitializeLandCase(i, j, altitude); LandCase landCase = landChunk.GetLandCase(i, j, altitude); if (mainLandObject != null) { landCase.AddLandGround(mainLandObject); } if (secondLandObject != null) { landCase.AddLandGround(secondLandObject); } } else { for (int z = 0; z < altitudeOffset; z++) { landChunk.InitializeLandCase(i, j, altitude + z); LandCase landCase = landChunk.GetLandCase(i, j, altitude + z); //if (landCase == null) //{ // throw new Exception("if offset > 0, case must be already initialized thanks to CliffLayerGenerator !"); //} if (mainLandObject != null) { ILandObject cloneMainObject = mainLandObject.Clone(); cloneMainObject.Altitude = altitude + z; landCase.AddLandGround(cloneMainObject); } if (secondLandObject != null) { ILandObject cloneSecondObject = secondLandObject.Clone(); cloneSecondObject.Altitude = altitude + z; landCase.AddLandGround(cloneSecondObject); } if (onlyGround == false && landCase.LandWall != null) { if (mainLandObject != null) { ILandObject cloneMainObject = mainLandObject.Clone(landCase.LandWall.LandTransition); if (cloneMainObject != null) { cloneMainObject.Altitude = altitude + z; landCase.AddLandGroundOverWall(cloneMainObject); } } if (secondLandObject != null) { ILandObject cloneSecondObject = secondLandObject.Clone(landCase.LandWall.LandTransition); if (cloneSecondObject != null) { cloneSecondObject.Altitude = altitude + z; landCase.AddLandGroundOverWall(cloneSecondObject); } } } } } } }