More cleanup

This commit is contained in:
Anuken 2020-03-31 19:39:14 -04:00
parent 77447c59f6
commit 19239a6890
8 changed files with 44 additions and 81 deletions

View File

@ -5,6 +5,7 @@ attribute vec4 a_color;
uniform mat4 u_proj; uniform mat4 u_proj;
uniform mat4 u_trans; uniform mat4 u_trans;
uniform vec3 u_lightdir; uniform vec3 u_lightdir;
//uniform vec3 u_camdir;
uniform vec3 u_ambientColor; uniform vec3 u_ambientColor;
varying vec4 v_col; varying vec4 v_col;

View File

@ -1,18 +1,15 @@
package mindustry.editor; package mindustry.editor;
import arc.util.ArcAnnotate.*; import arc.util.ArcAnnotate.*;
import mindustry.content.Blocks; import mindustry.content.*;
import mindustry.core.GameState.State; import mindustry.editor.DrawOperation.*;
import mindustry.editor.DrawOperation.OpType; import mindustry.game.*;
import mindustry.game.Team; import mindustry.gen.*;
import mindustry.gen.TileOp; import mindustry.world.*;
import mindustry.world.Block;
import mindustry.world.Tile;
import mindustry.world.blocks.environment.*; import mindustry.world.blocks.environment.*;
import mindustry.world.modules.*; import mindustry.world.modules.*;
import static mindustry.Vars.state; import static mindustry.Vars.*;
import static mindustry.Vars.ui;
public class EditorTile extends Tile{ public class EditorTile extends Tile{
@ -22,7 +19,7 @@ public class EditorTile extends Tile{
@Override @Override
public void setFloor(@NonNull Floor type){ public void setFloor(@NonNull Floor type){
if(state.is(State.playing)){ if(state.isGame()){
super.setFloor(type); super.setFloor(type);
return; return;
} }
@ -43,7 +40,7 @@ public class EditorTile extends Tile{
@Override @Override
public void setBlock(Block type, Team team, int rotation){ public void setBlock(Block type, Team team, int rotation){
if(state.is(State.playing)){ if(state.isGame()){
super.setBlock(type, team, rotation); super.setBlock(type, team, rotation);
return; return;
} }
@ -56,7 +53,7 @@ public class EditorTile extends Tile{
@Override @Override
public void setTeam(Team team){ public void setTeam(Team team){
if(state.is(State.playing)){ if(state.isGame()){
super.setTeam(team); super.setTeam(team);
return; return;
} }
@ -68,7 +65,7 @@ public class EditorTile extends Tile{
@Override @Override
public void rotation(int rotation){ public void rotation(int rotation){
if(state.is(State.playing)){ if(state.isGame()){
super.rotation(rotation); super.rotation(rotation);
return; return;
} }
@ -80,7 +77,7 @@ public class EditorTile extends Tile{
@Override @Override
public void setOverlay(Block overlay){ public void setOverlay(Block overlay){
if(state.is(State.playing)){ if(state.isGame()){
super.setOverlay(overlay); super.setOverlay(overlay);
return; return;
} }
@ -93,31 +90,28 @@ public class EditorTile extends Tile{
@Override @Override
protected void preChanged(){ protected void preChanged(){
if(state.is(State.playing)){ super.preChanged();
super.preChanged();
return;
}
super.setTeam(Team.derelict);
} }
@Override
public void recache(){
if(state.isGame()){
super.recache();
}
}
@Override @Override
protected void changed(Team team){ protected void changed(Team team){
if(state.is(State.playing)){ if(state.isGame()){
super.changed(team); super.changed(team);
return; return;
} }
entity = null; entity = null;
if(block == null){ if(block == null) block = Blocks.air;
block = Blocks.air; if(floor == null) floor = (Floor)Blocks.air;
}
if(floor == null){
floor = (Floor)Blocks.air;
}
Block block = block(); Block block = block();
if(block.hasEntity()){ if(block.hasEntity()){

View File

@ -1,17 +1,15 @@
package mindustry.editor; package mindustry.editor;
import arc.struct.StringMap; import arc.files.*;
import arc.files.Fi; import arc.func.*;
import arc.func.Cons; import arc.graphics.*;
import arc.func.Boolf; import arc.math.*;
import arc.graphics.Pixmap; import arc.struct.*;
import arc.math.Mathf; import mindustry.content.*;
import arc.util.Structs; import mindustry.game.*;
import mindustry.content.Blocks; import mindustry.gen.*;
import mindustry.game.Team; import mindustry.io.*;
import mindustry.gen.TileOp; import mindustry.maps.*;
import mindustry.io.MapIO;
import mindustry.maps.Map;
import mindustry.world.*; import mindustry.world.*;
import static mindustry.Vars.*; import static mindustry.Vars.*;
@ -126,31 +124,6 @@ public class MapEditor{
if(drawBlock.isMultiblock()){ if(drawBlock.isMultiblock()){
x = Mathf.clamp(x, (drawBlock.size - 1) / 2, width() - drawBlock.size / 2 - 1); x = Mathf.clamp(x, (drawBlock.size - 1) / 2, width() - drawBlock.size / 2 - 1);
y = Mathf.clamp(y, (drawBlock.size - 1) / 2, height() - drawBlock.size / 2 - 1); y = Mathf.clamp(y, (drawBlock.size - 1) / 2, height() - drawBlock.size / 2 - 1);
int offsetx = -(drawBlock.size - 1) / 2;
int offsety = -(drawBlock.size - 1) / 2;
//TODO this is completely unnecessary now!
for(int dx = 0; dx < drawBlock.size; dx++){
for(int dy = 0; dy < drawBlock.size; dy++){
int worldx = dx + offsetx + x;
int worldy = dy + offsety + y;
if(Structs.inBounds(worldx, worldy, width(), height())){
Tile tile = tile(worldx, worldy);
Block block = tile.block();
//bail out if there's anything blocking the way
if(block.isMultiblock()){
return;
}
renderer.updatePoint(worldx, worldy);
}
}
}
tile(x, y).setBlock(drawBlock, drawTeam, 0); tile(x, y).setBlock(drawBlock, drawTeam, 0);
}else{ }else{
boolean isFloor = drawBlock.isFloor() && drawBlock != Blocks.air; boolean isFloor = drawBlock.isFloor() && drawBlock != Blocks.air;
@ -158,12 +131,6 @@ public class MapEditor{
Cons<Tile> drawer = tile -> { Cons<Tile> drawer = tile -> {
if(!tester.get(tile)) return; if(!tester.get(tile)) return;
//remove linked tiles blocking the way
//TODO also unnecessary
//if(!isFloor && (tile.isLinked() || tile.block().isMultiblock())){
// tile.link().remove();
//}
if(isFloor){ if(isFloor){
tile.setFloor(drawBlock.asFloor()); tile.setFloor(drawBlock.asFloor());
}else{ }else{
@ -188,7 +155,7 @@ public class MapEditor{
public void drawCircle(int x, int y, Cons<Tile> drawer){ public void drawCircle(int x, int y, Cons<Tile> drawer){
for(int rx = -brushSize; rx <= brushSize; rx++){ for(int rx = -brushSize; rx <= brushSize; rx++){
for(int ry = -brushSize; ry <= brushSize; ry++){ for(int ry = -brushSize; ry <= brushSize; ry++){
if(Mathf.dst2(rx, ry) <= (brushSize - 0.5f) * (brushSize - 0.5f)){ if(Mathf.within(rx, ry, brushSize - 0.5f + 0.0001f)){
int wx = x + rx, wy = y + ry; int wx = x + rx, wy = y + ry;
if(wx < 0 || wy < 0 || wx >= width() || wy >= height()){ if(wx < 0 || wy < 0 || wx >= width() || wy >= height()){

View File

@ -146,7 +146,6 @@ public class MapGenerateDialog extends FloatingDialog{
} }
//reset undo stack as generation... messes things up //reset undo stack as generation... messes things up
editor.load(editor::checkLinkedTiles);
editor.renderer().updateAll(); editor.renderer().updateAll();
editor.clearOp(); editor.clearOp();
} }

View File

@ -118,9 +118,10 @@ public class MapRenderer implements Disposable{
int idxWall = (wx % chunkSize) + (wy % chunkSize) * chunkSize; int idxWall = (wx % chunkSize) + (wy % chunkSize) * chunkSize;
int idxDecal = (wx % chunkSize) + (wy % chunkSize) * chunkSize + chunkSize * chunkSize; int idxDecal = (wx % chunkSize) + (wy % chunkSize) * chunkSize + chunkSize * chunkSize;
boolean center = tile.isCenter();
if(wall != Blocks.air && wall.synthetic()){ if(wall != Blocks.air && wall.synthetic()){
region = !Core.atlas.isFound(wall.editorIcon()) ? Core.atlas.find("clear-editor") : wall.editorIcon(); region = !Core.atlas.isFound(wall.editorIcon()) || !center ? Core.atlas.find("clear-editor") : wall.editorIcon();
if(wall.rotate){ if(wall.rotate){
mesh.draw(idxWall, region, mesh.draw(idxWall, region,
@ -142,14 +143,14 @@ public class MapRenderer implements Disposable{
float offsetX = -(wall.size / 3) * tilesize, offsetY = -(wall.size / 3) * tilesize; float offsetX = -(wall.size / 3) * tilesize, offsetY = -(wall.size / 3) * tilesize;
if(wall.update || wall.destructible){ if((wall.update || wall.destructible) && center){
mesh.setColor(team.color); mesh.setColor(team.color);
region = Core.atlas.find("block-border-editor"); region = Core.atlas.find("block-border-editor");
}else if(!wall.synthetic() && wall != Blocks.air){ }else if(!wall.synthetic() && wall != Blocks.air && center){
region = !Core.atlas.isFound(wall.editorIcon()) ? Core.atlas.find("clear-editor") : wall.editorIcon(); region = !Core.atlas.isFound(wall.editorIcon()) ? Core.atlas.find("clear-editor") : wall.editorIcon();
offsetX = tilesize / 2f - region.getWidth() / 2f * Draw.scl; offsetX = tilesize / 2f - region.getWidth() / 2f * Draw.scl;
offsetY = tilesize / 2f - region.getHeight() / 2f * Draw.scl; offsetY = tilesize / 2f - region.getHeight() / 2f * Draw.scl;
}else if(wall == Blocks.air && tile.overlay() != null){ }else if(wall == Blocks.air){
region = tile.overlay().editorVariantRegions()[Mathf.randomSeed(idxWall, 0, tile.overlay().editorVariantRegions().length - 1)]; region = tile.overlay().editorVariantRegions()[Mathf.randomSeed(idxWall, 0, tile.overlay().editorVariantRegions().length - 1)];
}else{ }else{
region = Core.atlas.find("clear-editor"); region = Core.atlas.find("clear-editor");

View File

@ -241,7 +241,7 @@ public class FloorRenderer implements Disposable{
} }
} }
Log.info("Time to cache: {0}", Time.elapsed()); Log.debug("Time to cache: {0}", Time.elapsed());
} }
@Override @Override

View File

@ -60,7 +60,6 @@ public class FileMapGenerator implements WorldGenerator{
throw new IllegalArgumentException("All zone maps must have a core."); throw new IllegalArgumentException("All zone maps must have a core.");
} }
world.prepareTiles(tiles);
state.map = map; state.map = map;
} }
} }

View File

@ -59,7 +59,9 @@ public class TODOPlanetGenerator extends PlanetGenerator{
public Color getColor(Vec3 position){ public Color getColor(Vec3 position){
Block block = getBlock(position); Block block = getBlock(position);
//replace salt with sand color //replace salt with sand color
return block == Blocks.salt ? Blocks.sand.mapColor : block.mapColor; if(block == Blocks.salt) return Blocks.sand.mapColor;
//return block.asFloor().isLiquid ? Tmp.c1.set(block.mapColor).a(0.5f) : block.mapColor;
return block.mapColor;
} }
@Override @Override