From c1f765a4675bfec023f961535e9f1e7c794a6453 Mon Sep 17 00:00:00 2001 From: Patrick 'Quezler' Mounier Date: Thu, 5 Mar 2020 20:26:34 +0100 Subject: [PATCH] Bodge in a rotational blend bypass --- core/src/mindustry/world/Block.java | 9 +++++++++ core/src/mindustry/world/blocks/Autotiler.java | 4 +++- .../mindustry/world/blocks/distribution/Conveyor.java | 4 ++-- .../world/blocks/distribution/CraterConveyor.java | 6 ++++++ 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/core/src/mindustry/world/Block.java b/core/src/mindustry/world/Block.java index a0294013ad..89d393c114 100644 --- a/core/src/mindustry/world/Block.java +++ b/core/src/mindustry/world/Block.java @@ -53,6 +53,8 @@ public class Block extends BlockStorage{ public boolean solidifes; /** whether this is rotateable */ public boolean rotate; + /** whether this dumps as well */ + public boolean dumpling; /** whether you can break this with rightclick */ public boolean breakable; /** whether to add this block to brokenblocks */ @@ -667,6 +669,13 @@ public class Block extends BlockStorage{ } } + /** + * Whether blending this tile should respect dumpling. + */ + public boolean blendDumpling(Tile tile){ + return false; + } + public String getDisplayName(Tile tile){ return localizedName; } diff --git a/core/src/mindustry/world/blocks/Autotiler.java b/core/src/mindustry/world/blocks/Autotiler.java index 75cb41419a..a5fd69924f 100644 --- a/core/src/mindustry/world/blocks/Autotiler.java +++ b/core/src/mindustry/world/blocks/Autotiler.java @@ -9,6 +9,8 @@ import mindustry.world.*; import java.util.*; +import static mindustry.Vars.world; + public interface Autotiler{ class AutotilerHolder{ static final int[] blendresult = new int[3]; @@ -95,7 +97,7 @@ public interface Autotiler{ default boolean lookingAt(Tile tile, int rotation, int otherx, int othery, int otherrot, Block otherblock){ return (Point2.equals(tile.x + Geometry.d4(rotation).x, tile.y + Geometry.d4(rotation).y, otherx, othery) - || (!otherblock.rotate || Point2.equals(otherx + Geometry.d4(otherrot).x, othery + Geometry.d4(otherrot).y, tile.x, tile.y))); + || (!(otherblock.rotate && !(otherblock.dumpling && otherblock.blendDumpling(world.tile(otherx, othery)))) || Point2.equals(otherx + Geometry.d4(otherrot).x, othery + Geometry.d4(otherrot).y, tile.x, tile.y))); } boolean blends(Tile tile, int rotation, int otherx, int othery, int otherrot, Block otherblock); diff --git a/core/src/mindustry/world/blocks/distribution/Conveyor.java b/core/src/mindustry/world/blocks/distribution/Conveyor.java index e76fa3fb51..f1a58eb62d 100644 --- a/core/src/mindustry/world/blocks/distribution/Conveyor.java +++ b/core/src/mindustry/world/blocks/distribution/Conveyor.java @@ -116,7 +116,7 @@ public class Conveyor extends Block implements Autotiler{ @Override public boolean blends(Tile tile, int rotation, int otherx, int othery, int otherrot, Block otherblock){ - return otherblock.outputsItems() && (lookingAt(tile, rotation, otherx, othery, otherrot, otherblock) || (otherblock instanceof CraterConveyor && world.tile(otherx, othery).ent().blendbit2 == 6)); + return otherblock.outputsItems() && (lookingAt(tile, rotation, otherx, othery, otherrot, otherblock)); } @Override @@ -285,7 +285,7 @@ public class Conveyor extends Block implements Autotiler{ ConveyorEntity e = tile.ent(); if(e.len >= capacity) return false; int direction = source == null ? 0 : Math.abs(source.relativeTo(tile.x, tile.y) - tile.rotation()); - return (((direction == 0) && e.minitem >= itemSpace) || ((direction % 2 == 1) && e.minitem > 0.7f)) && (source == null || !(source.block().rotate && (source.rotation() + 2) % 4 == tile.rotation())); + return (((direction == 0) && e.minitem >= itemSpace) || ((direction % 2 == 1) && e.minitem > 0.7f)) && (source == null || !((source.block().rotate && !source.block().dumpling) && (source.rotation() + 2) % 4 == tile.rotation())); } @Override diff --git a/core/src/mindustry/world/blocks/distribution/CraterConveyor.java b/core/src/mindustry/world/blocks/distribution/CraterConveyor.java index 5fceab89e9..c270240133 100644 --- a/core/src/mindustry/world/blocks/distribution/CraterConveyor.java +++ b/core/src/mindustry/world/blocks/distribution/CraterConveyor.java @@ -43,6 +43,7 @@ public class CraterConveyor extends Block implements Autotiler{ idleSound = Sounds.conveyor; idleSoundVolume = 0.004f; unloadable = false; + dumpling = true; } @Override @@ -335,4 +336,9 @@ public class CraterConveyor extends Block implements Autotiler{ entity.dump = (byte)((entity.dump + 1) % prox); } + + @Override + public boolean blendDumpling(Tile tile){ + return tile.ent().blendbit2 == 6; + } }