directions property
Generates all of the directions for this atom.
Implementation
List<Direction> get directions {
if (teleport) return [Direction.none];
Direction baseDir = Betza.atomDirection(base)!;
int h = baseDir.h;
int v = baseDir.v;
bool allDirs = dirMods.isEmpty;
List<Direction> dirs = [];
if (baseDir.orthogonal) {
int m = h == 0 ? v : h;
if (allDirs || dirMods.contains('f') || dirMods.contains('v')) {
dirs.add(Direction(0, m));
}
if (allDirs || dirMods.contains('b') || dirMods.contains('v')) {
dirs.add(Direction(0, -m));
}
if (allDirs || dirMods.contains('r') || dirMods.contains('s')) {
dirs.add(Direction(m, 0));
}
if (allDirs || dirMods.contains('l') || dirMods.contains('s')) {
dirs.add(Direction(-m, 0));
}
}
if (baseDir.diagonal) {
bool vert = allDirs || dirMods.contains('v');
bool side = allDirs || dirMods.contains('s');
bool f = vert || dirMods.contains('f');
bool b = vert || dirMods.contains('b');
bool r = side || dirMods.contains('r');
bool l = side || dirMods.contains('l');
bool forward = f || !b;
bool backward = b || !f;
bool right = r || !l;
bool left = l || !r;
if (forward && right) dirs.add(Direction(h, v));
if (forward && left) dirs.add(Direction(-h, v));
if (backward && right) dirs.add(Direction(h, -v));
if (backward && left) dirs.add(Direction(-h, -v));
}
if (baseDir.oblique) {
if (allDirs) {
dirs.addAll(baseDir.permutations);
} else {
// this is extremely cursed but thinking of a better way hurts my brain
String dirString = dirMods.join('');
bool hasDir(String d) {
bool contains = dirString.contains(d);
if (!contains) return false;
dirString = dirString.replaceFirst(d, '');
return true;
}
bool fh = hasDir('fh');
bool bh = hasDir('bh');
bool lv = hasDir('lv');
bool rv = hasDir('rv');
bool ll = hasDir('ll');
bool rr = hasDir('rr');
bool ff = hasDir('ff');
bool bb = hasDir('bb');
bool fs = hasDir('fs');
bool bs = hasDir('bs');
bool hl = hasDir('hl');
bool hr = hasDir('hr');
bool lh = hasDir('lh');
bool rh = hasDir('rh');
bool vv = hasDir('v');
bool s = hasDir('s');
bool fr = hasDir('fr') || fh || rr || hl || rh || fs || s;
bool fl = hasDir('fl') || fh || ll || hr || lh || fs || s;
bool br = hasDir('br') || bh || rr || hr || rh || bs || s;
bool bl = hasDir('bl') || bh || ll || hl || lh || bs || s;
bool rf = hasDir('rf') || fh || rv || hr || rh || ff || vv;
bool rb = hasDir('rb') || bh || rv || hl || rh || bb || vv;
bool lf = hasDir('lf') || fh || lv || hl || lh || ff || vv;
bool lb = hasDir('lb') || bh || lv || hr || lh || bb || vv;
bool f = hasDir('f');
bool b = hasDir('b');
bool l = hasDir('l');
bool r = hasDir('r');
if (fr || r) {
dirs.add(Direction(h, v)); // fr
}
if (fl || l) {
dirs.add(Direction(-h, v)); // fl
}
if (br || r) {
dirs.add(Direction(h, -v)); // br
}
if (bl || l) {
dirs.add(Direction(-h, -v)); // bl
}
if (rf | f) {
dirs.add(Direction(v, h)); // rf
}
if (rb | b) {
dirs.add(Direction(v, -h)); // rb
}
if (lf | f) {
dirs.add(Direction(-v, h)); // lf
}
if (lb | b) {
dirs.add(Direction(-v, -h)); // lb
}
}
}
return dirs;
}