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);
|
||||
}
|
||||
|
||||
|
||||
@@ -52,10 +52,11 @@ public class Fx{
|
||||
if(!(e.data instanceof Unit)) return;
|
||||
|
||||
Unit select = e.data();
|
||||
boolean block = select instanceof BlockUnitc;
|
||||
|
||||
mixcol(Pal.accent, 1f);
|
||||
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);
|
||||
Lines.stroke(e.fslope() * 1f);
|
||||
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);
|
||||
y = Mathf.clamp(y, (drawBlock.size - 1) / 2, height() - drawBlock.size / 2 - 1);
|
||||
if(!hasOverlap(x, y)){
|
||||
tile(x, y).setBlock(drawBlock, drawTeam, 0);
|
||||
tile(x, y).setBlock(drawBlock, drawTeam, rotation);
|
||||
}
|
||||
}else{
|
||||
boolean isFloor = drawBlock.isFloor() && drawBlock != Blocks.air;
|
||||
|
||||
@@ -110,18 +110,13 @@ public class MapRenderer implements Disposable{
|
||||
if(wall != Blocks.air && wall.synthetic()){
|
||||
region = !Core.atlas.isFound(wall.editorIcon()) || !center ? Core.atlas.find("clear-editor") : wall.editorIcon();
|
||||
|
||||
if(wall.rotate){
|
||||
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;
|
||||
float width = region.getWidth() * Draw.scl, height = region.getHeight() * Draw.scl;
|
||||
|
||||
mesh.draw(idxWall, region,
|
||||
wx * tilesize + wall.offset + (tilesize - width) / 2f,
|
||||
wy * tilesize + wall.offset + (tilesize - height) / 2f,
|
||||
width, height);
|
||||
}
|
||||
mesh.draw(idxWall, region,
|
||||
wx * tilesize + wall.offset + (tilesize - width) / 2f,
|
||||
wy * tilesize + wall.offset + (tilesize - height) / 2f,
|
||||
width, height,
|
||||
tile.build == null || !wall.rotate ? 0 : tile.build.rotdeg() - 90);
|
||||
}else{
|
||||
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.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){
|
||||
String ps = " " + StatUnit.perSecond.localized();
|
||||
@@ -1005,9 +1005,21 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
||||
if(liquids != null){
|
||||
table.row();
|
||||
table.table(l -> {
|
||||
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);
|
||||
boolean[] had = {false};
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,11 +45,16 @@ abstract class PosComp implements Position{
|
||||
return tile == null || tile.block() != Blocks.air ? (Floor)Blocks.air : tile.floor();
|
||||
}
|
||||
|
||||
Block blockOn(){
|
||||
Block blockOn(){
|
||||
Tile tile = tileOn();
|
||||
return tile == null ? Blocks.air : tile.block();
|
||||
}
|
||||
|
||||
boolean onSolid(){
|
||||
Tile tile = tileOn();
|
||||
return tile != null && tile.solid();
|
||||
}
|
||||
|
||||
@Nullable Tile tileOn(){
|
||||
return world.tileWorld(x, y);
|
||||
}
|
||||
|
||||
@@ -132,23 +132,25 @@ public class OverlayRenderer{
|
||||
//draw selected block
|
||||
if(input.block == null && !Core.scene.hasMouse()){
|
||||
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()){
|
||||
tile.drawSelect();
|
||||
if(!tile.enabled && tile.block.drawDisabled){
|
||||
tile.drawDisabled();
|
||||
if(build != null && build.team == player.team()){
|
||||
build.drawSelect();
|
||||
if(!build.enabled && build.block.drawDisabled){
|
||||
build.drawDisabled();
|
||||
}
|
||||
|
||||
if(Core.input.keyDown(Binding.rotateplaced) && tile.block().rotate && tile.interactable(player.team())){
|
||||
control.input.drawArrow(tile.block(), tile.tileX(), tile.tileY(), tile.rotation, true);
|
||||
if(Core.input.keyDown(Binding.rotateplaced) && build.block().rotate && build.interactable(player.team())){
|
||||
control.input.drawArrow(build.block(), build.tileX(), build.tileY(), build.rotation, true);
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
input.drawOverSelect();
|
||||
|
||||
//draw selection overlay when dropping item
|
||||
if(input.isDroppingItem()){
|
||||
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){
|
||||
Drawf.selected(x, y, block, color);
|
||||
}
|
||||
|
||||
@@ -277,7 +277,7 @@ public class MobileInput extends InputHandler implements GestureListener{
|
||||
public void drawBottom(){
|
||||
Lines.stroke(1f);
|
||||
|
||||
//draw removals
|
||||
//draw requests about to be removed
|
||||
for(BuildPlan request : removals){
|
||||
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
|
||||
for(BuildPlan request : selectRequests){
|
||||
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
|
||||
if(target != null && !state.isEditor()){
|
||||
if(target != lastTarget){
|
||||
@@ -366,15 +380,6 @@ public class MobileInput extends InputHandler implements GestureListener{
|
||||
Draw.reset();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawTop(){
|
||||
|
||||
//draw schematic selection
|
||||
if(mode == schematicSelect){
|
||||
drawSelection(lineStartX, lineStartY, lastLineX, lastLineY, Vars.maxSchematicSize);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawRequest(BuildPlan request){
|
||||
if(request.tile() == null) return;
|
||||
|
||||
@@ -425,6 +425,7 @@ public class Mods implements Loadable{
|
||||
/** This must be run on the main thread! */
|
||||
public void loadScripts(){
|
||||
Time.mark();
|
||||
boolean[] any = {false};
|
||||
|
||||
try{
|
||||
eachEnabled(mod -> {
|
||||
@@ -438,6 +439,7 @@ public class Mods implements Loadable{
|
||||
if(scripts == null){
|
||||
scripts = platform.createScripts();
|
||||
}
|
||||
any[0] = true;
|
||||
scripts.run(mod, main);
|
||||
}catch(Throwable e){
|
||||
Core.app.post(() -> {
|
||||
@@ -454,7 +456,9 @@ public class Mods implements Loadable{
|
||||
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. */
|
||||
|
||||
@@ -68,13 +68,7 @@ public class BeControl{
|
||||
}else{
|
||||
Core.app.post(() -> done.get(false));
|
||||
}
|
||||
}, error -> Core.app.post(() -> {
|
||||
if(!headless){
|
||||
ui.showException(error);
|
||||
}else{
|
||||
error.printStackTrace();
|
||||
}
|
||||
}));
|
||||
}, error -> {}); //ignore errors
|
||||
}
|
||||
|
||||
/** @return whether a new update is available */
|
||||
|
||||
@@ -143,6 +143,7 @@ public class CustomRulesDialog extends BaseDialog{
|
||||
|
||||
main.button("@configure",
|
||||
() -> loadoutDialog.show(Blocks.coreShard.itemCapacity, rules.loadout,
|
||||
i -> true,
|
||||
() -> rules.loadout.clear().add(new ItemStack(Items.copper, 100)),
|
||||
() -> {}, () -> {}
|
||||
)).left().width(300f);
|
||||
|
||||
@@ -5,6 +5,7 @@ import arc.func.*;
|
||||
import arc.scene.ui.*;
|
||||
import arc.scene.ui.layout.*;
|
||||
import arc.struct.*;
|
||||
import mindustry.ctype.*;
|
||||
import mindustry.game.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.type.*;
|
||||
@@ -71,7 +72,7 @@ public class LaunchLoadoutDialog extends BaseDialog{
|
||||
Runnable rebuildItems = () -> rebuild.get(items);
|
||||
|
||||
buttons.button("@resources", Icon.terrain, () -> {
|
||||
loadout.show(core.itemCapacity, stacks, stacks::clear, () -> {}, () -> {
|
||||
loadout.show(core.itemCapacity, stacks, UnlockableContent::unlocked, stacks::clear, () -> {}, () -> {
|
||||
universe.updateLaunchResources(stacks);
|
||||
update.run();
|
||||
rebuildItems.run();
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
package mindustry.ui.dialogs;
|
||||
|
||||
import arc.*;
|
||||
import arc.struct.*;
|
||||
import arc.func.*;
|
||||
import arc.input.*;
|
||||
import arc.scene.ui.layout.*;
|
||||
import arc.struct.*;
|
||||
import arc.util.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.type.*;
|
||||
@@ -17,6 +18,7 @@ public class LoadoutDialog extends BaseDialog{
|
||||
private Runnable updater;
|
||||
private Seq<ItemStack> stacks = new Seq<>();
|
||||
private Seq<ItemStack> originalStacks = new Seq<>();
|
||||
private Boolf<Item> validator = i -> true;
|
||||
private Table items;
|
||||
private int capacity;
|
||||
|
||||
@@ -51,13 +53,14 @@ public class LoadoutDialog extends BaseDialog{
|
||||
}).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;
|
||||
reseed();
|
||||
this.validator = validator;
|
||||
this.resetter = reseter;
|
||||
this.updater = updater;
|
||||
this.capacity = capacity;
|
||||
this.hider = hider;
|
||||
reseed();
|
||||
show();
|
||||
}
|
||||
|
||||
@@ -106,7 +109,7 @@ public class LoadoutDialog extends BaseDialog{
|
||||
|
||||
private void reseed(){
|
||||
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));
|
||||
}
|
||||
|
||||
|
||||
@@ -134,7 +134,9 @@ public class ResearchDialog extends BaseDialog{
|
||||
}
|
||||
});
|
||||
|
||||
view.addListener(new ElementGestureListener(){
|
||||
touchable = Touchable.enabled;
|
||||
|
||||
addListener(new ElementGestureListener(){
|
||||
@Override
|
||||
public void zoom(InputEvent event, float initialDistance, float distance){
|
||||
if(view.lastZoom < 0){
|
||||
|
||||
@@ -56,6 +56,8 @@ public class Block extends UnlockableContent{
|
||||
public final BlockBars bars = new BlockBars();
|
||||
public final Consumers consumes = new Consumers();
|
||||
|
||||
/** whether to display flow rate */
|
||||
public boolean displayFlow = true;
|
||||
/** whether this block is visible in the editor */
|
||||
public boolean inEditor = true;
|
||||
/** 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());
|
||||
short a = read.s();
|
||||
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(){
|
||||
super.draw();
|
||||
|
||||
if(outputItem == null) return;
|
||||
|
||||
Draw.color(outputItem.color);
|
||||
Draw.rect("center", x, y);
|
||||
Draw.color();
|
||||
if(outputItem == null){
|
||||
Draw.rect("cross", x, y);
|
||||
}else{
|
||||
Draw.color(outputItem.color);
|
||||
Draw.rect("center", x, y);
|
||||
Draw.color();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -25,6 +25,7 @@ public class LiquidSource extends Block{
|
||||
outputsLiquid = true;
|
||||
saveConfig = true;
|
||||
noUpdateDisabled = true;
|
||||
displayFlow = false;
|
||||
|
||||
config(Liquid.class, (LiquidSourceBuild tile, Liquid l) -> tile.source = l);
|
||||
configClear((LiquidSourceBuild tile) -> tile.source = null);
|
||||
@@ -59,7 +60,9 @@ public class LiquidSource extends Block{
|
||||
public void draw(){
|
||||
super.draw();
|
||||
|
||||
if(source != null){
|
||||
if(source == null){
|
||||
Draw.rect("cross", x, y);
|
||||
}else{
|
||||
Draw.color(source.color);
|
||||
Draw.rect("center", x, y);
|
||||
Draw.color();
|
||||
|
||||
@@ -20,6 +20,7 @@ public class LiquidModule extends BlockModule{
|
||||
private Liquid current = content.liquid(0);
|
||||
private float smoothLiquid;
|
||||
|
||||
private boolean hadFlow;
|
||||
private @Nullable WindowedMean flow;
|
||||
private float lastAdded, currentFlowRate;
|
||||
|
||||
@@ -29,6 +30,8 @@ public class LiquidModule extends BlockModule{
|
||||
if(flowTimer.get(1, pollScl)){
|
||||
|
||||
if(flow == null) flow = new WindowedMean(windowSize);
|
||||
if(lastAdded > 0.0001f) hadFlow = true;
|
||||
|
||||
flow.add(lastAdded);
|
||||
lastAdded = 0;
|
||||
if(currentFlowRate < 0 || flowTimer.get(updateInterval)){
|
||||
@@ -38,16 +41,19 @@ public class LiquidModule extends BlockModule{
|
||||
}else{
|
||||
currentFlowRate = -1f;
|
||||
flow = null;
|
||||
hadFlow = false;
|
||||
}
|
||||
}
|
||||
|
||||
/** @return current liquid's flow rate in u/s; any value < 0 means 'not ready'. */
|
||||
public float getFlowRate(){
|
||||
//low throughput means no display
|
||||
if(currentFlowRate < 0.0001) return -1f;
|
||||
return currentFlowRate * 60;
|
||||
}
|
||||
|
||||
public boolean hadFlow(){
|
||||
return hadFlow;
|
||||
}
|
||||
|
||||
public float smoothAmount(){
|
||||
return smoothLiquid;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user