private void GrowVertically(int i, int j, Tile tile) { Tile above = Main.tile[i, j - 1]; if (tile.frameX < 3 * frameSize) // If we're on the body of the stalk... { if (above.type == Type) { TileLoader.RandomUpdate(i, j - 1, Type); } else if (Main.rand.NextBool(10) || TileExtensions.AnyTilesIn(i, i, j - 7, j - 1)) // Top the stalk if there's a roof or after a random age { above.frameX = (short)(Main.rand.Next(3, 6) * frameSize); above.frameY = 4 * frameSize; } else // Otherwise, continue stalk. { above.frameX = (short)(Main.rand.Next(0, 3) * frameSize); above.frameY = (short)(Main.rand.Next(0, 4) * frameSize); } above.type = Type; } else if (tile.frameY > 0) // Otherwise, we're at the top. Decrease frameY til we're { above.type = Type; above.frameX = tile.frameX; above.frameY = (short)(tile.frameY - frameSize); } above.active(true); if (Main.netMode != NetmodeID.SinglePlayer) { NetMessage.SendTileSquare(-1, i, j - 1, 1); } }
private static void InfectArea(GenerationProgress progress) { var area = BiomeManager.Get <Epicenter>().Area; var widthL = SurfaceWidth / 2f; // The left side of the biome's width. var widthR = SurfaceWidth / 2f; // The right side of the biome's width. var j = area.Top; // The current iterator. We iterate from top to bottom via rows. // Just a shortcut function :P void InfectRow() { for (int i = area.Center.X - (int)widthL; i < area.Center.X + (int)widthR; i++) { TileExtensions.Infect(i, j); } } float GetJPercent() => (j - area.Top) / (float)area.Height; // Initial surface. Skinny. for (; GetJPercent() < 0.1 && widthL + widthR < area.Width; j++) { widthL += Rand(-1, 1); widthR += Rand(-1, 1); InfectRow(); } progress.Value = 0.3f; float inc = 1f; // How the shape of the biome should expand/ // Expansion. The underground is a lot larger than the above ground. for (; GetJPercent() < 0.5 && widthL + widthR < area.Width; j++) { inc += 0.01f; widthL += Rand(-inc / 3, inc); widthR += Rand(-inc / 3, inc); InfectRow(); } progress.Value = 0.5f; // The more jagged edges of the bottom of the biome's bottom inc = 0f; for (; GetJPercent() < 0.8; j++) { inc += 0.02f; widthL += Rand(-inc, inc); widthR += Rand(-inc, inc); InfectRow(); } progress.Value = 0.7f; // Finally, close the bottom of the biome for (; GetJPercent() < 1 && widthL + widthR > 0 && inc > 0; j++) { inc -= 0.065f; widthL += Rand(-inc - 1, inc / 2); widthR += Rand(-inc - 1, inc / 2); InfectRow(); } progress.Value = 0.9f; }
public override void RandomUpdate(int i, int j) { // Choose a random point to infect Point offset = (WorldGen.genRand.NextFloat().ToRotationVector2() * WorldGen.genRand.Next(InfectiousTile.Range)).ToPoint(); Point tilePos = new Point(i + offset.X, j + offset.Y); TileExtensions.Infect(tilePos.X, tilePos.Y); }
private void IterateFloor(int i, int j, bool isFloor) { float bannerChance = ConfigReader.Get<float>("worldgen.lost city.banners per tile"); if (!isFloor && Framing.GetTileSafely(i, j).active() && WorldGen.genRand.Chance(bannerChance)) { TileExtensions.PlaceMultitile(i, j + 1, TileType<CityBanner>(), 2, 3); } }
private void GenLostChest(IList<LostBuilding> buildings) { LostBuilding lostChestBuilding = Main.rand.Next(buildings); for (int attempt = 0; attempt < 100; attempt++) { int i = WorldGen.genRand.Next(lostChestBuilding.Area.Left + 1, lostChestBuilding.Area.Right); int j = lostChestBuilding.Area.Bottom - WorldGen.genRand.Next(lostChestBuilding.Floors) * lostChestBuilding.FloorHeight; if (!WorldGen.SolidTile(i, j) || !WorldGen.SolidTile(i - 1, j)) { continue; } if (TileExtensions.PlaceMultitile(i - 1, j - 2, TileType<LostChest>(), 2, 2)) { return; } } GenLostChest(buildings); }
private static bool GrowthConditions(int i, int j) { return(WorldGen.InWorld(i, j, 1) && !TileExtensions.AnyTilesIn(i, i, j - 7, j - 1)); }