2023-09-21 01:09:08 +00:00
|
|
|
part of 'generator.dart';
|
|
|
|
|
|
|
|
class Vault {
|
2023-09-21 22:37:12 +00:00
|
|
|
final Bitmap<VaultTile> tiles;
|
2023-09-21 01:09:08 +00:00
|
|
|
final DirectionSet smooth;
|
|
|
|
|
2023-09-21 22:37:12 +00:00
|
|
|
geo.Size get size => tiles.size;
|
|
|
|
int get vx => size.dx;
|
|
|
|
int get vy => size.dy;
|
|
|
|
|
|
|
|
Vault(this.tiles, this.smooth);
|
|
|
|
|
|
|
|
static Vault blank(int vx, int vy, VaultTile lt, DirectionSet smooth) {
|
|
|
|
return Vault(Bitmap.blank(vx, vy, lt), smooth);
|
2023-09-21 01:09:08 +00:00
|
|
|
}
|
|
|
|
|
2023-09-22 00:33:48 +00:00
|
|
|
static Vault blankWith(
|
|
|
|
int vx, int vy, VaultTile Function(int, int) lt, DirectionSet smooth) {
|
|
|
|
return Vault(Bitmap.blankWith(vx, vy, lt), smooth);
|
|
|
|
}
|
|
|
|
|
2023-09-21 03:56:30 +00:00
|
|
|
void clear(VaultTile lt) {
|
2023-09-21 22:37:12 +00:00
|
|
|
tiles.clear(lt);
|
2023-09-21 01:09:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void blitFrom(Vault other, int dx, int dy) {
|
2023-09-22 00:33:48 +00:00
|
|
|
tiles.blitFromWith(other.tiles, dx, dy, mergeVaultTile);
|
2023-09-21 01:09:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Vault flip() {
|
2023-09-21 22:37:12 +00:00
|
|
|
return Vault(tiles.flip(), smooth.flip());
|
2023-09-21 01:09:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Vault rotateRight() {
|
2023-09-21 22:37:12 +00:00
|
|
|
return Vault(tiles.rotateRight(), smooth.rotateRight());
|
2023-09-21 01:09:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Vault rotateLeft() {
|
2023-09-21 22:37:12 +00:00
|
|
|
return Vault(tiles.rotateLeft(), smooth.rotateLeft());
|
2023-09-21 01:09:08 +00:00
|
|
|
}
|
|
|
|
}
|
2023-09-22 00:33:48 +00:00
|
|
|
|
|
|
|
VaultTile mergeVaultTile(VaultTile bottom, VaultTile top) {
|
|
|
|
if (bottom == VaultTile.wall && top == VaultTile.archpronewall) {
|
|
|
|
return VaultTile.wall;
|
|
|
|
}
|
|
|
|
if (bottom == VaultTile.wall && top == VaultTile.archwall) {
|
|
|
|
return VaultTile.wall;
|
|
|
|
}
|
|
|
|
if (bottom == VaultTile.archwall && top == VaultTile.archpronewall) {
|
|
|
|
return VaultTile.archwall;
|
|
|
|
}
|
|
|
|
return top;
|
|
|
|
}
|
2023-09-23 00:55:29 +00:00
|
|
|
|
|
|
|
LevelTile flattenVaultTile(VaultTile vt) {
|
|
|
|
switch (vt) {
|
|
|
|
case VaultTile.meta0:
|
|
|
|
case VaultTile.defaultwall:
|
|
|
|
case VaultTile.archpronewall:
|
|
|
|
case VaultTile.archwall:
|
|
|
|
case VaultTile.wall:
|
|
|
|
return LevelTile.wall;
|
|
|
|
|
|
|
|
case VaultTile.exit:
|
|
|
|
return LevelTile.exit;
|
|
|
|
case VaultTile.door:
|
|
|
|
return LevelTile.closedDoor;
|
|
|
|
|
|
|
|
case VaultTile.doorpronefloor:
|
|
|
|
case VaultTile.bspfloor:
|
|
|
|
case VaultTile.floor:
|
|
|
|
return LevelTile.floor;
|
|
|
|
}
|
|
|
|
}
|