mirror of
https://github.com/Anuken/Mindustry.git
synced 2024-11-11 03:31:19 +03:00
Generation minor improvements / Added debug map view
This commit is contained in:
parent
882790d133
commit
3a63fa5475
@ -43,7 +43,7 @@ public class NetServer extends Module{
|
||||
public final static boolean showSnapshotSize = false;
|
||||
|
||||
private final static byte[] reusableSnapArray = new byte[maxSnapshotSize];
|
||||
private final static float serverSyncTime = 4, kickDuration = 30 * 1000;
|
||||
private final static float serverSyncTime = 5, kickDuration = 30 * 1000;
|
||||
private final static Vector2 vector = new Vector2();
|
||||
/**If a play goes away of their server-side coordinates by this distance, they get teleported back.*/
|
||||
private final static float correctDist = 16f;
|
||||
|
@ -217,8 +217,8 @@ public class WorldGenerator{
|
||||
Block floor = Blocks.stone;
|
||||
Block wall = Blocks.air;
|
||||
|
||||
double elevation = sim.octaveNoise2D(detailed ? 7 : 2, 0.5, 1f / 500, x, y) * 4.1 - 1;
|
||||
double temp = vn.noise(x, y, 1f/200f)/2f + sim3.octaveNoise2D(detailed ? 12 : 6, 0.6, 1f / 620f, x, y);
|
||||
double elevation = sim.octaveNoise2D(detailed ? 7 : 2, 0.5, 1f / 500, x, y) * 5.1 - 1;
|
||||
double temp = vn.noise(x, y, 1f/400f)/2f + sim3.octaveNoise2D(detailed ? 12 : 6, 0.6, 1f / 620f, x, y);
|
||||
|
||||
double r = sim2.octaveNoise2D(1, 0.6, 1f / 70, x, y);
|
||||
double edgeDist = Math.max(sectorSize / 2, sectorSize / 2) - Math.max(Math.abs(x - sectorSize / 2), Math.abs(y - sectorSize / 2));
|
||||
@ -257,6 +257,10 @@ public class WorldGenerator{
|
||||
}
|
||||
}
|
||||
|
||||
if(((Floor)floor).liquidDrop != null){
|
||||
elevation = 0;
|
||||
}
|
||||
|
||||
if(detailed && wall == Blocks.air && decoration.containsKey(floor) && random.chance(0.03)){
|
||||
wall = decoration.get(floor);
|
||||
}
|
||||
|
88
core/src/io/anuke/mindustry/ui/dialogs/GenViewDialog.java
Normal file
88
core/src/io/anuke/mindustry/ui/dialogs/GenViewDialog.java
Normal file
@ -0,0 +1,88 @@
|
||||
package io.anuke.mindustry.ui.dialogs;
|
||||
|
||||
import com.badlogic.gdx.graphics.Pixmap;
|
||||
import com.badlogic.gdx.graphics.Pixmap.Format;
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
import io.anuke.mindustry.game.Team;
|
||||
import io.anuke.mindustry.maps.generation.WorldGenerator.GenResult;
|
||||
import io.anuke.mindustry.world.ColorMapper;
|
||||
import io.anuke.ucore.graphics.Draw;
|
||||
import io.anuke.ucore.scene.Element;
|
||||
import io.anuke.ucore.scene.event.InputEvent;
|
||||
import io.anuke.ucore.scene.event.InputListener;
|
||||
import io.anuke.ucore.scene.utils.Cursors;
|
||||
import io.anuke.ucore.util.GridMap;
|
||||
|
||||
import static io.anuke.mindustry.Vars.sectorSize;
|
||||
import static io.anuke.mindustry.Vars.world;
|
||||
|
||||
public class GenViewDialog extends FloatingDialog{
|
||||
|
||||
public GenViewDialog(){
|
||||
super("generate view");
|
||||
|
||||
content().add(new GenView()).grow();
|
||||
}
|
||||
|
||||
public class GenView extends Element{
|
||||
GridMap<Texture> map = new GridMap<>();
|
||||
float panX, panY;
|
||||
float lastX, lastY;
|
||||
int viewsize = 2;
|
||||
|
||||
{
|
||||
addListener(new InputListener(){
|
||||
@Override
|
||||
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button){
|
||||
Cursors.setHand();
|
||||
lastX = x;
|
||||
lastY = y;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void touchDragged(InputEvent event, float x, float y, int pointer){
|
||||
panX -= x - lastX;
|
||||
panY -= y - lastY;
|
||||
|
||||
lastX = x;
|
||||
lastY = y;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void touchUp(InputEvent event, float x, float y, int pointer, int button){
|
||||
Cursors.restoreCursor();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void draw(){
|
||||
int tx = (int)(panX / sectorSize);
|
||||
int ty = (int)(panY / sectorSize);
|
||||
float padSectorSize = 200f;
|
||||
|
||||
Draw.color();
|
||||
|
||||
for(int x = -viewsize; x <= viewsize; x++){
|
||||
for(int y = -viewsize; y <= viewsize; y++){
|
||||
int wx = tx + x, wy = ty + y;
|
||||
if(map.get(wx, wy) == null){
|
||||
Pixmap pixmap = new Pixmap(sectorSize, sectorSize, Format.RGBA8888);
|
||||
for(int i = 0; i < sectorSize; i++){
|
||||
for(int j = 0; j < sectorSize; j++){
|
||||
GenResult result = world.generator().generateTile(wx, wy, i, j);
|
||||
pixmap.drawPixel(i, sectorSize - 1 - j, ColorMapper.colorFor(result.floor, result.wall, Team.none, result.elevation));
|
||||
}
|
||||
}
|
||||
map.put(wx, wy, new Texture(pixmap));
|
||||
}
|
||||
|
||||
float drawX = x + width/2f+ wx * padSectorSize - tx * padSectorSize - panX % padSectorSize;
|
||||
float drawY = y + height/2f + wy * padSectorSize - ty * padSectorSize - panY % padSectorSize;
|
||||
|
||||
Draw.rect(map.get(wx, wy), drawX, drawY, padSectorSize, padSectorSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -11,6 +11,7 @@ import io.anuke.mindustry.game.Team;
|
||||
import io.anuke.mindustry.net.Net;
|
||||
import io.anuke.mindustry.type.Item;
|
||||
import io.anuke.mindustry.ui.dialogs.FloatingDialog;
|
||||
import io.anuke.mindustry.ui.dialogs.GenViewDialog;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
import io.anuke.ucore.entities.EntityGroup;
|
||||
import io.anuke.ucore.scene.Group;
|
||||
@ -123,6 +124,8 @@ public class DebugFragment extends Fragment{
|
||||
|
||||
t.add("Debug");
|
||||
t.row();
|
||||
t.addButton("map", () -> new GenViewDialog().show());
|
||||
t.row();
|
||||
t.addButton("noclip", "toggle", () -> noclip = !noclip);
|
||||
t.row();
|
||||
t.addButton("items", () -> {
|
||||
|
@ -17,6 +17,7 @@ import io.anuke.ucore.function.Consumer;
|
||||
import io.anuke.ucore.util.OS;
|
||||
import io.anuke.ucore.util.Strings;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.NetworkInterface;
|
||||
import java.text.DateFormat;
|
||||
import java.text.NumberFormat;
|
||||
@ -106,7 +107,9 @@ public class DesktopPlatform extends Platform{
|
||||
|
||||
@Override
|
||||
public boolean isDebug(){
|
||||
return args.length > 0 && args[0].equalsIgnoreCase("-debug_" + getUUID().hashCode());
|
||||
//honestly I'm just putting this ridiculous """anti-debug""" mess here to see if anyone bothers solving it without editing source
|
||||
return args.length > 0 && args[0].equals("-debug_" + getUUID().hashCode() + "_"
|
||||
+ " " + System.getProperty("os.arch") + "nice" + (int)(Math.sin(System.getProperty("user.dir").hashCode()) * 100) + Thread.currentThread().getStackTrace()[1].toString()) && new File("../../desktop/build/").exists();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user