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

◆ TileRunner()

static void Terraria.WorldGen.TileRunner ( int i,
int j,
double strength,
int steps,
int type,
bool addTile = false,
double speedX = 0::0,
double speedY = 0::0,
bool noYChange = false,
bool overRide = true,
int ignoreTileType = -1 )
inlinestatic

Definition at line 70676 of file WorldGen.cs.

70677 {
70678 if (!GenVars.mudWall)
70679 {
70680 if (drunkWorldGen)
70681 {
70682 strength *= 1.0 + (double)genRand.Next(-80, 81) * 0.01;
70683 steps = (int)((double)steps * (1.0 + (double)genRand.Next(-80, 81) * 0.01));
70684 }
70685 else if (remixWorldGen)
70686 {
70687 strength *= 1.0 + (double)genRand.Next(-50, 51) * 0.01;
70688 }
70689 else if (getGoodWorldGen && type != 57)
70690 {
70691 strength *= 1.0 + (double)genRand.Next(-80, 81) * 0.015;
70692 steps += genRand.Next(3);
70693 }
70694 }
70695 double num = strength;
70696 double num2 = steps;
70697 Vector2D vector2D = default(Vector2D);
70698 vector2D.X = i;
70699 vector2D.Y = j;
70700 Vector2D vector2D2 = default(Vector2D);
70701 vector2D2.X = (double)genRand.Next(-10, 11) * 0.1;
70702 vector2D2.Y = (double)genRand.Next(-10, 11) * 0.1;
70703 if (speedX != 0.0 || speedY != 0.0)
70704 {
70705 vector2D2.X = speedX;
70706 vector2D2.Y = speedY;
70707 }
70708 bool flag = type == 368;
70709 bool flag2 = type == 367;
70710 bool lava = false;
70711 if (getGoodWorldGen && genRand.Next(4) == 0)
70712 {
70713 lava = true;
70714 }
70715 while (num > 0.0 && num2 > 0.0)
70716 {
70717 if (drunkWorldGen && genRand.Next(30) == 0)
70718 {
70719 vector2D.X += (double)genRand.Next(-100, 101) * 0.05;
70720 vector2D.Y += (double)genRand.Next(-100, 101) * 0.05;
70721 }
70722 if (vector2D.Y < 0.0 && num2 > 0.0 && type == 59)
70723 {
70724 num2 = 0.0;
70725 }
70726 num = strength * (num2 / (double)steps);
70727 num2 -= 1.0;
70728 int num3 = (int)(vector2D.X - num * 0.5);
70729 int num4 = (int)(vector2D.X + num * 0.5);
70730 int num5 = (int)(vector2D.Y - num * 0.5);
70731 int num6 = (int)(vector2D.Y + num * 0.5);
70732 if (num3 < 1)
70733 {
70734 num3 = 1;
70735 }
70736 if (num4 > Main.maxTilesX - 1)
70737 {
70738 num4 = Main.maxTilesX - 1;
70739 }
70740 if (num5 < 1)
70741 {
70742 num5 = 1;
70743 }
70744 if (num6 > Main.maxTilesY - 1)
70745 {
70746 num6 = Main.maxTilesY - 1;
70747 }
70748 for (int k = num3; k < num4; k++)
70749 {
70750 if (k < beachDistance + 50 || k >= Main.maxTilesX - beachDistance - 50)
70751 {
70752 lava = false;
70753 }
70754 for (int l = num5; l < num6; l++)
70755 {
70756 if ((drunkWorldGen && l < Main.maxTilesY - 300 && type == 57) || (ignoreTileType >= 0 && Main.tile[k, l].active() && Main.tile[k, l].type == ignoreTileType) || !(Math.Abs((double)k - vector2D.X) + Math.Abs((double)l - vector2D.Y) < strength * 0.5 * (1.0 + (double)genRand.Next(-10, 11) * 0.015)))
70757 {
70758 continue;
70759 }
70760 if (GenVars.mudWall && (double)l > Main.worldSurface && Main.tile[k, l - 1].wall != 2 && l < Main.maxTilesY - 210 - genRand.Next(3) && Math.Abs((double)k - vector2D.X) + Math.Abs((double)l - vector2D.Y) < strength * 0.45 * (1.0 + (double)genRand.Next(-10, 11) * 0.01))
70761 {
70762 if (l > GenVars.lavaLine - genRand.Next(0, 4) - 50)
70763 {
70764 if (Main.tile[k, l - 1].wall != 64 && Main.tile[k, l + 1].wall != 64 && Main.tile[k - 1, l].wall != 64 && Main.tile[k + 1, l].wall != 64)
70765 {
70766 PlaceWall(k, l, 15, mute: true);
70767 }
70768 }
70769 else if (Main.tile[k, l - 1].wall != 15 && Main.tile[k, l + 1].wall != 15 && Main.tile[k - 1, l].wall != 15 && Main.tile[k + 1, l].wall != 15)
70770 {
70771 PlaceWall(k, l, 64, mute: true);
70772 }
70773 }
70774 if (type < 0)
70775 {
70776 if (Main.tile[k, l].type == 53)
70777 {
70778 continue;
70779 }
70780 if (type == -2 && Main.tile[k, l].active() && (l < GenVars.waterLine || l > GenVars.lavaLine))
70781 {
70782 Main.tile[k, l].liquid = byte.MaxValue;
70783 Main.tile[k, l].lava(lava);
70784 if (remixWorldGen)
70785 {
70786 if (l > GenVars.lavaLine && ((double)l < Main.rockLayer - 80.0 || l > Main.maxTilesY - 350) && !oceanDepths(k, l))
70787 {
70788 Main.tile[k, l].lava(lava: true);
70789 }
70790 }
70791 else if (l > GenVars.lavaLine)
70792 {
70793 Main.tile[k, l].lava(lava: true);
70794 }
70795 }
70796 Main.tile[k, l].active(active: false);
70797 continue;
70798 }
70799 if (flag && Math.Abs((double)k - vector2D.X) + Math.Abs((double)l - vector2D.Y) < strength * 0.3 * (1.0 + (double)genRand.Next(-10, 11) * 0.01))
70800 {
70801 PlaceWall(k, l, 180, mute: true);
70802 }
70803 if (flag2 && Math.Abs((double)k - vector2D.X) + Math.Abs((double)l - vector2D.Y) < strength * 0.3 * (1.0 + (double)genRand.Next(-10, 11) * 0.01))
70804 {
70805 PlaceWall(k, l, 178, mute: true);
70806 }
70807 if (overRide || !Main.tile[k, l].active())
70808 {
70809 Tile tile = Main.tile[k, l];
70810 bool flag3 = false;
70811 flag3 = Main.tileStone[type] && tile.type != 1;
70813 {
70814 flag3 = true;
70815 }
70816 switch (tile.type)
70817 {
70818 case 53:
70819 if (type == 59 && ((Rectangle)(ref GenVars.UndergroundDesertLocation)).Contains(k, l))
70820 {
70821 flag3 = true;
70822 }
70823 if (type == 40)
70824 {
70825 flag3 = true;
70826 }
70827 if ((double)l < Main.worldSurface && type != 59)
70828 {
70829 flag3 = true;
70830 }
70831 break;
70832 case 45:
70833 case 147:
70834 case 189:
70835 case 190:
70836 case 196:
70837 case 460:
70838 flag3 = true;
70839 break;
70840 case 396:
70841 case 397:
70842 flag3 = !TileID.Sets.Ore[type];
70843 break;
70844 case 1:
70845 if (type == 59 && (double)l < Main.worldSurface + (double)genRand.Next(-50, 50))
70846 {
70847 flag3 = true;
70848 }
70849 break;
70850 case 367:
70851 case 368:
70852 if (type == 59)
70853 {
70854 flag3 = true;
70855 }
70856 break;
70857 }
70858 if (!flag3)
70859 {
70860 tile.type = (ushort)type;
70861 }
70862 }
70863 if (addTile)
70864 {
70865 Main.tile[k, l].active(active: true);
70866 Main.tile[k, l].liquid = 0;
70867 Main.tile[k, l].lava(lava: false);
70868 }
70869 if (noYChange && (double)l < Main.worldSurface && type != 59)
70870 {
70871 Main.tile[k, l].wall = 2;
70872 }
70873 if (type == 59 && l > GenVars.waterLine && Main.tile[k, l].liquid > 0)
70874 {
70875 Main.tile[k, l].lava(lava: false);
70876 Main.tile[k, l].liquid = 0;
70877 }
70878 }
70879 }
70881 if ((!drunkWorldGen || genRand.Next(3) != 0) && num > 50.0)
70882 {
70884 num2 -= 1.0;
70885 vector2D2.Y += (double)genRand.Next(-10, 11) * 0.05;
70886 vector2D2.X += (double)genRand.Next(-10, 11) * 0.05;
70887 if (num > 100.0)
70888 {
70890 num2 -= 1.0;
70891 vector2D2.Y += (double)genRand.Next(-10, 11) * 0.05;
70892 vector2D2.X += (double)genRand.Next(-10, 11) * 0.05;
70893 if (num > 150.0)
70894 {
70896 num2 -= 1.0;
70897 vector2D2.Y += (double)genRand.Next(-10, 11) * 0.05;
70898 vector2D2.X += (double)genRand.Next(-10, 11) * 0.05;
70899 if (num > 200.0)
70900 {
70902 num2 -= 1.0;
70903 vector2D2.Y += (double)genRand.Next(-10, 11) * 0.05;
70904 vector2D2.X += (double)genRand.Next(-10, 11) * 0.05;
70905 if (num > 250.0)
70906 {
70908 num2 -= 1.0;
70909 vector2D2.Y += (double)genRand.Next(-10, 11) * 0.05;
70910 vector2D2.X += (double)genRand.Next(-10, 11) * 0.05;
70911 if (num > 300.0)
70912 {
70914 num2 -= 1.0;
70915 vector2D2.Y += (double)genRand.Next(-10, 11) * 0.05;
70916 vector2D2.X += (double)genRand.Next(-10, 11) * 0.05;
70917 if (num > 400.0)
70918 {
70920 num2 -= 1.0;
70921 vector2D2.Y += (double)genRand.Next(-10, 11) * 0.05;
70922 vector2D2.X += (double)genRand.Next(-10, 11) * 0.05;
70923 if (num > 500.0)
70924 {
70926 num2 -= 1.0;
70927 vector2D2.Y += (double)genRand.Next(-10, 11) * 0.05;
70928 vector2D2.X += (double)genRand.Next(-10, 11) * 0.05;
70929 if (num > 600.0)
70930 {
70932 num2 -= 1.0;
70933 vector2D2.Y += (double)genRand.Next(-10, 11) * 0.05;
70934 vector2D2.X += (double)genRand.Next(-10, 11) * 0.05;
70935 if (num > 700.0)
70936 {
70938 num2 -= 1.0;
70939 vector2D2.Y += (double)genRand.Next(-10, 11) * 0.05;
70940 vector2D2.X += (double)genRand.Next(-10, 11) * 0.05;
70941 if (num > 800.0)
70942 {
70944 num2 -= 1.0;
70945 vector2D2.Y += (double)genRand.Next(-10, 11) * 0.05;
70946 vector2D2.X += (double)genRand.Next(-10, 11) * 0.05;
70947 if (num > 900.0)
70948 {
70950 num2 -= 1.0;
70951 vector2D2.Y += (double)genRand.Next(-10, 11) * 0.05;
70952 vector2D2.X += (double)genRand.Next(-10, 11) * 0.05;
70953 }
70954 }
70955 }
70956 }
70957 }
70958 }
70959 }
70960 }
70961 }
70962 }
70963 }
70964 }
70965 vector2D2.X += (double)genRand.Next(-10, 11) * 0.05;
70966 if (drunkWorldGen)
70967 {
70968 vector2D2.X += (double)genRand.Next(-10, 11) * 0.25;
70969 }
70970 if (vector2D2.X > 1.0)
70971 {
70972 vector2D2.X = 1.0;
70973 }
70974 if (vector2D2.X < -1.0)
70975 {
70976 vector2D2.X = -1.0;
70977 }
70978 if (!noYChange)
70979 {
70980 vector2D2.Y += (double)genRand.Next(-10, 11) * 0.05;
70981 if (vector2D2.Y > 1.0)
70982 {
70983 vector2D2.Y = 1.0;
70984 }
70985 if (vector2D2.Y < -1.0)
70986 {
70987 vector2D2.Y = -1.0;
70988 }
70989 }
70990 else if (type != 59 && num < 3.0)
70991 {
70992 if (vector2D2.Y > 1.0)
70993 {
70994 vector2D2.Y = 1.0;
70995 }
70996 if (vector2D2.Y < -1.0)
70997 {
70998 vector2D2.Y = -1.0;
70999 }
71000 }
71001 if (type == 59 && !noYChange)
71002 {
71003 if (vector2D2.Y > 0.5)
71004 {
71005 vector2D2.Y = 0.5;
71006 }
71007 if (vector2D2.Y < -0.5)
71008 {
71009 vector2D2.Y = -0.5;
71010 }
71011 if (vector2D.Y < Main.rockLayer + 100.0)
71012 {
71013 vector2D2.Y = 1.0;
71014 }
71015 if (vector2D.Y > (double)(Main.maxTilesY - 300))
71016 {
71017 vector2D2.Y = -1.0;
71018 }
71019 }
71020 }
71021 }
static bool[] Ore
Indicates that the tile is an ore. Used in worldgen code for various purposes and by Fairies.
Definition TileID.cs:381
static bool[] CanBeClearedDuringGeneration
Definition TileID.cs:296
static Rectangle UndergroundDesertLocation
Definition GenVars.cs:110
static bool remixWorldGen
Definition WorldGen.cs:1386
static UnifiedRandom genRand
Definition WorldGen.cs:1455
static bool oceanDepths(int x, int y)
Definition WorldGen.cs:7780
static readonly int beachDistance
Definition WorldGen.cs:1166
static void PlaceWall(int i, int j, int type, bool mute=false)
static bool drunkWorldGen
Definition WorldGen.cs:1392
static bool getGoodWorldGen
Definition WorldGen.cs:1394

References Terraria.ID.TileID.Sets.CanBeClearedDuringGeneration, Terraria.WorldBuilding.GenVars.lavaLine, Terraria.Main.maxTilesX, Terraria.Main.maxTilesY, Terraria.WorldBuilding.GenVars.mudWall, Terraria.ID.TileID.Sets.Ore, Terraria.Main.rockLayer, Terraria.Main.tile, Terraria.Main.tileStone, Terraria.Tile.type, Terraria.WorldBuilding.GenVars.UndergroundDesertLocation, and Terraria.WorldBuilding.GenVars.waterLine.

Referenced by Terraria.WorldGen.AddGenPasses(), Terraria.GameContent.Biomes.JunglePass.ApplyPass(), Terraria.GameContent.Biomes.JunglePass.GenerateFinishingTouches(), Terraria.GameContent.Biomes.JunglePass.GenerateTunnelToSurface(), Terraria.GameContent.Biomes.JunglePass.PlaceFirstPassMud(), and Terraria.GameContent.Biomes.JunglePass.PlaceGemsAt().

+ Here is the caller graph for this function: