public void Fill(bool borderBlocks, Blockset.Block oldBlock, Blockset.Block newBlock, int destX, int destY) { Block[][] outArr = borderBlocks ? BorderBlocks : Blocks; int width = borderBlocks ? BorderWidth : Width; int height = borderBlocks ? BorderHeight : Height; void Fill(int x, int y) { if (x >= 0 && x < width && y >= 0 && y < height) { Block b = outArr[y][x]; if (b.BlocksetBlock == oldBlock) { b.BlocksetBlock = newBlock; DrawList.Add(b); Fill(x, y + 1); Fill(x, y - 1); Fill(x + 1, y); Fill(x - 1, y); } } } Fill(destX, destY); Draw(borderBlocks); }
public void Paste(bool borderBlocks, Blockset.Block[][] blocks, int destX, int destY) { Block[][] outArr = borderBlocks ? BorderBlocks : Blocks; int width = borderBlocks ? BorderWidth : Width; int height = borderBlocks ? BorderHeight : Height; List <Block> list = DrawList; for (int y = 0; y < blocks.Length; y++) { int dy = y + destY; if (dy >= 0 && dy < height) { Blockset.Block[] inArrY = blocks[y]; Block[] outArrY = outArr[dy]; for (int x = 0; x < inArrY.Length; x++) { int dx = x + destX; if (dx >= 0 && dx < width) { Blockset.Block b = inArrY[x]; if (b != null) { Block outB = outArrY[dx]; if (outB.BlocksetBlock != b) { outB.BlocksetBlock = b; list.Add(outB); } } } } } } Draw(borderBlocks); }
public Block(int x, int y, Blockset.Block defaultBlock) { X = x; Y = y; Elevations = 1 << 0; // Include elevation 0 BlocksetBlock = defaultBlock; }
public Block(int x, int y, EndianBinaryReader r) { X = x; Y = y; Elevations = r.ReadByte(); Passage = r.ReadEnum <LayoutBlockPassage>(); BlocksetBlock = Blockset.LoadOrGet(r.ReadInt32()).Blocks[r.ReadInt32()]; }
public Layout(string name, int width, int height, byte borderWidth, byte borderHeight, Blockset.Block defaultBlock) { Id = Ids.Add(name); _loadedLayouts.Add(Id, new WeakReference <Layout>(this)); Block[][] Create(int w, int h) { var arr = new Block[h][]; for (int y = 0; y < h; y++) { var arrY = new Block[w]; for (int x = 0; x < w; x++) { arrY[x] = new Block(x, y, defaultBlock); } arr[y] = arrY; } return(arr); } Blocks = Create(Width = width, Height = height); BorderBlocks = Create(BorderWidth = borderWidth, BorderHeight = borderHeight); Name = name; Save(); Ids.Save(); UpdateBitmapSize(false); UpdateBitmapSize(true); }