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

◆ AddTrees()

static void Terraria.WorldGen.AddTrees ( bool undergroundOnly = false)
inlinestatic

Definition at line 23188 of file WorldGen.cs.

23189 {
23190 double num = 0.1 + genRand.NextDouble() * 0.35;
23191 double num2 = 0.1 + genRand.NextDouble() * 0.35;
23192 int num3 = 20;
23193 int num4 = (int)Main.worldSurface;
23194 if (!undergroundOnly)
23195 {
23196 for (int i = 1; i < Main.maxTilesX - 1; i++)
23197 {
23198 for (int j = num3; j < num4; j++)
23199 {
23200 if (i < 380)
23201 {
23202 if (genRand.NextDouble() < num && Main.tile[i, j].liquid == 0)
23203 {
23204 GrowPalmTree(i, j);
23205 }
23206 }
23207 else if (i > Main.maxTilesX - 380 && genRand.NextDouble() < num2 && Main.tile[i, j].liquid == 0)
23208 {
23209 GrowPalmTree(i, j);
23210 }
23211 int num5 = 20;
23212 if (drunkWorldGen)
23213 {
23214 num5 /= 3;
23215 }
23216 if (remixWorldGen)
23217 {
23218 num5 /= 2;
23219 }
23220 if (Main.tile[i, j].type == 2 && (Main.tenthAnniversaryWorld || genRand.Next(num5) == 0))
23221 {
23222 if (genRand.Next(2) == 0)
23223 {
23224 GrowTreeWithSettings(i, j, GrowTreeSettings.Profiles.VanityTree_Willow);
23225 }
23226 else
23227 {
23228 GrowTreeWithSettings(i, j, GrowTreeSettings.Profiles.VanityTree_Sakura);
23229 }
23230 }
23231 else
23232 {
23233 GrowTree(i, j);
23234 }
23235 }
23236 if (genRand.Next(3) == 0)
23237 {
23238 i++;
23239 }
23240 if (genRand.Next(4) == 0)
23241 {
23242 i++;
23243 }
23244 }
23245 }
23246 if (!remixWorldGen)
23247 {
23248 return;
23249 }
23250 num3 = (int)Main.worldSurface;
23251 num4 = Main.maxTilesY - 300;
23252 for (int k = 1; k < Main.maxTilesX - 1; k++)
23253 {
23254 for (int l = num3; l < num4; l++)
23255 {
23256 int maxValue = 7;
23257 if (Main.tile[k, l].type == 2 && (Main.tenthAnniversaryWorld || genRand.Next(maxValue) == 0))
23258 {
23259 if (genRand.Next(2) == 0)
23260 {
23261 GrowTreeWithSettings(k, l, GrowTreeSettings.Profiles.VanityTree_Willow);
23262 }
23263 else
23264 {
23265 GrowTreeWithSettings(k, l, GrowTreeSettings.Profiles.VanityTree_Sakura);
23266 }
23267 }
23268 else
23269 {
23270 GrowTree(k, l);
23271 }
23272 }
23273 }
23274 }
static bool remixWorldGen
Definition WorldGen.cs:1148
static bool GrowTreeWithSettings(int checkedX, int checkedY, GrowTreeSettings settings)
static bool GrowPalmTree(int i, int y)
static UnifiedRandom genRand
Definition WorldGen.cs:1215
static bool GrowTree(int i, int y)
static bool drunkWorldGen
Definition WorldGen.cs:1154

References Terraria.Main.maxTilesX, Terraria.Main.tenthAnniversaryWorld, Terraria.Main.tile, Terraria.WorldGen.GrowTreeSettings.Profiles.VanityTree_Sakura, Terraria.WorldGen.GrowTreeSettings.Profiles.VanityTree_Willow, and Terraria.Main.worldSurface.