mirrors now flip Alchemist Lab colors (may be a bit unpredictable in minimal quotient)

This commit is contained in:
Zeno Rogue 2022-04-26 14:42:07 +02:00
parent 49d7ab3ed3
commit 7adb3dac5a
5 changed files with 39 additions and 15 deletions

View File

@ -302,8 +302,15 @@ EX void prespill(cell* c, eWall t, int rad, cell *from) {
// block spill // block spill
if(t == waTemporary) return; if(t == waTemporary) return;
// cwt.at->item = itNone; // cwt.at->item = itNone;
if(rad) for(cell *c2: adj_minefield_cells(c)) if(rad) for(auto p: adj_minefield_cells_with_orientation(c)) {
prespill(c2, t, rad-1, c); prespill(p.first, conditional_flip_slime(p.second, t), rad-1, c);
}
}
EX eWall conditional_flip_slime(bool flip, eWall t) {
if(flip && t == waFloorA) return waFloorB;
if(flip && t == waFloorB) return waFloorA;
return t;
} }
EX void spillfix(cell* c, eWall t, int rad) { EX void spillfix(cell* c, eWall t, int rad) {
@ -311,8 +318,9 @@ EX void spillfix(cell* c, eWall t, int rad) {
changes.ccell(c); changes.ccell(c);
c->wall = t; c->wall = t;
} }
if(rad) for(cell *c2: adj_minefield_cells(c)) if(rad) for(auto p: adj_minefield_cells_with_orientation(c)) {
spillfix(c2, t, rad-1); spillfix(p.first, conditional_flip_slime(p.second, t), rad-1);
}
} }
EX void spill(cell* c, eWall t, int rad) { EX void spill(cell* c, eWall t, int rad) {

View File

@ -1331,7 +1331,7 @@ EX int neighborId(cell *ofWhat, cell *whichOne) {
EX int mine_adjacency_rule = 0; EX int mine_adjacency_rule = 0;
EX map<cell*, vector<cell*>> adj_memo; EX map<cell*, vector<pair<cell*, bool>>> adj_memo;
EX bool geometry_has_alt_mine_rule() { EX bool geometry_has_alt_mine_rule() {
if(S3 >= OINF) return false; if(S3 >= OINF) return false;
@ -1340,17 +1340,17 @@ EX bool geometry_has_alt_mine_rule() {
return true; return true;
} }
EX vector<cell*> adj_minefield_cells(cell *c) { EX vector<pair<cell*, bool>> adj_minefield_cells_with_orientation(cell *c) {
vector<cell*> res; vector<pair<cell*, bool>> res;
if(mine_adjacency_rule == 0 || !geometry_has_alt_mine_rule()) if(mine_adjacency_rule == 0 || !geometry_has_alt_mine_rule())
forCellCM(c2, c) res.push_back(c2); forCellIdCM(c2, i, c) res.emplace_back(c2, c->c.mirror(i));
else if(WDIM == 2) { else if(WDIM == 2) {
cellwalker cw(c, 0); cellwalker cw(c, 0);
cw += wstep; cw += wstep;
cw++; cw++;
cellwalker cw1 = cw; cellwalker cw1 = cw;
do { do {
res.push_back(cw.at); res.emplace_back(cw.at, cw.mirrored);
cw += wstep; cw += wstep;
cw++; cw++;
if(cw.cpeek() == c) cw++; if(cw.cpeek() == c) cw++;
@ -1373,7 +1373,7 @@ EX vector<cell*> adj_minefield_cells(cell *c) {
auto& vertices1 = ss1.vertices_only_local; auto& vertices1 = ss1.vertices_only_local;
for(hyperpoint h: vertices) for(hyperpoint h2: vertices1) for(hyperpoint h: vertices) for(hyperpoint h2: vertices1)
if(hdist(h, T * h2) < 1e-6) shares = true; if(hdist(h, T * h2) < 1e-6) shares = true;
if(shares) res.push_back(c1); if(shares) res.emplace_back(c1, det(T) < 0);
} }
if(shares || c == c1) forCellIdEx(c2, i, c1) { if(shares || c == c1) forCellIdEx(c2, i, c1) {
if(cl.listed(c2)) continue; if(cl.listed(c2)) continue;
@ -1387,6 +1387,13 @@ EX vector<cell*> adj_minefield_cells(cell *c) {
return res; return res;
} }
EX vector<cell*> adj_minefield_cells(cell *c) {
vector<cell*> res;
auto ori = adj_minefield_cells_with_orientation(c);
for(auto p: ori) res.push_back(p.first);
return res;
}
EX vector<int> reverse_directions(cell *c, int dir) { EX vector<int> reverse_directions(cell *c, int dir) {
if(PURE && !(kite::in() && WDIM == 2)) return reverse_directions(c->master, dir); if(PURE && !(kite::in() && WDIM == 2)) return reverse_directions(c->master, dir);
int d = c->degree(); int d = c->degree();

View File

@ -502,6 +502,8 @@ void celldrawer::setcolors() {
} }
case waFloorA: case waFloorB: // isAlch case waFloorA: case waFloorB: // isAlch
wcol = winf[conditional_flip_slime(det(V.T) < 0, c->wall)].color;
if(c->item && !(history::includeHistory && history::infindhistory.count(c))) if(c->item && !(history::includeHistory && history::infindhistory.count(c)))
fcol = wcol = iinf[c->item].color; fcol = wcol = iinf[c->item].color;
else else
@ -2422,7 +2424,7 @@ void celldrawer::draw_monster_full() {
moncol >>= 1; moncol >>= 1;
if(c->monst == moSlime) { if(c->monst == moSlime) {
moncol = winf[c->wall].color; moncol = winf[conditional_flip_slime(det(V.T) < 0, c->wall)].color;
moncol |= (moncol>>1); moncol |= (moncol>>1);
} }

View File

@ -89,9 +89,16 @@ EX bool strictlyAgainstGravity(cell *w, cell *from, bool revdir, flagtype flags)
} }
EX bool anti_alchemy(cell *w, cell *from) { EX bool anti_alchemy(cell *w, cell *from) {
bool alch1 = w->wall == waFloorA && from && from->wall == waFloorB && !w->item && !from->item; if(!from) return false;
alch1 |= w->wall == waFloorB && from && from->wall == waFloorA && !w->item && !from->item; if(!isAlchAny(w)) return false;
return alch1; if(!isAlchAny(from)) return false;
if(w->item) return false;
if(from->item) return false;
if(!nonorientable) return w->wall != from->wall;
forCellIdEx(c1, i, w)
if(c1 == from && (w->c.mirror(i) ? w->wall != from->wall : w->wall == from->wall))
return false;
return true;
} }
#if HDR #if HDR

View File

@ -1112,7 +1112,7 @@ bool pcmove::perform_actual_move() {
}); });
if(c2->item && isAlch(c2)) { if(c2->item && isAlch(c2)) {
if(alchMayDuplicate(cwt.at->wall)) { if(alchMayDuplicate(cwt.at->wall)) {
c2->wall = cwt.at->wall; c2->wall = conditional_flip_slime(mi.mirror(), cwt.at->wall);
c2->wparam = cwt.at->wparam; c2->wparam = cwt.at->wparam;
} }
else else