mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-02-13 12:16:53 +07:00
Updated uCore / Sector deploying support
This commit is contained in:
parent
dd45b43d7f
commit
07f0be8d8d
@ -27,7 +27,7 @@ allprojects {
|
||||
gdxVersion = '1.9.8'
|
||||
roboVMVersion = '2.3.0'
|
||||
aiVersion = '1.8.1'
|
||||
uCoreVersion = 'b860a30db6'
|
||||
uCoreVersion = '27f83f3522e30c8f58e9fa4fe4764d5cd03195c7'
|
||||
|
||||
getVersionString = {
|
||||
String buildVersion = getBuildVersion()
|
||||
|
@ -50,6 +50,9 @@ text.addplayers=Add/Remove Players
|
||||
text.customgame=Custom Game
|
||||
text.campaign=Campaign
|
||||
text.sectors=Sectors
|
||||
text.sector=Selected Sector: {0}
|
||||
text.sector.deploy=Deploy
|
||||
text.sector.locked=[scarlet][[LOCKED]
|
||||
text.quit=Quit
|
||||
text.maps=Maps
|
||||
text.maps.none=[LIGHT_GRAY]No maps found!
|
||||
|
@ -207,7 +207,7 @@ public class World extends Module{
|
||||
}
|
||||
|
||||
/**Loads up a procedural map. This does not call play(), but calls reset().*/
|
||||
public void loadProceduralMap(){
|
||||
public void loadProceduralMap(int sectorX, int sectorY){
|
||||
Timers.mark();
|
||||
Timers.mark();
|
||||
|
||||
@ -215,17 +215,17 @@ public class World extends Module{
|
||||
|
||||
beginMapLoad();
|
||||
|
||||
int width = 400, height = 400;
|
||||
int width = sectorSize, height = sectorSize;
|
||||
|
||||
Tile[][] tiles = createTiles(width, height);
|
||||
|
||||
Map map = new Map("Generated Map", new MapMeta(0, new ObjectMap<>(), width, height, null), true, () -> null);
|
||||
Map map = new Map("Sector [" + sectorX + ", " + sectorY + "]", new MapMeta(0, new ObjectMap<>(), width, height, null), true, () -> null);
|
||||
setMap(map);
|
||||
|
||||
EntityPhysics.resizeTree(0, 0, width * tilesize, height * tilesize);
|
||||
|
||||
Timers.mark();
|
||||
generator.generateMap(tiles, Mathf.random(9999999));
|
||||
generator.generateMap(tiles, sectorX, sectorY);
|
||||
Log.info("Time to generate base map: {0}", Timers.elapsed());
|
||||
|
||||
Log.info("Time to generate fully without additional events: {0}", Timers.elapsed());
|
||||
|
@ -84,6 +84,7 @@ public enum EditorTool{
|
||||
|
||||
byte bf = editor.getMap().read(x, y, DataPosition.floor);
|
||||
byte bw = editor.getMap().read(x, y, DataPosition.wall);
|
||||
byte be = editor.getMap().read(x, y, DataPosition.elevation);
|
||||
boolean synth = editor.getDrawBlock().synthetic();
|
||||
byte brt = Bits.packByte((byte) editor.getDrawRotation(), (byte) editor.getDrawTeam().ordinal());
|
||||
|
||||
@ -105,8 +106,9 @@ public enum EditorTool{
|
||||
|
||||
byte nbf = editor.getMap().read(px, py, DataPosition.floor);
|
||||
byte nbw = editor.getMap().read(px, py, DataPosition.wall);
|
||||
byte nbe = editor.getMap().read(px, py, DataPosition.elevation);
|
||||
|
||||
if((floor ? nbf : nbw) == dest){
|
||||
if((floor ? nbf : nbw) == dest && nbe == be){
|
||||
TileDataMarker prev = editor.getPrev(px, py, false);
|
||||
|
||||
if(floor){
|
||||
|
@ -1,13 +1,12 @@
|
||||
package io.anuke.mindustry.maps;
|
||||
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.graphics.Pixmap;
|
||||
import com.badlogic.gdx.graphics.Pixmap.Format;
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
import com.badlogic.gdx.math.GridPoint2;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import io.anuke.mindustry.content.blocks.Blocks;
|
||||
import io.anuke.mindustry.maps.generation.WorldGenerator.GenResult;
|
||||
import io.anuke.mindustry.world.ColorMapper;
|
||||
import io.anuke.ucore.core.Settings;
|
||||
import io.anuke.ucore.util.Geometry;
|
||||
import io.anuke.ucore.util.GridMap;
|
||||
@ -77,8 +76,6 @@ public class Sectors{
|
||||
|
||||
Pixmap pixmap = new Pixmap(sectorImageSize, sectorImageSize, Format.RGBA8888);
|
||||
|
||||
int worldX = sector.x * sectorSize;
|
||||
int worldY = sector.y * sectorSize;
|
||||
for(int x = 0; x < sectorImageSize; x++){
|
||||
for(int y = 0; y < sectorImageSize; y++){
|
||||
int toX = x * sectorSize / sectorImageSize;
|
||||
@ -86,7 +83,7 @@ public class Sectors{
|
||||
|
||||
GenResult result = world.generator().generateTile(sector.x, sector.y, toX, toY);
|
||||
|
||||
int color = ColorMapper.getBlockColor(result.wall == Blocks.air ? result.floor : result.wall);
|
||||
int color = Color.rgba8888(result.floor.minimapColor);
|
||||
pixmap.drawPixel(x, sectorImageSize - 1 - y, color);
|
||||
}
|
||||
}
|
||||
|
@ -165,12 +165,12 @@ public class WorldGenerator{
|
||||
}
|
||||
}
|
||||
|
||||
public void generateMap(Tile[][] tiles, int seed){
|
||||
public void generateMap(Tile[][] tiles, int sectorX, int sectorY){
|
||||
int width = tiles.length, height = tiles[0].length;
|
||||
|
||||
for(int x = 0; x < width; x++){
|
||||
for(int y = 0; y < height; y++){
|
||||
GenResult result = generateTile(0, 0, x, y);
|
||||
GenResult result = generateTile(sectorX, sectorY, x, y);
|
||||
Tile tile = new Tile(x, y, (byte)result.floor.id, (byte)result.wall.id, (byte)0, (byte)0, result.elevation);
|
||||
tiles[x][y] = tile;
|
||||
}
|
||||
@ -212,12 +212,12 @@ public class WorldGenerator{
|
||||
Block floor = Blocks.stone;
|
||||
Block wall = Blocks.air;
|
||||
|
||||
double elevation = sim.octaveNoise2D(3, 0.5, 1f / 100, x, y) * 4.1 - 1;
|
||||
double temp = sim3.octaveNoise2D(7, 0.54, 1f / 320f, x, y);
|
||||
double elevation = sim.octaveNoise2D(3, 0.5, 1f / 500, x, y) * 4.1 - 1;
|
||||
double temp = sim3.octaveNoise2D(7, 0.54, 1f / 820f, 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));
|
||||
double dst = Vector2.dst(sectorSize / 2, sectorSize / 2, x, y);
|
||||
double dst = Vector2.dst((sectorX * sectorSize) + sectorSize/2f, (sectorY * sectorSize) + sectorSize/2f, x, y);
|
||||
double elevDip = 30;
|
||||
|
||||
double border = 14;
|
||||
|
@ -8,7 +8,6 @@ import io.anuke.mindustry.game.GameMode;
|
||||
import io.anuke.mindustry.maps.Map;
|
||||
import io.anuke.mindustry.ui.BorderImage;
|
||||
import io.anuke.ucore.core.Settings;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
import io.anuke.ucore.graphics.Draw;
|
||||
import io.anuke.ucore.scene.event.Touchable;
|
||||
import io.anuke.ucore.scene.ui.ButtonGroup;
|
||||
@ -16,7 +15,6 @@ import io.anuke.ucore.scene.ui.ImageButton;
|
||||
import io.anuke.ucore.scene.ui.ScrollPane;
|
||||
import io.anuke.ucore.scene.ui.TextButton;
|
||||
import io.anuke.ucore.scene.ui.layout.Table;
|
||||
import io.anuke.ucore.scene.utils.Cursors;
|
||||
import io.anuke.ucore.scene.utils.Elements;
|
||||
import io.anuke.ucore.util.Bundles;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
@ -119,17 +117,19 @@ public class LevelDialog extends FloatingDialog{
|
||||
|
||||
ImageButton genb = maps.addImageButton("icon-editor", "clear", 16 * 3, () -> {
|
||||
hide();
|
||||
//TODO
|
||||
|
||||
/*
|
||||
ui.loadfrag.show();
|
||||
|
||||
Timers.run(5f, () -> {
|
||||
Cursors.restoreCursor();
|
||||
threads.run(() -> {
|
||||
world.loadProceduralMap();
|
||||
world.loadProceduralMap(0, 0);
|
||||
logic.play();
|
||||
Gdx.app.postRunnable(ui.loadfrag::hide);
|
||||
});
|
||||
});
|
||||
});*/
|
||||
}).width(170).fillY().pad(4f).get();
|
||||
|
||||
genb.top();
|
||||
|
@ -1,20 +1,27 @@
|
||||
package io.anuke.mindustry.ui.dialogs;
|
||||
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.math.Rectangle;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import io.anuke.mindustry.graphics.Palette;
|
||||
import io.anuke.mindustry.maps.Sector;
|
||||
import io.anuke.ucore.core.Graphics;
|
||||
import io.anuke.ucore.graphics.Draw;
|
||||
import io.anuke.ucore.graphics.Lines;
|
||||
import io.anuke.ucore.scene.Element;
|
||||
import io.anuke.ucore.scene.event.ClickListener;
|
||||
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.scene.utils.ScissorStack;
|
||||
import io.anuke.ucore.util.Bundles;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
|
||||
import static io.anuke.mindustry.Vars.world;
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class SectorsDialog extends FloatingDialog{
|
||||
private Rectangle clip = new Rectangle();
|
||||
private Sector selected;
|
||||
|
||||
public SectorsDialog(){
|
||||
super("$text.sectors");
|
||||
@ -26,13 +33,26 @@ public class SectorsDialog extends FloatingDialog{
|
||||
void setup(){
|
||||
content().clear();
|
||||
|
||||
content().label(() -> Bundles.format("text.sector", selected == null ? "<none>" :
|
||||
selected.x + ", " + selected.y + (!selected.unlocked ? Bundles.get("text.sector.locked") : "")));
|
||||
content().row();
|
||||
content().add(new SectorView()).grow();
|
||||
content().row();
|
||||
buttons().addImageTextButton("$text.sector.deploy", "icon-play", 10*3, () -> {
|
||||
hide();
|
||||
|
||||
ui.loadLogic(() -> {
|
||||
world.loadProceduralMap(selected.x, selected.y);
|
||||
logic.play();
|
||||
});
|
||||
}).size(230f, 64f).disabled(b -> selected == null);
|
||||
}
|
||||
|
||||
class SectorView extends Element{
|
||||
float panX, panY;
|
||||
float lastX, lastY;
|
||||
float sectorSize = 100f;
|
||||
boolean clicked = false;
|
||||
|
||||
SectorView(){
|
||||
addListener(new InputListener(){
|
||||
@ -58,6 +78,13 @@ public class SectorsDialog extends FloatingDialog{
|
||||
Cursors.restoreCursor();
|
||||
}
|
||||
});
|
||||
|
||||
addListener(new ClickListener(){
|
||||
@Override
|
||||
public void clicked(InputEvent event, float x, float y){
|
||||
clicked = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -65,7 +92,7 @@ public class SectorsDialog extends FloatingDialog{
|
||||
Draw.alpha(alpha);
|
||||
|
||||
float clipSize = Math.min(width, height);
|
||||
int shownSectors = Math.round(clipSize/sectorSize/2f + 1f);
|
||||
int shownSectors = (int)(clipSize/sectorSize);
|
||||
clip.setSize(clipSize).setCenter(x + width/2f, y + height/2f);
|
||||
Graphics.flush();
|
||||
boolean clipped = ScissorStack.pushScissors(clip);
|
||||
@ -73,6 +100,8 @@ public class SectorsDialog extends FloatingDialog{
|
||||
int offsetX = (int)(panX / sectorSize);
|
||||
int offsetY = (int)(panY / sectorSize);
|
||||
|
||||
Vector2 mouse = Graphics.mouse();
|
||||
|
||||
for(int x = -shownSectors; x <= shownSectors; x++){
|
||||
for(int y = -shownSectors; y <= shownSectors; y++){
|
||||
int sectorX = offsetX + x;
|
||||
@ -86,16 +115,39 @@ public class SectorsDialog extends FloatingDialog{
|
||||
}
|
||||
|
||||
Sector sector = world.sectors().get(sectorX, sectorY);
|
||||
Draw.rect(sector.texture, drawX, drawY, sectorSize, sectorSize);
|
||||
Lines.stroke(2f);
|
||||
Lines.crect(drawX, drawY, sectorSize, sectorSize);
|
||||
|
||||
if(sector == null) continue;
|
||||
|
||||
Draw.color(Color.WHITE);
|
||||
Draw.rect(sector.texture, drawX, drawY, sectorSize, sectorSize);
|
||||
|
||||
if(sector == selected){
|
||||
Draw.color(Palette.place);
|
||||
}else if(Mathf.inRect(mouse.x, mouse.y, drawX - sectorSize/2f, drawY - sectorSize/2f, drawX + sectorSize/2f, drawY + sectorSize/2f)){
|
||||
if(clicked){
|
||||
selected = sector;
|
||||
}
|
||||
Draw.color(Palette.remove);
|
||||
}else if (sector.unlocked){
|
||||
Draw.color(Palette.accent);
|
||||
}else{
|
||||
Draw.color(Color.LIGHT_GRAY);
|
||||
}
|
||||
|
||||
Lines.stroke(selected == sector ? 5f : 3f);
|
||||
Lines.crect(drawX, drawY, sectorSize, sectorSize);
|
||||
}
|
||||
}
|
||||
|
||||
Draw.color(Palette.accent);
|
||||
Lines.stroke(4f);
|
||||
Lines.crect(x + width/2f, y + height/2f, clipSize, clipSize);
|
||||
|
||||
Draw.reset();
|
||||
Graphics.flush();
|
||||
if(clipped) ScissorStack.popScissors();
|
||||
|
||||
clicked = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user