Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
SandMound.cs
Go to the documentation of this file.
1using System;
3
5
6public static class SandMound
7{
8 public static void Place(DesertDescription description)
9 {
10 Rectangle desert = description.Desert;
11 desert.Height = Math.Min(description.Desert.Height, description.Hive.Height / 2);
12 Rectangle desert2 = description.Desert;
13 desert2.Y = desert.Bottom;
14 desert2.Height = Math.Max(0, description.Desert.Bottom - desert.Bottom);
15 SurfaceMap surface = description.Surface;
16 int num = 0;
17 int num2 = 0;
18 for (int i = -5; i < desert.Width + 5; i++)
19 {
20 double value = Math.Abs((double)(i + 5) / (double)(desert.Width + 10)) * 2.0 - 1.0;
21 value = Utils.Clamp(value, -1.0, 1.0);
22 if (i % 3 == 0)
23 {
24 num += WorldGen.genRand.Next(-1, 2);
25 num = Utils.Clamp(num, -10, 10);
26 }
27 num2 += WorldGen.genRand.Next(-1, 2);
28 num2 = Utils.Clamp(num2, -10, 10);
29 double num3 = Math.Sqrt(1.0 - value * value * value * value);
30 int num4 = desert.Bottom - (int)(num3 * (double)desert.Height) + num;
31 if (Math.Abs(value) < 1.0)
32 {
33 double num5 = Utils.UnclampedSmoothStep(0.5, 0.8, Math.Abs(value));
34 num5 = num5 * num5 * num5;
35 int val = 10 + (int)((double)desert.Top - num5 * 20.0) + num2;
36 val = Math.Min(val, num4);
37 for (int j = surface[i + desert.X] - 1; j < val; j++)
38 {
39 int num6 = i + desert.X;
40 int num7 = j;
41 Main.tile[num6, num7].active(active: false);
42 Main.tile[num6, num7].wall = 0;
43 }
44 }
45 PlaceSandColumn(i + desert.X, num4, desert2.Bottom - num4);
46 }
47 }
48
49 private static void PlaceSandColumn(int startX, int startY, int height)
50 {
51 for (int num = startY + height - 1; num >= startY; num--)
52 {
53 int num2 = num;
54 Tile tile = Main.tile[startX, num2];
56 {
57 tile.liquid = 0;
58 }
59 _ = Main.tile[startX, num2 + 1];
60 _ = Main.tile[startX, num2 + 2];
61 tile.type = 53;
62 tile.slope(0);
63 tile.halfBrick(halfBrick: false);
64 tile.active(active: true);
65 if (num < startY)
66 {
67 tile.active(active: false);
68 }
69 WorldGen.SquareWallFrame(startX, num2);
70 }
71 }
72}
static byte Min(byte val1, byte val2)
Definition Math.cs:912
static double Sqrt(double d)
static double Abs(double value)
static byte Max(byte val1, byte val2)
Definition Math.cs:738
static void PlaceSandColumn(int startX, int startY, int height)
Definition SandMound.cs:49
static void Place(DesertDescription description)
Definition SandMound.cs:8
static Tile[,] tile
Definition Main.cs:1675
bool active()
Definition Tile.cs:565
byte slope()
Definition Tile.cs:684
bool halfBrick()
Definition Tile.cs:650
static float UnclampedSmoothStep(float min, float max, float x)
Definition Utils.cs:93
static bool remixWorldGen
Definition WorldGen.cs:1148
static UnifiedRandom genRand
Definition WorldGen.cs:1215
static void SquareWallFrame(int i, int j, bool resetFrame=true)