예제 #1
0
        public static World CreateCopy(this IBlockAreaEnumerable blockArea)
        {
            var area  = blockArea.Area;
            var world = new World(area.Width, area.Height);

            for (var x = area.Left; x <= area.Right; x++)
            {
                for (var y = area.Top; y <= area.Bottom; y++)
                {
                    world.Foreground[x - area.Left, y - area.Top] = blockArea.Blocks.Foreground[x, y].Block;
                    world.Background[x - area.Left, y - area.Top] = blockArea.Blocks.Background[x, y].Block;
                }
            }
            return(world);
        }
예제 #2
0
        public BlocksAreaDictionary(IBlockAreaEnumerable blockArea, BotBitsClient client, IBlockFilter filter)
        {
            this._client    = client;
            this._blockArea = blockArea;

            var fgGen = new ForegroundDictionaryLayerGenerator <BlocksItem>((p, b) => this._blockArea.At(p.X, p.Y));
            var bgGen = new BackgroundDictionaryLayerGenerator <BlocksItem>((p, b) => this._blockArea.At(p.X, p.Y));

            this.InternalForeground = new DictionaryBlockLayer <Foreground.Id, ForegroundBlock, BlocksItem, PointSet>(fgGen, filter);
            this.InternalBackground = new DictionaryBlockLayer <Background.Id, BackgroundBlock, BlocksItem, PointSet>(bgGen, filter);

            this.Reindex();

            EventLoader.Of(this._client).Load(this);
        }
예제 #3
0
        public static void UploadWorld(this IBlockAreaEnumerable blockArea, IReadOnlyWorld <ForegroundBlock, BackgroundBlock> world)
        {
            var area = blockArea.Area;

            if (world.Width > area.Width || world.Height > area.Height)
            {
                throw new ArgumentException("The world is too big for this area.", nameof(world));
            }

            for (var y = area.Top; y < area.Top + world.Height; y++)
            {
                for (var x = area.Left; x < area.Left + world.Width; x++)
                {
                    blockArea.Blocks.Place(x, y, world.Foreground[x - area.Left, y - area.Top]);
                    blockArea.Blocks.Place(x, y, world.Background[x - area.Left, y - area.Top]);
                }
            }
        }
예제 #4
0
 public static BlocksAreaEnumerable In(this IBlockAreaEnumerable blockArea, Rectangle area)
 {
     return(new BlocksAreaEnumerable(blockArea.Blocks,
                                     Rectangle.Intersect(area.Offset(blockArea.Area.X, blockArea.Area.Y), blockArea.Area)));
 }
예제 #5
0
 public static IReadOnlyWorldAreaEnumerable <ForegroundBlock, BackgroundBlock> GetProxyWorldAreaEnumerable(this IBlockAreaEnumerable blockArea)
 {
     return(blockArea.Blocks.GetProxyWorld().In(blockArea.Area));
 }
예제 #6
0
 public static BlocksItem At(this IBlockAreaEnumerable blockArea, Point point)
 {
     return(blockArea.At(point.X, point.Y));
 }
예제 #7
0
 public static BlocksItem At(this IBlockAreaEnumerable blockArea, int x, int y)
 {
     return(new BlocksItem(blockArea.Blocks, blockArea.Area.X + x, blockArea.Area.Y + y));
 }
예제 #8
0
 public static BlocksAreaEnumerable In(this IBlockAreaEnumerable blockArea, int x, int y, int width, int height)
 {
     return(blockArea.In(new Rectangle(x, y, width, height)));
 }
예제 #9
0
 public static BlocksAreaEnumerable In(this IBlockAreaEnumerable blockArea, Point p, Size s)
 {
     return(blockArea.In(new Rectangle(p, s)));
 }
예제 #10
0
 public static BlocksAreaEnumerable In(this IBlockAreaEnumerable blockArea, Point p1, Point p2)
 {
     return(blockArea.In(new Rectangle(p1, p2)));
 }
예제 #11
0
 public BlocksAreaDictionary(IBlockAreaEnumerable blockArea, BotBitsClient client) : this(blockArea, client, null)
 {
 }