1
0
mirror of https://github.com/Anuken/Mindustry.git synced 2024-11-11 14:56:10 +03:00

Added elevation tool

This commit is contained in:
Anuken 2018-06-12 10:58:07 -04:00
parent d7120af5cb
commit 4b093812bc
14 changed files with 728 additions and 761 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 258 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 156 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 167 B

After

Width:  |  Height:  |  Size: 167 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 161 B

After

Width:  |  Height:  |  Size: 162 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 162 B

After

Width:  |  Height:  |  Size: 165 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 182 B

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 111 KiB

After

Width:  |  Height:  |  Size: 112 KiB

View File

@ -12,7 +12,7 @@ import io.anuke.mindustry.world.Tile;
import io.anuke.mindustry.world.blocks.*;
public class Blocks extends BlockList implements ContentList{
public static Block air, spawn, blockpart, space, metalfloor, deepwater, water, lava, oil, stone, blackstone, iron, lead, coal, titanium, thorium, dirt, sand, ice, snow, grass, sandblock, snowblock, stoneblock, blackstoneblock, grassblock, mossblock, shrub, rock, icerock, blackrock, dirtblock;
public static Block air, spawn, blockpart, space, metalfloor, deepwater, water, lava, oil, stone, blackstone, iron, lead, coal, titanium, thorium, dirt, sand, ice, snow, grass, shrub, rock, icerock, blackrock;
@Override
public void load() {
@ -138,35 +138,6 @@ public class Blocks extends BlockList implements ContentList{
grass = new Floor("grass");
sandblock = new StaticBlock("sandblock") {{
solid = true;
variants = 3;
}};
snowblock = new StaticBlock("snowblock") {{
solid = true;
variants = 3;
}};
stoneblock = new StaticBlock("stoneblock") {{
solid = true;
variants = 3;
}};
blackstoneblock = new StaticBlock("blackstoneblock") {{
solid = true;
variants = 3;
}};
grassblock = new StaticBlock("grassblock") {{
solid = true;
variants = 2;
}};
mossblock = new StaticBlock("mossblock") {{
solid = true;
}};
shrub = new Rock("shrub");
rock = new Rock("rock") {{
@ -183,9 +154,5 @@ public class Blocks extends BlockList implements ContentList{
variants = 1;
varyShadow = true;
}};
dirtblock = new StaticBlock("dirtblock") {{
solid = true;
}};
}
}

View File

@ -52,6 +52,17 @@ public enum EditorTool{
editor.draw(x, y, Blocks.air);
}
},
elevation{
{
edit = true;
draggable = true;
}
@Override
public void touched(MapEditor editor, int x, int y){
editor.elevate(x, y);
}
},
line{
{

View File

@ -182,6 +182,30 @@ public class MapEditor{
}
}
public void elevate(int x, int y){
if(x < 0 || y < 0 || x >= map.width() || y >= map.height()){
return;
}
for (int rx = -brushSize; rx <= brushSize; rx++) {
for (int ry = -brushSize; ry <= brushSize; ry++) {
if (Mathf.dst(rx, ry) <= brushSize - 0.5f) {
int wx = x + rx, wy = y + ry;
if (wx < 0 || wy < 0 || wx >= map.width() || wy >= map.height()) {
continue;
}
TileDataMarker prev = getPrev(wx, wy, true);
map.write(wx, wy, DataPosition.elevation, elevation);
onWrite(x + rx, y + ry, prev);
}
}
}
}
private void removeLinked(int x, int y){
Block block = Block.getByID(map.read(x, y, DataPosition.wall));

View File

@ -409,12 +409,14 @@ public class MapEditorDialog extends Dialog implements Disposable{
tools.defaults().size(size, size + 4f).padBottom(-5.1f);
tools.addImageButton("icon-back", 16*2, () -> tryExit());
//tools.addImageButton("icon-back", 16*2, () -> tryExit());
tools.addImageButton("icon-menu-large", 16*2f, menu::show);
ImageButton grid = tools.addImageButton("icon-grid", "toggle", 16*2f, () -> view.setGrid(!view.isGrid())).get();
addTool.accept(EditorTool.zoom);
tools.row();
ImageButton undo = tools.addImageButton("icon-undo", 16*2f, () -> view.undo()).get();
@ -438,7 +440,8 @@ public class MapEditorDialog extends Dialog implements Disposable{
tools.row();
addTool.accept(EditorTool.fill);
addTool.accept(EditorTool.zoom);
addTool.accept(EditorTool.elevation);
ImageButton rotate = tools.addImageButton("icon-arrow-16", 16*2f, () -> editor.setDrawRotation((editor.getDrawRotation() + 1)%4)).get();
rotate.getImage().update(() ->{

View File

@ -70,7 +70,7 @@ public class MapFilter{
noise += 2 * (dist - 0.8);
}
Block block = noise > 0.6 ? Blocks.stoneblock : Blocks.stone;
Block block = Blocks.stone;
pixmap.drawPixel(x, y, ColorMapper.getColor(block));
}
@ -110,32 +110,6 @@ public class MapFilter{
double noil = sim.octaveNoise2D(1, 1.0, 1 / 150.0, x + 9999, y) + sim.octaveNoise2D(1, 1.0, 1 / 2.0, x, y) / 290.0;
if(!floor || prefs.get("replace").enabled){
if(prefs.get("allgrass").enabled){
block = floor ? Blocks.grass : Blocks.grassblock;
}else if(prefs.get("allsnow").enabled){
block = floor ? Blocks.snow : Blocks.snowblock;
}else if(prefs.get("allsand").enabled){
block = floor ? Blocks.sand : Blocks.sandblock;
}else if(prefs.get("replace").enabled){
block = floor ? Blocks.stone : Blocks.stoneblock;
}
if(noise > 0.7 && prefs.get("grass").enabled){
block = floor ? Blocks.grass : Blocks.grassblock;
}
if(noise > 0.7 && prefs.get("blackstone").enabled){
block = floor ? Blocks.blackstone : Blocks.blackstoneblock;
}
if(noise > 0.7 && prefs.get("sand").enabled){
block = floor ? Blocks.sand : Blocks.sandblock;
}
if(noise > 0.8 && prefs.get("stone").enabled){
block = floor ? Blocks.stone : Blocks.stoneblock;
}
}
if(floor){
if(nwater > 0.93 && prefs.get("water").enabled){
block = Blocks.water;

View File

@ -23,18 +23,13 @@ public class ColorMapper{
colors = map(
"323232", pair(Blocks.stone),
"646464", pair(Blocks.stone, Blocks.stoneblock),
"50965a", pair(Blocks.grass),
"5ab464", pair(Blocks.grass, Blocks.grassblock),
"506eb4", pair(Blocks.water),
"465a96", pair(Blocks.deepwater),
"252525", pair(Blocks.blackstone),
"575757", pair(Blocks.blackstone, Blocks.blackstoneblock),
"988a67", pair(Blocks.sand),
"e5d8bb", pair(Blocks.sand, Blocks.sandblock),
"c2d1d2", pair(Blocks.snow),
"c4e3e7", pair(Blocks.ice),
"f7feff", pair(Blocks.snow, Blocks.snowblock),
"6e501e", pair(Blocks.dirt),
"ed5334", pair(Blocks.lava),
"292929", pair(Blocks.oil),