Пример #1
0
 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);
 }
Пример #2
0
 public override void OnKill()
 {
     if (Main.netMode == NetmodeID.MultiplayerClient)
     {
         NetHelper.SendSearchAndRefresh(Position.X, Position.Y);
     }
     else
     {
         TEStorageComponent.SearchAndRefreshNetwork(Position);
     }
 }
Пример #3
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());
        }
Пример #4
0
 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);
 }
Пример #5
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 != StorageComponent.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);
        }
Пример #6
0
        public override void SetDefaults()
        {
            Main.tileSolidTop[Type]                    = true;
            Main.tileFrameImportant[Type]              = true;
            TileObjectData.newTile.Width               = 2;
            TileObjectData.newTile.Height              = 2;
            TileObjectData.newTile.Origin              = new Point16(1, 1);
            TileObjectData.newTile.CoordinateHeights   = new int[] { 16, 16 };
            TileObjectData.newTile.CoordinateWidth     = 16;
            TileObjectData.newTile.CoordinatePadding   = 2;
            TileObjectData.newTile.HookCheckIfCanPlace = new PlacementHook(CanPlace, -1, 0, true);
            TileObjectData.newTile.UsesCustomCanPlace  = true;
            ModifyObjectData();
            ModTileEntity tileEntity = GetTileEntity();

            if (tileEntity != null)
            {
                TileObjectData.newTile.HookPostPlaceMyPlayer = new PlacementHook(
                    delegate(int i1, int i2, int i3, int i4, int i5, int i6) {
                    return(tileEntity.Hook_AfterPlacement(i1, i2, i3, i4, i5));
                }, -1, 0, false);
            }
            else
            {
                TileObjectData.newTile.HookPostPlaceMyPlayer = new PlacementHook(
                    delegate(int i1, int i2, int i3, int i4, int i5, int i6) {
                    return(TEStorageComponent.Hook_AfterPlacement_NoEntity(i1, i2, i3, i4, i5));
                }, -1, 0, false);
            }
            TileObjectData.addTile(Type);
            ModTranslation text = CreateMapEntryName();

            text.SetDefault("Magic Storage");
            AddMapEntry(new Color(153, 107, 61), text);
            dustType                      = 7;
            disableSmartCursor            = true;
            TileID.Sets.HasOutlines[Type] = HasSmartInteract();
        }
Пример #7
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);
        }