TModLoader v1.4.4.9
TModLoader source code documentation
Loading...
Searching...
No Matches

◆ UpdateAudio_DecideOnTOWMusic()

void Terraria.Main.UpdateAudio_DecideOnTOWMusic ( )
inlineprivate

Definition at line 11163 of file Main.cs.

11164 {
11165 //IL_046c: Unknown result type (might be due to invalid IL or missing references)
11166 //IL_08ce: Unknown result type (might be due to invalid IL or missing references)
11167 //IL_0906: Unknown result type (might be due to invalid IL or missing references)
11168 //IL_09d3: Unknown result type (might be due to invalid IL or missing references)
11169 //IL_09ef: Unknown result type (might be due to invalid IL or missing references)
11170 bool flag = false;
11171 bool flag10 = false;
11172 bool flag11 = false;
11173 bool flag12 = false;
11174 bool flag13 = false;
11175 bool flag14 = false;
11176 bool flag15 = false;
11177 bool flag16 = false;
11178 bool flag17 = false;
11179 bool flag2 = false;
11180 bool flag3 = false;
11181 bool flag4 = false;
11182 bool flag5 = false;
11183 bool flag6 = false;
11184 bool flag7 = false;
11185 bool flag8 = false;
11186 bool flag9 = false;
11187 int modMusic = -1;
11189 if (!gameMenu)
11190 {
11191 Rectangle rectangle = default(Rectangle);
11193 int num = 5000;
11194 Rectangle value = default(Rectangle);
11195 for (int i = 0; i < 200; i++)
11196 {
11197 if (!npc[i].active)
11198 {
11199 continue;
11200 }
11201 num = 5000;
11202 int num2 = 0;
11203 switch (npc[i].type)
11204 {
11205 case 13:
11206 case 14:
11207 case 15:
11208 num2 = 1;
11209 break;
11210 case 26:
11211 case 27:
11212 case 28:
11213 case 29:
11214 case 111:
11215 case 471:
11216 num2 = 11;
11217 break;
11218 case 113:
11219 case 114:
11220 num2 = 3;
11221 break;
11222 case 125:
11223 case 126:
11224 num2 = 2;
11225 break;
11226 case 127:
11227 case 134:
11228 num2 = 2;
11229 break;
11230 case 143:
11231 case 144:
11232 case 145:
11233 num2 = 11;
11234 break;
11235 case 266:
11236 num2 = 1;
11237 break;
11238 case 212:
11239 case 213:
11240 case 214:
11241 case 215:
11242 case 216:
11243 case 491:
11244 num2 = 8;
11245 break;
11246 case 245:
11247 num2 = 2;
11248 break;
11249 case 222:
11250 num2 = 1;
11251 break;
11252 case 262:
11253 case 263:
11254 case 264:
11255 num2 = 6;
11256 break;
11257 case 381:
11258 case 382:
11259 case 383:
11260 case 385:
11261 case 386:
11262 case 388:
11263 case 389:
11264 case 390:
11265 case 391:
11266 case 395:
11267 case 520:
11268 num2 = 9;
11269 break;
11270 case 398:
11271 num2 = 7;
11272 break;
11273 case 422:
11274 case 493:
11275 case 507:
11276 case 517:
11277 num2 = 10;
11278 break;
11279 case 439:
11280 num2 = 2;
11281 break;
11282 case 438:
11283 if (npc[i].ai[1] == 1f)
11284 {
11285 num = 1600;
11286 num2 = 2;
11287 }
11288 break;
11289 case 657:
11290 num2 = 13;
11291 break;
11292 case 636:
11293 num2 = 14;
11294 break;
11295 case 370:
11296 num2 = 15;
11297 break;
11298 case 668:
11299 num2 = 16;
11300 break;
11301 }
11303 {
11304 num2 = 12;
11305 }
11306 if (remixWorld && getGoodWorld && (npc[i].type == 127 || npc[i].type == 134 || npc[i].type == 125 || npc[i].type == 126))
11307 {
11308 num2 = 17;
11309 }
11310 if (num2 == 0 && npc[i].boss)
11311 {
11312 num2 = 1;
11313 }
11314 if (num2 == 0 && (npc[i].ModNPC == null || npc[i].ModNPC.Music < 0))
11315 {
11316 continue;
11317 }
11318 ((Rectangle)(ref value))._002Ector((int)(npc[i].position.X + (float)(npc[i].width / 2)) - num, (int)(npc[i].position.Y + (float)(npc[i].height / 2)) - num, num * 2, num * 2);
11319 if (((Rectangle)(ref rectangle)).Intersects(value))
11320 {
11321 if (npc[i].ModNPC != null && npc[i].ModNPC.Music >= 0 && (modMusic < 0 || npc[i].ModNPC.SceneEffectPriority > modPriority))
11322 {
11323 modMusic = npc[i].ModNPC.Music;
11324 modPriority = npc[i].ModNPC.SceneEffectPriority;
11325 }
11326 switch (num2)
11327 {
11328 case 1:
11329 flag = true;
11330 break;
11331 case 2:
11332 flag11 = true;
11333 break;
11334 case 3:
11335 flag12 = true;
11336 break;
11337 case 4:
11338 flag13 = true;
11339 break;
11340 case 5:
11341 flag14 = true;
11342 break;
11343 case 6:
11344 flag15 = true;
11345 break;
11346 case 7:
11347 flag16 = true;
11348 break;
11349 case 8:
11350 flag17 = true;
11351 break;
11352 case 9:
11353 flag2 = true;
11354 break;
11355 case 10:
11356 flag3 = true;
11357 break;
11358 case 11:
11359 flag4 = true;
11360 break;
11361 case 12:
11362 flag5 = true;
11363 break;
11364 case 13:
11365 flag6 = true;
11366 break;
11367 case 14:
11368 flag7 = true;
11369 break;
11370 case 15:
11371 flag8 = true;
11372 break;
11373 case 16:
11374 flag10 = true;
11375 break;
11376 case 17:
11377 flag9 = true;
11378 break;
11379 }
11380 }
11381 }
11383 }
11384 _ = (screenPosition.X + (float)(screenWidth / 2)) / 16f;
11385 if (musicVolume == 0f)
11386 {
11387 newMusic = 0;
11388 return;
11389 }
11390 float num3 = (float)maxTilesX / 4200f;
11391 num3 *= num3;
11392 float num4 = (float)((double)((screenPosition.Y + (float)(screenHeight / 2)) / 16f - (65f + 10f * num3)) / (worldSurface / 5.0));
11394 {
11395 newMusic = 89;
11396 }
11397 else if (modPriority >= SceneEffectPriority.BossHigh)
11398 {
11400 }
11401 else if (player[myPlayer].happyFunTorchTime)
11402 {
11403 newMusic = 87;
11404 }
11405 else if (flag16)
11406 {
11407 newMusic = 84;
11408 }
11409 else if (modPriority >= SceneEffectPriority.BossMedium)
11410 {
11412 }
11413 else if (flag9)
11414 {
11415 newMusic = 81;
11416 }
11417 else if (flag2)
11418 {
11419 newMusic = 82;
11420 }
11421 else if (flag3)
11422 {
11423 newMusic = 83;
11424 }
11425 else if (flag15)
11426 {
11427 newMusic = 85;
11428 }
11429 else if (modPriority >= SceneEffectPriority.BossLow)
11430 {
11432 }
11433 else if (flag7)
11434 {
11435 newMusic = 80;
11436 }
11437 else if (flag8)
11438 {
11439 newMusic = 80;
11440 }
11441 else if (flag11)
11442 {
11443 newMusic = 80;
11444 }
11445 else if (flag)
11446 {
11447 newMusic = 81;
11448 }
11449 else if (flag12)
11450 {
11451 newMusic = 87;
11452 }
11453 else if (flag13)
11454 {
11455 newMusic = 81;
11456 }
11457 else if (flag14)
11458 {
11459 newMusic = 81;
11460 }
11461 else if (flag6)
11462 {
11463 newMusic = 80;
11464 }
11465 else if (flag10)
11466 {
11467 newMusic = 80;
11468 }
11469 else if (modPriority >= SceneEffectPriority.Event)
11470 {
11472 }
11473 else if (flag17)
11474 {
11475 newMusic = 82;
11476 }
11477 else if (flag4)
11478 {
11479 newMusic = 82;
11480 }
11481 else if (flag5)
11482 {
11483 newMusic = 82;
11484 }
11485 else if (modPriority >= SceneEffectPriority.Environment)
11486 {
11488 }
11489 else if (eclipse && (double)player[myPlayer].position.Y < worldSurface * 16.0 + (double)(screenHeight / 2))
11490 {
11491 newMusic = 79;
11492 }
11493 else if (eclipse && remixWorld)
11494 {
11495 newMusic = 79;
11496 }
11497 else if (remixWorld && bloodMoon && !player[myPlayer].ZoneCrimson && !player[myPlayer].ZoneCorrupt && (double)player[myPlayer].position.Y > rockLayer * 16.0 && player[myPlayer].position.Y <= (float)(UnderworldLayer * 16))
11498 {
11499 newMusic = 79;
11500 }
11501 else if (remixWorld && bloodMoon && player[myPlayer].position.Y > (float)(UnderworldLayer * 16) && (double)(player[myPlayer].Center.X / 16f) > (double)maxTilesX * 0.37 + 50.0 && (double)(player[myPlayer].Center.X / 16f) < (double)maxTilesX * 0.63)
11502 {
11503 newMusic = 79;
11504 }
11505 else if (player[myPlayer].ZoneShimmer)
11506 {
11507 newMusic = 72;
11508 }
11509 else if (player[myPlayer].ZoneSandstorm)
11510 {
11511 newMusic = 66;
11512 }
11513 else if (player[myPlayer].position.Y > (float)(UnderworldLayer * 16))
11514 {
11515 newMusic = 71;
11516 }
11517 else if (num4 < 1f)
11518 {
11519 newMusic = 70;
11520 }
11521 else if (modPriority >= SceneEffectPriority.BiomeHigh)
11522 {
11524 }
11525 else if (tile[(int)(player[myPlayer].Center.X / 16f), (int)(player[myPlayer].Center.Y / 16f)].wall == 87)
11526 {
11527 newMusic = 69;
11528 }
11529 else if (player[myPlayer].ZoneDungeon)
11530 {
11531 newMusic = 69;
11532 }
11533 else if ((bgStyle == 9 && (double)player[myPlayer].position.Y < worldSurface * 16.0 + (double)(screenHeight / 2)) || undergroundBackground == 2)
11534 {
11535 newMusic = 68;
11536 }
11537 else if (player[myPlayer].ZoneCorrupt)
11538 {
11539 if (player[myPlayer].ZoneCrimson && SceneMetrics.BloodTileCount > SceneMetrics.EvilTileCount)
11540 {
11541 if ((double)player[myPlayer].position.Y > worldSurface * 16.0 + (double)(screenHeight / 2))
11542 {
11543 newMusic = 76;
11544 }
11545 else
11546 {
11547 newMusic = 75;
11548 }
11549 }
11550 else if ((double)player[myPlayer].position.Y > worldSurface * 16.0 + (double)(screenHeight / 2))
11551 {
11552 newMusic = 74;
11553 }
11554 else
11555 {
11556 newMusic = 73;
11557 }
11558 }
11559 else if (player[myPlayer].ZoneCrimson)
11560 {
11561 if ((double)player[myPlayer].position.Y > worldSurface * 16.0 + (double)(screenHeight / 2))
11562 {
11563 newMusic = 76;
11564 }
11565 else
11566 {
11567 newMusic = 75;
11568 }
11569 }
11570 else if (modPriority >= SceneEffectPriority.BiomeMedium)
11571 {
11573 }
11574 else if (player[myPlayer].ZoneMeteor)
11575 {
11576 newMusic = 79;
11577 }
11578 else if (player[myPlayer].ZoneGraveyard)
11579 {
11580 newMusic = 79;
11581 }
11582 else if (player[myPlayer].ZoneJungle)
11583 {
11584 if (remixWorld && (double)player[myPlayer].position.Y < worldSurface * 16.0 + (double)(screenHeight / 2))
11585 {
11586 newMusic = 70;
11587 }
11588 else
11589 {
11590 newMusic = 86;
11591 }
11592 }
11593 else if (player[myPlayer].ZoneSnow)
11594 {
11595 if (remixWorld)
11596 {
11597 if ((double)player[myPlayer].position.Y < rockLayer * 16.0 + (double)(screenHeight / 2))
11598 {
11599 if ((double)player[myPlayer].position.Y <= worldSurface * 16.0 + (double)(screenHeight / 2))
11600 {
11601 newMusic = 70;
11602 }
11603 else
11604 {
11605 newMusic = 77;
11606 }
11607 }
11608 else
11609 {
11610 newMusic = 72;
11611 }
11612 }
11613 else if ((double)player[myPlayer].position.Y > worldSurface * 16.0 + (double)(screenHeight / 2))
11614 {
11615 newMusic = 77;
11616 }
11617 else
11618 {
11619 newMusic = 72;
11620 }
11621 }
11622 else if (modPriority >= SceneEffectPriority.BiomeLow)
11623 {
11625 }
11626 else if ((double)player[myPlayer].position.Y >= worldSurface * 16.0 + (double)(screenHeight / 2) && !WorldGen.oceanDepths((int)(screenPosition.X + (float)(screenWidth / 2)) / 16, (int)(screenPosition.Y + (float)(screenHeight / 2)) / 16))
11627 {
11628 if (remixWorld && (double)player[myPlayer].position.Y >= rockLayer * 16.0 + (double)(screenHeight / 2))
11629 {
11630 if (player[myPlayer].ZoneUndergroundDesert)
11631 {
11632 newMusic = 66;
11633 }
11634 else if (cloudAlpha > 0f)
11635 {
11636 newMusic = 62;
11637 }
11638 else if (player[myPlayer].ZoneHallow)
11639 {
11640 newMusic = 88;
11641 }
11642 else if (player[myPlayer].ZoneDesert)
11643 {
11644 newMusic = 66;
11645 }
11646 else
11647 {
11648 newMusic = 62;
11649 }
11650 }
11651 else if (player[myPlayer].ZoneHallow)
11652 {
11653 newMusic = 78;
11654 }
11655 else if (player[myPlayer].ZoneUndergroundDesert)
11656 {
11657 newMusic = 66;
11658 }
11659 else
11660 {
11661 newMusic = 65;
11662 }
11663 }
11664 else if (dayTime && player[myPlayer].ZoneHallow)
11665 {
11666 if (cloudAlpha > 0f && !gameMenu)
11667 {
11668 newMusic = 62;
11669 }
11670 else
11671 {
11672 newMusic = 88;
11673 }
11674 }
11675 else if (_shouldUseStormMusic)
11676 {
11677 if (bloodMoon)
11678 {
11679 newMusic = 79;
11680 }
11681 else
11682 {
11683 newMusic = 62;
11684 }
11685 }
11686 else if (WorldGen.oceanDepths((int)(screenPosition.X + (float)(screenWidth / 2)) / 16, (int)(screenPosition.Y + (float)(screenHeight / 2)) / 16))
11687 {
11688 if (bloodMoon)
11689 {
11690 newMusic = 79;
11691 }
11692 else
11693 {
11694 newMusic = 67;
11695 }
11696 }
11697 else if (player[myPlayer].ZoneDesert)
11698 {
11699 newMusic = 66;
11700 }
11701 else if (remixWorld)
11702 {
11703 newMusic = 70;
11704 }
11705 else if (dayTime)
11706 {
11707 if (cloudAlpha > 0f && !gameMenu)
11708 {
11709 newMusic = 62;
11710 }
11711 else
11712 {
11713 newMusic = 63;
11714 }
11715 }
11716 else if (!dayTime)
11717 {
11718 if (bloodMoon)
11719 {
11720 newMusic = 79;
11721 }
11722 else if (cloudAlpha > 0f && !gameMenu)
11723 {
11724 newMusic = 64;
11725 }
11726 else
11727 {
11728 newMusic = 64;
11729 }
11730 }
11731 if (((double)(screenPosition.Y / 16f) < worldSurface + 10.0 || remixWorld) && pumpkinMoon)
11732 {
11733 newMusic = 82;
11734 }
11735 if (((double)(screenPosition.Y / 16f) < worldSurface + 10.0 || remixWorld) && snowMoon)
11736 {
11737 newMusic = 82;
11738 }
11739 }
static bool[] BelongsToInvasionOldOnesArmy
If true for a given NPC type (F:Terraria.NPC.type), then that NPC belongs to the Old One's Army event...
Definition NPCID.cs:292
static SceneMetrics SceneMetrics
Definition Main.cs:1441
static float cloudAlpha
Definition Main.cs:1393
static double worldSurface
The y-coordinate of the top of the dirt layer, in tile coordinates. Corresponds to 0' on the Depth Me...
Definition Main.cs:1351
static int myPlayer
The index in F:Terraria.Main.player of this client's Player. If this is 255, this client is the ser...
Definition Main.cs:1958
static double rockLayer
The y-coordinate of the top of the caverns layer, in tile coordinates.
Definition Main.cs:1357
static bool dayTime
Definition Main.cs:1365
static bool _shouldUseStormMusic
Definition Main.cs:2388
static bool bloodMoon
Definition Main.cs:1387
static int screenHeight
Definition Main.cs:1870
static Vector2 screenPosition
The position of the top left corner of the screen in world coordinates. Modify in M:Terraria....
Definition Main.cs:1864
static int undergroundBackground
Definition Main.cs:584
static int maxTilesX
The width of the currently-loaded world in tiles.
Definition Main.cs:1186
static bool getGoodWorld
Definition Main.cs:369
static bool eclipse
Definition Main.cs:1403
static NPC[] npc
Definition Main.cs:1830
static int newMusic
Definition Main.cs:1311
static int screenWidth
Definition Main.cs:1868
static int UnderworldLayer
The y-coordinate of the top of the underworld, in tile coordinates.
Definition Main.cs:2993
static float musicVolume
Definition Main.cs:1518
static bool snowMoon
Definition Main.cs:1391
static bool pumpkinMoon
Definition Main.cs:1389
static Tilemap tile
Definition Main.cs:1820
static bool gameMenu
Definition Main.cs:2076
static Player[] player
Definition Main.cs:1960
static int bgStyle
Definition Main.cs:877
static bool remixWorld
Definition Main.cs:377
int Music
The ID of the music that plays when this NPC is on or near the screen. Defaults to -1,...
Definition ModNPC.cs:62
This class serves as a place for you to place all your properties and hooks for each NPC....
Definition ModNPC.cs:21
This serves as the central class from which SceneEffect functions are supported and carried out.
SceneEffectPriority
This enum dictates from low to high which SceneEffect selections take priority. Setting appropriate p...

