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

◆ GrowPalmTree()

static bool Terraria.WorldGen.GrowPalmTree ( int i,
int y )
inlinestatic

Definition at line 18785 of file WorldGen.cs.

18786 {
18787 int num = y;
18788 if (!InWorld(i, y))
18789 {
18790 return false;
18791 }
18792 while (Main.tile[i, num].type == 20)
18793 {
18794 num++;
18795 if (Main.tile[i, num] == null)
18796 {
18797 return false;
18798 }
18799 }
18800 Tile tile = Main.tile[i, num];
18801 Tile tile2 = Main.tile[i, num - 1];
18802 byte color = 0;
18803 if (Main.tenthAnniversaryWorld && !gen)
18804 {
18805 color = (byte)genRand.Next(1, 13);
18806 }
18807 tile.slope();
18808 tile.halfBrick();
18809 if (!tile.active() || tile.halfBrick() || tile.slope() != 0)
18810 {
18811 return false;
18812 }
18813 if (tile2.wall != 0 || tile2.liquid != 0)
18814 {
18815 return false;
18816 }
18817 if (tile.type != 53 && tile.type != 234 && tile.type != 116 && tile.type != 112)
18818 {
18819 return false;
18820 }
18821 if (!EmptyTileCheck(i, i, num - 2, num - 1, 20))
18822 {
18823 return false;
18824 }
18825 if (!EmptyTileCheck(i - 1, i + 1, num - 30, num - 3, 20))
18826 {
18827 return false;
18828 }
18829 int num2 = genRand.Next(10, 21);
18830 int num3 = genRand.Next(-8, 9);
18831 num3 *= 2;
18832 short num4 = 0;
18833 for (int j = 0; j < num2; j++)
18834 {
18835 tile = Main.tile[i, num - 1 - j];
18836 if (j == 0)
18837 {
18838 tile.active(active: true);
18839 tile.type = 323;
18840 tile.frameX = 66;
18841 tile.frameY = 0;
18842 tile.color(color);
18843 continue;
18844 }
18845 if (j == num2 - 1)
18846 {
18847 tile.active(active: true);
18848 tile.type = 323;
18849 tile.frameX = (short)(22 * genRand.Next(4, 7));
18850 tile.frameY = num4;
18851 tile.color(color);
18852 continue;
18853 }
18854 if (num4 != num3)
18855 {
18856 double num5 = (double)j / (double)num2;
18857 bool flag = false;
18858 if (!(num5 < 0.25) && ((num5 < 0.5 && genRand.Next(13) == 0) || (num5 < 0.7 && genRand.Next(9) == 0) || !(num5 < 0.95) || genRand.Next(5) != 0 || true))
18859 {
18860 short num6 = (short)Math.Sign(num3);
18861 num4 += (short)(num6 * 2);
18862 }
18863 }
18864 tile.active(active: true);
18865 tile.type = 323;
18866 tile.frameX = (short)(22 * genRand.Next(0, 3));
18867 tile.frameY = num4;
18868 tile.color(color);
18869 }
18870 RangeFrame(i - 2, num - num2 - 1, i + 2, num + 1);
18871 NetMessage.SendTileSquare(-1, i, num - num2, 1, num2);
18872 return true;
18873 }
static int Sign(decimal value)
Definition Math.cs:1202
static volatile bool gen
Definition WorldGen.cs:972
static UnifiedRandom genRand
Definition WorldGen.cs:1215
static bool EmptyTileCheck(int startX, int endX, int startY, int endY, int ignoreID=-1)
static void RangeFrame(int startX, int startY, int endX, int endY)
static bool InWorld(int x, int y, int fluff=0)
Definition WorldGen.cs:5816

References Terraria.Tile.active(), Terraria.Tile.color(), Terraria.Tile.halfBrick(), Terraria.NetMessage.SendTileSquare(), System.Math.Sign(), Terraria.Tile.slope(), Terraria.Main.tenthAnniversaryWorld, Terraria.Main.tile, and Terraria.Tile.type.