From 5d79ad936336f6e2097409764db61d0268da017d Mon Sep 17 00:00:00 2001 From: Anuken Date: Sat, 9 Apr 2022 13:03:51 -0400 Subject: [PATCH] Bugfixes from testing session 1 --- core/src/mindustry/entities/comp/BuildingComp.java | 4 +++- core/src/mindustry/game/Objectives.java | 7 +++++-- core/src/mindustry/input/DesktopInput.java | 11 +++++++++-- core/src/mindustry/type/UnitType.java | 6 +++++- core/src/mindustry/world/Block.java | 4 +++- .../src/mindustry/world/blocks/environment/Floor.java | 2 -- core/src/mindustry/world/blocks/power/BeamNode.java | 7 +++++++ core/src/mindustry/world/meta/StatValues.java | 4 +++- 8 files changed, 35 insertions(+), 10 deletions(-) diff --git a/core/src/mindustry/entities/comp/BuildingComp.java b/core/src/mindustry/entities/comp/BuildingComp.java index 5c561c5f19..8f9ff64f31 100644 --- a/core/src/mindustry/entities/comp/BuildingComp.java +++ b/core/src/mindustry/entities/comp/BuildingComp.java @@ -1445,7 +1445,9 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc, public void displayBars(Table table){ for(Func bar : block.listBars()){ - table.add(bar.get(self())).growX(); + var result = bar.get(self()); + if(result == null) continue; + table.add(result).growX(); table.row(); } } diff --git a/core/src/mindustry/game/Objectives.java b/core/src/mindustry/game/Objectives.java index d72c8d3b59..2fde65c4a2 100644 --- a/core/src/mindustry/game/Objectives.java +++ b/core/src/mindustry/game/Objectives.java @@ -24,7 +24,9 @@ public class Objectives{ @Override public String display(){ - return Core.bundle.format("requirement.research", content.emoji() + " " + content.localizedName); + return Core.bundle.format("requirement.research", + (content.techNode == null || content.techNode.parent == null || content.techNode.parent.content.unlocked()) && !(content instanceof Item) ? + (content.emoji() + " " + content.localizedName) : "???"); } } @@ -44,7 +46,8 @@ public class Objectives{ @Override public String display(){ - return Core.bundle.format("requirement.produce", content.emoji() + " " + content.localizedName); + return Core.bundle.format("requirement.produce", + content.unlocked() ? (content.emoji() + " " + content.localizedName) : "???"); } } diff --git a/core/src/mindustry/input/DesktopInput.java b/core/src/mindustry/input/DesktopInput.java index eb6be076c0..9deec40430 100644 --- a/core/src/mindustry/input/DesktopInput.java +++ b/core/src/mindustry/input/DesktopInput.java @@ -744,7 +744,14 @@ public class DesktopInput extends InputHandler{ commandBuild = null; } } - }else if(button == KeyCode.mouseRight){ + } + + return super.tap(x, y, count, button); + } + + @Override + public boolean touchDown(float x, float y, int pointer, KeyCode button){ + if(button == KeyCode.mouseRight){ //right click: move to position //move to location - TODO right click instead? @@ -771,7 +778,7 @@ public class DesktopInput extends InputHandler{ } } - return super.tap(x, y, count, button); + return super.touchDown(x, y, pointer, button); } @Override diff --git a/core/src/mindustry/type/UnitType.java b/core/src/mindustry/type/UnitType.java index 69a3e9e6f3..9123a48bcd 100644 --- a/core/src/mindustry/type/UnitType.java +++ b/core/src/mindustry/type/UnitType.java @@ -372,7 +372,11 @@ public class UnitType extends UnlockableContent{ if(mineTier >= 1){ stats.addPercent(Stat.mineSpeed, mineSpeed); - stats.add(Stat.mineTier, StatValues.blocks(b -> b instanceof Floor f && f.itemDrop != null && f.itemDrop.hardness <= mineTier && (!f.playerUnmineable || Core.settings.getBool("doubletapmine")))); + stats.add(Stat.mineTier, StatValues.blocks(b -> + b.itemDrop != null && + (b instanceof Floor f && (((f.wallOre && mineWalls) || (!f.wallOre && mineFloor))) || + (!(b instanceof Floor) && mineWalls)) && + b.itemDrop.hardness <= mineTier && (!b.playerUnmineable || Core.settings.getBool("doubletapmine")))); } if(buildSpeed > 0){ stats.addPercent(Stat.buildSpeed, buildSpeed); diff --git a/core/src/mindustry/world/Block.java b/core/src/mindustry/world/Block.java index 1e10a2b883..8b24f851f6 100644 --- a/core/src/mindustry/world/Block.java +++ b/core/src/mindustry/world/Block.java @@ -134,6 +134,8 @@ public class Block extends UnlockableContent implements Senseable{ public boolean useColor = true; /** item that drops from this block, used for drills */ public @Nullable Item itemDrop = null; + /** if true, this block cannot be mined by players. useful for annoying things like sand. */ + public boolean playerUnmineable = false; /** Array of affinities to certain things. */ public Attributes attributes = new Attributes(); /** Health per square tile that this block occupies; essentially, this is multiplied by size * size. Overridden if health is > 0. If <0, the default is 40. */ @@ -519,7 +521,7 @@ public class Block extends UnlockableContent implements Senseable{ } public void addLiquidBar(Liquid liq){ - addBar("liquid-" + liq.name, entity -> new Bar( + addBar("liquid-" + liq.name, entity -> !liq.unlocked() ? null : new Bar( () -> liq.localizedName, liq::barColor, () -> entity.liquids.get(liq) / liquidCapacity diff --git a/core/src/mindustry/world/blocks/environment/Floor.java b/core/src/mindustry/world/blocks/environment/Floor.java index 301203101c..8df2226e5d 100644 --- a/core/src/mindustry/world/blocks/environment/Floor.java +++ b/core/src/mindustry/world/blocks/environment/Floor.java @@ -55,8 +55,6 @@ public class Floor extends Block{ public boolean supportsOverlay = false; /** shallow water flag used for generation */ public boolean shallow = false; - /** if true, this block cannot be mined by players. useful for annoying things like sand. */ - public boolean playerUnmineable = false; /** Group of blocks that this block does not draw edges on. */ public Block blendGroup = this; /** Whether this ore generates in maps by default. */ diff --git a/core/src/mindustry/world/blocks/power/BeamNode.java b/core/src/mindustry/world/blocks/power/BeamNode.java index 8afaa13623..bd8dcadabf 100644 --- a/core/src/mindustry/world/blocks/power/BeamNode.java +++ b/core/src/mindustry/world/blocks/power/BeamNode.java @@ -104,6 +104,13 @@ public class BeamNode extends PowerBlock{ } } + @Override + public BlockStatus status(){ + if(Mathf.equal(power.status, 0f, 0.001f)) return BlockStatus.noInput; + if(Mathf.equal(power.status, 1f, 0.001f)) return BlockStatus.active; + return BlockStatus.noOutput; + } + @Override public void draw(){ super.draw(); diff --git a/core/src/mindustry/world/meta/StatValues.java b/core/src/mindustry/world/meta/StatValues.java index cd2d6ecd4e..8e1a336327 100644 --- a/core/src/mindustry/world/meta/StatValues.java +++ b/core/src/mindustry/world/meta/StatValues.java @@ -145,7 +145,7 @@ public class StatValues{ return table -> table.stack( new Image(floor.uiIcon).setScaling(Scaling.fit), new Table(t -> t.top().right().add((multiplier < 0 ? "[scarlet]" : startZero ? "[accent]" : "[accent]+") + (int)((multiplier) * 100) + "%").style(Styles.outlineLabel)) - ); + ).maxSize(64f); } public static StatValue blocks(Attribute attr, boolean floating, float scale, boolean startZero){ @@ -204,6 +204,8 @@ public class StatValues{ for(int i = 0; i < list.size; i++){ var item = list.get(i); + if(item instanceof Block block && block.itemDrop != null && !block.itemDrop.unlocked()) continue; + l.image(item.uiIcon).size(iconSmall).padRight(2).padLeft(2).padTop(3).padBottom(3); l.add(item.localizedName).left().padLeft(1).padRight(4); if(i % 5 == 4){