Implemented #1129 / Bugfixes
This commit is contained in:
@@ -324,7 +324,6 @@ abstract class TileComp implements Posc, Teamc, Healthc, Tilec, Timerc{
|
||||
}
|
||||
|
||||
public void dumpLiquid(Liquid liquid){
|
||||
Array<Tilec> proximity = proximity();
|
||||
int dump = rotation();
|
||||
|
||||
for(int i = 0; i < proximity.size; i++){
|
||||
@@ -336,7 +335,7 @@ abstract class TileComp implements Posc, Teamc, Healthc, Tilec, Timerc{
|
||||
float ofract = other.liquids().get(liquid) / other.block().liquidCapacity;
|
||||
float fract = liquids().get(liquid) / block.liquidCapacity;
|
||||
|
||||
if(ofract < fract) moveLiquid(other, (fract - ofract) * block.liquidCapacity / 2f, liquid);
|
||||
if(ofract < fract) transferLiquid(other, (fract - ofract) * block.liquidCapacity / 2f, liquid);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -346,16 +345,14 @@ abstract class TileComp implements Posc, Teamc, Healthc, Tilec, Timerc{
|
||||
return true;
|
||||
}
|
||||
|
||||
//TODO why does this exist?
|
||||
/*
|
||||
public void tryMoveLiquid(Tilec next, float amount, Liquid liquid){
|
||||
public void transferLiquid(Tilec next, float amount, Liquid liquid){
|
||||
float flow = Math.min(next.block().liquidCapacity - next.liquids().get(liquid) - 0.001f, amount);
|
||||
|
||||
if(next.acceptLiquid(liquid, flow)){
|
||||
next.handleLiquid(liquid, flow);
|
||||
if(next.acceptLiquid(this, liquid, flow)){
|
||||
next.handleLiquid(this, liquid, flow);
|
||||
liquids().remove(liquid, flow);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
public float moveLiquid(Tilec next, boolean leak, Liquid liquid){
|
||||
return moveLiquid(next, leak ? 1.5f : 100, liquid);
|
||||
@@ -562,6 +559,19 @@ abstract class TileComp implements Posc, Teamc, Healthc, Tilec, Timerc{
|
||||
return shouldConsume();
|
||||
}
|
||||
|
||||
public void drawStatus(){
|
||||
if(block.consumes.any()){
|
||||
float brcx = tile.drawx() + (block.size * tilesize / 2f) - (tilesize / 2f);
|
||||
float brcy = tile.drawy() - (block.size * tilesize / 2f) + (tilesize / 2f);
|
||||
|
||||
Draw.color(Pal.gray);
|
||||
Fill.square(brcx, brcy, 2.5f, 45);
|
||||
Draw.color(cons.status().color);
|
||||
Fill.square(brcx, brcy, 1.5f, 45);
|
||||
Draw.color();
|
||||
}
|
||||
}
|
||||
|
||||
public void drawLayer(){
|
||||
}
|
||||
|
||||
|
||||
@@ -33,8 +33,8 @@ public class BlockRenderer implements Disposable{
|
||||
private FrameBuffer shadows = new FrameBuffer(2, 2);
|
||||
private FrameBuffer fog = new FrameBuffer(2, 2);
|
||||
private Array<Tilec> outArray2 = new Array<>();
|
||||
private Array<Tile> outArray = new Array<>();
|
||||
private Array<Tile> shadowEvents = new Array<>();
|
||||
private boolean displayStatus = false;
|
||||
|
||||
public BlockRenderer(){
|
||||
|
||||
@@ -177,6 +177,7 @@ public class BlockRenderer implements Disposable{
|
||||
|
||||
/** Process all blocks to draw. */
|
||||
public void processBlocks(){
|
||||
displayStatus = Core.settings.getBool("blockstatus");
|
||||
iterateidx = 0;
|
||||
|
||||
int avgx = (int)(camera.position.x / tilesize);
|
||||
@@ -257,6 +258,7 @@ public class BlockRenderer implements Disposable{
|
||||
}
|
||||
|
||||
Block block = request.tile.block();
|
||||
boolean isEnd = (request.layer == Layer.block && block.layer == null) || request.layer == block.layer;
|
||||
|
||||
if(request.layer == Layer.block){
|
||||
block.drawBase(request.tile);
|
||||
@@ -274,6 +276,10 @@ public class BlockRenderer implements Disposable{
|
||||
}else if(request.layer == block.layer2){
|
||||
block.drawLayer2(request.tile);
|
||||
}
|
||||
|
||||
if(isEnd && request.tile.entity != null && displayStatus && block.consumes.any()){
|
||||
request.tile.entity.drawStatus();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -47,7 +47,8 @@ public enum Binding implements KeyBind{
|
||||
minimap(KeyCode.M),
|
||||
toggle_menus(KeyCode.C),
|
||||
screenshot(KeyCode.P),
|
||||
toggle_power_lines(KeyCode.F7),
|
||||
toggle_power_lines(KeyCode.F5),
|
||||
toggle_block_status(KeyCode.F6),
|
||||
player_list(KeyCode.TAB, "multiplayer"),
|
||||
chat(KeyCode.ENTER),
|
||||
chat_history_prev(KeyCode.UP),
|
||||
|
||||
@@ -463,6 +463,10 @@ public class DesktopInput extends InputHandler{
|
||||
mode = none;
|
||||
}
|
||||
|
||||
if(Core.input.keyTap(Binding.toggle_block_status)){
|
||||
Core.settings.putSave("blockstatus", !Core.settings.getBool("blockstatus"));
|
||||
}
|
||||
|
||||
if(Core.input.keyTap(Binding.toggle_power_lines)){
|
||||
if(Core.settings.getInt("lasersopacity") == 0){
|
||||
Core.settings.put("lasersopacity", Core.settings.getInt("preferredlaseropacity", 100));
|
||||
|
||||
@@ -214,7 +214,7 @@ public class TODOPlanetGenerator extends PlanetGenerator{
|
||||
|
||||
FloatArray frequencies = new FloatArray();
|
||||
for(int i = 0; i < ores.size; i++){
|
||||
frequencies.add(rand.random(-0.05f, 0.05f));
|
||||
frequencies.add(rand.random(-0.02f, 0.08f));
|
||||
}
|
||||
|
||||
pass((x, y) -> {
|
||||
|
||||
@@ -318,6 +318,7 @@ public class SettingsMenuDialog extends SettingsDialog{
|
||||
|
||||
graphics.checkPref("effects", true);
|
||||
graphics.checkPref("destroyedblocks", true);
|
||||
graphics.checkPref("blockstatus", false);
|
||||
graphics.checkPref("playerchat", true);
|
||||
graphics.checkPref("minimap", !mobile);
|
||||
graphics.checkPref("position", false);
|
||||
|
||||
@@ -37,7 +37,7 @@ public class LiquidTurret extends Turret{
|
||||
consumes.add(new ConsumeLiquidFilter(i -> ammoTypes.containsKey(i), 1f){
|
||||
@Override
|
||||
public boolean valid(Tilec entity){
|
||||
return !((TurretEntity)entity).ammo.isEmpty();
|
||||
return entity.liquids().total() > 0.001f;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -254,7 +254,6 @@ public abstract class Turret extends Block{
|
||||
|
||||
if(alternate){
|
||||
float i = (shotCounter % shots) - shots/2f + (((shots+1)%2) / 2f);
|
||||
Log.info(i);
|
||||
|
||||
tr.trns(rotation - 90, spread * i + Mathf.range(xRand), size * tilesize / 2);
|
||||
bullet(type, rotation + Mathf.range(inaccuracy));
|
||||
|
||||
@@ -16,6 +16,10 @@ public class Consumers{
|
||||
public final Bits itemFilters = new Bits(Vars.content.items().size);
|
||||
public final Bits liquidfilters = new Bits(Vars.content.liquids().size);
|
||||
|
||||
public boolean any(){
|
||||
return results != null && results.length > 0;
|
||||
}
|
||||
|
||||
public void init(){
|
||||
results = Structs.filter(Consume.class, map, m -> m != null);
|
||||
optionalResults = Structs.filter(Consume.class, map, m -> m != null && m.isOptional());
|
||||
|
||||
16
core/src/mindustry/world/meta/BlockStatus.java
Normal file
16
core/src/mindustry/world/meta/BlockStatus.java
Normal file
@@ -0,0 +1,16 @@
|
||||
package mindustry.world.meta;
|
||||
|
||||
import arc.graphics.*;
|
||||
import mindustry.graphics.*;
|
||||
|
||||
public enum BlockStatus{
|
||||
active(Color.valueOf("5ce677")),
|
||||
noOutput(Color.orange),
|
||||
noInput(Pal.remove);
|
||||
|
||||
public final Color color;
|
||||
|
||||
BlockStatus(Color color){
|
||||
this.color = color;
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,8 @@ package mindustry.world.modules;
|
||||
|
||||
import arc.util.io.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.world.consumers.Consume;
|
||||
import mindustry.world.consumers.*;
|
||||
import mindustry.world.meta.*;
|
||||
|
||||
public class ConsumeModule extends BlockModule{
|
||||
private boolean valid, optionalValid;
|
||||
@@ -12,6 +13,18 @@ public class ConsumeModule extends BlockModule{
|
||||
this.entity = entity;
|
||||
}
|
||||
|
||||
public BlockStatus status(){
|
||||
if(!entity.shouldConsume()){
|
||||
return BlockStatus.noOutput;
|
||||
}
|
||||
|
||||
if(!valid || !entity.productionValid()){
|
||||
return BlockStatus.noInput;
|
||||
}
|
||||
|
||||
return BlockStatus.active;
|
||||
}
|
||||
|
||||
public void update(){
|
||||
//everything is valid here
|
||||
if(entity.tile().isEnemyCheat()){
|
||||
|
||||
Reference in New Issue
Block a user