Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
PitEntrance.cs
Go to the documentation of this file.
1using System;
3
5
6public static class PitEntrance
7{
8 public static void Place(DesertDescription description)
9 {
10 int holeRadius = WorldGen.genRand.Next(6, 9);
11 Point center = description.CombinedArea.Center;
12 center.Y = description.Surface[center.X];
13 PlaceAt(description, center, holeRadius);
14 }
15
16 private static void PlaceAt(DesertDescription description, Point position, int holeRadius)
17 {
18 for (int i = -holeRadius - 3; i < holeRadius + 3; i++)
19 {
20 for (int j = description.Surface[i + position.X]; j <= description.Hive.Top + 10; j++)
21 {
22 double value = (double)(j - description.Surface[i + position.X]) / (double)(description.Hive.Top - description.Desert.Top);
23 value = Utils.Clamp(value, 0.0, 1.0);
24 int num = (int)(GetHoleRadiusScaleAt(value) * (double)holeRadius);
25 if (Math.Abs(i) < num)
26 {
27 Main.tile[i + position.X, j].ClearEverything();
28 }
29 else if (Math.Abs(i) < num + 3 && value > 0.35)
30 {
31 Main.tile[i + position.X, j].ResetToType(397);
32 }
33 double num2 = Math.Abs((double)i / (double)holeRadius);
34 num2 *= num2;
35 if (Math.Abs(i) < num + 3 && (double)(j - position.Y) > 15.0 - 3.0 * num2)
36 {
37 Main.tile[i + position.X, j].wall = 187;
38 WorldGen.SquareWallFrame(i + position.X, j - 1);
39 WorldGen.SquareWallFrame(i + position.X, j);
40 }
41 }
42 }
43 holeRadius += 4;
44 for (int k = -holeRadius; k < holeRadius; k++)
45 {
46 int num3 = holeRadius - Math.Abs(k);
47 num3 = Math.Min(10, num3 * num3);
48 for (int l = 0; l < num3; l++)
49 {
50 Main.tile[k + position.X, l + description.Surface[k + position.X]].ClearEverything();
51 }
52 }
53 }
54
55 private static double GetHoleRadiusScaleAt(double yProgress)
56 {
57 if (yProgress < 0.6)
58 {
59 return 1.0;
60 }
61 return (1.0 - SmootherStep((yProgress - 0.6) / 0.4)) * 0.5 + 0.5;
62 }
63
64 private static double SmootherStep(double delta)
65 {
66 delta = Utils.Clamp(delta, 0.0, 1.0);
67 return 1.0 - Math.Cos(delta * 3.1415927410125732) * 0.5 - 0.5;
68 }
69}
static double Cos(double d)
static byte Min(byte val1, byte val2)
Definition Math.cs:912
static double Abs(double value)
static void PlaceAt(DesertDescription description, Point position, int holeRadius)
static void Place(DesertDescription description)
Definition PitEntrance.cs:8
static double SmootherStep(double delta)
static double GetHoleRadiusScaleAt(double yProgress)
static Tile[,] tile
Definition Main.cs:1675
static UnifiedRandom genRand
Definition WorldGen.cs:1215
static void SquareWallFrame(int i, int j, bool resetFrame=true)