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

◆ Lock()

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

Locks an unlocked chest.

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

Definition at line 645 of file Chest.cs.

646 {
647 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)
648 {
649 return false;
650 }
651 short num = 0;
652 Tile tileSafely = Framing.GetTileSafely(X, Y);
653 int type = tileSafely.type;
654 int num2 = tileSafely.frameX / 36;
655 if (Main.tile[X, Y].type >= TileID.Count)
656 {
657 num = 36;
658 bool manual = false;
659 if (!TileLoader.LockChest(X, Y, Main.tile[X, Y].type, ref num, ref manual))
660 {
661 return false;
662 }
663 if (manual)
664 {
665 return true;
666 }
667 }
668 else
669 {
670 switch (type)
671 {
672 case 21:
673 switch (num2)
674 {
675 case 1:
676 num = 36;
677 break;
678 case 3:
679 num = 36;
680 break;
681 case 18:
682 case 19:
683 case 20:
684 case 21:
685 case 22:
686 if (!NPC.downedPlantBoss)
687 {
688 return false;
689 }
690 num = 180;
691 break;
692 case 35:
693 case 37:
694 case 39:
695 num = 36;
696 break;
697 default:
698 return false;
699 }
700 break;
701 case 467:
702 if (num2 == 12)
703 {
704 if (!NPC.downedPlantBoss)
705 {
706 return false;
707 }
708 num = 36;
710 break;
711 }
712 return false;
713 }
714 }
715 SoundEngine.PlaySound(22, X * 16, Y * 16);
716 for (int i = X; i <= X + 1; i++)
717 {
718 for (int j = Y; j <= Y + 1; j++)
719 {
720 Tile tileSafely2 = Framing.GetTileSafely(i, j);
721 if (tileSafely2.type == type)
722 {
723 tileSafely2.frameX += num;
724 }
725 }
726 }
727 return true;
728 }
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 LockChest(int i, int j, int type, ref short frameXAdjustment, 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.ModLoader.TileLoader.LockChest(), Terraria.GameContent.Achievements.AchievementsHelper.NotifyProgressionEvent(), Terraria.Audio.SoundEngine.PlaySound(), and Terraria.Main.tile.

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

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