Find() public static method

public static Find ( int x, int y ) : int
x int
y int
return int
Esempio n. 1
0
        public static void TryPlacing(int x, int y, int netid, int prefix, int stack)
        {
            int index = TEItemFrame.Find(x, y);

            if (index == -1)
            {
                int number = Item.NewItem(x * 16, y * 16, 32, 32, 1, 1, false, 0, false);
                Main.item[number].netDefaults(netid);
                Main.item[number].Prefix(prefix);
                Main.item[number].stack = stack;
                NetMessage.SendData(21, -1, -1, "", number, 0.0f, 0.0f, 0.0f, 0, 0, 0);
            }
            else
            {
                TEItemFrame teItemFrame = (TEItemFrame)TileEntity.ByID[index];
                if (teItemFrame.item.stack > 0)
                {
                    teItemFrame.DropItem();
                }

                teItemFrame.item = new Item();
                teItemFrame.item.netDefaults(netid);
                teItemFrame.item.Prefix(prefix);
                teItemFrame.item.stack = stack;
                NetMessage.SendData(86, -1, -1, "", teItemFrame.ID, (float)x, (float)y, 0.0f, 0, 0, 0);
            }
        }
Esempio n. 2
0
        public static void TryPlacing(int x, int y, int netid, int prefix, int stack)
        {
            int num = TEItemFrame.Find(x, y);

            if (num == -1)
            {
                int num1 = Item.NewItem(x * 16, y * 16, 32, 32, 1, 1, false, 0, false);
                Main.item[num1].netDefaults(netid);
                Main.item[num1].Prefix(prefix);
                Main.item[num1].stack = stack;
                NetMessage.SendData((int)PacketTypes.ItemDrop, -1, -1, "", num1, 0f, 0f, 0f, 0, 0, 0);
                return;
            }
            TEItemFrame item = (TEItemFrame)TileEntity.ByID[num];

            if (item.item.stack > 0)
            {
                int num2 = Item.NewItem(x * 16, y * 16, 32, 32, 1, 1, false, 0, false);
                Main.item[num2].netDefaults(item.item.netID);
                Main.item[num2].Prefix((int)item.item.prefix);
                Main.item[num2].stack = item.item.stack;
                NetMessage.SendData((int)PacketTypes.ItemDrop, -1, -1, "", num2, 0f, 0f, 0f, 0, 0, 0);
            }
            item.item = new Item();
            item.item.netDefaults(netid);
            item.item.Prefix(prefix);
            item.item.stack = stack;
            NetMessage.SendData((int)PacketTypes.UpdateTileEntity, -1, -1, "", item.ID, (float)x, (float)y, 0f, 0, 0, 0);
        }
Esempio n. 3
0
 public static void OnPlayerInteraction(Player player, int clickX, int clickY)
 {
     if (TEItemFrame.FitsItemFrame(player.inventory[player.selectedItem]) && !player.inventory[player.selectedItem].favorited)
     {
         player.GamepadEnableGrappleCooldown();
         TEItemFrame.PlaceItemInFrame(player, clickX, clickY);
         Recipe.FindRecipes(false);
     }
     else
     {
         int x = clickX;
         int y = clickY;
         if ((int)Main.tile[x, y].frameX % 36 != 0)
         {
             --x;
         }
         if ((int)Main.tile[x, y].frameY % 36 != 0)
         {
             --y;
         }
         int index = TEItemFrame.Find(x, y);
         if (index == -1 || ((TEItemFrame)TileEntity.ByID[index]).item.stack <= 0)
         {
             return;
         }
         player.GamepadEnableGrappleCooldown();
         WorldGen.KillTile(clickX, clickY, true, false, false);
         if (Main.netMode != 1)
         {
             return;
         }
         NetMessage.SendData(17, -1, -1, (NetworkText)null, 0, (float)x, (float)y, 1f, 0, 0, 0);
     }
 }
Esempio n. 4
0
        // Token: 0x06000F97 RID: 3991 RVA: 0x003F60A8 File Offset: 0x003F42A8
        public static void TryPlacing(int x, int y, int netid, int prefix, int stack)
        {
            int num = TEItemFrame.Find(x, y);

            if (num == -1)
            {
                int num2 = Item.NewItem(x * 16, y * 16, 32, 32, 1, 1, false, 0, false, false);
                Main.item[num2].netDefaults(netid);
                Main.item[num2].Prefix(prefix);
                Main.item[num2].stack = stack;
                NetMessage.SendData(21, -1, -1, null, num2, 0f, 0f, 0f, 0, 0, 0);
                return;
            }
            TEItemFrame tEItemFrame = (TEItemFrame)TileEntity.ByID[num];

            if (tEItemFrame.item.stack > 0)
            {
                tEItemFrame.DropItem();
            }
            tEItemFrame.item = new Item();
            tEItemFrame.item.netDefaults(netid);
            tEItemFrame.item.Prefix(prefix);
            tEItemFrame.item.stack = stack;
            NetMessage.SendData(86, -1, -1, null, tEItemFrame.ID, (float)x, (float)y, 0f, 0, 0, 0);
        }
Esempio n. 5
0
        public static void PlaceItemInFrame(Player player, int x, int y)
        {
            if ((int)Main.tile[x, y].frameX % 36 != 0)
            {
                --x;
            }
            if ((int)Main.tile[x, y].frameY % 36 != 0)
            {
                --y;
            }
            int index = TEItemFrame.Find(x, y);

            if (index == -1)
            {
                return;
            }
            if (((TEItemFrame)TileEntity.ByID[index]).item.stack > 0)
            {
                WorldGen.KillTile(x, y, true, false, false);
                if (Main.netMode == 1)
                {
                    NetMessage.SendData(17, -1, -1, (NetworkText)null, 0, (float)Player.tileTargetX, (float)y, 1f, 0, 0, 0);
                }
            }
            if (Main.netMode == 1)
            {
                NetMessage.SendData(89, -1, -1, (NetworkText)null, x, (float)y, (float)player.selectedItem, (float)player.whoAmI, 1, 0, 0);
            }
            else
            {
                TEItemFrame.TryPlacing(x, y, player.inventory[player.selectedItem].netID, (int)player.inventory[player.selectedItem].prefix, 1);
            }
            --player.inventory[player.selectedItem].stack;
            if (player.inventory[player.selectedItem].stack <= 0)
            {
                player.inventory[player.selectedItem].SetDefaults(0);
                Main.mouseItem.SetDefaults(0);
            }
            if (player.selectedItem == 58)
            {
                Main.mouseItem = player.inventory[player.selectedItem].Clone();
            }
            player.releaseUseItem = false;
            player.mouseInterface = true;
            WorldGen.RangeFrame(x, y, x + 2, y + 2);
        }