References Terraria.Main._shouldUseStormMusic, Terraria.ID.NPCID.Sets.BelongsToInvasionOldOnesArmy, Terraria.Main.bgStyle, Terraria.Main.bloodMoon, Terraria.SceneMetrics.BloodTileCount, Terraria.Main.cloudAlpha, Terraria.Main.dayTime, Terraria.Main.eclipse, Terraria.SceneMetrics.EvilTileCount, Terraria.Main.gameMenu, Terraria.Main.getGoodWorld, Terraria.GameContent.Events.CreditsRollEvent.IsEventOngoing, Terraria.Main.maxTilesX, Terraria.ModLoader.ModNPC.Music, Terraria.Main.musicVolume, Terraria.Main.myPlayer, Terraria.Main.newMusic, Terraria.Main.npc, Terraria.WorldGen.oceanDepths(), Terraria.Main.player, Terraria.Main.pumpkinMoon, Terraria.Main.remixWorld, Terraria.Main.rockLayer, Terraria.Main.screenHeight, Terraria.Main.screenPosition, Terraria.Main.screenWidth, Terraria.Main.snowMoon, Terraria.Main.tile, Terraria.Main.undergroundBackground, Terraria.Main.UnderworldLayer, and Terraria.Main.worldSurface.

Referenced by Terraria.Main.UpdateAudio().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: