Exemple #1
0
        private void ResolveNeighbors(Vector2D offset)
        {
            for (int x = 0; x < Width; x++)
            {
                for (int y = 0; y < Height; y++)
                {
                    if (!TileMap[x, y].Initialized && TileMap[x, y].Enabled && TileMap[x, y].TileMapOffset == offset)
                    {
                        RoomTileRaw tile = TileMap[x, y];

                        byte primaryNeighbors =
                            (byte)(
                                ((this[x, y + 1].CanBlend(tile) ? 1 : 0) << 3) +
                                ((this[x + 1, y].CanBlend(tile) ? 1 : 0) << 2) +
                                ((this[x, y - 1].CanBlend(tile) ? 1 : 0) << 1) +
                                ((this[x - 1, y].CanBlend(tile) ? 1 : 0)));
                        byte secondaryNeighbors =
                            (byte)(
                                ((this[x - 1, y + 1].CanBlend(tile) ? 1 : 0) << 3) +
                                ((this[x + 1, y + 1].CanBlend(tile) ? 1 : 0) << 2) +
                                ((this[x + 1, y - 1].CanBlend(tile) ? 1 : 0) << 1) +
                                ((this[x - 1, y - 1].CanBlend(tile) ? 1 : 0)));

                        tile.Neighbors   = (byte)(primaryNeighbors + (secondaryNeighbors << 4));
                        tile.Initialized = true;

                        TileMap[x, y] = tile;
                    }
                }
            }
        }
Exemple #2
0
 public void Fill(Rectangle rectangle, RoomTileRaw tileInfo)
 {
     for (int x = (int)rectangle.X; x < rectangle.X + rectangle.Width; x++)
     {
         for (int y = (int)rectangle.Y; y < rectangle.Y + rectangle.Height; y++)
         {
             Set(x, y, tileInfo);
         }
     }
 }
Exemple #3
0
 private RoomTileRaw this[int x, int y] => (x >= 0 && y >= 0 && x < Width && y < Height) ? TileMap[x, y] : RoomTileRaw.CreateOutOfBounds();
Exemple #4
0
 public void Set(int x, int y, RoomTileRaw tileInfo)
 {
     TileMap[x, y] = tileInfo;
 }
Exemple #5
0
 public bool CanBlend(RoomTileRaw other)
 {
     return((this.Enabled && other.Enabled) && (this.OutOfBounds || other.OutOfBounds || this.TileMapOffset == other.TileMapOffset));
 }