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

◆ Unlock()

static bool Terraria.Chest.Unlock ( int X,
int Y )
inlinestatic

Unlocks a locked chest.

Parameters
XThe x-coordinate of the locked chest, in tile coordinates.
YThe y-coordinate of the locked chest, in tile coordinates.
Returns
true if the chest successfully unlocked, false otherwise.

Definition at line 537 of file Chest.cs.

538 {
539 //IL_01dc: Unknown result type (might be due to invalid IL or missing references)
540 //IL_01f3: Unknown result type (might be due to invalid IL or missing references)
541 //IL_01f9: Unknown result type (might be due to invalid IL or missing references)
542 if (Main.tile[X, Y] == null || Main.tile[X + 1, Y] == null || Main.tile[X, Y + 1] == null || Main.tile[X + 1, Y + 1] == null)
543 {
544 return false;
545 }
546 short num = 0;
547 int type = 0;
548 Tile tileSafely = Framing.GetTileSafely(X, Y);
549 int type2 = tileSafely.type;
550 int num2 = tileSafely.frameX / 36;
551 if (Main.tile[X, Y].type >= TileID.Count)
552 {
553 num = -36;
554 type = 11;
555 bool manual = false;
556 if (!TileLoader.UnlockChest(X, Y, Main.tile[X, Y].type, ref num, ref type, ref manual))
557 {
558 return false;
559 }
560 if (manual)
561 {
562 return true;
563 }
564 num *= -1;
565 }
566 else
567 {
568 switch (type2)
569 {
570 case 21:
571 switch (num2)
572 {
573 case 2:
574 num = 36;
575 type = 11;
577 break;
578 case 4:
579 num = 36;
580 type = 11;
581 break;
582 case 23:
583 case 24:
584 case 25:
585 case 26:
586 case 27:
587 if (!NPC.downedPlantBoss)
588 {
589 return false;
590 }
591 num = 180;
592 type = 11;
594 break;
595 case 36:
596 case 38:
597 case 40:
598 num = 36;
599 type = 11;
600 break;
601 default:
602 return false;
603 }
604 break;
605 case 467:
606 if (num2 == 13)
607 {
608 if (!NPC.downedPlantBoss)
609 {
610 return false;
611 }
612 num = 36;
613 type = 11;
615 break;
616 }
617 return false;
618 }
619 }
620 SoundEngine.PlaySound(22, X * 16, Y * 16);
621 for (int i = X; i <= X + 1; i++)
622 {
623 for (int j = Y; j <= Y + 1; j++)
624 {
625 Tile tileSafely2 = Framing.GetTileSafely(i, j);
626 if (tileSafely2.type == type2)
627 {
628 tileSafely2.frameX -= num;
629 for (int k = 0; k < 4; k++)
630 {
631 Dust.NewDust(new Vector2((float)(i * 16), (float)(j * 16)), 16, 16, type);
632 }
633 }
634 }
635 }
636 return true;
637 }
static SlotId PlaySound(in SoundStyle? style, Vector2? position=null, SoundUpdateCallback? updateCallback=null)
Attempts to play a sound style with the provided sound style (if it's not null), and returns a valid ...
static readonly ushort Count
Definition TileID.cs:1928
static bool UnlockChest(int i, int j, int type, ref short frameXAdjustment, ref int dustType, ref bool manual)
This serves as the central class from which tile-related functions are supported and carried out.
Definition TileLoader.cs:23

References Terraria.ID.TileID.Count, Terraria.NPC.downedPlantBoss, Terraria.Framing.GetTileSafely(), Terraria.Dust.NewDust(), Terraria.GameContent.Achievements.AchievementsHelper.NotifyProgressionEvent(), Terraria.Audio.SoundEngine.PlaySound(), Terraria.Main.tile, and Terraria.ModLoader.TileLoader.UnlockChest().

Referenced by Terraria.MessageBuffer.GetData(), and Terraria.Player.TileInteractionsUse().

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