Terraria v1.4.4.9
Terraria source code documentation
All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events Macros

◆ ChasmRunner()

static void Terraria.WorldGen.ChasmRunner ( int i,
int j,
int steps,
bool makeOrb = false )
inlinestatic

Definition at line 65791 of file WorldGen.cs.

65792 {
65793 //IL_0107: Unknown result type (might be due to invalid IL or missing references)
65794 //IL_012f: Unknown result type (might be due to invalid IL or missing references)
65795 //IL_0165: Unknown result type (might be due to invalid IL or missing references)
65796 //IL_01cc: Unknown result type (might be due to invalid IL or missing references)
65797 //IL_01e2: Unknown result type (might be due to invalid IL or missing references)
65798 //IL_01f8: Unknown result type (might be due to invalid IL or missing references)
65799 //IL_020e: Unknown result type (might be due to invalid IL or missing references)
65800 //IL_017e: Unknown result type (might be due to invalid IL or missing references)
65801 //IL_0185: Unknown result type (might be due to invalid IL or missing references)
65802 //IL_01a0: Unknown result type (might be due to invalid IL or missing references)
65803 //IL_01a7: Unknown result type (might be due to invalid IL or missing references)
65804 //IL_0328: Unknown result type (might be due to invalid IL or missing references)
65805 //IL_045d: Unknown result type (might be due to invalid IL or missing references)
65806 //IL_045e: Unknown result type (might be due to invalid IL or missing references)
65807 //IL_0460: Unknown result type (might be due to invalid IL or missing references)
65808 //IL_0465: Unknown result type (might be due to invalid IL or missing references)
65809 //IL_048a: Unknown result type (might be due to invalid IL or missing references)
65810 //IL_04ac: Unknown result type (might be due to invalid IL or missing references)
65811 //IL_035f: Unknown result type (might be due to invalid IL or missing references)
65812 //IL_0366: Unknown result type (might be due to invalid IL or missing references)
65813 //IL_04ce: Unknown result type (might be due to invalid IL or missing references)
65814 //IL_04e4: Unknown result type (might be due to invalid IL or missing references)
65815 //IL_04fa: Unknown result type (might be due to invalid IL or missing references)
65816 //IL_0510: Unknown result type (might be due to invalid IL or missing references)
65817 //IL_038f: Unknown result type (might be due to invalid IL or missing references)
65818 //IL_0399: Unknown result type (might be due to invalid IL or missing references)
65819 //IL_03af: Unknown result type (might be due to invalid IL or missing references)
65820 //IL_03b9: Unknown result type (might be due to invalid IL or missing references)
65821 //IL_026d: Unknown result type (might be due to invalid IL or missing references)
65822 //IL_027c: Unknown result type (might be due to invalid IL or missing references)
65823 //IL_056f: Unknown result type (might be due to invalid IL or missing references)
65824 //IL_057e: Unknown result type (might be due to invalid IL or missing references)
65825 //IL_0676: Unknown result type (might be due to invalid IL or missing references)
65826 //IL_0685: Unknown result type (might be due to invalid IL or missing references)
65827 bool flag = false;
65828 bool flag2 = false;
65829 bool flag3 = false;
65830 if (!makeOrb)
65831 {
65832 flag2 = true;
65833 }
65834 double num = steps;
65835 Vector2D val = default(Vector2D);
65836 val.X = i;
65837 val.Y = j;
65838 Vector2D val2 = default(Vector2D);
65839 val2.X = (double)genRand.Next(-10, 11) * 0.1;
65840 val2.Y = (double)genRand.Next(11) * 0.2 + 0.5;
65841 int num2 = 5;
65842 double num3 = genRand.Next(5) + 7;
65843 while (num3 > 0.0)
65844 {
65845 if (num > 0.0)
65846 {
65847 num3 += (double)genRand.Next(3);
65848 num3 -= (double)genRand.Next(3);
65849 if (num3 < 7.0)
65850 {
65851 num3 = 7.0;
65852 }
65853 if (num3 > 20.0)
65854 {
65855 num3 = 20.0;
65856 }
65857 if (num == 1.0 && num3 < 10.0)
65858 {
65859 num3 = 10.0;
65860 }
65861 }
65862 else if (val.Y > Main.worldSurface + 45.0)
65863 {
65864 num3 -= (double)genRand.Next(4);
65865 }
65866 if (val.Y > Main.rockLayer && num > 0.0)
65867 {
65868 num = 0.0;
65869 }
65870 num -= 1.0;
65871 if (!flag && val.Y > Main.worldSurface + 20.0)
65872 {
65873 flag = true;
65874 ChasmRunnerSideways((int)val.X, (int)val.Y, -1, genRand.Next(20, 40));
65875 ChasmRunnerSideways((int)val.X, (int)val.Y, 1, genRand.Next(20, 40));
65876 }
65877 int num4;
65878 int num5;
65879 int num6;
65880 int num7;
65881 if (num > (double)num2)
65882 {
65883 num4 = (int)(val.X - num3 * 0.5);
65884 num5 = (int)(val.X + num3 * 0.5);
65885 num6 = (int)(val.Y - num3 * 0.5);
65886 num7 = (int)(val.Y + num3 * 0.5);
65887 if (num4 < 0)
65888 {
65889 num4 = 0;
65890 }
65891 if (num5 > Main.maxTilesX - 1)
65892 {
65893 num5 = Main.maxTilesX - 1;
65894 }
65895 if (num6 < 0)
65896 {
65897 num6 = 0;
65898 }
65899 if (num7 > Main.maxTilesY)
65900 {
65901 num7 = Main.maxTilesY;
65902 }
65903 for (int k = num4; k < num5; k++)
65904 {
65905 for (int l = num6; l < num7; l++)
65906 {
65907 if (Math.Abs((double)k - val.X) + Math.Abs((double)l - val.Y) < num3 * 0.5 * (1.0 + (double)genRand.Next(-10, 11) * 0.015) && Main.tile[k, l].type != 31 && Main.tile[k, l].type != 22)
65908 {
65909 Main.tile[k, l].active(active: false);
65910 }
65911 }
65912 }
65913 }
65914 if (num <= 2.0 && val.Y < Main.worldSurface + 45.0)
65915 {
65916 num = 2.0;
65917 }
65918 if (num <= 0.0)
65919 {
65920 if (!flag2)
65921 {
65922 flag2 = true;
65923 AddShadowOrb((int)val.X, (int)val.Y);
65924 }
65925 else if (!flag3)
65926 {
65927 flag3 = false;
65928 bool flag4 = false;
65929 int num8 = 0;
65930 while (!flag4)
65931 {
65932 int num9 = genRand.Next((int)val.X - 25, (int)val.X + 25);
65933 int num10 = genRand.Next((int)val.Y - 50, (int)val.Y);
65934 if (num9 < 5)
65935 {
65936 num9 = 5;
65937 }
65938 if (num9 > Main.maxTilesX - 5)
65939 {
65940 num9 = Main.maxTilesX - 5;
65941 }
65942 if (num10 < 5)
65943 {
65944 num10 = 5;
65945 }
65946 if (num10 > Main.maxTilesY - 5)
65947 {
65948 num10 = Main.maxTilesY - 5;
65949 }
65950 if ((double)num10 > Main.worldSurface)
65951 {
65952 if (!IsTileNearby(num9, num10, 26, 3))
65953 {
65954 Place3x2(num9, num10, 26);
65955 }
65956 if (Main.tile[num9, num10].type == 26)
65957 {
65958 flag4 = true;
65959 continue;
65960 }
65961 num8++;
65962 if (num8 >= 10000)
65963 {
65964 flag4 = true;
65965 }
65966 }
65967 else
65968 {
65969 flag4 = true;
65970 }
65971 }
65972 }
65973 }
65974 val += val2;
65975 val2.X += (double)genRand.Next(-10, 11) * 0.01;
65976 if (val2.X > 0.3)
65977 {
65978 val2.X = 0.3;
65979 }
65980 if (val2.X < -0.3)
65981 {
65982 val2.X = -0.3;
65983 }
65984 num4 = (int)(val.X - num3 * 1.1);
65985 num5 = (int)(val.X + num3 * 1.1);
65986 num6 = (int)(val.Y - num3 * 1.1);
65987 num7 = (int)(val.Y + num3 * 1.1);
65988 if (num4 < 1)
65989 {
65990 num4 = 1;
65991 }
65992 if (num5 > Main.maxTilesX - 1)
65993 {
65994 num5 = Main.maxTilesX - 1;
65995 }
65996 if (num6 < 0)
65997 {
65998 num6 = 0;
65999 }
66000 if (num7 > Main.maxTilesY)
66001 {
66002 num7 = Main.maxTilesY;
66003 }
66004 for (int m = num4; m < num5; m++)
66005 {
66006 for (int n = num6; n < num7; n++)
66007 {
66008 if (Math.Abs((double)m - val.X) + Math.Abs((double)n - val.Y) < num3 * 1.1 * (1.0 + (double)genRand.Next(-10, 11) * 0.015))
66009 {
66010 if (Main.tile[m, n].type != 25 && n > j + genRand.Next(3, 20))
66011 {
66012 Main.tile[m, n].active(active: true);
66013 }
66014 if (steps <= num2)
66015 {
66016 Main.tile[m, n].active(active: true);
66017 }
66018 if (Main.tile[m, n].type != 31)
66019 {
66020 Main.tile[m, n].type = 25;
66021 }
66022 }
66023 }
66024 }
66025 for (int num11 = num4; num11 < num5; num11++)
66026 {
66027 for (int num12 = num6; num12 < num7; num12++)
66028 {
66029 if (Math.Abs((double)num11 - val.X) + Math.Abs((double)num12 - val.Y) < num3 * 1.1 * (1.0 + (double)genRand.Next(-10, 11) * 0.015))
66030 {
66031 if (Main.tile[num11, num12].type != 31)
66032 {
66033 Main.tile[num11, num12].type = 25;
66034 }
66035 if (steps <= num2)
66036 {
66037 Main.tile[num11, num12].active(active: true);
66038 }
66039 if (num12 > j + genRand.Next(3, 20))
66040 {
66041 Main.tile[num11, num12].wall = 3;
66042 }
66043 }
66044 }
66045 }
66046 }
66047 }
static double Abs(double value)
static void AddShadowOrb(int x, int y)
static void Place3x2(int x, int y, ushort type, int style=0)
static UnifiedRandom genRand
Definition WorldGen.cs:1215
static void ChasmRunnerSideways(int i, int j, int direction, int steps)
static bool IsTileNearby(int x, int y, int type, int distance)
Definition WorldGen.cs:5117

References System.Math.Abs(), Terraria.Main.maxTilesX, Terraria.Main.maxTilesY, Terraria.Main.rockLayer, Terraria.Main.tile, Terraria.Main.worldSurface, ReLogic.Utilities.Vector2D.X, and ReLogic.Utilities.Vector2D.Y.

Referenced by Terraria.WorldGen.GenerateWorld().