Intelligent graphics sets support removal of fields too
This commit is contained in:
parent
e6c247c655
commit
c5eef3c657
|
@ -199,24 +199,40 @@ export default class Tilorswift
|
|||
this.level.terrain.getFieldNeighbourCode(field)
|
||||
);
|
||||
|
||||
field.setIndex(index % this.tileset.tiles);
|
||||
field.setIndex(index);
|
||||
|
||||
for (const neighbour of this.level.terrain.getFieldNeighbours(field)) {
|
||||
if (neighbour.index === -1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const neighbourIndex = (neighbour.index % this.tileset.primaryTiles) + this.tileset.primaryTiles * this.tileset.getTileIndexFactor(
|
||||
this.level.terrain.getFieldNeighbourCode(neighbour)
|
||||
);
|
||||
|
||||
neighbour.setIndex(neighbourIndex);
|
||||
}
|
||||
this.updateNeighbours(field);
|
||||
} else {
|
||||
field.setIndex(this.level.terrain.brushTileIndex);
|
||||
}
|
||||
}
|
||||
|
||||
updateNeighbours(field)
|
||||
{
|
||||
for (const neighbour of this.level.terrain.getFieldNeighbours(field)) {
|
||||
if (neighbour.index === -1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const neighbourIndex = (neighbour.index % this.tileset.primaryTiles) + this.tileset.primaryTiles * this.tileset.getTileIndexFactor(
|
||||
this.level.terrain.getFieldNeighbourCode(neighbour)
|
||||
);
|
||||
|
||||
neighbour.setIndex(neighbourIndex);
|
||||
}
|
||||
}
|
||||
|
||||
removeTerrain(field)
|
||||
{
|
||||
field.setIndex(-1);
|
||||
|
||||
if (this.brush.isIntelligent) {
|
||||
for (const neighbour of this.level.terrain.getFieldNeighbours(field)) {
|
||||
this.updateNeighbours(field);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
addEventListeners()
|
||||
{
|
||||
window.addEventListener(
|
||||
|
@ -228,7 +244,7 @@ export default class Tilorswift
|
|||
this.addTerrain(event.getField());
|
||||
break;
|
||||
case 2:
|
||||
event.getField().setIndex(-1);
|
||||
this.removeTerrain(event.getField());
|
||||
break;
|
||||
}
|
||||
} else if (this.brush.mode === BrushMode.ENTRANCE) {
|
||||
|
|
Loading…
Reference in New Issue