diff --git a/core/src/io/anuke/mindustry/graphics/OverlayRenderer.java b/core/src/io/anuke/mindustry/graphics/OverlayRenderer.java index 10c87ea51b..b3115f2f52 100644 --- a/core/src/io/anuke/mindustry/graphics/OverlayRenderer.java +++ b/core/src/io/anuke/mindustry/graphics/OverlayRenderer.java @@ -65,7 +65,7 @@ public class OverlayRenderer{ Vector2 vec = Graphics.world(input.getMouseX(), input.getMouseY()); Tile tile = world.tileWorld(vec.x, vec.y); - if(tile != null && tile.block() != Blocks.air){ + if(tile != null && tile.block() != Blocks.air && tile.getTeam() == players[0].getTeam()){ Tile target = tile.target(); if(showBlockDebug && target.entity != null){ diff --git a/core/src/io/anuke/mindustry/world/Block.java b/core/src/io/anuke/mindustry/world/Block.java index 4b78de36a7..9f06a14ce9 100644 --- a/core/src/io/anuke/mindustry/world/Block.java +++ b/core/src/io/anuke/mindustry/world/Block.java @@ -13,6 +13,7 @@ import io.anuke.mindustry.entities.bullet.Bullet; import io.anuke.mindustry.entities.effect.Puddle; import io.anuke.mindustry.entities.effect.RubbleDecal; import io.anuke.mindustry.game.Content; +import io.anuke.mindustry.game.UnlockableContent; import io.anuke.mindustry.graphics.CacheLayer; import io.anuke.mindustry.graphics.Layer; import io.anuke.mindustry.graphics.Palette; @@ -29,8 +30,7 @@ import io.anuke.ucore.util.Bundles; import io.anuke.ucore.util.EnumSet; import io.anuke.ucore.util.Mathf; -import static io.anuke.mindustry.Vars.tilesize; -import static io.anuke.mindustry.Vars.world; +import static io.anuke.mindustry.Vars.*; public class Block extends BaseBlock implements Content{ private static int lastid; @@ -181,6 +181,13 @@ public class Block extends BaseBlock implements Content{ return true; } + /**Call when some content is produced. This unlocks the content if it is applicable.*/ + public void useContent(UnlockableContent content){ + if(!headless){ + control.database().unlockContent(content); + } + } + /** Called after all blocks are created. */ @Override public void init(){ diff --git a/core/src/io/anuke/mindustry/world/blocks/production/Drill.java b/core/src/io/anuke/mindustry/world/blocks/production/Drill.java index d4a1d33368..8a5235da6e 100644 --- a/core/src/io/anuke/mindustry/world/blocks/production/Drill.java +++ b/core/src/io/anuke/mindustry/world/blocks/production/Drill.java @@ -21,9 +21,6 @@ import io.anuke.ucore.core.Timers; import io.anuke.ucore.graphics.Draw; import io.anuke.ucore.util.Mathf; -import static io.anuke.mindustry.Vars.control; -import static io.anuke.mindustry.Vars.headless; - public class Drill extends Block{ protected final static float hardnessDrillMultiplier = 50f; protected final int timerDump = timers++; @@ -187,10 +184,7 @@ public class Drill extends Block{ int index = entity.index % toAdd.size; offloadNear(tile, toAdd.get(index)); - //unlock item content - if(!headless){ - control.database().unlockContent(toAdd.get(index)); - } + useContent(toAdd.get(index)); entity.index++; entity.progress = 0f; diff --git a/core/src/io/anuke/mindustry/world/blocks/production/GenericCrafter.java b/core/src/io/anuke/mindustry/world/blocks/production/GenericCrafter.java index 9c0f60ba75..d1a3c3c26f 100644 --- a/core/src/io/anuke/mindustry/world/blocks/production/GenericCrafter.java +++ b/core/src/io/anuke/mindustry/world/blocks/production/GenericCrafter.java @@ -22,9 +22,6 @@ import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; -import static io.anuke.mindustry.Vars.control; -import static io.anuke.mindustry.Vars.headless; - public class GenericCrafter extends Block{ protected final int timerDump = timers++; @@ -93,10 +90,7 @@ public class GenericCrafter extends Block{ if(consumes.has(ConsumeItem.class)) tile.entity.items.remove(consumes.item(), consumes.itemAmount()); - //unlock output item - if(!headless){ - control.database().unlockContent(output); - } + useContent(output); offloadNear(tile, output); Effects.effect(craftEffect, tile.drawx(), tile.drawy()); diff --git a/core/src/io/anuke/mindustry/world/blocks/storage/CoreBlock.java b/core/src/io/anuke/mindustry/world/blocks/storage/CoreBlock.java index 028d0651ce..6bc1afbeb9 100644 --- a/core/src/io/anuke/mindustry/world/blocks/storage/CoreBlock.java +++ b/core/src/io/anuke/mindustry/world/blocks/storage/CoreBlock.java @@ -229,6 +229,8 @@ public class CoreBlock extends StorageBlock{ unit.setDead(true); unit.add(); + useContent(droneType); + entity.droneID = unit.id; } } diff --git a/core/src/io/anuke/mindustry/world/blocks/units/UnitFactory.java b/core/src/io/anuke/mindustry/world/blocks/units/UnitFactory.java index 98142a6972..5eb92f5260 100644 --- a/core/src/io/anuke/mindustry/world/blocks/units/UnitFactory.java +++ b/core/src/io/anuke/mindustry/world/blocks/units/UnitFactory.java @@ -176,6 +176,7 @@ public class UnitFactory extends Block{ entity.open = true; Timers.run(openDuration / 1.5f, () -> CallBlocks.onUnitFactorySpawn(tile)); + useContent(type); entity.openCountdown = openDuration;