Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ GeneratePlanteraBulbOnAllMechsDefeated()

static bool Terraria.WorldGen.GeneratePlanteraBulbOnAllMechsDefeated ( )
inlinestatic

Definition at line 64090 of file WorldGen.cs.

64091 {
64092 bool num = (double)Main.dungeonX > (double)Main.maxTilesX * 0.5;
64093 int num2 = (int)(num ? ((double)Main.maxTilesX * 0.15) : ((double)Main.maxTilesX * 0.65));
64094 int num3 = (int)(num ? ((double)Main.maxTilesX * 0.35) : ((double)Main.maxTilesX * 0.85));
64095 int num4 = (int)Main.worldSurface;
64096 int underworldLayer = Main.UnderworldLayer;
64097 int width = num3 - num2;
64098 int height = underworldLayer - num4;
64099 Rectangle rectangle = new Rectangle(num2, num4, width, height);
64100 int num5 = 2500;
64101 while (num5 > 0)
64102 {
64103 bool flag = num5 < 500;
64104 bool flag2 = num5 < 200;
64105 num5--;
64106 Point point = new Point(rectangle.X + genRand.Next(rectangle.Width), rectangle.Y + genRand.Next(rectangle.Height));
64107 Tile tile = Main.tile[point.X, point.Y];
64108 int num6 = 500;
64109 bool flag3 = false;
64110 while (!flag3)
64111 {
64112 num6--;
64113 if (num6 <= 0)
64114 {
64115 flag3 = true;
64116 }
64117 point.Y--;
64118 if (point.Y < rectangle.Y)
64119 {
64120 break;
64121 }
64122 tile = Main.tile[point.X, point.Y];
64123 if (tile != null && (flag2 || tile.active()))
64124 {
64125 if (tile.type == 60)
64126 {
64127 flag3 = true;
64128 }
64129 else if (flag && tile.type == 59)
64130 {
64131 flag3 = true;
64132 }
64133 }
64134 }
64135 if (tile == null)
64136 {
64137 continue;
64138 }
64139 bool num7 = tile.active() || flag2;
64140 bool flag4 = tile.type == 60 || (flag && tile.type == 59);
64141 if (num7 && flag4)
64142 {
64143 if (AttemptToGeneratePlanteraBulbAt(point.X, point.Y - 1, flag))
64144 {
64145 return true;
64146 }
64147 if (AttemptToGeneratePlanteraBulbAt(point.X - 1, point.Y - 1, flag))
64148 {
64149 return true;
64150 }
64151 if (AttemptToGeneratePlanteraBulbAt(point.X + 1, point.Y - 1, flag))
64152 {
64153 return true;
64154 }
64155 }
64156 }
64157 return false;
64158 }
static bool AttemptToGeneratePlanteraBulbAt(int i, int j, bool forceBulb)
static UnifiedRandom genRand
Definition WorldGen.cs:1215

References Terraria.Tile.active(), Terraria.Main.dungeonX, Terraria.Main.maxTilesX, Terraria.Main.tile, Terraria.Tile.type, Terraria.Main.UnderworldLayer, Terraria.Main.worldSurface, Microsoft.Xna.Framework.Point.X, and Microsoft.Xna.Framework.Point.Y.

Referenced by Terraria.NPC.OnGameEventClearedForTheFirstTime().