From e66a1a92c352a5cc420c7a9dad6861c4373a31e3 Mon Sep 17 00:00:00 2001 From: Patrick 'Quezler' Mounier Date: Thu, 16 Apr 2020 18:56:00 +0200 Subject: [PATCH] Phase out the need for isSleeping Thanks to knowledge gained from the previous commit. --- core/src/mindustry/entities/def/TileComp.java | 4 -- .../blocks/distribution/CraterConveyor.java | 37 ++++++++++--------- 2 files changed, 19 insertions(+), 22 deletions(-) diff --git a/core/src/mindustry/entities/def/TileComp.java b/core/src/mindustry/entities/def/TileComp.java index bd7eb2a312..1436e46255 100644 --- a/core/src/mindustry/entities/def/TileComp.java +++ b/core/src/mindustry/entities/def/TileComp.java @@ -249,10 +249,6 @@ abstract class TileComp implements Posc, Teamc, Healthc, Tilec, Timerc, QuadTree } } - public boolean isSleeping(){ - return sleeping; - } - /** Call when this entity is updating. This wakes it up. */ public void noSleep(){ sleepTime = 0f; diff --git a/core/src/mindustry/world/blocks/distribution/CraterConveyor.java b/core/src/mindustry/world/blocks/distribution/CraterConveyor.java index f443fadf6e..39a83a36b3 100644 --- a/core/src/mindustry/world/blocks/distribution/CraterConveyor.java +++ b/core/src/mindustry/world/blocks/distribution/CraterConveyor.java @@ -224,31 +224,32 @@ public class CraterConveyor extends Block implements Autotiler{ } // crater conveyor tiles that input into this one - private void upstream(Tilec tile, Cons cons){ - CraterConveyorEntity entity = (CraterConveyorEntity)tile; + private void upstream(CraterConveyorEntity tile, Cons cons){ - if( entity.blendbit1 == 0 // 1 input from the back, 0 from the sides - || entity.blendbit1 == 2 // 1 input from the back, 1 from the sides - || entity.blendbit1 == 3 // 1 input from the back, 2 from the sides - ) cons.get(back()); // fixme, fires for 0 while nothing behind + if(tile.blendbit1 == 0 && !(back() instanceof CraterConveyorEntity)) return; - if( entity.blendbit1 == 3 // 1 input from the back, 2 from the sides - || entity.blendbit1 == 4 // 0 input from the back, 2 from the sides - ||(entity.blendbit1 == 1 && entity.blendscly == -1) // side is open - ||(entity.blendbit1 == 2 && entity.blendscly == +1) // side is open - ) cons.get(right()); + if( tile.blendbit1 == 0 // 1 input from the back, 0 from the sides + || tile.blendbit1 == 2 // 1 input from the back, 1 from the sides + || tile.blendbit1 == 3 // 1 input from the back, 2 from the sides + ) cons.get((CraterConveyorEntity)back()); - if( entity.blendbit1 == 3 // 1 input from the back, 2 from the sides - || entity.blendbit1 == 4 // 0 input from the back, 2 from the sides - ||(entity.blendbit1 == 1 && entity.blendscly == +1) // side is open - ||(entity.blendbit1 == 2 && entity.blendscly == -1) // side is open - ) cons.get(left()); + if( tile.blendbit1 == 3 // 1 input from the back, 2 from the sides + || tile.blendbit1 == 4 // 0 input from the back, 2 from the sides + ||(tile.blendbit1 == 1 && tile.blendscly == -1) // side is open + ||(tile.blendbit1 == 2 && tile.blendscly == +1) // side is open + ) cons.get((CraterConveyorEntity)right()); + + if( tile.blendbit1 == 3 // 1 input from the back, 2 from the sides + || tile.blendbit1 == 4 // 0 input from the back, 2 from the sides + ||(tile.blendbit1 == 1 && tile.blendscly == +1) // side is open + ||(tile.blendbit1 == 2 && tile.blendscly == -1) // side is open + ) cons.get((CraterConveyorEntity)left()); } // awaken inputting conveyors - private void bump(Tilec tile){ + private void bump(CraterConveyorEntity tile){ upstream(tile, t -> { - if(t == null || !t.isSleeping() || t.items().total() <= 0) return; + if(t == null || !t.sleeping || t.items().total() <= 0) return; t.noSleep(); bump(t); });