From e827bb17e747d81ccaf77f7cae7d47610ea28126 Mon Sep 17 00:00:00 2001 From: Patrick 'Quezler' Mounier Date: Sun, 10 Nov 2019 09:24:24 +0100 Subject: [PATCH] Move blend check to autotiler --- .../io/anuke/mindustry/world/blocks/Autotiler.java | 6 ++++++ .../world/blocks/distribution/ArmoredConduit.java | 2 +- .../world/blocks/distribution/ArmoredConveyor.java | 11 ++--------- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/core/src/io/anuke/mindustry/world/blocks/Autotiler.java b/core/src/io/anuke/mindustry/world/blocks/Autotiler.java index 081651d40e..29e99361a4 100644 --- a/core/src/io/anuke/mindustry/world/blocks/Autotiler.java +++ b/core/src/io/anuke/mindustry/world/blocks/Autotiler.java @@ -87,6 +87,12 @@ public interface Autotiler{ return other != null && blends(tile, rotation, other.x, other.y, other.rotation(), other.block()); } + default boolean blendsArmored(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 && Edges.getFacingEdge(otherblock, otherx, othery, tile) != null && + Edges.getFacingEdge(otherblock, otherx, othery, tile).relativeTo(tile) == rotation) || (otherblock.rotate && Point2.equals(otherx + Geometry.d4(otherrot).x, othery + Geometry.d4(otherrot).y, tile.x, tile.y)))); + } + 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))); diff --git a/core/src/io/anuke/mindustry/world/blocks/distribution/ArmoredConduit.java b/core/src/io/anuke/mindustry/world/blocks/distribution/ArmoredConduit.java index d9ed02dddc..1f452fdd2e 100644 --- a/core/src/io/anuke/mindustry/world/blocks/distribution/ArmoredConduit.java +++ b/core/src/io/anuke/mindustry/world/blocks/distribution/ArmoredConduit.java @@ -41,6 +41,6 @@ public class ArmoredConduit extends Conduit{ @Override public boolean blends(Tile tile, int rotation, int otherx, int othery, int otherrot, Block otherblock){ - return otherblock.outputsLiquid && ArmoredConveyor.blender(tile, rotation, otherx, othery, otherrot, otherblock); + return otherblock.outputsLiquid && blendsArmored(tile, rotation, otherx, othery, otherrot, otherblock); } } diff --git a/core/src/io/anuke/mindustry/world/blocks/distribution/ArmoredConveyor.java b/core/src/io/anuke/mindustry/world/blocks/distribution/ArmoredConveyor.java index c71ff7e208..c91c16318b 100644 --- a/core/src/io/anuke/mindustry/world/blocks/distribution/ArmoredConveyor.java +++ b/core/src/io/anuke/mindustry/world/blocks/distribution/ArmoredConveyor.java @@ -1,6 +1,5 @@ package io.anuke.mindustry.world.blocks.distribution; -import io.anuke.arc.math.geom.*; import io.anuke.mindustry.type.*; import io.anuke.mindustry.world.*; @@ -16,13 +15,7 @@ public class ArmoredConveyor extends Conveyor{ } @Override - public boolean blends(Tile tile, int rotation, int otherx, int othery, int otherrot, Block otherblock){ - return otherblock.outputsItems() && blender(tile, rotation, otherx, othery, otherrot, otherblock); - } - - public static boolean blender(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 && Edges.getFacingEdge(otherblock, otherx, othery, tile) != null && - Edges.getFacingEdge(otherblock, otherx, othery, tile).relativeTo(tile) == rotation) || (otherblock.rotate && Point2.equals(otherx + Geometry.d4(otherrot).x, othery + Geometry.d4(otherrot).y, tile.x, tile.y)))); + public boolean blends(Tile tile, int rotation, int otherx, int othery, int otherrot, Block otherblock) { + return otherblock.outputsItems() && blendsArmored(tile, rotation, otherx, othery, otherrot, otherblock); } }