mirror of
https://github.com/Anuken/Mindustry.git
synced 2026-04-27 07:50:54 -07:00
Removed sector camera clamp / Added map edge padding / Turret sprite fix
This commit is contained in:
parent
7ff4e5879d
commit
363bf7c552
15 changed files with 141 additions and 102 deletions
|
|
@ -46,6 +46,7 @@ public class Vars{
|
|||
public static final float itemSize = 5f;
|
||||
public static final int tilesize = 8;
|
||||
public static final int sectorSize = 256;
|
||||
public static final int mapPadding = 3;
|
||||
public static final int invalidSector = Integer.MAX_VALUE;
|
||||
public static final Locale[] locales = {new Locale("en"), new Locale("fr"), new Locale("ru"), new Locale("uk", "UA"), new Locale("pl"),
|
||||
new Locale("de"), new Locale("pt", "BR"), new Locale("ko"), new Locale("in", "ID"),
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import com.badlogic.gdx.utils.ObjectSet;
|
|||
import com.badlogic.gdx.utils.ObjectSet.ObjectSetIterator;
|
||||
import com.badlogic.gdx.utils.Queue;
|
||||
import com.badlogic.gdx.utils.TimeUtils;
|
||||
import io.anuke.mindustry.content.blocks.Blocks;
|
||||
import io.anuke.mindustry.game.EventType.TileChangeEvent;
|
||||
import io.anuke.mindustry.game.EventType.WorldLoadEvent;
|
||||
import io.anuke.mindustry.game.Team;
|
||||
|
|
@ -84,7 +85,7 @@ public class Pathfinder{
|
|||
}
|
||||
|
||||
private boolean passable(Tile tile, Team team){
|
||||
return (tile.getWallID() == 0 && !tile.floor().isLiquid && tile.cliffs == 0 && !tile.floor().solid && !(tile.floor().isLiquid && (tile.floor().damageTaken > 0 || tile.floor().drownTime > 0)))
|
||||
return (tile.block() == Blocks.air && !tile.floor().isLiquid && tile.cliffs == 0 && !tile.floor().solid && !(tile.floor().isLiquid && (tile.floor().damageTaken > 0 || tile.floor().drownTime > 0)))
|
||||
|| (tile.breakable() && (tile.getTeam() != team)) || !tile.solid();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ public class StatusEffects implements ContentList{
|
|||
freezing = new StatusEffect(5 * 60f){
|
||||
{
|
||||
oppositeScale = 0.4f;
|
||||
speedMultiplier = 0.7f;
|
||||
speedMultiplier = 0.5f;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -63,7 +63,7 @@ public class StatusEffects implements ContentList{
|
|||
wet = new StatusEffect(3 * 60f){
|
||||
{
|
||||
oppositeScale = 0.5f;
|
||||
speedMultiplier = 0.999f;
|
||||
speedMultiplier = 0.9f;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -155,7 +155,9 @@ public class Renderer extends RendererModule{
|
|||
setCamera(position.x + 0.0001f, position.y + 0.0001f);
|
||||
}
|
||||
|
||||
//clampCamera(-tilesize / 2f, -tilesize / 2f + 1, world.width() * tilesize - tilesize / 2f, world.height() * tilesize - tilesize / 2f);
|
||||
if(world.getSector() == null){
|
||||
clampCamera(-tilesize / 2f, -tilesize / 2f + 1, world.width() * tilesize - tilesize / 2f, world.height() * tilesize - tilesize / 2f);
|
||||
}
|
||||
|
||||
float prex = camera.position.x, prey = camera.position.y;
|
||||
updateShake(0.75f);
|
||||
|
|
|
|||
|
|
@ -566,8 +566,13 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
|||
|
||||
for(Block block : Block.all()){
|
||||
TextureRegion[] regions = block.getCompactIcon();
|
||||
if((block.synthetic() && (Recipe.getByResult(block) == null || !control.database().isUnlocked(Recipe.getByResult(block)))) && !debug && block != StorageBlocks.core)
|
||||
if((block.synthetic() && (Recipe.getByResult(block) == null || !control.database().isUnlocked(Recipe.getByResult(block)))) && !debug && block != StorageBlocks.core){
|
||||
continue;
|
||||
}
|
||||
|
||||
if(Recipe.getByResult(block) != null && Recipe.getByResult(block).debugOnly && !debug){
|
||||
continue;
|
||||
}
|
||||
|
||||
if(regions.length == 0 || regions[0] == Draw.region("jjfgj")) continue;
|
||||
|
||||
|
|
|
|||
|
|
@ -4,13 +4,15 @@ import com.badlogic.gdx.Gdx;
|
|||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.graphics.GL20;
|
||||
import com.badlogic.gdx.graphics.OrthographicCamera;
|
||||
import com.badlogic.gdx.graphics.glutils.ShaderProgram;
|
||||
import com.badlogic.gdx.utils.IntArray;
|
||||
import com.badlogic.gdx.utils.IntSet;
|
||||
import com.badlogic.gdx.utils.IntSet.IntSetIterator;
|
||||
import com.badlogic.gdx.utils.ObjectSet;
|
||||
import io.anuke.mindustry.game.EventType.WorldLoadGraphicsEvent;
|
||||
import io.anuke.mindustry.maps.Sector;
|
||||
import io.anuke.mindustry.maps.generation.WorldGenerator.GenResult;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.blocks.Floor;
|
||||
import io.anuke.ucore.core.Core;
|
||||
import io.anuke.ucore.core.Events;
|
||||
import io.anuke.ucore.core.Graphics;
|
||||
|
|
@ -18,11 +20,13 @@ import io.anuke.ucore.core.Timers;
|
|||
import io.anuke.ucore.graphics.CacheBatch;
|
||||
import io.anuke.ucore.graphics.Draw;
|
||||
import io.anuke.ucore.graphics.Fill;
|
||||
import io.anuke.ucore.util.Geometry;
|
||||
import io.anuke.ucore.util.Log;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import static io.anuke.mindustry.Vars.mapPadding;
|
||||
import static io.anuke.mindustry.Vars.tilesize;
|
||||
import static io.anuke.mindustry.Vars.world;
|
||||
|
||||
|
|
@ -30,6 +34,8 @@ public class FloorRenderer{
|
|||
private final static int chunksize = 64;
|
||||
|
||||
private int gutter;
|
||||
private Tile gutterTile;
|
||||
private Tile gutterNearTile = new Tile(0, 0);
|
||||
private Chunk[][] cache;
|
||||
private CacheBatch cbatch;
|
||||
private IntSet drawnLayerSet = new IntSet();
|
||||
|
|
@ -37,35 +43,26 @@ public class FloorRenderer{
|
|||
|
||||
public FloorRenderer(){
|
||||
Events.on(WorldLoadGraphicsEvent.class, this::clearTiles);
|
||||
}
|
||||
|
||||
static ShaderProgram createDefaultShader(){
|
||||
String vertexShader = "attribute vec4 " + ShaderProgram.POSITION_ATTRIBUTE + ";\n" //
|
||||
+ "attribute vec2 " + ShaderProgram.TEXCOORD_ATTRIBUTE + "0;\n" //
|
||||
+ "uniform mat4 u_projTrans;\n" //
|
||||
+ "varying vec2 v_texCoords;\n" //
|
||||
+ "\n" //
|
||||
+ "void main()\n" //
|
||||
+ "{\n" //
|
||||
+ " v_texCoords = " + ShaderProgram.TEXCOORD_ATTRIBUTE + "0;\n" //
|
||||
+ " gl_Position = u_projTrans * " + ShaderProgram.POSITION_ATTRIBUTE + ";\n" //
|
||||
+ "}\n";
|
||||
String fragmentShader = "#ifdef GL_ES\n" //
|
||||
+ "#define LOWP lowp\n" //
|
||||
+ "precision mediump float;\n" //
|
||||
+ "#else\n" //
|
||||
+ "#define LOWP \n" //
|
||||
+ "#endif\n" //
|
||||
+ "varying vec2 v_texCoords;\n" //
|
||||
+ "uniform sampler2D u_texture;\n" //
|
||||
+ "void main()\n"//
|
||||
+ "{\n" //
|
||||
+ " gl_FragColor = texture2D(u_texture, v_texCoords);\n" //
|
||||
+ "}";
|
||||
gutterTile = new Tile(0, 0){
|
||||
@Override
|
||||
public Tile getNearby(int dx, int dy){
|
||||
Sector sec = world.getSector();
|
||||
GenResult result = world.generator().generateTile(sec.x, sec.y, x + dx, y + dy);
|
||||
gutterNearTile.x = (short)(x + dx);
|
||||
gutterNearTile.y = (short)(y + dy);
|
||||
gutterNearTile.setElevation(result.elevation);
|
||||
gutterNearTile.setFloor((Floor)result.floor);
|
||||
return gutterNearTile;
|
||||
}
|
||||
|
||||
ShaderProgram shader = new ShaderProgram(vertexShader, fragmentShader);
|
||||
if(!shader.isCompiled()) throw new IllegalArgumentException("Error compiling shader: " + shader.getLog());
|
||||
return shader;
|
||||
@Override
|
||||
public Tile getNearby(int rotation){
|
||||
int dx = Geometry.d4[rotation].x;
|
||||
int dy = Geometry.d4[rotation].y;
|
||||
return getNearby(dx, dy);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public void drawFloor(){
|
||||
|
|
@ -198,11 +195,22 @@ public class FloorRenderer{
|
|||
|
||||
ObjectSet<CacheLayer> used = new ObjectSet<>();
|
||||
|
||||
Sector sector = world.getSector();
|
||||
|
||||
for(int tilex = cx * chunksize; tilex < (cx + 1) * chunksize; tilex++){
|
||||
for(int tiley = cy * chunksize; tiley < (cy + 1) * chunksize; tiley++){
|
||||
Tile tile = world.tile(tilex - gutter, tiley - gutter);
|
||||
if(tile != null){
|
||||
used.add(tile.floor().cacheLayer);
|
||||
Floor floor = null;
|
||||
|
||||
if(tile == null && sector != null){
|
||||
GenResult result = world.generator().generateTile(sector.x, sector.y, tilex - gutter, tiley - gutter);
|
||||
floor = (Floor) result.floor;
|
||||
}else if(tile != null){
|
||||
floor = tile.floor();
|
||||
}
|
||||
|
||||
if(floor != null){
|
||||
used.add(floor.cacheLayer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -217,18 +225,34 @@ public class FloorRenderer{
|
|||
Graphics.useBatch(cbatch);
|
||||
cbatch.begin();
|
||||
|
||||
Sector sector = world.getSector();
|
||||
|
||||
for(int tilex = cx * chunksize; tilex < (cx + 1) * chunksize; tilex++){
|
||||
for(int tiley = cy * chunksize; tiley < (cy + 1) * chunksize; tiley++){
|
||||
Tile tile = world.tile(tilex - gutter, tiley - gutter);
|
||||
Floor floor;
|
||||
|
||||
if(tile == null){
|
||||
Fill.rect((tilex - gutter) * tilesize, (tiley - gutter) * tilesize, tilesize, tilesize);
|
||||
continue;
|
||||
if(sector != null){
|
||||
GenResult result = world.generator().generateTile(sector.x, sector.y, tilex - gutter, tiley - gutter);
|
||||
floor = (Floor)result.floor;
|
||||
gutterTile.setFloor(floor);
|
||||
gutterTile.x = (short)(tilex - gutter);
|
||||
gutterTile.y = (short)(tiley - gutter);
|
||||
gutterTile.setElevation(result.elevation);
|
||||
gutterTile.updateOcclusion();
|
||||
tile = gutterTile;
|
||||
}else{
|
||||
continue;
|
||||
}
|
||||
}else{
|
||||
floor = tile.floor();
|
||||
}
|
||||
|
||||
if(tile.floor().cacheLayer == layer){
|
||||
tile.floor().draw(tile);
|
||||
}else if(tile.floor().cacheLayer.ordinal() < layer.ordinal()){
|
||||
tile.floor().drawNonLayer(tile);
|
||||
if(floor.cacheLayer == layer){
|
||||
floor.draw(tile);
|
||||
}else if(floor.cacheLayer.ordinal() < layer.ordinal()){
|
||||
floor.drawNonLayer(tile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -244,7 +268,7 @@ public class FloorRenderer{
|
|||
Timers.mark();
|
||||
|
||||
if(world.getSector() != null){
|
||||
gutter = 32;
|
||||
gutter = mapPadding;
|
||||
}else{
|
||||
gutter = 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import com.badlogic.gdx.graphics.Pixmap.Format;
|
|||
import com.badlogic.gdx.graphics.Texture;
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||
import com.badlogic.gdx.graphics.glutils.FrameBuffer;
|
||||
import com.badlogic.gdx.math.Rectangle;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.badlogic.gdx.utils.Disposable;
|
||||
import io.anuke.mindustry.entities.Unit;
|
||||
|
|
@ -16,9 +17,9 @@ import io.anuke.ucore.core.Core;
|
|||
import io.anuke.ucore.core.Events;
|
||||
import io.anuke.ucore.core.Graphics;
|
||||
import io.anuke.ucore.entities.EntityDraw;
|
||||
import io.anuke.ucore.graphics.ClipSpriteBatch;
|
||||
import io.anuke.ucore.graphics.Draw;
|
||||
import io.anuke.ucore.graphics.Fill;
|
||||
import io.anuke.ucore.scene.utils.ScissorStack;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
|
|
@ -28,15 +29,23 @@ import static io.anuke.mindustry.Vars.*;
|
|||
* Used for rendering fog of war. A framebuffer is used for this.
|
||||
*/
|
||||
public class FogRenderer implements Disposable{
|
||||
private static final int extraPadding = 3;
|
||||
private static final int shadowPadding = 1;
|
||||
|
||||
private TextureRegion region = new TextureRegion();
|
||||
private FrameBuffer buffer;
|
||||
private ByteBuffer pixelBuffer = ByteBuffer.allocateDirect(4);
|
||||
private Array<Tile> changeQueue = new Array<>();
|
||||
private int padding;
|
||||
private Rectangle rect = new Rectangle();
|
||||
|
||||
public FogRenderer(){
|
||||
Events.on(WorldLoadGraphicsEvent.class, () -> {
|
||||
dispose();
|
||||
buffer = new FrameBuffer(Format.RGBA8888, world.width(), world.height(), false);
|
||||
|
||||
padding = world.getSector() != null ? mapPadding + extraPadding : 0;
|
||||
|
||||
buffer = new FrameBuffer(Format.RGBA8888, world.width() + padding*2, world.height() + padding*2, false);
|
||||
changeQueue.clear();
|
||||
|
||||
//clear buffer to black
|
||||
|
|
@ -62,26 +71,26 @@ public class FogRenderer implements Disposable{
|
|||
}));
|
||||
}
|
||||
|
||||
public int getPadding(){
|
||||
return padding;
|
||||
}
|
||||
|
||||
public void draw(){
|
||||
if(buffer == null) return;
|
||||
|
||||
float vw = Core.camera.viewportWidth * Core.camera.zoom;
|
||||
float vh = Core.camera.viewportHeight * Core.camera.zoom;
|
||||
|
||||
float px = Core.camera.position.x -= vw / 2f;
|
||||
float py = Core.camera.position.y -= vh / 2f;
|
||||
float px = Core.camera.position.x - vw / 2f;
|
||||
float py = Core.camera.position.y - vh / 2f;
|
||||
|
||||
float u = px / tilesize / world.width();
|
||||
float v = py / tilesize / world.height();
|
||||
float u = (px / tilesize + padding) / buffer.getWidth();
|
||||
float v = (py / tilesize + padding) / buffer.getHeight();
|
||||
|
||||
float u2 = (px + vw) / tilesize / world.width();
|
||||
float v2 = (py + vh) / tilesize / world.height();
|
||||
float u2 = ((px + vw) / tilesize + padding) / buffer.getWidth();
|
||||
float v2 = ((py + vh) / tilesize + padding) / buffer.getHeight();
|
||||
|
||||
if(Core.batch instanceof ClipSpriteBatch){
|
||||
((ClipSpriteBatch) Core.batch).enableClip(false);
|
||||
}
|
||||
|
||||
Core.batch.getProjectionMatrix().setToOrtho2D(0, 0, world.width() * tilesize, world.height() * tilesize);
|
||||
Core.batch.getProjectionMatrix().setToOrtho2D(-padding * tilesize, -padding * tilesize, buffer.getWidth() * tilesize, buffer.getHeight() * tilesize);
|
||||
|
||||
Draw.color(Color.WHITE);
|
||||
|
||||
|
|
@ -93,6 +102,10 @@ public class FogRenderer implements Disposable{
|
|||
//Gdx.gl.glReadPixels(world.width()/2, world.height()/2 + 20, 1, 1, GL20.GL_RGB, GL20.GL_UNSIGNED_BYTE, pixelBuffer);
|
||||
//Log.info(pixelBuffer.get(0));
|
||||
|
||||
boolean pop = ScissorStack.pushScissors(rect.set((padding-shadowPadding), (padding-shadowPadding),
|
||||
(world.width() + shadowPadding*2) ,
|
||||
(world.height() + shadowPadding*2)));
|
||||
|
||||
Graphics.begin();
|
||||
EntityDraw.setClip(false);
|
||||
|
||||
|
|
@ -111,6 +124,8 @@ public class FogRenderer implements Disposable{
|
|||
Graphics.end();
|
||||
buffer.end();
|
||||
|
||||
if(pop) ScissorStack.popScissors();
|
||||
|
||||
region.setTexture(buffer.getColorBufferTexture());
|
||||
region.setRegion(u, v2, u2, v);
|
||||
|
||||
|
|
@ -128,10 +143,6 @@ public class FogRenderer implements Disposable{
|
|||
Graphics.setScreen();
|
||||
Core.batch.draw(renderer.pixelSurface.texture(), 0, Gdx.graphics.getHeight(), Gdx.graphics.getWidth(), -Gdx.graphics.getHeight());
|
||||
Graphics.end();
|
||||
|
||||
if(Core.batch instanceof ClipSpriteBatch){
|
||||
((ClipSpriteBatch) Core.batch).enableClip(true);
|
||||
}
|
||||
}
|
||||
|
||||
public Texture getTexture(){
|
||||
|
|
|
|||
|
|
@ -57,6 +57,10 @@ public class MinimapRenderer implements Disposable{
|
|||
zoom = Mathf.clamp(zoom, 1, Math.min(world.width(), world.height()) / baseSize / 2);
|
||||
}
|
||||
|
||||
public float getZoom(){
|
||||
return zoom;
|
||||
}
|
||||
|
||||
public void reset(){
|
||||
if(pixmap != null){
|
||||
pixmap.dispose();
|
||||
|
|
|
|||
|
|
@ -215,7 +215,7 @@ public class Save16 extends SaveFileVersion{
|
|||
Tile tile = world.tile(i);
|
||||
|
||||
stream.writeByte(tile.getFloorID());
|
||||
stream.writeByte(tile.getWallID());
|
||||
stream.writeByte(tile.getBlockID());
|
||||
stream.writeByte(tile.getElevation());
|
||||
|
||||
if(tile.block() instanceof BlockPart){
|
||||
|
|
@ -230,13 +230,13 @@ public class Save16 extends SaveFileVersion{
|
|||
if(tile.entity.cons != null) tile.entity.cons.write(stream);
|
||||
|
||||
tile.entity.write(stream);
|
||||
}else if(tile.getWallID() == 0){
|
||||
}else if(tile.block() == Blocks.air){
|
||||
int consecutives = 0;
|
||||
|
||||
for(int j = i + 1; j < world.width() * world.height() && consecutives < 255; j++){
|
||||
Tile nextTile = world.tile(j);
|
||||
|
||||
if(nextTile.getFloorID() != tile.getFloorID() || nextTile.getWallID() != 0 || nextTile.getElevation() != tile.getElevation()){
|
||||
if(nextTile.getFloorID() != tile.getFloorID() || nextTile.block() != Blocks.air || nextTile.getElevation() != tile.getElevation()){
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ public class NetworkIO{
|
|||
Tile tile = world.tile(i);
|
||||
|
||||
stream.writeByte(tile.getFloorID());
|
||||
stream.writeByte(tile.getWallID());
|
||||
stream.writeByte(tile.getBlockID());
|
||||
stream.writeByte(tile.getElevation());
|
||||
|
||||
if(tile.block() instanceof BlockPart){
|
||||
|
|
@ -78,13 +78,13 @@ public class NetworkIO{
|
|||
if(tile.entity.cons != null) tile.entity.cons.write(stream);
|
||||
|
||||
tile.entity.write(stream);
|
||||
}else if(tile.getWallID() == 0){
|
||||
}else if(tile.block() == Blocks.air){
|
||||
int consecutives = 0;
|
||||
|
||||
for(int j = i + 1; j < world.width() * world.height() && consecutives < 255; j++){
|
||||
Tile nextTile = world.tile(j);
|
||||
|
||||
if(nextTile.getFloorID() != tile.getFloorID() || nextTile.getWallID() != 0 || nextTile.getElevation() != tile.getElevation()){
|
||||
if(nextTile.getFloorID() != tile.getFloorID() || nextTile.block() != Blocks.air || nextTile.getElevation() != tile.getElevation()){
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ import io.anuke.ucore.scene.ui.layout.Table;
|
|||
|
||||
import static io.anuke.mindustry.Vars.renderer;
|
||||
import static io.anuke.mindustry.Vars.showFog;
|
||||
import static io.anuke.mindustry.Vars.world;
|
||||
|
||||
public class Minimap extends Table{
|
||||
|
||||
|
|
@ -39,9 +40,27 @@ public class Minimap extends Table{
|
|||
if(showFog){
|
||||
renderer.fog().getTexture().setFilter(TextureFilter.Nearest, TextureFilter.Nearest);
|
||||
|
||||
draw.getRegion().setTexture(renderer.fog().getTexture());
|
||||
draw.getRegion().setV(1f - draw.getRegion().getV());
|
||||
draw.getRegion().setV2(1f - draw.getRegion().getV2());
|
||||
TextureRegion r = draw.getRegion();
|
||||
float pad = renderer.fog().getPadding();
|
||||
|
||||
float px = r.getU() * world.width() + pad;
|
||||
float py = r.getV() * world.height() + pad;
|
||||
float px2 = r.getU2() * world.width() + pad;
|
||||
float py2 = r.getV2() * world.height() + pad;
|
||||
|
||||
r.setTexture(renderer.fog().getTexture());
|
||||
r.setU(px / (world.width() + pad*2f));
|
||||
r.setV(1f - py / (world.height() + pad*2f));
|
||||
r.setU2(px2 / (world.width() + pad*2f));
|
||||
r.setV2(1f - py2 / (world.height() + pad*2f));
|
||||
|
||||
//r.setV(1f - draw.getRegion().getV());
|
||||
//r.setV2(1f - draw.getRegion().getV2());
|
||||
|
||||
//r.setU(r.getU() + renderer.fog().getPadding()/(float)(world.width() + renderer.fog().getPadding()*2) * renderer.minimap().getZoom());
|
||||
//r.setV(r.getV() - renderer.fog().getPadding()/(float)(world.height() + renderer.fog().getPadding()*2) * renderer.minimap().getZoom());
|
||||
//r.setU2(r.getU2() - renderer.fog().getPadding()/(float)(world.width() + renderer.fog().getPadding()*2) * renderer.minimap().getZoom());
|
||||
//r.setV2(r.getV2() + renderer.fog().getPadding()/(float)(world.height() + renderer.fog().getPadding()*2) * renderer.minimap().getZoom());
|
||||
|
||||
Graphics.shader(Shaders.fog);
|
||||
super.draw(batch, parentAlpha);
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ import io.anuke.mindustry.content.blocks.Blocks;
|
|||
import io.anuke.mindustry.entities.TileEntity;
|
||||
import io.anuke.mindustry.entities.traits.TargetTrait;
|
||||
import io.anuke.mindustry.game.Team;
|
||||
import io.anuke.mindustry.type.Recipe;
|
||||
import io.anuke.mindustry.world.blocks.Floor;
|
||||
import io.anuke.mindustry.world.modules.ConsumeModule;
|
||||
import io.anuke.mindustry.world.modules.InventoryModule;
|
||||
|
|
@ -18,7 +17,6 @@ import io.anuke.ucore.entities.trait.PosTrait;
|
|||
import io.anuke.ucore.function.Consumer;
|
||||
import io.anuke.ucore.util.Bits;
|
||||
import io.anuke.ucore.util.Geometry;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
|
||||
import static io.anuke.mindustry.Vars.tilesize;
|
||||
import static io.anuke.mindustry.Vars.world;
|
||||
|
|
@ -74,7 +72,7 @@ public class Tile implements PosTrait, TargetTrait{
|
|||
return x + y * world.width();
|
||||
}
|
||||
|
||||
public byte getWallID(){
|
||||
public byte getBlockID(){
|
||||
return (byte) wall.id;
|
||||
}
|
||||
|
||||
|
|
@ -151,16 +149,6 @@ public class Tile implements PosTrait, TargetTrait{
|
|||
return team;
|
||||
}
|
||||
|
||||
/** Returns the break time of the block, <i>or</i> the breaktime of the linked block, if this tile is linked. */
|
||||
public float getBreakTime(){
|
||||
Block block = target().block();
|
||||
if(Recipe.getByResult(block) != null){
|
||||
return Recipe.getByResult(block).cost;
|
||||
}else{
|
||||
return 15f;
|
||||
}
|
||||
}
|
||||
|
||||
public void setBlock(Block type, int rotation){
|
||||
synchronized(tileSetLock){
|
||||
preChanged();
|
||||
|
|
@ -340,14 +328,6 @@ public class Tile implements PosTrait, TargetTrait{
|
|||
return null;
|
||||
}
|
||||
|
||||
public Tile[] getNearby(Tile[] temptiles){
|
||||
temptiles[0] = world.tile(x + 1, y);
|
||||
temptiles[1] = world.tile(x, y + 1);
|
||||
temptiles[2] = world.tile(x - 1, y);
|
||||
temptiles[3] = world.tile(x, y - 1);
|
||||
return temptiles;
|
||||
}
|
||||
|
||||
public void updateOcclusion(){
|
||||
cost = 1;
|
||||
cliffs = 0;
|
||||
|
|
@ -365,16 +345,10 @@ public class Tile implements PosTrait, TargetTrait{
|
|||
|
||||
//check for bitmasking cliffs
|
||||
for(int i = 0; i < 4; i++){
|
||||
GridPoint2 pc = Geometry.d4[i];
|
||||
GridPoint2 pcprev = Geometry.d4[Mathf.mod(i - 1, 4)];
|
||||
GridPoint2 pcnext = Geometry.d4[(i + 1) % 4];
|
||||
|
||||
Tile tc = world.tile(x + pc.x, y + pc.y);
|
||||
Tile tprev = world.tile(x + pcprev.x, y + pcprev.y);
|
||||
Tile tnext = world.tile(x + pcnext.x, y + pcnext.y);
|
||||
Tile tc = getNearby(i);
|
||||
|
||||
//check for cardinal direction elevation changes and bitmask that
|
||||
if(tc != null && tprev != null && tnext != null && ((tc.elevation < elevation && tc.elevation != -1))){
|
||||
if(tc != null && ((tc.elevation < elevation && tc.elevation != -1))){
|
||||
cliffs |= (1 << (i * 2));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -208,7 +208,7 @@ public class BuildBlock extends Block{
|
|||
if(builder instanceof Player){
|
||||
builderID = builder.getID();
|
||||
}
|
||||
|
||||
|
||||
if(progress >= 1f || debug){
|
||||
CallBlocks.onConstructFinish(tile, recipe.result, builderID, tile.getRotation(), tile.getTeam());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,8 +17,6 @@ import io.anuke.ucore.graphics.Draw;
|
|||
import io.anuke.ucore.util.Geometry;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
|
||||
import static io.anuke.mindustry.Vars.world;
|
||||
|
||||
public class Floor extends Block{
|
||||
//TODO implement proper bitmasking
|
||||
protected static IntIntMap bitmask = Mathf.mapInt(2, 1, 8, 2, 10, 3, 11, 4, 16, 5, 18, 6, 22, 7, 24, 8,
|
||||
|
|
@ -174,7 +172,7 @@ public class Floor extends Block{
|
|||
for(int i = 0; i < 8; i++){
|
||||
int dx = Geometry.d8[i].x, dy = Geometry.d8[i].y;
|
||||
|
||||
Tile other = world.tile(tile.x + dx, tile.y + dy);
|
||||
Tile other = tile.getNearby(dx, dy);
|
||||
|
||||
if(other == null) continue;
|
||||
|
||||
|
|
|
|||
|
|
@ -133,7 +133,7 @@ public abstract class Turret extends Block{
|
|||
|
||||
drawer.accept(tile, entity);
|
||||
|
||||
if(heatRegion != null){
|
||||
if(heatRegion != Draw.region("error")){
|
||||
heatDrawer.accept(tile, entity);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue