From 9e8e0709b5323b9282e529857d1e0e3173c55dc3 Mon Sep 17 00:00:00 2001 From: Anuken Date: Thu, 10 Jun 2021 18:51:49 -0400 Subject: [PATCH] Merge --- .github/workflows/deployment.yml | 2 +- .../blocks/production/melter-liquid.png | Bin 0 -> 198 bytes .../blocks/production/pulverizer-rotator.png | Bin 210 -> 216 bytes .../blocks/production/pulverizer-top.png | Bin 0 -> 306 bytes .../sprites/blocks/production/pulverizer.png | Bin 292 -> 114 bytes core/src/mindustry/content/Blocks.java | 29 ++++++------- core/src/mindustry/editor/MapRenderer.java | 13 ++++-- .../mindustry/entities/comp/BuildingComp.java | 6 ++- .../graphics/g3d/PlanetRenderer.java | 2 +- core/src/mindustry/mod/ContentParser.java | 5 +++ core/src/mindustry/type/Planet.java | 3 +- .../mindustry/ui/dialogs/GameOverDialog.java | 3 +- .../mindustry/ui/dialogs/PlanetDialog.java | 2 +- .../mindustry/ui/fragments/HudFragment.java | 2 +- core/src/mindustry/world/Block.java | 32 +++++++++++++-- .../mindustry/world/blocks/defense/Wall.java | 22 +--------- .../blocks/distribution/ArmoredConveyor.java | 1 + .../world/blocks/distribution/Duct.java | 1 + .../blocks/distribution/StackConveyor.java | 3 +- .../world/blocks/environment/Floor.java | 19 ++++----- .../world/blocks/environment/MetalFloor.java | 19 --------- .../world/blocks/environment/Prop.java | 15 ------- .../world/blocks/logic/LogicBlock.java | 13 +++--- core/src/mindustry/world/draw/DrawLiquid.java | 38 ++++++++++++++++++ .../src/mindustry/world/draw/DrawRotator.java | 6 ++- servers_v6.json | 2 +- tools/src/mindustry/tools/Generators.java | 2 +- 27 files changed, 131 insertions(+), 109 deletions(-) create mode 100644 core/assets-raw/sprites/blocks/production/melter-liquid.png create mode 100644 core/assets-raw/sprites/blocks/production/pulverizer-top.png delete mode 100644 core/src/mindustry/world/blocks/environment/MetalFloor.java create mode 100644 core/src/mindustry/world/draw/DrawLiquid.java diff --git a/.github/workflows/deployment.yml b/.github/workflows/deployment.yml index f3e83da601..29dad558e5 100644 --- a/.github/workflows/deployment.yml +++ b/.github/workflows/deployment.yml @@ -47,7 +47,7 @@ jobs: git clone --depth=1 --branch=master https://github.com/Anuken/MindustryBuilds ../MindustryBuilds cd ../MindustryBuilds echo "Updating version to ${RELEASE_VERSION:1}" - echo versionName=6-fdroid-${RELEASE_VERSION:1}$'\n'versionCode=${RELEASE_VERSION:1} > version_fdroid.txt + echo versionName=6-fdroid-${RELEASE_VERSION:1}$'\n'versionCode=${GITHUB_RUN_NUMBER} > version_fdroid.txt git add . git commit -m "Updating to build ${RELEASE_VERSION:1}" git push https://Anuken:${{ secrets.API_TOKEN_GITHUB }}@github.com/Anuken/MindustryBuilds diff --git a/core/assets-raw/sprites/blocks/production/melter-liquid.png b/core/assets-raw/sprites/blocks/production/melter-liquid.png new file mode 100644 index 0000000000000000000000000000000000000000..19d66fa18a06d9ded298f7982a1e8ae673813db6 GIT binary patch literal 198 zcmeAS@N?(olHy`uVBq!ia0y~yU{C;I4mJh`hT^KKFANL}jKx9jP7LeL$-HD>U|>mi z^mSxl*x1kgCy|wbfq}EYBeIx*f$uN~Gak=hk;1^h5bf#W7!u+B_L?CVg94B9#aDmd z#|X;Ecr7dx_{hGb*;!60qquzc%ze+cGJrsX@PQhaZ>p}WF0DdNj47_EEYm-DIz$_L qZ4-C1ZCtS;#_sTZ0g%Ev_8GiO7V??Cl+)P`;(NOKxvX%fdzOY#aD z7#J9qJQplxU|?V^3Gxg6|NsAghTq%xf*BYX(mY)pLo9lqUb5yppuod?VaJbu>3UNq z6m$hzZM-7fWd6i?gNF>ui^AsoO{}xO3qTiAmzNUPb za%g{JQNVq-Sbgpc<WIY=L14D6D)fWZ^hMAr&jv*Ddk`p9Y7dLQhNW9+o-@qpMn$RAJNZn9f zwd0H;mMpU!pI9}dxIZvz5n`Y4gu{zx;SI(s9~fQJ0#x}l4coI;&WPFkiA(CAa4zEhJJ?bKeXOpZ$~dq(*{Mz7R9i?P zgPr??*9@zcCKbszT)k$f$tUslLJw0C0|Uz%UdicUSAQ}vFfe$!`njxgN@xNAvr$Rn diff --git a/core/assets-raw/sprites/blocks/production/pulverizer-top.png b/core/assets-raw/sprites/blocks/production/pulverizer-top.png new file mode 100644 index 0000000000000000000000000000000000000000..6c2aa6d6539cd8475e0c1aa60cf3a216f17cc8a3 GIT binary patch literal 306 zcmeAS@N?(olHy`uVBq!ia0y~yU{C;I4mJh`hT^KKFANL}jKx9jP7LeL$-HD>V0h!{ z;usRq`u4gt-ys7YhJfSG-}KB7aDO2vAe{8fXYLN}xk{qyemT#R6(6o#U{N>anCIcg zKYukCoLjEyaV+!Mk=$zU<9wVf3?Ez)_Iz-9@X?u5@$dhw$rI})I%lX|d8We9wL#?i zlQc%bi$O7635?%w--?N8I>A&Wwq8-_K*uA~mh2g>(_jC(`hIQsxhXE)+ZC>G#uREd z#kOsJ#Q$S&`vm8noCIg(Gyhb-9GGR(vbFTy<_a+bu7k2yZ>HW54y^Lm_|_=baZBc^ z+m)t{ol7roTOk}JVAAf~5xtS^VDDMQW$#%<9&VD970lb6=<%ii3%Pf#HwD+rP t%7RDtxz!$cvzko2`hHV=6*~hAbn|xqX4IIu#@YuY;_2$=vd$@?2>_@w9moIx literal 292 zcmeAS@N?(olHy`uVBq!ia0y~yU{C;I7G?$phQ^Te;|vT8jKx9jP7LeL$-HD>U|>mi z^mSxl*x1kgCy|wbfx#faC&V=@EG@5~VaBW_48#HX9M%~O3=EtF9+AZi419+{nDKc2 ziWCM0hFVV-#}JM4OD8xAH7M{fE9)!NHa`9@uX*8!WAzsCl)Fw`>q6BpeB$01)+4ll zMLWS`0@J336MSEJ95`3{T;QF>utD=i%hH7V{!EWT#Z`VRStieZf9+?zf2_9`KD{Nh z#!dh5)sL^4ZM`H)+6@@Oy render(i % width, i / width)); updates.clear(); @@ -80,6 +82,7 @@ public class MapRenderer implements Disposable{ } public void updateAll(){ + clearEditor = Core.atlas.find("clear-editor"); for(int x = 0; x < width; x++){ for(int y = 0; y < height; y++){ render(x, y); @@ -103,7 +106,7 @@ public class MapRenderer implements Disposable{ boolean center = tile.isCenter(); if(wall != Blocks.air && wall.synthetic()){ - region = !Core.atlas.isFound(wall.editorIcon()) || !center ? Core.atlas.find("clear-editor") : wall.editorIcon(); + region = !wall.editorIcon().found() || !center ? clearEditor : wall.editorIcon(); float width = region.width * Draw.scl, height = region.height * Draw.scl; @@ -124,13 +127,17 @@ public class MapRenderer implements Disposable{ mesh.setColor(team.color); region = Core.atlas.find("block-border-editor"); }else if(!wall.synthetic() && wall != Blocks.air && center){ - region = !Core.atlas.isFound(wall.editorIcon()) ? Core.atlas.find("clear-editor") : wall.editorIcon(); + region = !wall.editorIcon().found() ? + clearEditor : wall.variants > 0 ? + wall.editorVariantRegions()[Mathf.randomSeed(idxWall, 0, wall.editorVariantRegions().length - 1)] : + wall.editorIcon(); + offsetX = tilesize / 2f - region.width / 2f * Draw.scl; offsetY = tilesize / 2f - region.height / 2f * Draw.scl; }else if(wall == Blocks.air && !tile.overlay().isAir()){ region = tile.overlay().editorVariantRegions()[Mathf.randomSeed(idxWall, 0, tile.overlay().editorVariantRegions().length - 1)]; }else{ - region = Core.atlas.find("clear-editor"); + region = clearEditor; } float width = region.width * Draw.scl, height = region.height * Draw.scl; diff --git a/core/src/mindustry/entities/comp/BuildingComp.java b/core/src/mindustry/entities/comp/BuildingComp.java index 8493610a4f..6c6bf1250d 100644 --- a/core/src/mindustry/entities/comp/BuildingComp.java +++ b/core/src/mindustry/entities/comp/BuildingComp.java @@ -907,7 +907,11 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc, } public void draw(){ - Draw.rect(block.region, x, y, block.rotate ? rotdeg() : 0); + if(block.variants == 0){ + Draw.rect(block.region, x, y, block.rotate ? rotdeg() : 0); + }else{ + Draw.rect(block.variantRegions[Mathf.randomSeed(tile.pos(), 0, Math.max(0, block.variantRegions.length - 1))], x, y, block.rotate ? rotdeg() : 0); + } drawTeamTop(); } diff --git a/core/src/mindustry/graphics/g3d/PlanetRenderer.java b/core/src/mindustry/graphics/g3d/PlanetRenderer.java index 3401ba8b3d..37c38e3833 100644 --- a/core/src/mindustry/graphics/g3d/PlanetRenderer.java +++ b/core/src/mindustry/graphics/g3d/PlanetRenderer.java @@ -149,7 +149,7 @@ public class PlanetRenderer implements Disposable{ public void renderTransparent(Planet planet){ if(!planet.visible()) return; - if(planet.isLandable() && planet == this.planet){ + if(planet.hasGrid() && planet == this.planet){ renderSectors(planet); } diff --git a/core/src/mindustry/mod/ContentParser.java b/core/src/mindustry/mod/ContentParser.java index 6738257d79..6862b1a540 100644 --- a/core/src/mindustry/mod/ContentParser.java +++ b/core/src/mindustry/mod/ContentParser.java @@ -707,6 +707,11 @@ public class ContentParser{ node.objectives.addAll(parser.readValue(Objective[].class, research.get("objectives"))); } + //all items have a produce requirement unless already specified + if(object instanceof Item i && !node.objectives.contains(o -> o instanceof Produce p && p.content == i)){ + node.objectives.add(new Produce(i)); + } + //remove old node from parent if(node.parent != null){ node.parent.children.remove(node); diff --git a/core/src/mindustry/type/Planet.java b/core/src/mindustry/type/Planet.java index 20968951f9..ce92bf0ca1 100644 --- a/core/src/mindustry/type/Planet.java +++ b/core/src/mindustry/type/Planet.java @@ -127,7 +127,8 @@ public class Planet extends UnlockableContent{ sectors.get(index).preset = preset; } - public boolean isLandable(){ + /** @return whether this planet has a sector grid to select. */ + public boolean hasGrid(){ return grid != null && generator != null && sectors.size > 0; } diff --git a/core/src/mindustry/ui/dialogs/GameOverDialog.java b/core/src/mindustry/ui/dialogs/GameOverDialog.java index 083e49c116..32e593ea0e 100644 --- a/core/src/mindustry/ui/dialogs/GameOverDialog.java +++ b/core/src/mindustry/ui/dialogs/GameOverDialog.java @@ -5,7 +5,6 @@ import mindustry.core.GameState.*; import mindustry.game.EventType.*; import mindustry.game.*; import mindustry.type.*; -import mindustry.ui.*; import static mindustry.Vars.*; @@ -31,7 +30,7 @@ public class GameOverDialog extends BaseDialog{ } void rebuild(){ - title.setText(state.isCampaign() ? "@sector.curlost" : "@gameover"); + title.setText(state.isCampaign() ? Core.bundle.format("sector.lost", state.getSector().name()) : "@gameover"); buttons.clear(); cont.clear(); diff --git a/core/src/mindustry/ui/dialogs/PlanetDialog.java b/core/src/mindustry/ui/dialogs/PlanetDialog.java index 1e671c43b1..f9a838b9e1 100644 --- a/core/src/mindustry/ui/dialogs/PlanetDialog.java +++ b/core/src/mindustry/ui/dialogs/PlanetDialog.java @@ -593,7 +593,7 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{ } } - if(planets.planet.isLandable()){ + if(planets.planet.hasGrid()){ hovered = planets.planet.getSector(planets.cam.getMouseRay(), PlanetRenderer.outlineRad); }else{ hovered = selected = null; diff --git a/core/src/mindustry/ui/fragments/HudFragment.java b/core/src/mindustry/ui/fragments/HudFragment.java index 79dcf85e40..9cb5d850e0 100644 --- a/core/src/mindustry/ui/fragments/HudFragment.java +++ b/core/src/mindustry/ui/fragments/HudFragment.java @@ -322,7 +322,7 @@ public class HudFragment extends Fragment{ } return max == 0f ? 0f : val / max; }).blink(Color.white).outline(new Color(0, 0, 0, 0.6f), 7f)).grow()) - .fillX().width(320f).height(60f).name("boss").visible(() -> state.rules.waves && state.boss() != null).padTop(7).row(); + .fillX().width(320f).height(60f).name("boss").visible(() -> state.rules.waves && state.boss() != null && !(mobile && Core.graphics.isPortrait())).padTop(7).row(); t.table(Styles.black3, p -> p.margin(4).label(() -> hudText).style(Styles.outlineLabel)).touchable(Touchable.disabled).with(p -> p.visible(() -> { p.color.a = Mathf.lerpDelta(p.color.a, Mathf.num(showHudText), 0.2f); diff --git a/core/src/mindustry/world/Block.java b/core/src/mindustry/world/Block.java index bcee08544e..11eb6b3bef 100644 --- a/core/src/mindustry/world/Block.java +++ b/core/src/mindustry/world/Block.java @@ -46,6 +46,7 @@ public class Block extends UnlockableContent{ public boolean outputsPayload = false; public boolean acceptsPayload = false; public boolean outputFacing = true; + public boolean noSideBlend = false; public boolean acceptsItems = false; public int itemCapacity = 10; @@ -77,6 +78,8 @@ public class Block extends UnlockableContent{ public boolean solidifes; /** whether this is rotateable */ public boolean rotate; + /** number of different variant regions to use */ + public int variants = 0; /** whether to draw a rotation arrow - this does not apply to lines of blocks */ public boolean drawArrow = true; /** for static blocks only: if true, tile data() is saved in world data. */ @@ -239,11 +242,11 @@ public class Block extends UnlockableContent{ public ObjectMap, Cons2> configurations = new ObjectMap<>(); protected TextureRegion[] generatedIcons; - protected TextureRegion[] variantRegions, editorVariantRegions; + protected TextureRegion[] editorVariantRegions; public TextureRegion region, editorIcon; public @Load("@-team") TextureRegion teamRegion; - public TextureRegion[] teamRegions; + public TextureRegion[] teamRegions, variantRegions; protected static final Seq tempTiles = new Seq<>(); protected static final Seq tempTileEnts = new Seq<>(); @@ -263,7 +266,11 @@ public class Block extends UnlockableContent{ if(tile.build != null){ tile.build.draw(); }else{ - Draw.rect(region, tile.drawx(), tile.drawy()); + if(variants == 0){ + Draw.rect(region, tile.drawx(), tile.drawy()); + }else{ + Draw.rect(variantRegions[Mathf.randomSeed(tile.pos(), 0, Math.max(0, variantRegions.length - 1))], tile.drawx(), tile.drawy()); + } } } @@ -587,7 +594,8 @@ public class Block extends UnlockableContent{ protected TextureRegion[] icons(){ //use team region in vanilla team blocks - return teamRegion.found() && minfo.mod == null ? new TextureRegion[]{region, teamRegions[Team.sharded.id]} : new TextureRegion[]{region}; + TextureRegion r = variants > 0 ? Core.atlas.find(name + "1") : region; + return teamRegion.found() && minfo.mod == null ? new TextureRegion[]{r, teamRegions[Team.sharded.id]} : new TextureRegion[]{r}; } public TextureRegion[] getGeneratedIcons(){ @@ -830,6 +838,15 @@ public class Block extends UnlockableContent{ for(Team team : Team.all){ teamRegions[team.id] = teamRegion.found() ? Core.atlas.find(name + "-team-" + team.name, teamRegion) : teamRegion; } + + if(variants != 0){ + variantRegions = new TextureRegion[variants]; + + for(int i = 0; i < variants; i++){ + variantRegions[i] = Core.atlas.find(name + (i + 1)); + } + region = variantRegions[0]; + } } @Override @@ -846,6 +863,13 @@ public class Block extends UnlockableContent{ mapColor.set(image.get(image.width/2, image.height/2)); } + if(variants > 0){ + for(int i = 0; i < variants; i++){ + String rname = name + (i + 1); + packer.add(PageType.editor, "editor-" + rname, Core.atlas.getPixmap(rname)); + } + } + Pixmap last = null; var gen = icons(); diff --git a/core/src/mindustry/world/blocks/defense/Wall.java b/core/src/mindustry/world/blocks/defense/Wall.java index cde36ba964..d8d1c620b4 100644 --- a/core/src/mindustry/world/blocks/defense/Wall.java +++ b/core/src/mindustry/world/blocks/defense/Wall.java @@ -15,8 +15,6 @@ import mindustry.world.meta.*; import static mindustry.Vars.*; public class Wall extends Block{ - public int variants = 0; - /** Lighting chance. -1 to disable */ public float lightningChance = -1f; public float lightningDamage = 20f; @@ -51,20 +49,6 @@ public class Wall extends Block{ } } - @Override - public void load(){ - super.load(); - - if(variants != 0){ - variantRegions = new TextureRegion[variants]; - - for(int i = 0; i < variants; i++){ - variantRegions[i] = Core.atlas.find(name + (i + 1)); - } - region = variantRegions[0]; - } - } - @Override public TextureRegion[] icons(){ return new TextureRegion[]{Core.atlas.find(Core.atlas.has(name) ? name : name + "1")}; @@ -75,11 +59,7 @@ public class Wall extends Block{ @Override public void draw(){ - if(variants == 0){ - Draw.rect(region, x, y); - }else{ - Draw.rect(variantRegions[Mathf.randomSeed(tile.pos(), 0, Math.max(0, variantRegions.length - 1))], x, y); - } + super.draw(); //draw flashing white overlay if enabled if(flashHit){ diff --git a/core/src/mindustry/world/blocks/distribution/ArmoredConveyor.java b/core/src/mindustry/world/blocks/distribution/ArmoredConveyor.java index af7e2c985b..e5e2c05545 100644 --- a/core/src/mindustry/world/blocks/distribution/ArmoredConveyor.java +++ b/core/src/mindustry/world/blocks/distribution/ArmoredConveyor.java @@ -8,6 +8,7 @@ public class ArmoredConveyor extends Conveyor{ public ArmoredConveyor(String name){ super(name); + noSideBlend = true; } @Override diff --git a/core/src/mindustry/world/blocks/distribution/Duct.java b/core/src/mindustry/world/blocks/distribution/Duct.java index c2a63f238e..b485fe6341 100644 --- a/core/src/mindustry/world/blocks/distribution/Duct.java +++ b/core/src/mindustry/world/blocks/distribution/Duct.java @@ -38,6 +38,7 @@ public class Duct extends Block implements Autotiler{ itemCapacity = 1; noUpdateDisabled = true; rotate = true; + noSideBlend = true; envEnabled = Env.space | Env.terrestrial | Env.underwater; } diff --git a/core/src/mindustry/world/blocks/distribution/StackConveyor.java b/core/src/mindustry/world/blocks/distribution/StackConveyor.java index 7c7007cb54..030319a447 100644 --- a/core/src/mindustry/world/blocks/distribution/StackConveyor.java +++ b/core/src/mindustry/world/blocks/distribution/StackConveyor.java @@ -12,7 +12,6 @@ import mindustry.entities.units.*; import mindustry.gen.*; import mindustry.graphics.*; import mindustry.type.*; -import mindustry.ui.*; import mindustry.world.*; import mindustry.world.blocks.*; import mindustry.world.blocks.distribution.Conveyor.*; @@ -63,7 +62,7 @@ public class StackConveyor extends Block implements Autotiler{ return otherblock.outputsItems() && lookingAtEither(tile, rotation, otherx, othery, otherrot, otherblock); }else if(state == stateUnload){ //router mode return otherblock.acceptsItems && - (!(otherblock instanceof ArmoredConveyor) || lookingAtEither(tile, rotation, otherx, othery, otherrot, otherblock)) && + (!otherblock.noSideBlend || lookingAtEither(tile, rotation, otherx, othery, otherrot, otherblock)) && (notLookingAt(tile, rotation, otherx, othery, otherrot, otherblock) || (otherblock instanceof StackConveyor && facing(otherx, othery, otherrot, tile.x, tile.y))) && !(world.build(otherx, othery) instanceof StackConveyorBuild s && s.state == stateUnload) && diff --git a/core/src/mindustry/world/blocks/environment/Floor.java b/core/src/mindustry/world/blocks/environment/Floor.java index 7cee47c4d0..762a5e4f9d 100644 --- a/core/src/mindustry/world/blocks/environment/Floor.java +++ b/core/src/mindustry/world/blocks/environment/Floor.java @@ -20,8 +20,6 @@ import mindustry.world.blocks.*; import static mindustry.Vars.*; public class Floor extends Block{ - /** number of different variant regions to use */ - public int variants = 3; /** edge fallback, used mainly for ores */ public String edge = "stone"; /** Multiplies unit velocity by this when walked on. */ @@ -76,6 +74,12 @@ public class Floor extends Block{ public Floor(String name){ super(name); + variants = 3; + } + + public Floor(String name, int variants){ + super(name); + this.variants = variants; } @Override @@ -85,7 +89,6 @@ public class Floor extends Block{ //load variant regions for drawing if(variants > 0){ variantRegions = new TextureRegion[variants]; - for(int i = 0; i < variants; i++){ variantRegions[i] = Core.atlas.find(name + (i + 1)); } @@ -93,7 +96,6 @@ public class Floor extends Block{ variantRegions = new TextureRegion[1]; variantRegions[0] = Core.atlas.find(name); } - int size = (int)(tilesize / Draw.scl); if(Core.atlas.has(name + "-edge")){ edges = Core.atlas.find(name + "-edge").split(size, size); @@ -130,19 +132,12 @@ public class Floor extends Block{ @Override public void createIcons(MultiPacker packer){ super.createIcons(packer); - packer.add(PageType.editor, "editor-" + name, Core.atlas.getPixmap(fullIcon).crop()); + packer.add(PageType.editor, "editor-" + name, Core.atlas.getPixmap(fullIcon)); if(blendGroup != this){ return; } - if(variants > 0){ - for(int i = 0; i < variants; i++){ - String rname = name + (i + 1); - packer.add(PageType.editor, "editor-" + rname, Core.atlas.getPixmap(rname).crop()); - } - } - PixmapRegion image = Core.atlas.getPixmap(icons()[0]); PixmapRegion edge = Core.atlas.getPixmap("edge-stencil"); Pixmap result = new Pixmap(edge.width, edge.height); diff --git a/core/src/mindustry/world/blocks/environment/MetalFloor.java b/core/src/mindustry/world/blocks/environment/MetalFloor.java deleted file mode 100644 index fd26f90183..0000000000 --- a/core/src/mindustry/world/blocks/environment/MetalFloor.java +++ /dev/null @@ -1,19 +0,0 @@ -package mindustry.world.blocks.environment; - -import mindustry.world.meta.*; - -/** Class for quickly defining a floor with no water and no variants. Offers no new functionality. */ -public class MetalFloor extends Floor{ - - public MetalFloor(String name){ - super(name); - variants = 0; - attributes.set(Attribute.water, -1); - } - - public MetalFloor(String name, int variants){ - super(name); - this.variants = variants; - attributes.set(Attribute.water, -1); - } -} diff --git a/core/src/mindustry/world/blocks/environment/Prop.java b/core/src/mindustry/world/blocks/environment/Prop.java index 1056748bce..6adfff5edb 100644 --- a/core/src/mindustry/world/blocks/environment/Prop.java +++ b/core/src/mindustry/world/blocks/environment/Prop.java @@ -7,8 +7,6 @@ import mindustry.content.*; import mindustry.world.*; public class Prop extends Block{ - public int variants; - public Prop(String name){ super(name); breakable = true; @@ -28,17 +26,4 @@ public class Prop extends Block{ public TextureRegion[] icons(){ return variants == 0 ? super.icons() : new TextureRegion[]{Core.atlas.find(name + "1")}; } - - @Override - public void load(){ - super.load(); - - if(variants > 0){ - variantRegions = new TextureRegion[variants]; - - for(int i = 0; i < variants; i++){ - variantRegions[i] = Core.atlas.find(name + (i + 1)); - } - } - } } diff --git a/core/src/mindustry/world/blocks/logic/LogicBlock.java b/core/src/mindustry/world/blocks/logic/LogicBlock.java index f38644e5f5..a12ed08399 100644 --- a/core/src/mindustry/world/blocks/logic/LogicBlock.java +++ b/core/src/mindustry/world/blocks/logic/LogicBlock.java @@ -174,6 +174,7 @@ public class LogicBlock extends Block{ public boolean active = true, valid; public int x, y; public String name; + Building lastBuild; public LogicLink(int x, int y, String name, boolean valid){ this.x = x; @@ -405,20 +406,22 @@ public class LogicBlock extends Block{ if(!l.active) continue; - boolean valid = validLink(world.build(l.x, l.y)); - if(valid != l.valid){ + var cur = world.build(l.x, l.y); + + boolean valid = validLink(cur); + if(valid != l.valid || (l.lastBuild != null && l.lastBuild != cur)){ + l.lastBuild = cur; changed = true; l.valid = valid; if(valid){ - Building lbuild = world.build(l.x, l.y); //this prevents conflicts l.name = ""; //finds a new matching name after toggling - l.name = findLinkName(lbuild.block); + l.name = findLinkName(cur.block); //remove redundant links - links.removeAll(o -> world.build(o.x, o.y) == lbuild && o != l); + links.removeAll(o -> world.build(o.x, o.y) == cur && o != l); //break to prevent concurrent modification updates = true; diff --git a/core/src/mindustry/world/draw/DrawLiquid.java b/core/src/mindustry/world/draw/DrawLiquid.java new file mode 100644 index 0000000000..16cfd14934 --- /dev/null +++ b/core/src/mindustry/world/draw/DrawLiquid.java @@ -0,0 +1,38 @@ +package mindustry.world.draw; + +import arc.*; +import arc.graphics.g2d.*; +import mindustry.graphics.*; +import mindustry.world.*; +import mindustry.world.blocks.production.*; +import mindustry.world.blocks.production.GenericCrafter.*; + +public class DrawLiquid extends DrawBlock{ + public TextureRegion liquid, top; + + @Override + public void draw(GenericCrafterBuild build){ + Draw.rect(build.block.region, build.x, build.y); + GenericCrafter type = (GenericCrafter)build.block; + + if(type.outputLiquid != null && build.liquids.get(type.outputLiquid.liquid) > 0){ + Drawf.liquid(liquid, build.x, build.y, + build.liquids.get(type.outputLiquid.liquid) / type.liquidCapacity, + type.outputLiquid.liquid.color + ); + } + + if(top.found()) Draw.rect(top, build.x, build.y); + } + + @Override + public void load(Block block){ + top = Core.atlas.find(block.name + "-top"); + liquid = Core.atlas.find(block.name + "-liquid"); + } + + @Override + public TextureRegion[] icons(Block block){ + return top.found() ? new TextureRegion[]{block.region, top} : new TextureRegion[]{block.region}; + } +} diff --git a/core/src/mindustry/world/draw/DrawRotator.java b/core/src/mindustry/world/draw/DrawRotator.java index 166245fa6c..5d75b77825 100644 --- a/core/src/mindustry/world/draw/DrawRotator.java +++ b/core/src/mindustry/world/draw/DrawRotator.java @@ -6,21 +6,23 @@ import mindustry.world.*; import mindustry.world.blocks.production.GenericCrafter.*; public class DrawRotator extends DrawBlock{ - public TextureRegion rotator; + public TextureRegion rotator, top; @Override public void draw(GenericCrafterBuild build){ Draw.rect(build.block.region, build.x, build.y); Draw.rect(rotator, build.x, build.y, build.totalProgress * 2f); + if(top.found()) Draw.rect(top, build.x, build.y); } @Override public void load(Block block){ rotator = Core.atlas.find(block.name + "-rotator"); + top = Core.atlas.find(block.name + "-top"); } @Override public TextureRegion[] icons(Block block){ - return new TextureRegion[]{block.region, rotator}; + return top.found() ? new TextureRegion[]{block.region, rotator, top} : new TextureRegion[]{block.region, rotator}; } } diff --git a/servers_v6.json b/servers_v6.json index 79c86fc799..dfcd37de1b 100644 --- a/servers_v6.json +++ b/servers_v6.json @@ -101,7 +101,7 @@ }, { "name": "Sakura", - "address": ["160.16.207.141"] + "address": ["160.16.207.141", "160.16.207.141:21527", "160.16.207.141:31587"] }, { "name": "MeowLand", diff --git a/tools/src/mindustry/tools/Generators.java b/tools/src/mindustry/tools/Generators.java index 6f7ba3f5c5..626986b5ce 100644 --- a/tools/src/mindustry/tools/Generators.java +++ b/tools/src/mindustry/tools/Generators.java @@ -220,7 +220,7 @@ public class Generators{ TextureRegion[] regions = block.getGeneratedIcons(); - if(block instanceof Floor){ + if(block.variants > 0){ for(TextureRegion region : block.variantRegions()){ GenRegion gen = (GenRegion)region; if(gen.path == null) continue;