mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-17 09:41:24 +01:00
river edit - allow to move river to occupied cells
This commit is contained in:
parent
9c68c2b09e
commit
ca5aefaf15
2 changed files with 9 additions and 20 deletions
|
|
@ -991,12 +991,6 @@ body button.noicon {
|
||||||
stroke-width: 0.4;
|
stroke-width: 0.4;
|
||||||
}
|
}
|
||||||
|
|
||||||
#controlCells > .occupied {
|
|
||||||
fill: #ff828240;
|
|
||||||
stroke: #ff8282;
|
|
||||||
stroke-width: 0.4;
|
|
||||||
}
|
|
||||||
|
|
||||||
#vertices > circle {
|
#vertices > circle {
|
||||||
fill: #ff0000;
|
fill: #ff0000;
|
||||||
stroke: #841f1f;
|
stroke: #841f1f;
|
||||||
|
|
|
||||||
|
|
@ -124,18 +124,13 @@ function editRiver(id) {
|
||||||
const initCell = +this.dataset.cell;
|
const initCell = +this.dataset.cell;
|
||||||
const index = +this.dataset.i;
|
const index = +this.dataset.i;
|
||||||
|
|
||||||
const occupiedCells = i.filter(i => r[i] && !river.cells.includes(i));
|
|
||||||
drawCells(occupiedCells, "occupied");
|
|
||||||
let movedToCell = null;
|
let movedToCell = null;
|
||||||
|
|
||||||
d3.event.on("drag", function () {
|
d3.event.on("drag", function () {
|
||||||
const {x, y} = d3.event;
|
const {x, y} = d3.event;
|
||||||
const currentCell = findCell(x, y);
|
const currentCell = findCell(x, y);
|
||||||
|
|
||||||
if (initCell !== currentCell) {
|
movedToCell = initCell !== currentCell ? currentCell : null;
|
||||||
if (occupiedCells.includes(currentCell)) return;
|
|
||||||
movedToCell = currentCell;
|
|
||||||
} else movedToCell = null;
|
|
||||||
|
|
||||||
this.setAttribute("cx", x);
|
this.setAttribute("cx", x);
|
||||||
this.setAttribute("cy", y);
|
this.setAttribute("cy", y);
|
||||||
|
|
@ -149,6 +144,7 @@ function editRiver(id) {
|
||||||
river.cells[index] = movedToCell;
|
river.cells[index] = movedToCell;
|
||||||
drawCells(river.cells, "current");
|
drawCells(river.cells, "current");
|
||||||
|
|
||||||
|
if (!r[movedToCell]) {
|
||||||
// swap river data
|
// swap river data
|
||||||
r[initCell] = 0;
|
r[initCell] = 0;
|
||||||
r[movedToCell] = river.i;
|
r[movedToCell] = river.i;
|
||||||
|
|
@ -156,8 +152,7 @@ function editRiver(id) {
|
||||||
fl[initCell] = fl[movedToCell];
|
fl[initCell] = fl[movedToCell];
|
||||||
fl[movedToCell] = sourceFlux;
|
fl[movedToCell] = sourceFlux;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
debug.select("#controlCells").selectAll("polygon.available, polygon.occupied").remove();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue