Merge branch 'master' of https://github.com/Anuken/Mindustry into 4.0
# Conflicts: # core/assets-raw/sprites/blocks/chainturret-icon.png # core/assets-raw/sprites/blocks/chainturret.png # core/assets-raw/sprites/blocks/titancannon-icon.png # core/assets-raw/sprites/blocks/titancannon.png # core/assets/sprites/sprites.atlas # core/assets/sprites/sprites.png # core/assets/version.properties # core/src/io/anuke/mindustry/entities/effect/TeslaOrb.java # core/src/io/anuke/mindustry/graphics/BlockRenderer.java # core/src/io/anuke/mindustry/input/InputHandler.java # core/src/io/anuke/mindustry/input/PlaceMode.java
This commit is contained in:
@@ -1,22 +1,23 @@
|
||||
package io.anuke.mindustry.graphics;
|
||||
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import io.anuke.mindustry.content.blocks.Blocks;
|
||||
import io.anuke.mindustry.game.Team;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.blocks.types.StaticBlock;
|
||||
import io.anuke.mindustry.world.blocks.types.defense.Turret;
|
||||
import io.anuke.ucore.core.Graphics;
|
||||
import io.anuke.ucore.core.Settings;
|
||||
import io.anuke.ucore.graphics.Draw;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
import static io.anuke.ucore.core.Core.camera;
|
||||
|
||||
public class BlockRenderer{
|
||||
private final static int chunksize = 32;
|
||||
private final static int initialRequests = 32*32;
|
||||
|
||||
private FloorRenderer floorRenderer;
|
||||
@@ -25,6 +26,8 @@ public class BlockRenderer{
|
||||
private Layer lastLayer;
|
||||
private int requestidx = 0;
|
||||
private int iterateidx = 0;
|
||||
|
||||
private float storeX, storeY;
|
||||
|
||||
public BlockRenderer(){
|
||||
floorRenderer = new FloorRenderer();
|
||||
@@ -81,12 +84,12 @@ public class BlockRenderer{
|
||||
if(!expanded){
|
||||
addRequest(tile, Layer.block);
|
||||
}
|
||||
|
||||
|
||||
if(block.expanded || !expanded){
|
||||
if(block.layer != null && block.isLayer(tile)){
|
||||
addRequest(tile, block.layer);
|
||||
}
|
||||
|
||||
|
||||
if(block.layer2 != null && block.isLayer2(tile)){
|
||||
addRequest(tile, block.layer2);
|
||||
}
|
||||
@@ -206,4 +209,49 @@ public class BlockRenderer{
|
||||
r.layer = layer;
|
||||
requestidx ++;
|
||||
}
|
||||
|
||||
public void drawPreview(Block block, float drawx, float drawy, float rotation, float opacity) {
|
||||
Draw.alpha(opacity);
|
||||
Draw.rect(block.name(), drawx, drawy, rotation);
|
||||
}
|
||||
|
||||
public void handlePreview(Block block, float rotation, float drawx, float drawy, int tilex, int tiley) {
|
||||
|
||||
if(control.input().recipe != null && state.inventory.hasItems(control.input().recipe.requirements)
|
||||
&& control.input().validPlace(tilex, tiley, block) && (android || control.input().cursorNear())) {
|
||||
|
||||
if(block.isMultiblock()) {
|
||||
float halfBlockWidth = (block.size * tilesize) / 2;
|
||||
float halfBlockHeight = (block.size * tilesize) / 2;
|
||||
if((storeX == 0 && storeY == 0)) {
|
||||
storeX = drawx;
|
||||
storeY = drawy;
|
||||
}
|
||||
if((storeX == drawx - halfBlockWidth || storeX == drawx + halfBlockWidth || storeY == drawy - halfBlockHeight || storeY == drawy + halfBlockHeight) &&
|
||||
((tiley - control.input().getBlockY()) % block.size != 0 || (tilex - control.input().getBlockX()) % block.size != 0)) {
|
||||
return;
|
||||
}
|
||||
else {
|
||||
storeX = drawx;
|
||||
storeY = drawy;
|
||||
}
|
||||
}
|
||||
|
||||
float opacity = (float) Settings.getInt("previewopacity") / 100f;
|
||||
Draw.color(Color.WHITE);
|
||||
Draw.alpha(opacity);
|
||||
|
||||
if(block instanceof Turret) {
|
||||
if (block.isMultiblock()) {
|
||||
Draw.rect("block-" + block.size + "x" + block.size, drawx, drawy);
|
||||
} else {
|
||||
Draw.rect("block", drawx, drawy);
|
||||
}
|
||||
}
|
||||
|
||||
drawPreview(block, drawx, drawy, rotation, opacity);
|
||||
|
||||
Draw.reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user