public bool Remove(object Key, bool Cleanup = true)
 {
     lock (Locker)
     {
         if (!Data.ContainsKey(Key))
         {
             return(false);
         }
         FakeTileRectangle o = Data[Key];
         Data.Remove(Key);
         Order.Remove(Key);
         int x = o.X, y = o.Y;
         int w = o.Width, h = o.Height;
         int sx = Netplay.GetSectionX(x), sy = Netplay.GetSectionY(y);
         int ex = Netplay.GetSectionX(x + w - 1), ey = Netplay.GetSectionY(y + h - 1);
         o.Tile.Dispose();
         if (Cleanup)
         {
             GC.Collect();
         }
         NetMessage.SendData((int)PacketTypes.TileSendSection,
                             -1, -1, null, x, y, w, h);
         NetMessage.SendData((int)PacketTypes.TileFrameSection,
                             -1, -1, null, sx, sy, ex, ey);
         return(true);
     }
 }
Beispiel #2
0
        public static Dictionary <int, Sign> GetAppliedSigns(int X, int Y, int Width, int Height)
        {
            Dictionary <int, Sign> signs = new Dictionary <int, Sign>();
            int X2 = (X + Width), Y2 = (Y + Height);

            for (int i = 0; i < Main.sign.Length; i++)
            {
                Sign sign = Main.sign[i];
                if ((sign != null) && (sign.x >= X) && (sign.x < X2) &&
                    (sign.y >= Y) && (sign.y < Y2))
                {
                    signs.Add(i, sign);
                }
            }

            for (int i = 0; i < Common.Order.Count; i++)
            {
                FakeTileRectangle fake = Common.Data[Common.Order[i]];
                if (fake.Enabled && fake.IsIntersecting(X, Y, Width, Height))
                {
                    fake.ApplySigns(signs, X, Y, Width, Height);
                }
            }

            /*
             * for (int i = 0; i < Personal[Who].Order.Count; i++)
             * {
             *  FakeTileRectangle fake = Personal[Who].Data[Personal[Who].Order[i]];
             *  if (fake.Enabled && fake.IsIntersecting(X, Y, Width, Height))
             *      fake.ApplySigns(signs, X, Y, Width, Height);
             * }
             */
            return(signs);
        }
Beispiel #3
0
        public static ITile[,] GetAppliedTiles(int X, int Y, int Width, int Height)
        {
            ITile[,] tiles = new ITile[Width, Height];
            int X2 = (X + Width), Y2 = (Y + Height);

            for (int i = X; i < X2; i++)
            {
                for (int j = Y; j < Y2; j++)
                {
                    tiles[i - X, j - Y] = Main.tile[i, j];
                }
            }

            for (int i = 0; i < Common.Order.Count; i++)
            {
                FakeTileRectangle fake = Common.Data[Common.Order[i]];
                if (fake.Enabled && fake.IsIntersecting(X, Y, Width, Height))
                {
                    fake.ApplyTiles(tiles, X, Y);
                }
            }

            /*
             * for (int i = 0; i < Personal[Who].Order.Count; i++)
             * {
             *  FakeTileRectangle fake = Personal[Who].Data[Personal[Who].Order[i]];
             *  if (fake.Enabled && fake.IsIntersecting(X, Y, Width, Height))
             *      fake.ApplyTiles(tiles, X, Y);
             * }
             */
            return(tiles);
        }
 public FakeTileRectangle Add(object Key, int X, int Y,
                              int Width, int Height, ITileCollection CopyFrom = null)
 {
     lock (Locker)
     {
         if (Data.ContainsKey(Key))
         {
             throw new ArgumentException($"Key '{Key}' is already in use.");
         }
         FakeTileRectangle fake = new FakeTileRectangle(this, Key, X, Y, Width, Height, CopyFrom);
         Data.Add(Key, fake);
         Order.Add(Key);
         return(fake);
     }
 }