Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
SceneMetrics.cs
Go to the documentation of this file.
1using System;
4using Terraria.ID;
6
7namespace Terraria;
8
9public class SceneMetrics
10{
11 public static int ShimmerTileThreshold = 300;
12
13 public static int CorruptionTileThreshold = 300;
14
15 public static int CorruptionTileMax = 1000;
16
17 public static int CrimsonTileThreshold = 300;
18
19 public static int CrimsonTileMax = 1000;
20
21 public static int HallowTileThreshold = 125;
22
23 public static int HallowTileMax = 600;
24
25 public static int JungleTileThreshold = 140;
26
27 public static int JungleTileMax = 700;
28
29 public static int SnowTileThreshold = 1500;
30
31 public static int SnowTileMax = 6000;
32
33 public static int DesertTileThreshold = 1500;
34
35 public static int MushroomTileThreshold = 100;
36
37 public static int MushroomTileMax = 160;
38
39 public static int MeteorTileThreshold = 75;
40
41 public static int GraveyardTileMax = 36;
42
43 public static int GraveyardTileMin = 16;
44
45 public static int GraveyardTileThreshold = 28;
46
47 public bool CanPlayCreditsRoll;
48
49 public bool[] NPCBannerBuff = new bool[290];
50
51 public bool hasBanner;
52
53 private readonly int[] _tileCounts = new int[TileID.Count];
54
55 private readonly int[] _liquidCounts = new int[LiquidID.Count];
56
57 private readonly List<Point> _oreFinderTileLocations = new List<Point>(512);
58
59 public int bestOre;
60
61 public Point? ClosestOrePosition { get; private set; }
62
63 public int ShimmerTileCount { get; set; }
64
65 public int EvilTileCount { get; set; }
66
67 public int HolyTileCount { get; set; }
68
69 public int HoneyBlockCount { get; set; }
70
71 public int ActiveMusicBox { get; set; }
72
73 public int SandTileCount { get; private set; }
74
75 public int MushroomTileCount { get; private set; }
76
77 public int SnowTileCount { get; private set; }
78
79 public int WaterCandleCount { get; private set; }
80
81 public int PeaceCandleCount { get; private set; }
82
83 public int ShadowCandleCount { get; private set; }
84
85 public int PartyMonolithCount { get; private set; }
86
87 public int MeteorTileCount { get; private set; }
88
89 public int BloodTileCount { get; private set; }
90
91 public int JungleTileCount { get; private set; }
92
93 public int DungeonTileCount { get; private set; }
94
95 public bool HasSunflower { get; private set; }
96
97 public bool HasGardenGnome { get; private set; }
98
99 public bool HasClock { get; private set; }
100
101 public bool HasCampfire { get; private set; }
102
103 public bool HasStarInBottle { get; private set; }
104
105 public bool HasHeartLantern { get; private set; }
106
107 public int ActiveFountainColor { get; private set; }
108
109 public int ActiveMonolithType { get; private set; }
110
111 public bool BloodMoonMonolith { get; private set; }
112
113 public bool MoonLordMonolith { get; private set; }
114
115 public bool EchoMonolith { get; private set; }
116
117 public int ShimmerMonolithState { get; private set; }
118
119 public bool HasCatBast { get; private set; }
120
121 public int GraveyardTileCount { get; private set; }
122
124
126
128
130
132
134
136
138
140
142
144 {
145 Reset();
146 }
147
149 {
150 Reset();
151 int num = 0;
152 int num2 = 0;
153 int num3 = 0;
154 if (settings.ScanOreFinderData)
155 {
157 }
158 if (settings.BiomeScanCenterPositionInWorld.HasValue)
159 {
160 Point point = settings.BiomeScanCenterPositionInWorld.Value.ToTileCoordinates();
163 for (int i = tileRectangle.Left; i < tileRectangle.Right; i++)
164 {
165 for (int j = tileRectangle.Top; j < tileRectangle.Bottom; j++)
166 {
167 if (!tileRectangle.Contains(i, j))
168 {
169 continue;
170 }
171 Tile tile = Main.tile[i, j];
172 if (tile == null)
173 {
174 continue;
175 }
176 if (!tile.active())
177 {
178 if (tile.liquid > 0)
179 {
180 _liquidCounts[tile.liquidType()]++;
181 }
182 continue;
183 }
186 {
187 _tileCounts[tile.type]++;
188 }
189 if (tile.type == 215 && tile.frameY < 36)
190 {
191 HasCampfire = true;
192 }
193 if (tile.type == 49 && tile.frameX < 18)
194 {
195 num++;
196 }
197 if (tile.type == 372 && tile.frameX < 18)
198 {
199 num2++;
200 }
201 if (tile.type == 646 && tile.frameX < 18)
202 {
203 num3++;
204 }
205 if (tile.type == 405 && tile.frameX < 54)
206 {
207 HasCampfire = true;
208 }
209 if (tile.type == 506 && tile.frameX < 72)
210 {
211 HasCatBast = true;
212 }
213 if (tile.type == 42 && tile.frameY >= 324 && tile.frameY <= 358)
214 {
215 HasHeartLantern = true;
216 }
217 if (tile.type == 42 && tile.frameY >= 252 && tile.frameY <= 286)
218 {
219 HasStarInBottle = true;
220 }
221 if (tile.type == 91 && (tile.frameX >= 396 || tile.frameY >= 54))
222 {
223 int num4 = tile.frameX / 18 - 21;
224 for (int num5 = tile.frameY; num5 >= 54; num5 -= 54)
225 {
226 num4 += 90;
227 num4 += 21;
228 }
229 int num6 = Item.BannerToItem(num4);
230 if (ItemID.Sets.BannerStrength.IndexInRange(num6) && ItemID.Sets.BannerStrength[num6].Enabled)
231 {
232 NPCBannerBuff[num4] = true;
233 hasBanner = true;
234 }
235 }
236 if (settings.ScanOreFinderData && Main.tileOreFinderPriority[tile.type] != 0)
237 {
239 }
240 }
241 }
242 }
243 if (settings.VisualScanArea.HasValue)
244 {
246 for (int k = rectangle.Left; k < rectangle.Right; k++)
247 {
248 for (int l = rectangle.Top; l < rectangle.Bottom; l++)
249 {
250 Tile tile2 = Main.tile[k, l];
251 if (tile2 == null || !tile2.active())
252 {
253 continue;
254 }
255 if (tile2.type == 104)
256 {
257 HasClock = true;
258 }
259 switch (tile2.type)
260 {
261 case 139:
262 if (tile2.frameX >= 36)
263 {
264 ActiveMusicBox = tile2.frameY / 36;
265 }
266 break;
267 case 207:
268 if (tile2.frameY >= 72)
269 {
270 switch (tile2.frameX / 36)
271 {
272 case 0:
274 break;
275 case 1:
277 break;
278 case 2:
280 break;
281 case 3:
283 break;
284 case 4:
286 break;
287 case 5:
289 break;
290 case 6:
292 break;
293 case 7:
295 break;
296 case 8:
298 break;
299 case 9:
301 break;
302 default:
304 break;
305 }
306 }
307 break;
308 case 410:
309 if (tile2.frameY >= 56)
310 {
311 int activeMonolithType = tile2.frameX / 36;
313 }
314 break;
315 case 509:
316 if (tile2.frameY >= 56)
317 {
319 }
320 break;
321 case 480:
322 if (tile2.frameY >= 54)
323 {
324 BloodMoonMonolith = true;
325 }
326 break;
327 case 657:
328 if (tile2.frameY >= 54)
329 {
330 EchoMonolith = true;
331 }
332 break;
333 case 658:
334 {
335 int shimmerMonolithState = tile2.frameY / 54;
337 break;
338 }
339 }
340 }
341 }
342 }
343 WaterCandleCount = num;
348 if (settings.ScanOreFinderData)
349 {
351 }
352 }
353
355 {
356 if (_tileCounts[27] > 0)
357 {
358 HasSunflower = true;
359 }
360 if (_tileCounts[567] > 0)
361 {
362 HasGardenGnome = true;
363 }
366 HolyTileCount = _tileCounts[109] + _tileCounts[492] + _tileCounts[110] + _tileCounts[113] + _tileCounts[117] + _tileCounts[116] + _tileCounts[164] + _tileCounts[403] + _tileCounts[402];
367 SnowTileCount = _tileCounts[147] + _tileCounts[148] + _tileCounts[161] + _tileCounts[162] + _tileCounts[164] + _tileCounts[163] + _tileCounts[200];
368 if (Main.remixWorld)
369 {
371 EvilTileCount = _tileCounts[23] + _tileCounts[661] + _tileCounts[24] + _tileCounts[25] + _tileCounts[32] + _tileCounts[112] + _tileCounts[163] + _tileCounts[400] + _tileCounts[398] + -10 * _tileCounts[27] + _tileCounts[474];
372 BloodTileCount = _tileCounts[199] + _tileCounts[662] + _tileCounts[203] + _tileCounts[200] + _tileCounts[401] + _tileCounts[399] + _tileCounts[234] + _tileCounts[352] - 10 * _tileCounts[27] + _tileCounts[195];
373 }
374 else
375 {
377 EvilTileCount = _tileCounts[23] + _tileCounts[661] + _tileCounts[24] + _tileCounts[25] + _tileCounts[32] + _tileCounts[112] + _tileCounts[163] + _tileCounts[400] + _tileCounts[398] + -10 * _tileCounts[27];
378 BloodTileCount = _tileCounts[199] + _tileCounts[662] + _tileCounts[203] + _tileCounts[200] + _tileCounts[401] + _tileCounts[399] + _tileCounts[234] + _tileCounts[352] - 10 * _tileCounts[27];
379 }
383 SandTileCount = _tileCounts[53] + _tileCounts[112] + _tileCounts[116] + _tileCounts[234] + _tileCounts[397] + _tileCounts[398] + _tileCounts[402] + _tileCounts[399] + _tileCounts[396] + _tileCounts[400] + _tileCounts[403] + _tileCounts[401];
387 if (_tileCounts[27] > 0)
388 {
389 HasSunflower = true;
390 }
392 {
393 HasSunflower = false;
394 }
395 if (GraveyardTileCount < 0)
396 {
398 }
399 if (HolyTileCount < 0)
400 {
401 HolyTileCount = 0;
402 }
403 if (EvilTileCount < 0)
404 {
405 EvilTileCount = 0;
406 }
407 if (BloodTileCount < 0)
408 {
409 BloodTileCount = 0;
410 }
416 if (HolyTileCount < 0)
417 {
418 HolyTileCount = 0;
419 }
420 if (EvilTileCount < 0)
421 {
422 EvilTileCount = 0;
423 }
424 if (BloodTileCount < 0)
425 {
426 BloodTileCount = 0;
427 }
428 }
429
430 public int GetTileCount(ushort tileId)
431 {
432 return _tileCounts[tileId];
433 }
434
435 public void Reset()
436 {
439 SandTileCount = 0;
440 EvilTileCount = 0;
441 BloodTileCount = 0;
444 SnowTileCount = 0;
445 HolyTileCount = 0;
446 MeteorTileCount = 0;
447 JungleTileCount = 0;
449 HasCampfire = false;
450 HasSunflower = false;
451 HasGardenGnome = false;
452 HasStarInBottle = false;
453 HasHeartLantern = false;
454 HasClock = false;
455 HasCatBast = false;
456 ActiveMusicBox = -1;
460 bestOre = -1;
461 BloodMoonMonolith = false;
462 MoonLordMonolith = false;
463 EchoMonolith = false;
466 hasBanner = false;
467 CanPlayCreditsRoll = false;
468 }
469
470 private void UpdateOreFinderData()
471 {
472 int num = -1;
474 {
476 if (IsValidForOreFinder(tile) && (num < 0 || Main.tileOreFinderPriority[tile.type] > Main.tileOreFinderPriority[num]))
477 {
478 num = tile.type;
480 }
481 }
482 bestOre = num;
483 }
484
485 public static bool IsValidForOreFinder(Tile t)
486 {
487 if (t.type == 227 && (t.frameX < 272 || t.frameX > 374))
488 {
489 return false;
490 }
491 if (t.type == 129 && t.frameX < 324)
492 {
493 return false;
494 }
495 return Main.tileOreFinderPriority[t.type] > 0;
496 }
497}
static unsafe void Clear(Array array)
Definition Array.cs:755
bool ICollection< KeyValuePair< TKey, TValue > >. Contains(KeyValuePair< TKey, TValue > keyValuePair)
static BannerEffect[] BannerStrength
Definition ItemID.cs:1018
static readonly short Count
Definition LiquidID.cs:13
static bool[] isDesertBiomeSand
Definition TileID.cs:119
static readonly ushort Count
Definition TileID.cs:1698
static int BannerToItem(int banner)
Definition Item.cs:1246
static int buffScanAreaWidth
Definition Main.cs:764
static short[] tileOreFinderPriority
Definition Main.cs:1475
static Tile[,] tile
Definition Main.cs:1675
static int buffScanAreaHeight
Definition Main.cs:766
static bool remixWorld
Definition Main.cs:349
static int MushroomTileThreshold
static int MushroomTileMax
static int JungleTileThreshold
static int CrimsonTileMax
static int MeteorTileThreshold
static int HallowTileThreshold
static int ShimmerTileThreshold
void ScanAndExportToMain(SceneMetricsScanSettings settings)
static int CorruptionTileThreshold
static int GraveyardTileThreshold
static int SnowTileThreshold
static int CorruptionTileMax
readonly int[] _liquidCounts
readonly List< Point > _oreFinderTileLocations
static int DesertTileThreshold
static int CrimsonTileThreshold
int GetTileCount(ushort tileId)
static bool IsValidForOreFinder(Tile t)
readonly int[] _tileCounts
static int GraveyardTileMin
static int GraveyardTileMax
void liquidType(int liquidType)
Definition Tile.cs:233
byte liquid
Definition Tile.cs:12
short frameY
Definition Tile.cs:24
ushort type
Definition Tile.cs:8
short frameX
Definition Tile.cs:22
bool active()
Definition Tile.cs:565
static Rectangle ClampToWorld(Rectangle tileRectangle)
Definition WorldUtils.cs:8
static bool oceanDepths(int x, int y)
Definition WorldGen.cs:7142