Inheritance: Terraria.DataStructures.TileEntity
Ejemplo n.º 1
0
        public static void TryPlacing(int x, int y, int netid, int prefix, int stack)
        {
            WorldGen.RangeFrame(x, y, x + 2, y + 2);
            int num = Find(x, y);

            if (num == -1)
            {
                int num2 = Item.NewItem(x * 16, y * 16, 32, 32, 1);
                Main.item[num2].netDefaults(netid);
                Main.item[num2].Prefix(prefix);
                Main.item[num2].stack = stack;
                NetMessage.SendData(21, -1, -1, null, num2);
                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, x, y);
        }
Ejemplo 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);
        }
Ejemplo n.º 3
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);
            }
        }
Ejemplo n.º 4
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);
     }
 }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
0
 public static void NetPlaceEntity(int x, int y, int type)
 {
     if (type != 1 || !TEItemFrame.ValidTile(x, y))
     {
         return;
     }
     NetMessage.SendData(86, -1, -1, (NetworkText)null, TEItemFrame.Place(x, y), (float)x, (float)y, 0.0f, 0, 0, 0);
 }
Ejemplo n.º 7
0
 public static int Hook_AfterPlacement(int x, int y, int type = 395, int style = 0, int direction = 1)
 {
     if (Main.netMode != 1)
     {
         return(TEItemFrame.Place(x, y));
     }
     NetMessage.SendTileSquare(Main.myPlayer, x, y, 2, TileChangeType.None);
     NetMessage.SendData(87, -1, -1, (NetworkText)null, x, (float)y, 1f, 0.0f, 0, 0, 0);
     return(-1);
 }
Ejemplo n.º 8
0
 public static int Hook_AfterPlacement(int x, int y, int type = 21, int style = 0, int direction = 1)
 {
     if (Main.netMode != 1)
     {
         return(TEItemFrame.Place(x, y));
     }
     NetMessage.SendTileSquare(Main.myPlayer, x, y, 2);
     NetMessage.SendData((int)PacketTypes.PlaceTileEntity, -1, -1, "", x, (float)y, 1f, 0f, 0, 0, 0);
     return(-1);
 }
Ejemplo n.º 9
0
 public static int Place(int x, int y)
 {
     TEItemFrame teItemFrame = new TEItemFrame();
     teItemFrame.Position = new Point16(x, y);
     teItemFrame.ID = TileEntity.AssignNewID();
     teItemFrame.type = 1;
     TileEntity.ByID[teItemFrame.ID] = teItemFrame;
     TileEntity.ByPosition[teItemFrame.Position] = teItemFrame;
     return teItemFrame.ID;
 }
Ejemplo n.º 10
0
        public static int Place(int x, int y)
        {
            TEItemFrame teItemFrame = new TEItemFrame();

            teItemFrame.Position                        = new Point16(x, y);
            teItemFrame.ID                              = TileEntity.AssignNewID();
            teItemFrame.type                            = 1;
            TileEntity.ByID[teItemFrame.ID]             = teItemFrame;
            TileEntity.ByPosition[teItemFrame.Position] = teItemFrame;
            return(teItemFrame.ID);
        }
Ejemplo n.º 11
0
        public static void NetPlaceEntity(int x, int y, int type)
        {
            if (type != 1)
            {
                return;
            }
            if (!TEItemFrame.ValidTile(x, y))
            {
                return;
            }
            int number = TEItemFrame.Place(x, y);

            NetMessage.SendData(86, -1, -1, "", number, (float)x, (float)y, 0f, 0, 0, 0);
        }
Ejemplo n.º 12
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);
        }
		public static TileEntity Read(BinaryReader reader)
		{
			TileEntity tileEntity = null;
			byte b = reader.ReadByte();
			switch (b)
			{
			case 0:
				tileEntity = new TETrainingDummy();
				break;
			case 1:
				tileEntity = new TEItemFrame();
				break;
			}
			tileEntity.type = b;
			tileEntity.ReadInner(reader);
			return tileEntity;
		}
Ejemplo n.º 14
0
 public static TileEntity Read(BinaryReader reader)
 {
     TileEntity tETrainingDummy = null;
     byte num = reader.ReadByte();
     switch (num)
     {
         case 0:
         {
             tETrainingDummy = new TETrainingDummy();
             break;
         }
         case 1:
         {
             tETrainingDummy = new TEItemFrame();
             break;
         }
     }
     tETrainingDummy.type = num;
     tETrainingDummy.ReadInner(reader);
     return tETrainingDummy;
 }
Ejemplo n.º 15
0
 public override void NetPlaceEntityAttempt(int x, int y)
 {
     TEItemFrame.NetPlaceEntity(x, y);
 }
Ejemplo n.º 16
0
 public static void NetPlaceEntity(int x, int y)
 {
     NetMessage.SendData(86, -1, -1, (NetworkText)null, TEItemFrame.Place(x, y), (float)x, (float)y, 0.0f, 0, 0, 0);
 }
Ejemplo n.º 17
0
 public override bool IsTileValidForEntity(int x, int y)
 {
     return(TEItemFrame.ValidTile(x, y));
 }