示例#1
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);
        }
示例#2
0
        public ReadOnlyWorldDictionary(IReadOnlyWorldAreaEnumerable <ForegroundBlock, BackgroundBlock> worldArea, IBlockFilter filter)
        {
            if (worldArea.Area.Width > ushort.MaxValue || worldArea.Area.Height > ushort.MaxValue)
            {
                throw new NotSupportedException($"WorldDictionary only supports worlds that are {ushort.MaxValue} wide or tall at maximum.");
            }
            var fgGen = new ForegroundDictionaryLayerGenerator <ReadOnlyWorldDictionaryItem>((p, b) => new ReadOnlyWorldDictionaryItem(b, p.X, p.Y));
            var bgGen = new BackgroundDictionaryLayerGenerator <ReadOnlyWorldDictionaryItem>((p, b) => new ReadOnlyWorldDictionaryItem(b, p.X, p.Y));

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

            this.Width  = worldArea.Area.Width;
            this.Height = worldArea.Area.Height;

            for (var y = 0; y < this.Height; y++)
            {
                for (var x = 0; x < this.Width; x++)
                {
                    this.InternalForeground.Add(worldArea.At(x, y).Foreground, new Point(x, y));
                    this.InternalBackground.Add(worldArea.At(x, y).Background, new Point(x, y));
                }
            }
        }