public static int Hook_AfterPlacement(int i, int j, int type, int style, int direction)
 {
     if (Main.netMode == 1)
     {
         NetMessage.SendTileRange(Main.myPlayer, i, j, 1, 1);
         NetHelper.SendSearchAndRefresh(i, j);
         return(0);
     }
     TEStorageComponent.SearchAndRefreshNetwork(new Point16(i, j));
     return(0);
 }
        public virtual TEStorageHeart GetHeart(int i, int j)
        {
            Point16 point = TEStorageComponent.FindStorageCenter(new Point16(i, j));

            if (point.X < 0 || point.Y < 0 || !TileEntity.ByPosition.ContainsKey(point))
            {
                return(null);
            }
            TileEntity heart = TileEntity.ByPosition[point];

            if (!(heart is TEStorageCenter))
            {
                return(null);
            }
            return(((TEStorageCenter)heart).GetHeart());
        }
 public override void KillTile(int i, int j, ref bool fail, ref bool effectOnly, ref bool noItem)
 {
     if (fail || effectOnly)
     {
         return;
     }
     StorageComponent.killTile = new Point16(i, j);
     if (Main.netMode == 1)
     {
         NetHelper.SendSearchAndRefresh(StorageComponent.killTile.X, StorageComponent.killTile.Y);
     }
     else
     {
         TEStorageComponent.SearchAndRefreshNetwork(StorageComponent.killTile);
     }
     StorageComponent.killTile = new Point16(-1, -1);
 }
示例#4
0
        public int CanPlace(int i, int j, int type, int style, int direction)
        {
            int count = 0;

            if (GetTileEntity() != null && GetTileEntity() is TEStorageCenter)
            {
                count++;
            }

            Point16           startSearch = new Point16(i - 1, j - 1);
            HashSet <Point16> explored    = new HashSet <Point16>();

            explored.Add(startSearch);
            Queue <Point16> toExplore = new Queue <Point16>();

            foreach (Point16 point in TEStorageComponent.AdjacentComponents(startSearch))
            {
                toExplore.Enqueue(point);
            }

            while (toExplore.Count > 0)
            {
                Point16 explore = toExplore.Dequeue();
                if (!explored.Contains(explore) && explore != killTile)
                {
                    explored.Add(explore);
                    if (TEStorageCenter.IsStorageCenter(explore))
                    {
                        count++;
                        if (count >= 2)
                        {
                            return(-1);
                        }
                    }
                    foreach (Point16 point in TEStorageComponent.AdjacentComponents(explore))
                    {
                        toExplore.Enqueue(point);
                    }
                }
            }
            return(count);
        }
示例#5
0
        public override void KillMultiTile(int i, int j, int frameX, int frameY)
        {
            Item.NewItem(i * 16, j * 16, 32, 32, ItemType(frameX, frameY));
            killTile = new Point16(i, j);
            ModTileEntity tileEntity = GetTileEntity();

            if (tileEntity != null)
            {
                tileEntity.Kill(i, j);
            }
            else
            {
                if (Main.netMode == 1)
                {
                    NetHelper.SendSearchAndRefresh(killTile.X, killTile.Y);
                }
                else
                {
                    TEStorageComponent.SearchAndRefreshNetwork(killTile);
                }
            }
            killTile = new Point16(-1, -1);
        }