Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
CaptureBiome.cs
Go to the documentation of this file.
2
3public class CaptureBiome
4{
5 public enum TileColorStyle
6 {
7 Normal,
8 Jungle,
10 Corrupt,
12 }
13
14 public class Sets
15 {
16 public class WaterStyles
17 {
18 public const int BloodMoon = 9;
19 }
20 }
21
22 public class Styles
23 {
24 public static CaptureBiome Purity = new CaptureBiome(0, 0);
25
26 public static CaptureBiome Purity2 = new CaptureBiome(10, 0);
27
28 public static CaptureBiome Purity3 = new CaptureBiome(11, 0);
29
30 public static CaptureBiome Purity4 = new CaptureBiome(12, 0);
31
32 public static CaptureBiome Corruption = new CaptureBiome(1, 2, TileColorStyle.Corrupt);
33
34 public static CaptureBiome Jungle = new CaptureBiome(3, 3, TileColorStyle.Jungle);
35
36 public static CaptureBiome Hallow = new CaptureBiome(6, 4);
37
38 public static CaptureBiome Snow = new CaptureBiome(7, 5);
39
40 public static CaptureBiome Desert = new CaptureBiome(2, 6);
41
42 public static CaptureBiome DirtLayer = new CaptureBiome(0, 7);
43
44 public static CaptureBiome RockLayer = new CaptureBiome(0, 8);
45
46 public static CaptureBiome BloodMoon = new CaptureBiome(0, 9);
47
48 public static CaptureBiome Crimson = new CaptureBiome(8, 10, TileColorStyle.Crimson);
49
50 public static CaptureBiome UndergroundDesert = new CaptureBiome(2, 12);
51
52 public static CaptureBiome Ocean = new CaptureBiome(4, 13);
53
54 public static CaptureBiome Mushroom = new CaptureBiome(9, 7, TileColorStyle.Mushroom);
55 }
56
57 private enum BiomeChoiceIndex
58 {
60 Purity = 1,
61 Corruption = 2,
62 Jungle = 3,
63 Hallow = 4,
64 Snow = 5,
65 Desert = 6,
66 DirtLayer = 7,
67 RockLayer = 8,
68 Crimson = 9,
70 Ocean = 11,
71 Mushroom = 12
72 }
73
74 public static readonly CaptureBiome DefaultPurity = new CaptureBiome(0, 0);
75
77 {
78 null,
79 null,
89 null,
92 Styles.Mushroom
93 };
94
95 public readonly int WaterStyle;
96
97 public readonly int BackgroundIndex;
98
99 public readonly TileColorStyle TileColor;
100
101 public CaptureBiome(int backgroundIndex, int waterStyle, TileColorStyle tileColorStyle = TileColorStyle.Normal)
102 {
103 BackgroundIndex = backgroundIndex;
104 WaterStyle = waterStyle;
105 TileColor = tileColorStyle;
106 }
107
108 public static CaptureBiome GetCaptureBiome(int biomeChoice)
109 {
110 switch ((BiomeChoiceIndex)biomeChoice)
111 {
112 case BiomeChoiceIndex.Purity:
113 return GetPurityForPlayer();
114 case BiomeChoiceIndex.Corruption:
115 return Styles.Corruption;
116 case BiomeChoiceIndex.Jungle:
117 return Styles.Jungle;
118 case BiomeChoiceIndex.Hallow:
119 return Styles.Hallow;
120 case BiomeChoiceIndex.Snow:
121 return Styles.Snow;
122 case BiomeChoiceIndex.Desert:
123 return Styles.Desert;
124 case BiomeChoiceIndex.DirtLayer:
125 return Styles.DirtLayer;
126 case BiomeChoiceIndex.RockLayer:
127 return Styles.RockLayer;
128 case BiomeChoiceIndex.Crimson:
129 return Styles.Crimson;
130 case BiomeChoiceIndex.UndergroundDesert:
132 case BiomeChoiceIndex.Ocean:
133 return Styles.Ocean;
134 case BiomeChoiceIndex.Mushroom:
135 return Styles.Mushroom;
136 default:
137 {
138 CaptureBiome biomeByLocation = GetBiomeByLocation();
139 if (biomeByLocation != null)
140 {
141 return biomeByLocation;
142 }
143 CaptureBiome biomeByWater = GetBiomeByWater();
144 if (biomeByWater != null)
145 {
146 return biomeByWater;
147 }
148 return GetPurityForPlayer();
149 }
150 }
151 }
152
154 {
155 int num = Main.CalculateWaterStyle(ignoreFountains: true);
156 for (int i = 0; i < BiomesByWaterStyle.Length; i++)
157 {
158 CaptureBiome captureBiome = BiomesByWaterStyle[i];
159 if (captureBiome != null && captureBiome.WaterStyle == num)
160 {
161 return captureBiome;
162 }
163 }
164 return null;
165 }
166
168 {
169 return Main.GetPreferredBGStyleForPlayer() switch
170 {
171 0 => Styles.Purity,
172 10 => Styles.Purity2,
173 11 => Styles.Purity3,
174 12 => Styles.Purity4,
175 1 => Styles.Corruption,
176 2 => Styles.Desert,
177 3 => Styles.Jungle,
178 4 => Styles.Ocean,
179 5 => Styles.Desert,
180 6 => Styles.Hallow,
181 7 => Styles.Snow,
182 8 => Styles.Crimson,
183 9 => Styles.Mushroom,
184 _ => null,
185 };
186 }
187
189 {
190 int num = (int)Main.LocalPlayer.Center.X / 16;
191 if (num < Main.treeX[0])
192 {
193 return Styles.Purity;
194 }
195 if (num < Main.treeX[1])
196 {
197 return Styles.Purity2;
198 }
199 if (num < Main.treeX[2])
200 {
201 return Styles.Purity3;
202 }
203 return Styles.Purity4;
204 }
205}
static readonly CaptureBiome DefaultPurity
static CaptureBiome GetCaptureBiome(int biomeChoice)
static CaptureBiome[] BiomesByWaterStyle
static CaptureBiome GetBiomeByLocation()
static CaptureBiome GetPurityForPlayer()
readonly TileColorStyle TileColor
CaptureBiome(int backgroundIndex, int waterStyle, TileColorStyle tileColorStyle=TileColorStyle.Normal)
static int[] treeX
Definition Main.cs:668
static int CalculateWaterStyle(bool ignoreFountains=false)
Definition Main.cs:54160
static int GetPreferredBGStyleForPlayer()
Definition Main.cs:61005
static Player LocalPlayer
Definition Main.cs:2829