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

◆ UpdateWorld_GrassGrowth()

static void Terraria.WorldGen.UpdateWorld_GrassGrowth ( int i,
int j,
int minI,
int maxI,
int minJ,
int maxJ,
bool underground )
inlinestaticprivate

Definition at line 64243 of file WorldGen.cs.

64244 {
64245 if (!InWorld(i, j, 10))
64246 {
64247 return;
64248 }
64249 if (underground)
64250 {
64251 int type = Main.tile[i, j].type;
64252 int num = -1;
64253 int num2 = -1;
64254 int num3 = -1;
64255 int maxValue = 1;
64256 int num4 = type;
64257 int num5 = -1;
64258 switch (type)
64259 {
64260 case 23:
64261 num = 0;
64262 num2 = 59;
64263 num4 = 23;
64264 num5 = 661;
64265 num3 = 24;
64266 maxValue = 2;
64268 {
64269 return;
64270 }
64271 break;
64272 case 199:
64273 num = 0;
64274 num2 = 59;
64275 num4 = 199;
64276 num5 = 662;
64277 num3 = 201;
64278 maxValue = 2;
64280 {
64281 return;
64282 }
64283 break;
64284 case 661:
64285 num = 59;
64286 num2 = 0;
64287 num4 = 661;
64288 num5 = 23;
64289 num3 = 24;
64290 maxValue = 2;
64292 {
64293 return;
64294 }
64295 break;
64296 case 662:
64297 num = 59;
64298 num2 = 0;
64299 num4 = 662;
64300 num5 = 199;
64301 num3 = 201;
64302 maxValue = 2;
64304 {
64305 return;
64306 }
64307 break;
64308 case 60:
64309 num = 59;
64310 num3 = 61;
64311 maxValue = 10;
64312 break;
64313 case 70:
64314 num = 59;
64315 num3 = 71;
64316 maxValue = 10;
64317 break;
64318 case 633:
64319 num = 57;
64320 num3 = 637;
64321 maxValue = 2;
64322 break;
64323 }
64324 bool flag = false;
64325 if (num3 != -1 && !Main.tile[i, minJ].active() && genRand.Next(maxValue) == 0)
64326 {
64327 flag = true;
64328 if (PlaceTile(i, minJ, num3, mute: true))
64329 {
64330 Main.tile[i, minJ].CopyPaintAndCoating(Main.tile[i, j]);
64331 }
64332 if (Main.netMode == 2 && Main.tile[i, minJ].active())
64333 {
64334 NetMessage.SendTileSquare(-1, i, minJ);
64335 }
64336 }
64337 if (num != -1)
64338 {
64339 bool flag2 = false;
64340 TileColorCache color = Main.tile[i, j].BlockColorAndCoating();
64341 for (int k = minI; k < maxI; k++)
64342 {
64343 for (int l = minJ; l < maxJ; l++)
64344 {
64345 if (!InWorld(k, l, 10) || (i == k && j == l) || !Main.tile[k, l].active())
64346 {
64347 continue;
64348 }
64349 if (Main.tile[k, l].type == num)
64350 {
64351 SpreadGrass(k, l, num, num4, repeat: false, color);
64352 if (Main.tile[k, l].type == num4)
64353 {
64355 flag2 = true;
64356 }
64357 }
64358 else if (num2 > -1 && num5 > -1 && Main.tile[k, l].type == num2)
64359 {
64360 SpreadGrass(k, l, num2, num5, repeat: false, color);
64361 if (Main.tile[k, l].type == num5)
64362 {
64364 flag2 = true;
64365 }
64366 }
64367 }
64368 }
64369 if (Main.netMode == 2 && flag2)
64370 {
64371 NetMessage.SendTileSquare(-1, i, j, 3);
64372 }
64373 }
64374 switch (type)
64375 {
64376 case 60:
64377 {
64378 if (flag || genRand.Next(25) != 0 || Main.tile[i, minJ].liquid != 0)
64379 {
64380 break;
64381 }
64382 if (Main.hardMode && NPC.downedMechBoss1 && NPC.downedMechBoss2 && NPC.downedMechBoss3 && genRand.Next(60) == 0)
64383 {
64384 bool flag3 = true;
64385 int num6 = 150;
64386 for (int m = i - num6; m < i + num6; m += 2)
64387 {
64388 for (int n = j - num6; n < j + num6; n += 2)
64389 {
64390 if (m > 1 && m < Main.maxTilesX - 2 && n > 1 && n < Main.maxTilesY - 2 && Main.tile[m, n].active() && Main.tile[m, n].type == 238)
64391 {
64392 flag3 = false;
64393 break;
64394 }
64395 }
64396 }
64397 if (flag3)
64398 {
64399 PlaceJunglePlant(i, minJ, 238, 0, 0);
64401 SquareTileFrame(i + 2, minJ);
64402 SquareTileFrame(i - 1, minJ);
64403 if (Main.tile[i, minJ].type == 238 && Main.netMode == 2)
64404 {
64405 NetMessage.SendTileSquare(-1, i, minJ, 5);
64406 }
64407 }
64408 }
64409 int maxValue2 = (Main.expertMode ? 30 : 40);
64410 if (Main.hardMode && NPC.downedMechBossAny && genRand.Next(maxValue2) == 0)
64411 {
64412 bool flag4 = true;
64413 int num7 = 60;
64414 if (Main.expertMode)
64415 {
64416 num7 -= 10;
64417 }
64418 for (int num8 = i - num7; num8 < i + num7; num8 += 2)
64419 {
64420 for (int num9 = j - num7; num9 < j + num7; num9 += 2)
64421 {
64422 if (num8 > 1 && num8 < Main.maxTilesX - 2 && num9 > 1 && num9 < Main.maxTilesY - 2 && Main.tile[num8, num9].active() && Main.tile[num8, num9].type == 236)
64423 {
64424 flag4 = false;
64425 break;
64426 }
64427 }
64428 }
64429 if (flag4)
64430 {
64431 PlaceJunglePlant(i, minJ, 236, genRand.Next(3), 0);
64433 SquareTileFrame(i + 1, minJ + 1);
64434 if (Main.tile[i, minJ].type == 236 && Main.netMode == 2)
64435 {
64436 NetMessage.SendTileSquare(-1, i, minJ, 4);
64437 }
64438 }
64439 break;
64440 }
64441 PlaceJunglePlant(i, minJ, 233, genRand.Next(8), 0);
64442 if (Main.tile[i, minJ].type != 233)
64443 {
64444 break;
64445 }
64446 if (Main.netMode == 2)
64447 {
64448 NetMessage.SendTileSquare(-1, i, minJ, 4);
64449 break;
64450 }
64451 PlaceJunglePlant(i, minJ, 233, genRand.Next(12), 1);
64452 if (Main.tile[i, minJ].type == 233 && Main.netMode == 2)
64453 {
64454 NetMessage.SendTileSquare(-1, i, minJ, 3);
64455 }
64456 break;
64457 }
64458 case 70:
64459 if (Main.tile[i, j - 1].liquid > 0)
64460 {
64461 PlaceCatTail(i, j - 1);
64462 }
64463 if (genRand.Next(250) == 0 && GrowTree(i, j) && PlayerLOS(i, j))
64464 {
64465 TreeGrowFXCheck(i, j - 1);
64466 }
64467 break;
64468 }
64469 return;
64470 }
64471 int num10 = Main.tile[i, j].type;
64472 switch (num10)
64473 {
64474 case 2:
64475 case 23:
64476 case 32:
64477 case 109:
64478 case 199:
64479 case 352:
64480 case 477:
64481 case 492:
64482 case 661:
64483 case 662:
64484 {
64485 if (Main.halloween && genRand.Next(75) == 0 && (num10 == 2 || num10 == 109))
64486 {
64487 int num13 = 100;
64488 int num14 = 0;
64489 for (int num15 = i - num13; num15 < i + num13; num15 += 2)
64490 {
64491 for (int num16 = j - num13; num16 < j + num13; num16 += 2)
64492 {
64493 if (num15 > 1 && num15 < Main.maxTilesX - 2 && num16 > 1 && num16 < Main.maxTilesY - 2 && Main.tile[num15, num16].active() && Main.tile[num15, num16].type == 254)
64494 {
64495 num14++;
64496 }
64497 }
64498 }
64499 if (num14 < 6)
64500 {
64501 PlacePumpkin(i, minJ);
64502 if (Main.netMode == 2 && Main.tile[i, minJ].type == 254)
64503 {
64504 NetMessage.SendTileSquare(-1, i - 1, minJ - 1, 2, 2);
64505 }
64506 }
64507 }
64508 if (!Main.tile[i, minJ].active() && Main.tile[i, minJ].liquid == 0)
64509 {
64510 int num17 = -1;
64511 if (num10 == 2 && genRand.Next(12) == 0)
64512 {
64513 num17 = 3;
64514 }
64515 else if (num10 == 23 && genRand.Next(10) == 0)
64516 {
64517 num17 = 24;
64518 }
64519 else if (num10 == 199 && genRand.Next(10) == 0)
64520 {
64521 num17 = 201;
64522 }
64523 else if (num10 == 661 && genRand.Next(10) == 0)
64524 {
64525 num17 = 24;
64526 }
64527 else if (num10 == 662 && genRand.Next(10) == 0)
64528 {
64529 num17 = 201;
64530 }
64531 else if (num10 == 109 && genRand.Next(10) == 0)
64532 {
64533 num17 = 110;
64534 }
64535 else if (num10 == 633 && genRand.Next(10) == 0)
64536 {
64537 num17 = 637;
64538 }
64539 if (num17 != -1 && PlaceTile(i, minJ, num17, mute: true))
64540 {
64541 Main.tile[i, minJ].CopyPaintAndCoating(Main.tile[i, j]);
64542 if (Main.netMode == 2)
64543 {
64544 NetMessage.SendTileSquare(-1, i, minJ);
64545 }
64546 }
64547 }
64548 bool flag6 = false;
64549 switch (num10)
64550 {
64551 case 32:
64552 num10 = 23;
64554 {
64555 return;
64556 }
64557 break;
64558 case 352:
64559 num10 = 199;
64561 {
64562 return;
64563 }
64564 break;
64565 case 477:
64566 num10 = 2;
64567 break;
64568 case 492:
64569 num10 = 109;
64570 break;
64571 }
64572 int grass = num10;
64573 int num18 = -1;
64574 if (num10 == 23 || num10 == 661)
64575 {
64576 grass = 23;
64577 num18 = 661;
64578 }
64579 if (num10 == 199 || num10 == 662)
64580 {
64581 grass = 199;
64582 num18 = 662;
64583 }
64584 bool flag7 = AllowedToSpreadInfections && (num10 == 23 || num10 == 199 || num10 == 109 || num10 == 492 || num10 == 661 || num10 == 662) && InWorld(i, j, 10);
64585 for (int num19 = minI; num19 < maxI; num19++)
64586 {
64587 for (int num20 = minJ; num20 < maxJ; num20++)
64588 {
64589 if (!InWorld(num19, num20, 10) || (i == num19 && j == num20) || !Main.tile[num19, num20].active())
64590 {
64591 continue;
64592 }
64593 int type2 = Main.tile[num19, num20].type;
64594 if (!flag7 && type2 != 0 && (num18 == -1 || type2 != 59))
64595 {
64596 continue;
64597 }
64598 TileColorCache color3 = Main.tile[i, j].BlockColorAndCoating();
64599 if (type2 == 0 || (num18 > -1 && type2 == 59) || ((num10 == 23 || num10 == 661 || num10 == 199 || num10 == 662) && (type2 == 2 || type2 == 109 || type2 == 477 || type2 == 492)))
64600 {
64602 if (num18 > -1)
64603 {
64605 }
64606 if (AllowedToSpreadInfections && (num10 == 23 || num10 == 199 || num10 == 661 || num10 == 662))
64607 {
64612 if (num18 > -1)
64613 {
64615 }
64616 }
64617 if (Main.tile[num19, num20].type == num10 || (num18 > -1 && Main.tile[num19, num20].type == num18))
64618 {
64620 flag6 = true;
64621 }
64622 }
64623 if (type2 == 0 || ((num10 == 109 || num10 == 492) && (type2 == 2 || type2 == 477 || type2 == 23 || type2 == 199)))
64624 {
64626 if (num10 == 109)
64627 {
64629 }
64630 switch (num10)
64631 {
64632 case 492:
64634 break;
64635 case 109:
64636 SpreadGrass(num19, num20, 477, 492, repeat: false, color3);
64637 break;
64638 }
64639 if ((num10 == 492 || num10 == 109) && AllowedToSpreadInfections)
64640 {
64641 SpreadGrass(num19, num20, 23, 109, repeat: false, color3);
64642 }
64643 if ((num10 == 492 || num10 == 109) && AllowedToSpreadInfections)
64644 {
64645 SpreadGrass(num19, num20, 199, 109, repeat: false, color3);
64646 }
64647 if (Main.tile[num19, num20].type == num10)
64648 {
64650 flag6 = true;
64651 }
64652 }
64653 }
64654 }
64655 if (Main.netMode == 2 && flag6)
64656 {
64657 NetMessage.SendTileSquare(-1, i, j, 3);
64658 }
64659 break;
64660 }
64661 case 70:
64662 {
64663 if (!Main.tile[i, j].inActive())
64664 {
64665 if (!Main.tile[i, minJ].active() && genRand.Next(10) == 0)
64666 {
64667 PlaceTile(i, minJ, 71, mute: true);
64668 if (Main.tile[i, minJ].active())
64669 {
64670 Main.tile[i, minJ].CopyPaintAndCoating(Main.tile[i, j]);
64671 }
64672 if (Main.netMode == 2 && Main.tile[i, minJ].active())
64673 {
64674 NetMessage.SendTileSquare(-1, i, minJ);
64675 }
64676 }
64677 if (genRand.Next(300) == 0)
64678 {
64679 bool flag8 = PlayerLOS(i, j);
64680 if (GrowTree(i, j) && flag8)
64681 {
64682 TreeGrowFXCheck(i, j - 1);
64683 }
64684 }
64685 }
64686 bool flag9 = false;
64687 TileColorCache color4 = Main.tile[i, j].BlockColorAndCoating();
64688 for (int num21 = minI; num21 < maxI; num21++)
64689 {
64690 for (int num22 = minJ; num22 < maxJ; num22++)
64691 {
64692 if ((i != num21 || j != num22) && Main.tile[num21, num22].active() && Main.tile[num21, num22].type == 59)
64693 {
64695 if (Main.tile[num21, num22].type == num10)
64696 {
64698 flag9 = true;
64699 }
64700 }
64701 }
64702 }
64703 if (Main.netMode == 2 && flag9)
64704 {
64705 NetMessage.SendTileSquare(-1, i, j, 3);
64706 }
64707 break;
64708 }
64709 case 60:
64710 {
64711 if (!Main.tile[i, minJ].active() && genRand.Next(7) == 0)
64712 {
64713 PlaceTile(i, minJ, 61, mute: true);
64714 if (Main.tile[i, minJ].active())
64715 {
64716 Main.tile[i, minJ].CopyPaintAndCoating(Main.tile[i, j]);
64717 }
64718 if (Main.netMode == 2 && Main.tile[i, minJ].active())
64719 {
64720 NetMessage.SendTileSquare(-1, i, minJ);
64721 }
64722 }
64723 else if (genRand.Next(500) == 0 && (!Main.tile[i, minJ].active() || Main.tile[i, minJ].type == 61 || Main.tile[i, minJ].type == 74 || Main.tile[i, minJ].type == 69))
64724 {
64725 if (GrowTree(i, j) && PlayerLOS(i, j))
64726 {
64727 TreeGrowFXCheck(i, j - 1);
64728 }
64729 }
64730 else if (genRand.Next(25) == 0 && Main.tile[i, minJ].liquid == 0)
64731 {
64732 PlaceJunglePlant(i, minJ, 233, genRand.Next(8), 0);
64733 if (Main.tile[i, minJ].type == 233)
64734 {
64735 if (Main.netMode == 2)
64736 {
64737 NetMessage.SendTileSquare(-1, i, minJ, 4);
64738 }
64739 else
64740 {
64741 PlaceJunglePlant(i, minJ, 233, genRand.Next(12), 1);
64742 if (Main.tile[i, minJ].type == 233 && Main.netMode == 2)
64743 {
64744 NetMessage.SendTileSquare(-1, i, minJ, 3);
64745 }
64746 }
64747 }
64748 }
64749 bool flag10 = false;
64750 TileColorCache color5 = Main.tile[i, j].BlockColorAndCoating();
64751 for (int num23 = minI; num23 < maxI; num23++)
64752 {
64753 for (int num24 = minJ; num24 < maxJ; num24++)
64754 {
64755 if ((i != num23 || j != num24) && Main.tile[num23, num24].active() && Main.tile[num23, num24].type == 59)
64756 {
64758 if (Main.tile[num23, num24].type == num10)
64759 {
64761 flag10 = true;
64762 }
64763 }
64764 }
64765 }
64766 if (Main.netMode == 2 && flag10)
64767 {
64768 NetMessage.SendTileSquare(-1, i, j, 3);
64769 }
64770 break;
64771 }
64772 case 633:
64773 {
64774 if (!Main.tile[i, minJ].active() && genRand.Next(10) == 0)
64775 {
64776 PlaceTile(i, minJ, 637, mute: true);
64777 if (Main.tile[i, minJ].active())
64778 {
64779 Main.tile[i, minJ].CopyPaintAndCoating(Main.tile[i, j]);
64780 }
64781 if (Main.netMode == 2 && Main.tile[i, minJ].active())
64782 {
64783 NetMessage.SendTileSquare(-1, i, minJ);
64784 }
64785 }
64786 TileColorCache color2 = Main.tile[i, j].BlockColorAndCoating();
64787 bool flag5 = false;
64788 for (int num11 = minI; num11 < maxI; num11++)
64789 {
64790 for (int num12 = minJ; num12 < maxJ; num12++)
64791 {
64792 if ((i != num11 || j != num12) && Main.tile[num11, num12].active() && Main.tile[num11, num12].type == 57)
64793 {
64795 if (Main.tile[num11, num12].type == num10)
64796 {
64798 flag5 = true;
64799 }
64800 }
64801 }
64802 }
64803 if (Main.netMode == 2 && flag5)
64804 {
64805 NetMessage.SendTileSquare(-1, i, j, 3);
64806 }
64807 break;
64808 }
64809 }
64810 }
static bool AllowedToSpreadInfections
Definition WorldGen.cs:1008
static bool PlaceTile(int i, int j, int Type, bool mute=false, bool forced=false, int plr=-1, int style=0)
static UnifiedRandom genRand
Definition WorldGen.cs:1215
static Point PlaceCatTail(int x, int j)
static void TreeGrowFXCheck(int x, int y)
static bool PlayerLOS(int x, int y)
static void PlaceJunglePlant(int X2, int Y2, ushort type, int styleX, int styleY)
static void PlacePumpkin(int x, int superY)
static bool GrowTree(int i, int y)
static void SpreadGrass(int i, int j, int dirt=0, int grass=2, bool repeat=true, TileColorCache color=default(TileColorCache))
static bool InWorld(int x, int y, int fluff=0)
Definition WorldGen.cs:5816
static void SquareTileFrame(int i, int j, bool resetFrame=true)

References Terraria.NPC.downedMechBoss1, Terraria.NPC.downedMechBoss2, Terraria.NPC.downedMechBoss3, Terraria.NPC.downedMechBossAny, Terraria.Main.expertMode, Terraria.Main.halloween, Terraria.Main.hardMode, Terraria.Main.maxTilesY, Terraria.Main.netMode, Terraria.NetMessage.SendTileSquare(), Terraria.Main.tile, and System.type.