This commit is contained in:
@@ -46,7 +46,7 @@ public class GroundAI extends AIController{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(unit.type().canBoost){
|
if(unit.type().canBoost && !unit.onSolid()){
|
||||||
unit.elevation = Mathf.approachDelta(unit.elevation, 0f, 0.08f);
|
unit.elevation = Mathf.approachDelta(unit.elevation, 0f, 0.08f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -52,10 +52,11 @@ public class Fx{
|
|||||||
if(!(e.data instanceof Unit)) return;
|
if(!(e.data instanceof Unit)) return;
|
||||||
|
|
||||||
Unit select = e.data();
|
Unit select = e.data();
|
||||||
|
boolean block = select instanceof BlockUnitc;
|
||||||
|
|
||||||
mixcol(Pal.accent, 1f);
|
mixcol(Pal.accent, 1f);
|
||||||
alpha(e.fout());
|
alpha(e.fout());
|
||||||
rect(select.type().icon(Cicon.full), select.x, select.y, select.rotation - 90f);
|
rect(block ? ((BlockUnitc)select).tile().block.icon(Cicon.full) : select.type().icon(Cicon.full), select.x, select.y, block ? 0f : select.rotation - 90f);
|
||||||
alpha(1f);
|
alpha(1f);
|
||||||
Lines.stroke(e.fslope() * 1f);
|
Lines.stroke(e.fslope() * 1f);
|
||||||
Lines.square(select.x, select.y, e.fout() * select.hitSize * 2f, 45);
|
Lines.square(select.x, select.y, e.fout() * select.hitSize * 2f, 45);
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ public class MapEditor{
|
|||||||
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);
|
||||||
if(!hasOverlap(x, y)){
|
if(!hasOverlap(x, y)){
|
||||||
tile(x, y).setBlock(drawBlock, drawTeam, 0);
|
tile(x, y).setBlock(drawBlock, drawTeam, rotation);
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
boolean isFloor = drawBlock.isFloor() && drawBlock != Blocks.air;
|
boolean isFloor = drawBlock.isFloor() && drawBlock != Blocks.air;
|
||||||
|
|||||||
@@ -110,18 +110,13 @@ public class MapRenderer implements Disposable{
|
|||||||
if(wall != Blocks.air && wall.synthetic()){
|
if(wall != Blocks.air && wall.synthetic()){
|
||||||
region = !Core.atlas.isFound(wall.editorIcon()) || !center ? Core.atlas.find("clear-editor") : wall.editorIcon();
|
region = !Core.atlas.isFound(wall.editorIcon()) || !center ? Core.atlas.find("clear-editor") : wall.editorIcon();
|
||||||
|
|
||||||
if(wall.rotate){
|
float width = region.getWidth() * Draw.scl, height = region.getHeight() * Draw.scl;
|
||||||
mesh.draw(idxWall, region,
|
|
||||||
wx * tilesize + wall.offset, wy * tilesize + wall.offset,
|
|
||||||
region.getWidth() * Draw.scl, region.getHeight() * Draw.scl, tile.build == null ? 0 : tile.build.rotdeg() - 90);
|
|
||||||
}else{
|
|
||||||
float width = region.getWidth() * Draw.scl, height = region.getHeight() * Draw.scl;
|
|
||||||
|
|
||||||
mesh.draw(idxWall, region,
|
mesh.draw(idxWall, region,
|
||||||
wx * tilesize + wall.offset + (tilesize - width) / 2f,
|
wx * tilesize + wall.offset + (tilesize - width) / 2f,
|
||||||
wy * tilesize + wall.offset + (tilesize - height) / 2f,
|
wy * tilesize + wall.offset + (tilesize - height) / 2f,
|
||||||
width, height);
|
width, height,
|
||||||
}
|
tile.build == null || !wall.rotate ? 0 : tile.build.rotdeg() - 90);
|
||||||
}else{
|
}else{
|
||||||
region = floor.editorVariantRegions()[Mathf.randomSeed(idxWall, 0, floor.editorVariantRegions().length - 1)];
|
region = floor.editorVariantRegions()[Mathf.randomSeed(idxWall, 0, floor.editorVariantRegions().length - 1)];
|
||||||
|
|
||||||
|
|||||||
@@ -967,7 +967,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
|||||||
table.row();
|
table.row();
|
||||||
table.table(this::displayConsumption).growX();
|
table.table(this::displayConsumption).growX();
|
||||||
|
|
||||||
boolean displayFlow = (block.category == Category.distribution || block.category == Category.liquid) && Core.settings.getBool("flow");
|
boolean displayFlow = (block.category == Category.distribution || block.category == Category.liquid) && Core.settings.getBool("flow") && block.displayFlow;
|
||||||
|
|
||||||
if(displayFlow){
|
if(displayFlow){
|
||||||
String ps = " " + StatUnit.perSecond.localized();
|
String ps = " " + StatUnit.perSecond.localized();
|
||||||
@@ -1005,9 +1005,21 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
|||||||
if(liquids != null){
|
if(liquids != null){
|
||||||
table.row();
|
table.row();
|
||||||
table.table(l -> {
|
table.table(l -> {
|
||||||
l.left();
|
boolean[] had = {false};
|
||||||
l.image(() -> liquids.current().icon(Cicon.small)).padRight(3f);
|
|
||||||
l.label(() -> liquids.getFlowRate() < 0 ? "..." : Strings.fixed(liquids.getFlowRate(), 2) + ps).color(Color.lightGray);
|
Runnable rebuild = () -> {
|
||||||
|
l.clearChildren();
|
||||||
|
l.left();
|
||||||
|
l.image(() -> liquids.current().icon(Cicon.small)).padRight(3f);
|
||||||
|
l.label(() -> liquids.getFlowRate() < 0 ? "..." : Strings.fixed(liquids.getFlowRate(), 2) + ps).color(Color.lightGray);
|
||||||
|
};
|
||||||
|
|
||||||
|
l.update(() -> {
|
||||||
|
if(!had[0] && liquids.hadFlow()){
|
||||||
|
had[0] = true;
|
||||||
|
rebuild.run();
|
||||||
|
}
|
||||||
|
});
|
||||||
}).left();
|
}).left();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,11 +45,16 @@ abstract class PosComp implements Position{
|
|||||||
return tile == null || tile.block() != Blocks.air ? (Floor)Blocks.air : tile.floor();
|
return tile == null || tile.block() != Blocks.air ? (Floor)Blocks.air : tile.floor();
|
||||||
}
|
}
|
||||||
|
|
||||||
Block blockOn(){
|
Block blockOn(){
|
||||||
Tile tile = tileOn();
|
Tile tile = tileOn();
|
||||||
return tile == null ? Blocks.air : tile.block();
|
return tile == null ? Blocks.air : tile.block();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean onSolid(){
|
||||||
|
Tile tile = tileOn();
|
||||||
|
return tile != null && tile.solid();
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable Tile tileOn(){
|
@Nullable Tile tileOn(){
|
||||||
return world.tileWorld(x, y);
|
return world.tileWorld(x, y);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -132,23 +132,25 @@ public class OverlayRenderer{
|
|||||||
//draw selected block
|
//draw selected block
|
||||||
if(input.block == null && !Core.scene.hasMouse()){
|
if(input.block == null && !Core.scene.hasMouse()){
|
||||||
Vec2 vec = Core.input.mouseWorld(input.getMouseX(), input.getMouseY());
|
Vec2 vec = Core.input.mouseWorld(input.getMouseX(), input.getMouseY());
|
||||||
Building tile = world.buildWorld(vec.x, vec.y);
|
Building build = world.buildWorld(vec.x, vec.y);
|
||||||
|
|
||||||
if(tile != null && tile.team == player.team()){
|
if(build != null && build.team == player.team()){
|
||||||
tile.drawSelect();
|
build.drawSelect();
|
||||||
if(!tile.enabled && tile.block.drawDisabled){
|
if(!build.enabled && build.block.drawDisabled){
|
||||||
tile.drawDisabled();
|
build.drawDisabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Core.input.keyDown(Binding.rotateplaced) && tile.block().rotate && tile.interactable(player.team())){
|
if(Core.input.keyDown(Binding.rotateplaced) && build.block().rotate && build.interactable(player.team())){
|
||||||
control.input.drawArrow(tile.block(), tile.tileX(), tile.tileY(), tile.rotation, true);
|
control.input.drawArrow(build.block(), build.tileX(), build.tileY(), build.rotation, true);
|
||||||
Draw.color(Pal.accent, 0.3f + Mathf.absin(4f, 0.2f));
|
Draw.color(Pal.accent, 0.3f + Mathf.absin(4f, 0.2f));
|
||||||
Fill.square(tile.x, tile.y, tile.block().size * tilesize/2f);
|
Fill.square(build.x, build.y, build.block().size * tilesize/2f);
|
||||||
Draw.color();
|
Draw.color();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
input.drawOverSelect();
|
||||||
|
|
||||||
//draw selection overlay when dropping item
|
//draw selection overlay when dropping item
|
||||||
if(input.isDroppingItem()){
|
if(input.isDroppingItem()){
|
||||||
Vec2 v = Core.input.mouseWorld(input.getMouseX(), input.getMouseY());
|
Vec2 v = Core.input.mouseWorld(input.getMouseX(), input.getMouseY());
|
||||||
|
|||||||
@@ -387,6 +387,10 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void drawOverSelect(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public void drawSelected(int x, int y, Block block, Color color){
|
public void drawSelected(int x, int y, Block block, Color color){
|
||||||
Drawf.selected(x, y, block, color);
|
Drawf.selected(x, y, block, color);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -277,7 +277,7 @@ public class MobileInput extends InputHandler implements GestureListener{
|
|||||||
public void drawBottom(){
|
public void drawBottom(){
|
||||||
Lines.stroke(1f);
|
Lines.stroke(1f);
|
||||||
|
|
||||||
//draw removals
|
//draw requests about to be removed
|
||||||
for(BuildPlan request : removals){
|
for(BuildPlan request : removals){
|
||||||
Tile tile = request.tile();
|
Tile tile = request.tile();
|
||||||
|
|
||||||
@@ -292,6 +292,43 @@ public class MobileInput extends InputHandler implements GestureListener{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Draw.mixcol();
|
||||||
|
Draw.color(Pal.accent);
|
||||||
|
|
||||||
|
//Draw lines
|
||||||
|
if(lineMode){
|
||||||
|
int tileX = tileX(Core.input.mouseX());
|
||||||
|
int tileY = tileY(Core.input.mouseY());
|
||||||
|
|
||||||
|
if(mode == placing && block != null){
|
||||||
|
//draw placing
|
||||||
|
for(int i = 0; i < lineRequests.size; i++){
|
||||||
|
BuildPlan request = lineRequests.get(i);
|
||||||
|
if(i == lineRequests.size - 1 && request.block.rotate){
|
||||||
|
drawArrow(block, request.x, request.y, request.rotation);
|
||||||
|
}
|
||||||
|
request.block.drawRequest(request, allRequests(), validPlace(request.x, request.y, request.block, request.rotation) && getRequest(request.x, request.y, request.block.size, null) == null);
|
||||||
|
drawSelected(request.x, request.y, request.block, Pal.accent);
|
||||||
|
}
|
||||||
|
}else if(mode == breaking){
|
||||||
|
drawBreakSelection(lineStartX, lineStartY, tileX, tileY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Draw.reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void drawTop(){
|
||||||
|
|
||||||
|
//draw schematic selection
|
||||||
|
if(mode == schematicSelect){
|
||||||
|
drawSelection(lineStartX, lineStartY, lastLineX, lastLineY, Vars.maxSchematicSize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void drawOverSelect(){
|
||||||
//draw list of requests
|
//draw list of requests
|
||||||
for(BuildPlan request : selectRequests){
|
for(BuildPlan request : selectRequests){
|
||||||
Tile tile = request.tile();
|
Tile tile = request.tile();
|
||||||
@@ -322,29 +359,6 @@ public class MobileInput extends InputHandler implements GestureListener{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Draw.mixcol();
|
|
||||||
Draw.color(Pal.accent);
|
|
||||||
|
|
||||||
//Draw lines
|
|
||||||
if(lineMode){
|
|
||||||
int tileX = tileX(Core.input.mouseX());
|
|
||||||
int tileY = tileY(Core.input.mouseY());
|
|
||||||
|
|
||||||
if(mode == placing && block != null){
|
|
||||||
//draw placing
|
|
||||||
for(int i = 0; i < lineRequests.size; i++){
|
|
||||||
BuildPlan request = lineRequests.get(i);
|
|
||||||
if(i == lineRequests.size - 1 && request.block.rotate){
|
|
||||||
drawArrow(block, request.x, request.y, request.rotation);
|
|
||||||
}
|
|
||||||
request.block.drawRequest(request, allRequests(), validPlace(request.x, request.y, request.block, request.rotation) && getRequest(request.x, request.y, request.block.size, null) == null);
|
|
||||||
drawSelected(request.x, request.y, request.block, Pal.accent);
|
|
||||||
}
|
|
||||||
}else if(mode == breaking){
|
|
||||||
drawBreakSelection(lineStartX, lineStartY, tileX, tileY);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//draw targeting crosshair
|
//draw targeting crosshair
|
||||||
if(target != null && !state.isEditor()){
|
if(target != null && !state.isEditor()){
|
||||||
if(target != lastTarget){
|
if(target != lastTarget){
|
||||||
@@ -366,15 +380,6 @@ public class MobileInput extends InputHandler implements GestureListener{
|
|||||||
Draw.reset();
|
Draw.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void drawTop(){
|
|
||||||
|
|
||||||
//draw schematic selection
|
|
||||||
if(mode == schematicSelect){
|
|
||||||
drawSelection(lineStartX, lineStartY, lastLineX, lastLineY, Vars.maxSchematicSize);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void drawRequest(BuildPlan request){
|
protected void drawRequest(BuildPlan request){
|
||||||
if(request.tile() == null) return;
|
if(request.tile() == null) return;
|
||||||
|
|||||||
@@ -425,6 +425,7 @@ public class Mods implements Loadable{
|
|||||||
/** This must be run on the main thread! */
|
/** This must be run on the main thread! */
|
||||||
public void loadScripts(){
|
public void loadScripts(){
|
||||||
Time.mark();
|
Time.mark();
|
||||||
|
boolean[] any = {false};
|
||||||
|
|
||||||
try{
|
try{
|
||||||
eachEnabled(mod -> {
|
eachEnabled(mod -> {
|
||||||
@@ -438,6 +439,7 @@ public class Mods implements Loadable{
|
|||||||
if(scripts == null){
|
if(scripts == null){
|
||||||
scripts = platform.createScripts();
|
scripts = platform.createScripts();
|
||||||
}
|
}
|
||||||
|
any[0] = true;
|
||||||
scripts.run(mod, main);
|
scripts.run(mod, main);
|
||||||
}catch(Throwable e){
|
}catch(Throwable e){
|
||||||
Core.app.post(() -> {
|
Core.app.post(() -> {
|
||||||
@@ -454,7 +456,9 @@ public class Mods implements Loadable{
|
|||||||
content.setCurrentMod(null);
|
content.setCurrentMod(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.info("Time to initialize modded scripts: @", Time.elapsed());
|
if(any[0]){
|
||||||
|
Log.info("Time to initialize modded scripts: @", Time.elapsed());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Creates all the content found in mod files. */
|
/** Creates all the content found in mod files. */
|
||||||
|
|||||||
@@ -68,13 +68,7 @@ public class BeControl{
|
|||||||
}else{
|
}else{
|
||||||
Core.app.post(() -> done.get(false));
|
Core.app.post(() -> done.get(false));
|
||||||
}
|
}
|
||||||
}, error -> Core.app.post(() -> {
|
}, error -> {}); //ignore errors
|
||||||
if(!headless){
|
|
||||||
ui.showException(error);
|
|
||||||
}else{
|
|
||||||
error.printStackTrace();
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @return whether a new update is available */
|
/** @return whether a new update is available */
|
||||||
|
|||||||
@@ -143,6 +143,7 @@ public class CustomRulesDialog extends BaseDialog{
|
|||||||
|
|
||||||
main.button("@configure",
|
main.button("@configure",
|
||||||
() -> loadoutDialog.show(Blocks.coreShard.itemCapacity, rules.loadout,
|
() -> loadoutDialog.show(Blocks.coreShard.itemCapacity, rules.loadout,
|
||||||
|
i -> true,
|
||||||
() -> rules.loadout.clear().add(new ItemStack(Items.copper, 100)),
|
() -> rules.loadout.clear().add(new ItemStack(Items.copper, 100)),
|
||||||
() -> {}, () -> {}
|
() -> {}, () -> {}
|
||||||
)).left().width(300f);
|
)).left().width(300f);
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import arc.func.*;
|
|||||||
import arc.scene.ui.*;
|
import arc.scene.ui.*;
|
||||||
import arc.scene.ui.layout.*;
|
import arc.scene.ui.layout.*;
|
||||||
import arc.struct.*;
|
import arc.struct.*;
|
||||||
|
import mindustry.ctype.*;
|
||||||
import mindustry.game.*;
|
import mindustry.game.*;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.type.*;
|
import mindustry.type.*;
|
||||||
@@ -71,7 +72,7 @@ public class LaunchLoadoutDialog extends BaseDialog{
|
|||||||
Runnable rebuildItems = () -> rebuild.get(items);
|
Runnable rebuildItems = () -> rebuild.get(items);
|
||||||
|
|
||||||
buttons.button("@resources", Icon.terrain, () -> {
|
buttons.button("@resources", Icon.terrain, () -> {
|
||||||
loadout.show(core.itemCapacity, stacks, stacks::clear, () -> {}, () -> {
|
loadout.show(core.itemCapacity, stacks, UnlockableContent::unlocked, stacks::clear, () -> {}, () -> {
|
||||||
universe.updateLaunchResources(stacks);
|
universe.updateLaunchResources(stacks);
|
||||||
update.run();
|
update.run();
|
||||||
rebuildItems.run();
|
rebuildItems.run();
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
package mindustry.ui.dialogs;
|
package mindustry.ui.dialogs;
|
||||||
|
|
||||||
import arc.*;
|
import arc.*;
|
||||||
import arc.struct.*;
|
import arc.func.*;
|
||||||
import arc.input.*;
|
import arc.input.*;
|
||||||
import arc.scene.ui.layout.*;
|
import arc.scene.ui.layout.*;
|
||||||
|
import arc.struct.*;
|
||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.type.*;
|
import mindustry.type.*;
|
||||||
@@ -17,6 +18,7 @@ public class LoadoutDialog extends BaseDialog{
|
|||||||
private Runnable updater;
|
private Runnable updater;
|
||||||
private Seq<ItemStack> stacks = new Seq<>();
|
private Seq<ItemStack> stacks = new Seq<>();
|
||||||
private Seq<ItemStack> originalStacks = new Seq<>();
|
private Seq<ItemStack> originalStacks = new Seq<>();
|
||||||
|
private Boolf<Item> validator = i -> true;
|
||||||
private Table items;
|
private Table items;
|
||||||
private int capacity;
|
private int capacity;
|
||||||
|
|
||||||
@@ -51,13 +53,14 @@ public class LoadoutDialog extends BaseDialog{
|
|||||||
}).size(210f, 64f);
|
}).size(210f, 64f);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void show(int capacity, Seq<ItemStack> stacks, Runnable reseter, Runnable updater, Runnable hider){
|
public void show(int capacity, Seq<ItemStack> stacks, Boolf<Item> validator, Runnable reseter, Runnable updater, Runnable hider){
|
||||||
this.originalStacks = stacks;
|
this.originalStacks = stacks;
|
||||||
reseed();
|
this.validator = validator;
|
||||||
this.resetter = reseter;
|
this.resetter = reseter;
|
||||||
this.updater = updater;
|
this.updater = updater;
|
||||||
this.capacity = capacity;
|
this.capacity = capacity;
|
||||||
this.hider = hider;
|
this.hider = hider;
|
||||||
|
reseed();
|
||||||
show();
|
show();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,7 +109,7 @@ public class LoadoutDialog extends BaseDialog{
|
|||||||
|
|
||||||
private void reseed(){
|
private void reseed(){
|
||||||
this.stacks = originalStacks.map(ItemStack::copy);
|
this.stacks = originalStacks.map(ItemStack::copy);
|
||||||
this.stacks.addAll(content.items().select(i -> !stacks.contains(stack -> stack.item == i)).map(i -> new ItemStack(i, 0)));
|
this.stacks.addAll(content.items().select(i -> validator.get(i) && !stacks.contains(stack -> stack.item == i)).map(i -> new ItemStack(i, 0)));
|
||||||
this.stacks.sort(Structs.comparingInt(s -> s.item.id));
|
this.stacks.sort(Structs.comparingInt(s -> s.item.id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -134,7 +134,9 @@ public class ResearchDialog extends BaseDialog{
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
view.addListener(new ElementGestureListener(){
|
touchable = Touchable.enabled;
|
||||||
|
|
||||||
|
addListener(new ElementGestureListener(){
|
||||||
@Override
|
@Override
|
||||||
public void zoom(InputEvent event, float initialDistance, float distance){
|
public void zoom(InputEvent event, float initialDistance, float distance){
|
||||||
if(view.lastZoom < 0){
|
if(view.lastZoom < 0){
|
||||||
|
|||||||
@@ -56,6 +56,8 @@ public class Block extends UnlockableContent{
|
|||||||
public final BlockBars bars = new BlockBars();
|
public final BlockBars bars = new BlockBars();
|
||||||
public final Consumers consumes = new Consumers();
|
public final Consumers consumes = new Consumers();
|
||||||
|
|
||||||
|
/** whether to display flow rate */
|
||||||
|
public boolean displayFlow = true;
|
||||||
/** whether this block is visible in the editor */
|
/** whether this block is visible in the editor */
|
||||||
public boolean inEditor = true;
|
public boolean inEditor = true;
|
||||||
/** the last configuration value applied to this block. */
|
/** the last configuration value applied to this block. */
|
||||||
|
|||||||
@@ -162,7 +162,11 @@ public class ItemTurret extends Turret{
|
|||||||
Item item = Vars.content.item(revision < 2 ? read.ub() : read.s());
|
Item item = Vars.content.item(revision < 2 ? read.ub() : read.s());
|
||||||
short a = read.s();
|
short a = read.s();
|
||||||
totalAmmo += a;
|
totalAmmo += a;
|
||||||
ammo.add(new ItemEntry(item, a));
|
|
||||||
|
//only add ammo if this is a valid ammo type
|
||||||
|
if(ammoTypes.containsKey(item)){
|
||||||
|
ammo.add(new ItemEntry(item, a));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,11 +52,13 @@ public class ItemSource extends Block{
|
|||||||
public void draw(){
|
public void draw(){
|
||||||
super.draw();
|
super.draw();
|
||||||
|
|
||||||
if(outputItem == null) return;
|
if(outputItem == null){
|
||||||
|
Draw.rect("cross", x, y);
|
||||||
Draw.color(outputItem.color);
|
}else{
|
||||||
Draw.rect("center", x, y);
|
Draw.color(outputItem.color);
|
||||||
Draw.color();
|
Draw.rect("center", x, y);
|
||||||
|
Draw.color();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ public class LiquidSource extends Block{
|
|||||||
outputsLiquid = true;
|
outputsLiquid = true;
|
||||||
saveConfig = true;
|
saveConfig = true;
|
||||||
noUpdateDisabled = true;
|
noUpdateDisabled = true;
|
||||||
|
displayFlow = false;
|
||||||
|
|
||||||
config(Liquid.class, (LiquidSourceBuild tile, Liquid l) -> tile.source = l);
|
config(Liquid.class, (LiquidSourceBuild tile, Liquid l) -> tile.source = l);
|
||||||
configClear((LiquidSourceBuild tile) -> tile.source = null);
|
configClear((LiquidSourceBuild tile) -> tile.source = null);
|
||||||
@@ -59,7 +60,9 @@ public class LiquidSource extends Block{
|
|||||||
public void draw(){
|
public void draw(){
|
||||||
super.draw();
|
super.draw();
|
||||||
|
|
||||||
if(source != null){
|
if(source == null){
|
||||||
|
Draw.rect("cross", x, y);
|
||||||
|
}else{
|
||||||
Draw.color(source.color);
|
Draw.color(source.color);
|
||||||
Draw.rect("center", x, y);
|
Draw.rect("center", x, y);
|
||||||
Draw.color();
|
Draw.color();
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ public class LiquidModule extends BlockModule{
|
|||||||
private Liquid current = content.liquid(0);
|
private Liquid current = content.liquid(0);
|
||||||
private float smoothLiquid;
|
private float smoothLiquid;
|
||||||
|
|
||||||
|
private boolean hadFlow;
|
||||||
private @Nullable WindowedMean flow;
|
private @Nullable WindowedMean flow;
|
||||||
private float lastAdded, currentFlowRate;
|
private float lastAdded, currentFlowRate;
|
||||||
|
|
||||||
@@ -29,6 +30,8 @@ public class LiquidModule extends BlockModule{
|
|||||||
if(flowTimer.get(1, pollScl)){
|
if(flowTimer.get(1, pollScl)){
|
||||||
|
|
||||||
if(flow == null) flow = new WindowedMean(windowSize);
|
if(flow == null) flow = new WindowedMean(windowSize);
|
||||||
|
if(lastAdded > 0.0001f) hadFlow = true;
|
||||||
|
|
||||||
flow.add(lastAdded);
|
flow.add(lastAdded);
|
||||||
lastAdded = 0;
|
lastAdded = 0;
|
||||||
if(currentFlowRate < 0 || flowTimer.get(updateInterval)){
|
if(currentFlowRate < 0 || flowTimer.get(updateInterval)){
|
||||||
@@ -38,16 +41,19 @@ public class LiquidModule extends BlockModule{
|
|||||||
}else{
|
}else{
|
||||||
currentFlowRate = -1f;
|
currentFlowRate = -1f;
|
||||||
flow = null;
|
flow = null;
|
||||||
|
hadFlow = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @return current liquid's flow rate in u/s; any value < 0 means 'not ready'. */
|
/** @return current liquid's flow rate in u/s; any value < 0 means 'not ready'. */
|
||||||
public float getFlowRate(){
|
public float getFlowRate(){
|
||||||
//low throughput means no display
|
|
||||||
if(currentFlowRate < 0.0001) return -1f;
|
|
||||||
return currentFlowRate * 60;
|
return currentFlowRate * 60;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean hadFlow(){
|
||||||
|
return hadFlow;
|
||||||
|
}
|
||||||
|
|
||||||
public float smoothAmount(){
|
public float smoothAmount(){
|
||||||
return smoothLiquid;
|
return smoothLiquid;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user