private void DecorateCircle(Circle circle) { if (circle.decorated) { return; } var under = new Rectangle(circle.position.X - circle.radius - 1, circle.position.Y + 18, circle.radius * 2 + 2, circle.radius - 12); if (circle.radius > 22 && !CheckForTunnel(under)) //no tunnels under this circle { WorldGen.PlaceTile(circle.position.X - 15, circle.position.Y - 15, TileType <Tiles.Permafrost.VFX.CaveVFX>()); //aurora VFX actor Helper.PlaceMultitile(circle.position - new Point16(8, 0), TileType <BigTree>()); //tree for (int x = -4; x <= 4; x++) //island under the tree { for (int y = 0; y < 2; y++) { WorldGen.PlaceTile(circle.position.X + x, circle.position.Y + 17 + y, TileType <PermafrostSnow>()); } } FloodRectangle(under); //water under the tree for (int x = -circle.radius; x <= circle.radius; x++) //layer of ice over the water { WorldGen.PlaceTile(circle.position.X + x, circle.position.Y + 17, TileType <PhotoreactiveIce>()); } } }
private void PlaceTeleporter(Point16 pos, Point16 target) { Helper.PlaceMultitile(pos, TileType <PermafrostTeleporter>()); TileEntity.PlaceEntityNet(pos.X, pos.Y, TileEntityType <PermafrostTeleporterEntity>()); var entity = TileEntity.ByPosition[pos] as PermafrostTeleporterEntity; entity.target = target.ToVector2() * 16; }
private void ForestHerbGen(GenerationProgress progress) { progress.Message = "Planting ivy..."; for (int k = 60; k < Main.maxTilesX - 60; k++) { if (Main.rand.Next(8) == 0 && k > Main.maxTilesX / 3 && k < Main.maxTilesX / 3 * 2) //Berry Bushes { for (int y = 10; y < Main.worldSurface; y++) { if (Main.tile[k, y].type == TileID.Grass && Helper.CheckAirRectangle(new Point16(k, y - 2), new Point16(2, 2))) { Helper.PlaceMultitile(new Point16(k, y - 2), ModContent.TileType <Tiles.Herbology.ForestBerryBush>()); } } } /*else if(Main.rand.Next(30) == 0) //Ivy Patches * { * int size = Main.rand.Next(7, 20); * * for (int x = k - (int)(size / 2); x < k + (int)(size / 2); x++) * { * for (int y = 10; y < Main.worldSurface; y++) * { * if (Main.tile[x, y].type == TileID.Grass && Main.tile[x, y - 1].collisionType != 1 && Main.tile[x, y].slope() == 0) * { * WorldGen.PlaceTile(x, y - 1, ModContent.TileType<Tiles.Herbology.ForestIvyWild>()); * } * } * } * //k += size * 2; * }*/ for (int j = 15; j < Main.worldSurface; j++) { if (Main.rand.Next(500) == 0) //a check for grass could also be here which would speed up this step { int size = Main.rand.Next(3, 10); for (int x = k - (int)(size / 2); x < k + (int)(size / 2); x++) { for (int y = j - (int)(size / 2); y < j + (int)(size / 2); y++) { if (Main.tile[x, y].active() && Main.tile[x, y].type == TileID.Grass && Main.tile[x, y - 1].collisionType != 1 && Main.tile[x, y].slope() == 0) //!Main.tileSolid[Main.tile[x, y - 1].type] may be redundant { WorldGen.PlaceTile(x, y - 1, ModContent.TileType <Tiles.Herbology.ForestIvyWild>()); //WorldGen.PlaceTile((int)x, y - 2, TileID.RubyGemspark, true, true); break; } } } } } } }
private void ForestHerbGen(GenerationProgress progress) { progress.Message = "Planting the forest..."; for (int k = 60; k < Main.maxTilesX - 60; k++) { if (k > Main.maxTilesX / 3 && k < Main.maxTilesX / 3 * 2) //inner part of the world { if (k % 50 == 0 && WorldGen.genRand.Next(3) == 0) //Starlight groves { int max = WorldGen.genRand.Next(30, 50); for (int x = 0; x < max; x++) { bool shouldPlace = (x <5 || x> max - 5) ? WorldGen.genRand.NextBool() : true; if (shouldPlace) { for (int y = 10; y < Main.worldSurface; y++) { if (Main.tile[k + x, y].type == TileID.Grass) { WorldGen.PlaceTile(k + x, y, TileType <Tiles.Forest.Sod>(), true, true); } } } } k += max + 5; } if (WorldGen.genRand.Next(16) == 0) //Berry Bushes { for (int y = 10; y < Main.worldSurface; y++) { if (Main.tile[k, y].type == TileID.Grass && Main.tile[k + 1, y].type == TileID.Grass && Helper.CheckAirRectangle(new Point16(k, y - 2), new Point16(2, 2))) { Helper.PlaceMultitile(new Point16(k, y - 2), TileType <Tiles.Herbology.ForestBerryBush>()); k += 3; } } } else if (WorldGen.genRand.Next(50) == 0) //Palestone { for (int y = 10; y < Main.worldSurface; y++) { bool canPlace = true; for (int w = -2; w < 2; ++w) //Scans are for valid placement (fixed some really bizzare placement issues) { if (Main.tile[k, y].type != TileID.Grass || !Main.tile[k, y].active()) { canPlace = false; break; } } if (canPlace) { PalestoneChunk(k, y); //Place chunk break; } } k += 15; } } for (int j = 15; j < Main.worldSurface; j++) //ivy { if (WorldGen.genRand.Next(500) == 0) //a check for grass could also be here which would speed up this step { int size = WorldGen.genRand.Next(6, 15); for (int x = k - size / 2; x < k + size / 2; x++) { for (int y = j - size / 2; y < j + size / 2; y++) { if (Main.tile[x, y].active() && Main.tile[x, y].type == TileID.Grass && Main.tile[x, y - 1].collisionType != 1 && Main.tile[x, y].slope() == 0) //!Main.tileSolid[Main.tile[x, y - 1].type] may be redundant { WorldGen.PlaceTile(x, y - 1, TileType <Tiles.Herbology.ForestIvyWild>()); break; } } } } } if (WorldGen.genRand.Next(30) == 0 && AnyGrass(k)) { int size = WorldGen.genRand.Next(10, 15); for (int x = 0; x < size; x++) { int surface = 0; for (int j = 50; j < Main.worldSurface; j++) //Wall Bushes { if (Main.tile[k + x, j].wall != 0 && Main.tile[k, j].wall != WallType <Tiles.Forest.LeafWall>()) { surface = j; break; } } int xOff = x > size / 2 ? size - x : x; for (int y = surface - (xOff / 2 + WorldGen.genRand.Next(2)) - 3; true; y++) { WorldGen.PlaceWall(k + x, y, WallType <Tiles.Forest.LeafWall>()); if (y - surface > 20 || !WorldGen.InWorld(k + x, y + 1) || Main.tile[k + x, y + 1].wall != 0) { break; } } } } } }
/// <summary>Generates a large island at X/Y.</summary> /// <param name="x">X position.</param> /// <param name="y">Y position.</param> private static void CreateIsland(int x, int y, bool small = false) { int wid = genRand.Next(32, 42); if (small) { wid = genRand.Next(10, 18); } int top = 5; int depth = 2; bool peak = false; int peakEnd = 0; int peakStart = 0; int offset = 0; for (int i = x - (int)(wid / 2f); i < x + (wid / 2f); ++i) { if (i == x - (int)(wid / 2f) + 1) { top++; } else if (i == (x + (int)(wid / 2f)) - 1) { top--; } if (!peak) { if (depth <= 2) { depth += genRand.Next(2); } else { depth += genRand.Next(-1, 2); } if (genRand.Next(3) == 0) { peak = true; peakStart = i; peakEnd = i + genRand.Next(3, 8); if (peakEnd > (x + (wid / 2f)) - 1) { peakEnd = (int)(x + (wid / 2f)) - 1; } } } else { int dist = peakEnd - i; int dif = peakEnd - peakStart; int deep = (7 - dif); if (dist > (int)(dif / 2f)) { depth += genRand.Next(deep, deep + 2); } else { depth -= genRand.Next(deep, deep + 2); } if (x >= peakEnd) { peak = false; } } if (i % 4 == 0) { if (i < x) { top += genRand.Next(2); } else { top -= genRand.Next(2); } } if (i % 8 == 2) { offset += genRand.Next(-1, 2); } if (top < 3) { top = 3; } if (i > x + (wid / 2f) - 4 && depth > 4) { depth--; } if (i > x + (wid / 2f) - 4 && depth > 8) { depth--; } for (int j = y - top + offset; j < y + depth + offset; j++) { int t = j > (y + depth + offset) - 4 ? TileType <VitricSand>() : TileType <VitricSoftSand>(); PlaceTile(i, j, t, false, true); } } //Place crystal if needed if (crystalsPlaced <= (VitricBiome.Width / 240) + 2 && !small) { int tries = 0; while (true) { int cX = x + genRand.Next((int)(wid * -0.60f), (int)(wid * 0.60f)) - 3; int cY = y - 5; while (Main.tile[cX, cY].active()) { cY--; } cY = Math.Max( FindType(cX, cY, -1, ValidGround), FindType(cX + 1, cY, -1, ValidGround) ); if (ValidGround.Any(v => v == Main.tile[cX + 1, cY].type) && ValidGround.Any(v => v == Main.tile[cX + 2, cY].type) && ScanRectangle(cX, cY - 6, 4, 6) < 3) { StructureHelper.StructureHelper.GenerateStructure( "Structures/Vitric/VitricSmallCrystal_" + genRand.Next(2), new Point16(cX, cY - 6), StarlightRiver.Instance ); crystalsPlaced++; break; } else if (tries++ >= 20) { break; } } } else if (small) { // Input variables int spawnAttempts = 30; int cX, cY; // Perform several checks while (spawnAttempts-- > 0) { cX = x + genRand.Next((int)(wid * -0.60f), (int)(wid * 0.60f)) - 3; cY = y - 5; cY = FindType(cX, cY, -1, ValidGround); // If the left side of the crystal isn't valid, // or if the right side is occupied, // skip. if (cY == -1) { continue; } // If there are solid tiles in the way, skip. if (ScanRectangle(cX, cY - 3, 2, 3) > 2) { continue; } // Success! Halve the spawnAttempts count so we don't spam crystals. PlaceTile(cX + 1, cY, Framing.GetTileSafely(cX, cY).type, true, true); Helper.PlaceMultitile(new Point16(cX, cY - 3), TileType <VitricOre>()); spawnAttempts /= 4; } } }