mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-02-08 01:43:59 +07:00
More cleanup
This commit is contained in:
parent
77447c59f6
commit
19239a6890
@ -5,6 +5,7 @@ attribute vec4 a_color;
|
||||
uniform mat4 u_proj;
|
||||
uniform mat4 u_trans;
|
||||
uniform vec3 u_lightdir;
|
||||
//uniform vec3 u_camdir;
|
||||
uniform vec3 u_ambientColor;
|
||||
|
||||
varying vec4 v_col;
|
||||
|
@ -1,18 +1,15 @@
|
||||
package mindustry.editor;
|
||||
|
||||
import arc.util.ArcAnnotate.*;
|
||||
import mindustry.content.Blocks;
|
||||
import mindustry.core.GameState.State;
|
||||
import mindustry.editor.DrawOperation.OpType;
|
||||
import mindustry.game.Team;
|
||||
import mindustry.gen.TileOp;
|
||||
import mindustry.world.Block;
|
||||
import mindustry.world.Tile;
|
||||
import mindustry.content.*;
|
||||
import mindustry.editor.DrawOperation.*;
|
||||
import mindustry.game.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.environment.*;
|
||||
import mindustry.world.modules.*;
|
||||
|
||||
import static mindustry.Vars.state;
|
||||
import static mindustry.Vars.ui;
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class EditorTile extends Tile{
|
||||
|
||||
@ -22,7 +19,7 @@ public class EditorTile extends Tile{
|
||||
|
||||
@Override
|
||||
public void setFloor(@NonNull Floor type){
|
||||
if(state.is(State.playing)){
|
||||
if(state.isGame()){
|
||||
super.setFloor(type);
|
||||
return;
|
||||
}
|
||||
@ -43,7 +40,7 @@ public class EditorTile extends Tile{
|
||||
|
||||
@Override
|
||||
public void setBlock(Block type, Team team, int rotation){
|
||||
if(state.is(State.playing)){
|
||||
if(state.isGame()){
|
||||
super.setBlock(type, team, rotation);
|
||||
return;
|
||||
}
|
||||
@ -56,7 +53,7 @@ public class EditorTile extends Tile{
|
||||
|
||||
@Override
|
||||
public void setTeam(Team team){
|
||||
if(state.is(State.playing)){
|
||||
if(state.isGame()){
|
||||
super.setTeam(team);
|
||||
return;
|
||||
}
|
||||
@ -68,7 +65,7 @@ public class EditorTile extends Tile{
|
||||
|
||||
@Override
|
||||
public void rotation(int rotation){
|
||||
if(state.is(State.playing)){
|
||||
if(state.isGame()){
|
||||
super.rotation(rotation);
|
||||
return;
|
||||
}
|
||||
@ -80,7 +77,7 @@ public class EditorTile extends Tile{
|
||||
|
||||
@Override
|
||||
public void setOverlay(Block overlay){
|
||||
if(state.is(State.playing)){
|
||||
if(state.isGame()){
|
||||
super.setOverlay(overlay);
|
||||
return;
|
||||
}
|
||||
@ -93,31 +90,28 @@ public class EditorTile extends Tile{
|
||||
|
||||
@Override
|
||||
protected void preChanged(){
|
||||
if(state.is(State.playing)){
|
||||
super.preChanged();
|
||||
return;
|
||||
}
|
||||
|
||||
super.setTeam(Team.derelict);
|
||||
super.preChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recache(){
|
||||
if(state.isGame()){
|
||||
super.recache();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void changed(Team team){
|
||||
if(state.is(State.playing)){
|
||||
if(state.isGame()){
|
||||
super.changed(team);
|
||||
return;
|
||||
}
|
||||
|
||||
entity = null;
|
||||
|
||||
if(block == null){
|
||||
block = Blocks.air;
|
||||
}
|
||||
|
||||
if(floor == null){
|
||||
floor = (Floor)Blocks.air;
|
||||
}
|
||||
|
||||
if(block == null) block = Blocks.air;
|
||||
if(floor == null) floor = (Floor)Blocks.air;
|
||||
|
||||
Block block = block();
|
||||
|
||||
if(block.hasEntity()){
|
||||
|
@ -1,17 +1,15 @@
|
||||
package mindustry.editor;
|
||||
|
||||
import arc.struct.StringMap;
|
||||
import arc.files.Fi;
|
||||
import arc.func.Cons;
|
||||
import arc.func.Boolf;
|
||||
import arc.graphics.Pixmap;
|
||||
import arc.math.Mathf;
|
||||
import arc.util.Structs;
|
||||
import mindustry.content.Blocks;
|
||||
import mindustry.game.Team;
|
||||
import mindustry.gen.TileOp;
|
||||
import mindustry.io.MapIO;
|
||||
import mindustry.maps.Map;
|
||||
import arc.files.*;
|
||||
import arc.func.*;
|
||||
import arc.graphics.*;
|
||||
import arc.math.*;
|
||||
import arc.struct.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.game.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.io.*;
|
||||
import mindustry.maps.*;
|
||||
import mindustry.world.*;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
@ -126,31 +124,6 @@ public class MapEditor{
|
||||
if(drawBlock.isMultiblock()){
|
||||
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);
|
||||
|
||||
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);
|
||||
}else{
|
||||
boolean isFloor = drawBlock.isFloor() && drawBlock != Blocks.air;
|
||||
@ -158,12 +131,6 @@ public class MapEditor{
|
||||
Cons<Tile> drawer = tile -> {
|
||||
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){
|
||||
tile.setFloor(drawBlock.asFloor());
|
||||
}else{
|
||||
@ -188,7 +155,7 @@ public class MapEditor{
|
||||
public void drawCircle(int x, int y, Cons<Tile> drawer){
|
||||
for(int rx = -brushSize; rx <= brushSize; rx++){
|
||||
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;
|
||||
|
||||
if(wx < 0 || wy < 0 || wx >= width() || wy >= height()){
|
||||
|
@ -146,7 +146,6 @@ public class MapGenerateDialog extends FloatingDialog{
|
||||
}
|
||||
|
||||
//reset undo stack as generation... messes things up
|
||||
editor.load(editor::checkLinkedTiles);
|
||||
editor.renderer().updateAll();
|
||||
editor.clearOp();
|
||||
}
|
||||
|
@ -118,9 +118,10 @@ public class MapRenderer implements Disposable{
|
||||
|
||||
int idxWall = (wx % chunkSize) + (wy % chunkSize) * chunkSize;
|
||||
int idxDecal = (wx % chunkSize) + (wy % chunkSize) * chunkSize + chunkSize * chunkSize;
|
||||
boolean center = tile.isCenter();
|
||||
|
||||
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){
|
||||
mesh.draw(idxWall, region,
|
||||
@ -142,14 +143,14 @@ public class MapRenderer implements Disposable{
|
||||
|
||||
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);
|
||||
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();
|
||||
offsetX = tilesize / 2f - region.getWidth() / 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)];
|
||||
}else{
|
||||
region = Core.atlas.find("clear-editor");
|
||||
|
@ -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
|
||||
|
@ -60,7 +60,6 @@ public class FileMapGenerator implements WorldGenerator{
|
||||
throw new IllegalArgumentException("All zone maps must have a core.");
|
||||
}
|
||||
|
||||
world.prepareTiles(tiles);
|
||||
state.map = map;
|
||||
}
|
||||
}
|
||||
|
@ -59,7 +59,9 @@ public class TODOPlanetGenerator extends PlanetGenerator{
|
||||
public Color getColor(Vec3 position){
|
||||
Block block = getBlock(position);
|
||||
//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
|
||||
|
Loading…
Reference in New Issue
Block a user