예제 #1
0
        public override void MouseOverFar(int i, int j)
        {
            // fixFrames(i, j);
            int x = i; int y = j;

            while (Main.tile[x, y].frameY % 70 != 0)
            {
                y--;
            }
            while (Main.tile[x, y].frameX % 54 != 0)
            {
                x--;
            }

            int vmID = VendingMachineWorld.GetVendingMachineFromCoordinates(x, y);

            if (vmID < 0)
            {
                return;
            }

            Player player = Main.player[Main.myPlayer];

            if (VendingMachineWorld.vm[vmID].isItem)
            {
                Item itm = new Item();
                itm.SetDefaults(SoulOfNPC.getTypeFromItemTag(VendingMachineWorld.vm[vmID].id));
                if (itm.type != 0)
                {
                    player.showItemIconText = itm.modItem.DisplayName.GetDefault();
                }
                else
                {
                    player.showItemIconText = "Vending Machine (Empty)";
                }
            }
            else
            {
                NPC n = SoulOfNPC.getNPCfromNPCTag(VendingMachineWorld.vm[vmID].id);

                if (n != null && n.type != 0)
                {
                    if (n.type == NPCID.SkeletonMerchant)
                    {
                        player.showItemIconText = "Vending Machine (Skeleton Merchant)";
                    }
                    else
                    {
                        player.showItemIconText = "Vending Machine (" + Lang.GetNPCNameValue(n.netID) + ")";
                    }
                }
                else
                {
                    player.showItemIconText = "Vending Machine (Empty)";
                }
            }
            player.noThrow       = 2;
            player.showItemIcon2 = -1;
            player.showItemIcon  = true;
        }
예제 #2
0
        public override void KillMultiTile(int i, int j, int frameX, int frameY)
        {
            int x = i; int y = j;
            int vmID = VendingMachineWorld.GetVendingMachineFromCoordinates(x, y);
            int k    = -1;

            if (vmID >= 0 && VendingMachineWorld.vm[vmID] != null)
            {
                string   id      = VendingMachineWorld.vm[vmID].Clear();
                string[] idSplit = id.Split(';');
                bool     itm     = (idSplit[0] == "Item");
                id = idSplit[1];
                if (Main.netMode != 1)
                {
                    if (itm)
                    {
                        k = Item.NewItem(x * 16, y * 16, 48, 64, SoulOfNPC.getTypeFromItemTag(id), 1, false, 0, false, false);
                    }
                    else
                    {
                        k = Item.NewItem(x * 16, y * 16, 48, 64, dropID, 1, false, 0, false, false);
                        VendingMachineItem vmi = Main.item[k].modItem as VendingMachineItem;
                        if (vmi != null)
                        {
                            vmi.setNPCType(SoulOfNPC.getNPCfromNPCTag(id));
                        }
                    }
                }
            }
            else
            {
                if (Main.netMode != 1)
                {
                    k = Item.NewItem(x * 16, y * 16, 48, 64, dropID, 1, false, 0, false, false);
                }
            }
            if (Main.netMode == 2 && k >= 0)
            {
                NetMessage.SendData(21, -1, -1, null, k, 0f, 0f, 0f, 0, 0, 0);
            }
            if (Main.netMode != 0)
            {
                ModPacket pk = mod.GetPacket();
                pk.Write((byte)2);
                pk.Write((short)vmID);
                pk.Send();
            }
        }