[Script] automatic update
This commit is contained in:
@@ -68,6 +68,22 @@ public class MapEditor{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void updateRenderer(){
|
public void updateRenderer(){
|
||||||
|
Tiles tiles = world.tiles;
|
||||||
|
Seq<Building> builds = new Seq<>();
|
||||||
|
|
||||||
|
for(int i = 0; i < tiles.width * tiles.height; i++){
|
||||||
|
Tile tile = tiles.geti(i);
|
||||||
|
var build = tile.build;
|
||||||
|
if(build != null){
|
||||||
|
builds.add(build);
|
||||||
|
}
|
||||||
|
tiles.seti(i, new EditorTile(tile.x, tile.y, tile.floorID(), tile.overlayID(), build == null ? tile.blockID() : 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
for(var build : builds){
|
||||||
|
tiles.get(build.tileX(), build.tileY()).setBlock(build.block, build.team, build.rotation, () -> build);
|
||||||
|
}
|
||||||
|
|
||||||
renderer.resize(width(), height());
|
renderer.resize(width(), height());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -278,6 +278,8 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
|||||||
unit.spawnedByCore = true;
|
unit.spawnedByCore = true;
|
||||||
player.unit(unit);
|
player.unit(unit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
player.checkSpawn();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -87,7 +87,16 @@ public class SectorGenerateDialog extends BaseDialog{
|
|||||||
ui.loadAnd(() -> {
|
ui.loadAnd(() -> {
|
||||||
editor.clearOp();
|
editor.clearOp();
|
||||||
editor.load(() -> {
|
editor.load(() -> {
|
||||||
world.loadSector(planet.sectors.get(sector), seed);
|
var sectorobj = planet.sectors.get(sector);
|
||||||
|
|
||||||
|
//remove presets during generation: massive hack, but it works
|
||||||
|
var preset = sectorobj.preset;
|
||||||
|
sectorobj.preset = null;
|
||||||
|
|
||||||
|
world.loadSector(sectorobj, seed);
|
||||||
|
|
||||||
|
sectorobj.preset = preset;
|
||||||
|
|
||||||
editor.updateRenderer();
|
editor.updateRenderer();
|
||||||
state.rules.sector = null;
|
state.rules.sector = null;
|
||||||
//clear extra filters
|
//clear extra filters
|
||||||
|
|||||||
@@ -39,6 +39,11 @@ public class Tiles implements Iterable<Tile>{
|
|||||||
array[y*width + x] = tile;
|
array[y*width + x] = tile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** set a tile at a raw array position; does not range-check. use with caution. */
|
||||||
|
public void seti(int i, Tile tile){
|
||||||
|
array[i] = tile;
|
||||||
|
}
|
||||||
|
|
||||||
/** @return whether these coordinates are in bounds */
|
/** @return whether these coordinates are in bounds */
|
||||||
public boolean in(int x, int y){
|
public boolean in(int x, int y){
|
||||||
return x >= 0 && x < width && y >= 0 && y < height;
|
return x >= 0 && x < width && y >= 0 && y < height;
|
||||||
|
|||||||
Reference in New Issue
Block a user