Пример #1
0
        private void OpenStorage(Player player)
        {
            StoragePlayer modPlayer = player.GetModPlayer <StoragePlayer>();

            if (player.sign > -1)
            {
                Main.PlaySound(11, -1, -1, 1);
                player.sign      = -1;
                Main.editSign    = false;
                Main.npcChatText = string.Empty;
            }
            if (Main.editChest)
            {
                Main.PlaySound(12, -1, -1, 1);
                Main.editChest   = false;
                Main.npcChatText = string.Empty;
            }
            if (player.editedChestName)
            {
                NetMessage.SendData(MessageID.SyncPlayerChest, -1, -1, NetworkText.FromLiteral(Main.chest[player.chest].name), player.chest, 1f, 0f, 0f, 0, 0, 0);
                player.editedChestName = false;
            }
            if (player.talkNPC > -1)
            {
                player.talkNPC         = -1;
                Main.npcChatCornerItem = 0;
                Main.npcChatText       = string.Empty;
            }
            bool hadChestOpen = player.chest != -1;

            player.chest    = -1;
            Main.stackSplit = 600;
            Point16 toOpen   = location;
            Point16 prevOpen = modPlayer.ViewingStorage();

            if (prevOpen == toOpen)
            {
                modPlayer.CloseStorage();
                Main.PlaySound(11, -1, -1, 1);
                Recipe.FindRecipes();
            }
            else
            {
                bool hadOtherOpen = prevOpen.X >= 0 && prevOpen.Y >= 0;
                modPlayer.OpenStorage(toOpen, true);
                modPlayer.timeSinceOpen = 0;
                Main.playerInventory    = true;
                Main.recBigList         = false;
                Main.PlaySound(hadChestOpen || hadOtherOpen ? 12 : 10, -1, -1, 1);
                Recipe.FindRecipes();
            }
        }
Пример #2
0
        public override bool NewRightClick(int i, int j)
        {
            if (Main.tile[i, j].frameX % 36 == 18)
            {
                i--;
            }
            if (Main.tile[i, j].frameY % 36 == 18)
            {
                j--;
            }
            Player player = Main.player[Main.myPlayer];

            if (GetHeart(i, j) == null)
            {
                Main.NewText("This access is not connected to a Storage Heart!");
                return(true);
            }
            StoragePlayer modPlayer = player.GetModPlayer <StoragePlayer>();

            Main.mouseRightRelease = false;
            if (player.sign > -1)
            {
                Main.PlaySound(11, -1, -1, 1);
                player.sign      = -1;
                Main.editSign    = false;
                Main.npcChatText = string.Empty;
            }
            if (Main.editChest)
            {
                Main.PlaySound(12, -1, -1, 1);
                Main.editChest   = false;
                Main.npcChatText = string.Empty;
            }
            if (player.editedChestName)
            {
                NetMessage.SendData(MessageID.SyncPlayerChest, -1, -1, NetworkText.FromLiteral(Main.chest[player.chest].name), player.chest, 1f, 0f, 0f, 0, 0, 0);
                player.editedChestName = false;
            }
            if (player.talkNPC > -1)
            {
                player.talkNPC         = -1;
                Main.npcChatCornerItem = 0;
                Main.npcChatText       = string.Empty;
            }
            bool hadChestOpen = player.chest != -1;

            player.chest    = -1;
            Main.stackSplit = 600;
            Point16 toOpen   = new Point16(i, j);
            Point16 prevOpen = modPlayer.ViewingStorage();

            if (prevOpen == toOpen)
            {
                modPlayer.CloseStorage();
                Main.PlaySound(11, -1, -1, 1);
                Recipe.FindRecipes();
            }
            else
            {
                bool hadOtherOpen = prevOpen.X >= 0 && prevOpen.Y >= 0;
                modPlayer.OpenStorage(toOpen);
                modPlayer.timeSinceOpen = 0;
                if (PlayerInput.GrappleAndInteractAreShared)
                {
                    PlayerInput.Triggers.JustPressed.Grapple = false;
                }
                Main.recBigList = false;
                Main.PlaySound(hadChestOpen || hadOtherOpen ? 12 : 10, -1, -1, 1);
                Recipe.FindRecipes();
            }
            return(true);
        }