Editor bugfixes / Arbitrary map resizing
This commit is contained in:
@@ -128,33 +128,35 @@ public class Pathfinder implements Runnable{
|
||||
if(net.client()) return;
|
||||
try{
|
||||
|
||||
queue.run();
|
||||
if(state.isPlaying()){
|
||||
queue.run();
|
||||
|
||||
//total update time no longer than maxUpdate
|
||||
for(Flowfield data : threadList){
|
||||
updateFrontier(data, maxUpdate / threadList.size);
|
||||
//total update time no longer than maxUpdate
|
||||
for(Flowfield data : threadList){
|
||||
updateFrontier(data, maxUpdate / threadList.size);
|
||||
|
||||
//remove flowfields that have 'timed out' so they can be garbage collected and no longer waste space
|
||||
if(data.target.refreshRate() > 0 && Time.timeSinceMillis(data.lastUpdateTime) > fieldTimeout){
|
||||
//make sure it doesn't get removed twice
|
||||
data.lastUpdateTime = Time.millis();
|
||||
//remove flowfields that have 'timed out' so they can be garbage collected and no longer waste space
|
||||
if(data.target.refreshRate() > 0 && Time.timeSinceMillis(data.lastUpdateTime) > fieldTimeout){
|
||||
//make sure it doesn't get removed twice
|
||||
data.lastUpdateTime = Time.millis();
|
||||
|
||||
Team team = data.team;
|
||||
Team team = data.team;
|
||||
|
||||
Core.app.post(() -> {
|
||||
//remove its used state
|
||||
if(fieldMap[team.uid] != null){
|
||||
fieldMap[team.uid].remove(data.target);
|
||||
fieldMapUsed[team.uid].remove(data.target);
|
||||
}
|
||||
//remove from main thread list
|
||||
mainList.remove(data);
|
||||
});
|
||||
Core.app.post(() -> {
|
||||
//remove its used state
|
||||
if(fieldMap[team.uid] != null){
|
||||
fieldMap[team.uid].remove(data.target);
|
||||
fieldMapUsed[team.uid].remove(data.target);
|
||||
}
|
||||
//remove from main thread list
|
||||
mainList.remove(data);
|
||||
});
|
||||
|
||||
queue.post(() -> {
|
||||
//remove from this thread list with a delay
|
||||
threadList.remove(data);
|
||||
});
|
||||
queue.post(() -> {
|
||||
//remove from this thread list with a delay
|
||||
threadList.remove(data);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -132,10 +132,10 @@ public class Logic implements ApplicationListener{
|
||||
if(!state.isCampaign()){
|
||||
for(TeamData team : state.teams.getActive()){
|
||||
if(team.hasCore()){
|
||||
Tilec entity = team.core();
|
||||
entity.items().clear();
|
||||
TileEntity entity = team.core();
|
||||
entity.items.clear();
|
||||
for(ItemStack stack : state.rules.loadout){
|
||||
entity.items().add(stack.item, stack.amount);
|
||||
entity.items.add(stack.item, stack.amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,8 +2,10 @@ package mindustry.editor;
|
||||
|
||||
import arc.func.*;
|
||||
import arc.math.*;
|
||||
import arc.scene.ui.TextField.*;
|
||||
import arc.scene.ui.layout.*;
|
||||
import mindustry.gen.*;
|
||||
import arc.util.*;
|
||||
import mindustry.*;
|
||||
import mindustry.ui.dialogs.*;
|
||||
|
||||
public class MapResizeDialog extends BaseDialog{
|
||||
@@ -22,21 +24,12 @@ public class MapResizeDialog extends BaseDialog{
|
||||
for(boolean w : Mathf.booleans){
|
||||
table.add(w ? "$width" : "$height").padRight(8f);
|
||||
table.defaults().height(60f).padTop(8);
|
||||
table.button("<", () -> {
|
||||
if(w)
|
||||
width = move(width, -1);
|
||||
else
|
||||
height = move(height, -1);
|
||||
}).size(60f);
|
||||
|
||||
table.table(Tex.button, t -> t.label(() -> (w ? width : height) + "")).width(200);
|
||||
Vars.platform.addDialog(table.field((w ? width : height) + "", TextFieldFilter.digitsOnly, value -> {
|
||||
int val = Integer.parseInt(value);
|
||||
if(w) width = val; else height = val;
|
||||
}).valid(value -> Strings.canParsePostiveInt(value) && Integer.parseInt(value) <= maxSize && Integer.parseInt(value) >= minSize).get());
|
||||
|
||||
table.button(">", () -> {
|
||||
if(w)
|
||||
width = move(width, 1);
|
||||
else
|
||||
height = move(height, 1);
|
||||
}).size(60f);
|
||||
table.row();
|
||||
}
|
||||
cont.row();
|
||||
@@ -51,8 +44,4 @@ public class MapResizeDialog extends BaseDialog{
|
||||
hide();
|
||||
});
|
||||
}
|
||||
|
||||
static int move(int value, int direction){
|
||||
return Mathf.clamp((value / increment + direction) * increment, minSize, maxSize);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ public class MinimapRenderer implements Disposable{
|
||||
}
|
||||
|
||||
public void update(Tile tile){
|
||||
if(world.isGenerating()) return;
|
||||
if(world.isGenerating() || !state.isGame()) return;
|
||||
|
||||
int color = colorFor(world.tile(tile.x, tile.y));
|
||||
pixmap.draw(tile.x, pixmap.getHeight() - 1 - tile.y, color);
|
||||
|
||||
@@ -94,8 +94,10 @@ public class Sector{
|
||||
return (normal.dot(light) + 1f) / 2f;
|
||||
}
|
||||
|
||||
/** @return the sector size, in tiles */
|
||||
public int getSize(){
|
||||
return (int)(rect.radius * 3200);
|
||||
int res = (int)(rect.radius * 3200);
|
||||
return res % 2 == 0 ? res : res + 1;
|
||||
}
|
||||
|
||||
//TODO implement
|
||||
|
||||
Reference in New Issue
Block a user