private VolcanoBranch GenerateLavaInBranch(VolcanoBranch branch, int x) { for (int y = branch.currentPoint.Y - 2; y < branch.currentPoint.Y + 3; y++) { if (WorldGen.genRand.Next(4) == 0) { Main.tile[x, y].type = mod.TileID("SolarMineralObsidian"); } else { Main.tile[x, y].type = mod.TileID("SolarDirt"); } if (y == branch.currentPoint.Y && Main.tile[x, y].active()) { Main.tile[x, y].ClearTile(); Main.tile[x, y].lava(true); Main.tile[x, y].liquid = 255; if (WorldGen.genRand.NextFloat() >= 0.6f) { int yModifier = (branch.horizontal) ? 1 : -1; branch.originPoint.Y += (branch.horizontal) ? 1 : -1; branch.currentPoint.Y += yModifier; branch.currentPoint.X = x; branch.originPoint.X = x; Main.tile[x, y + yModifier].ClearTile(); Main.tile[x, y + yModifier].lava(true); Main.tile[x, y + yModifier].liquid = 255; } } } return(branch); }
public void GenerateBranch(VolcanoBranch branch) { ILog log = LogManager.GetLogger("Volcano Gen"); int lastX = branch.originPoint.X + ((branch.left) ? -branch.length : branch.length); if (branch.left) { for (int x = branch.originPoint.X; x > lastX; x--) { branch = GenerateLavaInBranch(branch, x); } } else { for (int x = branch.currentPoint.X; x < lastX; x++) { branch = GenerateLavaInBranch(branch, x); } } if (branch.currentStep < branch.maxStep) { bool horizontal = WorldGen.genRand.NextBool(); VolcanoBranch newerbranch = new VolcanoBranch(branch, WorldGen.genRand.Next(10, 15), horizontal); GenerateBranch(newerbranch); if (WorldGen.genRand.NextBool(5)) { newerbranch = new VolcanoBranch(branch, WorldGen.genRand.Next(10, 15), !horizontal); GenerateBranch(newerbranch); } } }
public VolcanoBranch(VolcanoBranch previousBranch, int length, bool horizontal) { this.length = length; this.horizontal = horizontal; this.currentPoint = previousBranch.currentPoint; this.originPoint = currentPoint; this.maxStep = previousBranch.maxStep; this.currentStep = previousBranch.currentStep++; this.currentStep += 1; this.left = previousBranch.left; this.loop = previousBranch.loop++; this.loop += 1; }