From f31fd622dd7cf034d8221585b6bce01bcce3e91c Mon Sep 17 00:00:00 2001 From: Anuken Date: Sun, 27 Jan 2019 09:19:23 -0500 Subject: [PATCH] Fixed #396 --- core/assets/bundles/bundle.properties | 1 + .../io/anuke/mindustry/content/Blocks.java | 73 +++++++++---------- .../world/blocks/storage/CoreBlock.java | 2 +- .../world/consumers/ConsumePower.java | 21 +----- .../mindustry/world/consumers/Consumers.java | 4 +- tools/build.gradle | 21 ------ 6 files changed, 39 insertions(+), 83 deletions(-) diff --git a/core/assets/bundles/bundle.properties b/core/assets/bundles/bundle.properties index 723ca2a021..0c10c9a278 100644 --- a/core/assets/bundles/bundle.properties +++ b/core/assets/bundles/bundle.properties @@ -507,6 +507,7 @@ liquid.heatcapacity = [LIGHT_GRAY]Heat Capacity: {0} liquid.viscosity = [LIGHT_GRAY]Viscosity: {0} liquid.temperature = [LIGHT_GRAY]Temperature: {0} block.graphite-press.name = Graphite Press +block.multi-press.name = Multi-Press block.constructing = {0} [LIGHT_GRAY](Constructing) block.spawn.name = Enemy Spawn block.core.name = Core diff --git a/core/src/io/anuke/mindustry/content/Blocks.java b/core/src/io/anuke/mindustry/content/Blocks.java index f2d4ef22c6..3be4fa2d2a 100644 --- a/core/src/io/anuke/mindustry/content/Blocks.java +++ b/core/src/io/anuke/mindustry/content/Blocks.java @@ -361,10 +361,10 @@ public class Blocks implements ContentList{ separator = new Separator("separator"){{ requirements(Category.crafting, ItemStack.with(Items.copper, 60, Items.titanium, 50)); results = new ItemStack[]{ - new ItemStack(Items.copper, 5), - new ItemStack(Items.lead, 3), - new ItemStack(Items.titanium, 2), - new ItemStack(Items.thorium, 1) + new ItemStack(Items.copper, 5), + new ItemStack(Items.lead, 3), + new ItemStack(Items.titanium, 2), + new ItemStack(Items.thorium, 1) }; hasPower = true; filterTime = 15f; @@ -458,7 +458,6 @@ public class Blocks implements ContentList{ titaniumWallLarge = new Wall("titanium-wall-large"){{ requirements(Category.defense, ItemStack.with(Items.titanium, 12 * 4)); - requirements(Category.defense, ItemStack.with(Items.titanium, 12)); health = 110 * wallHealthMultiplier * 4; size = 2; }}; @@ -470,7 +469,6 @@ public class Blocks implements ContentList{ thoriumWallLarge = new Wall("thorium-wall-large"){{ requirements(Category.defense, ItemStack.with(Items.thorium, 12 * 4)); - requirements(Category.defense, ItemStack.with(Items.thorium, 12)); health = 200 * wallHealthMultiplier * 4; size = 2; }}; @@ -482,7 +480,6 @@ public class Blocks implements ContentList{ phaseWallLarge = new DeflectorWall("phase-wall-large"){{ requirements(Category.defense, ItemStack.with(Items.phasefabric, 12 * 4)); - requirements(Category.defense, ItemStack.with(Items.phasefabric, 12)); health = 150 * 4 * wallHealthMultiplier; size = 2; }}; @@ -494,7 +491,6 @@ public class Blocks implements ContentList{ surgeWallLarge = new SurgeWall("surge-wall-large"){{ requirements(Category.defense, ItemStack.with(Items.surgealloy, 12 * 4)); - requirements(Category.defense, ItemStack.with(Items.surgealloy, 12)); health = 230 * 4 * wallHealthMultiplier; size = 2; }}; @@ -506,7 +502,6 @@ public class Blocks implements ContentList{ doorLarge = new Door("door-large"){{ requirements(Category.defense, ItemStack.with(Items.titanium, 12 * 4, Items.silicon, 8 * 4)); - requirements(Category.defense, ItemStack.with(Items.titanium, 12, Items.silicon, 8)); openfx = Fx.dooropenlarge; closefx = Fx.doorcloselarge; health = 100 * 4 * wallHealthMultiplier; @@ -902,10 +897,10 @@ public class Blocks implements ContentList{ duo = new DoubleTurret("duo"){{ requirements(Category.turret, ItemStack.with(Items.copper, 60), true); ammo( - Items.copper, Bullets.standardCopper, - Items.graphite, Bullets.standardDense, - Items.pyratite, Bullets.standardIncendiary, - Items.silicon, Bullets.standardHoming + Items.copper, Bullets.standardCopper, + Items.graphite, Bullets.standardDense, + Items.pyratite, Bullets.standardIncendiary, + Items.silicon, Bullets.standardHoming ); reload = 20f; restitution = 0.03f; @@ -920,9 +915,9 @@ public class Blocks implements ContentList{ hail = new ArtilleryTurret("hail"){{ requirements(Category.turret, ItemStack.with(Items.copper, 60, Items.graphite, 35)); ammo( - Items.graphite, Bullets.artilleryDense, - Items.silicon, Bullets.artilleryHoming, - Items.pyratite, Bullets.artlleryIncendiary + Items.graphite, Bullets.artilleryDense, + Items.silicon, Bullets.artilleryHoming, + Items.pyratite, Bullets.artlleryIncendiary ); reload = 60f; recoil = 2f; @@ -935,10 +930,10 @@ public class Blocks implements ContentList{ wave = new LiquidTurret("wave"){{ requirements(Category.turret, ItemStack.with(Items.titanium, 70, Items.lead, 150)); ammo( - Liquids.water, Bullets.waterShot, - Liquids.slag, Bullets.slagShot, - Liquids.cryofluid, Bullets.cryoShot, - Liquids.oil, Bullets.oilShot + Liquids.water, Bullets.waterShot, + Liquids.slag, Bullets.slagShot, + Liquids.cryofluid, Bullets.cryoShot, + Liquids.oil, Bullets.oilShot ); size = 2; recoil = 0f; @@ -1001,9 +996,9 @@ public class Blocks implements ContentList{ swarmer = new BurstTurret("swarmer"){{ requirements(Category.turret, ItemStack.with(Items.graphite, 70, Items.titanium, 70, Items.plastanium, 90, Items.silicon, 60)); ammo( - Items.blastCompound, Bullets.missileExplosive, - Items.pyratite, Bullets.missileIncendiary, - Items.surgealloy, Bullets.missileSurge + Items.blastCompound, Bullets.missileExplosive, + Items.pyratite, Bullets.missileIncendiary, + Items.surgealloy, Bullets.missileSurge ); reload = 50f; shots = 4; @@ -1018,11 +1013,11 @@ public class Blocks implements ContentList{ salvo = new BurstTurret("salvo"){{ requirements(Category.turret, ItemStack.with(Items.copper, 210, Items.graphite, 190, Items.thorium, 130)); ammo( - Items.copper, Bullets.standardCopper, - Items.graphite, Bullets.standardDense, - Items.pyratite, Bullets.standardIncendiary, - Items.silicon, Bullets.standardHoming, - Items.thorium, Bullets.standardThorium + Items.copper, Bullets.standardCopper, + Items.graphite, Bullets.standardDense, + Items.pyratite, Bullets.standardIncendiary, + Items.silicon, Bullets.standardHoming, + Items.thorium, Bullets.standardThorium ); size = 2; @@ -1042,11 +1037,11 @@ public class Blocks implements ContentList{ ripple = new ArtilleryTurret("ripple"){{ requirements(Category.turret, ItemStack.with(Items.copper, 300, Items.graphite, 220, Items.thorium, 120)); ammo( - Items.graphite, Bullets.artilleryDense, - Items.silicon, Bullets.artilleryHoming, - Items.pyratite, Bullets.artlleryIncendiary, - Items.blastCompound, Bullets.artilleryExplosive, - Items.plastanium, Bullets.arilleryPlastic + Items.graphite, Bullets.artilleryDense, + Items.silicon, Bullets.artilleryHoming, + Items.pyratite, Bullets.artlleryIncendiary, + Items.blastCompound, Bullets.artilleryExplosive, + Items.plastanium, Bullets.arilleryPlastic ); size = 3; shots = 4; @@ -1067,9 +1062,9 @@ public class Blocks implements ContentList{ cyclone = new ItemTurret("cyclone"){{ requirements(Category.turret, ItemStack.with(Items.copper, 400, Items.surgealloy, 200, Items.plastanium, 150)); ammo( - Items.blastCompound, Bullets.flakExplosive, - Items.plastanium, Bullets.flakPlastic, - Items.surgealloy, Bullets.flakSurge + Items.blastCompound, Bullets.flakExplosive, + Items.plastanium, Bullets.flakPlastic, + Items.surgealloy, Bullets.flakSurge ); xRand = 4f; reload = 8f; @@ -1099,9 +1094,9 @@ public class Blocks implements ContentList{ spectre = new DoubleTurret("spectre"){{ requirements(Category.turret, ItemStack.with(Items.copper, 700, Items.graphite, 600, Items.surgealloy, 500, Items.plastanium, 350, Items.thorium, 500)); ammo( - Items.graphite, Bullets.standardDenseBig, - Items.pyratite, Bullets.standardIncendiaryBig, - Items.thorium, Bullets.standardThoriumBig + Items.graphite, Bullets.standardDenseBig, + Items.pyratite, Bullets.standardIncendiaryBig, + Items.thorium, Bullets.standardThoriumBig ); reload = 6f; coolantMultiplier = 0.5f; 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 259c66d127..39e4da0bda 100644 --- a/core/src/io/anuke/mindustry/world/blocks/storage/CoreBlock.java +++ b/core/src/io/anuke/mindustry/world/blocks/storage/CoreBlock.java @@ -153,7 +153,7 @@ public class CoreBlock extends LaunchPad{ //TODO play animation of some sort Effects.effect(Fx.dooropenlarge, tile); //items sent are split evenly across every player in the game - data.addItem(item, launchChunkSize / playerGroup.size()); + data.addItem(item, launchChunkSize / Math.max(playerGroup.size(), 1)); entity.items.remove(item, launchChunkSize); } } diff --git a/core/src/io/anuke/mindustry/world/consumers/ConsumePower.java b/core/src/io/anuke/mindustry/world/consumers/ConsumePower.java index abf70d164c..83231c82c1 100644 --- a/core/src/io/anuke/mindustry/world/consumers/ConsumePower.java +++ b/core/src/io/anuke/mindustry/world/consumers/ConsumePower.java @@ -17,31 +17,12 @@ public class ConsumePower extends Consume{ /** True if the module can store power. */ public final boolean isBuffered; - protected ConsumePower(float powerPerTick, float powerCapacity, boolean isBuffered){ + public ConsumePower(float powerPerTick, float powerCapacity, boolean isBuffered){ this.powerPerTick = powerPerTick; this.powerCapacity = powerCapacity; this.isBuffered = isBuffered; } - /** - * Makes the owner consume powerPerTick each tick and disables it unless minimumSatisfaction (1.0 = 100%) of that power is being supplied. - * @param powerPerTick The maximum amount of power which is required per tick for 100% efficiency. - * @param minimumSatisfaction The percentage of powerPerTick which must be available for the module to work. - */ - public static ConsumePower consumePowerDirect(float powerPerTick){ - return new ConsumePower(powerPerTick, 0.0f, false); - } - - /** - * Adds a power buffer to the owner which takes ticksToFill number of ticks to be filled. - * Note that this object does not remove power from the buffer. - * @param powerCapacity The maximum capacity in power units. - * @param ticksToFill The number of ticks it shall take to fill the buffer. - */ - public static ConsumePower consumePowerBuffered(float powerCapacity, float ticksToFill){ - return new ConsumePower(powerCapacity / ticksToFill, powerCapacity, true); - } - @Override public void buildTooltip(Table table){ // No tooltip for power diff --git a/core/src/io/anuke/mindustry/world/consumers/Consumers.java b/core/src/io/anuke/mindustry/world/consumers/Consumers.java index 8963ef9662..23f6f456bf 100644 --- a/core/src/io/anuke/mindustry/world/consumers/Consumers.java +++ b/core/src/io/anuke/mindustry/world/consumers/Consumers.java @@ -42,7 +42,7 @@ public class Consumers{ * @return the created consumer object. */ public ConsumePower power(float powerPerTick){ - ConsumePower c = ConsumePower.consumePowerDirect(powerPerTick); + ConsumePower c = new ConsumePower(powerPerTick, 0.0f, false); add(c); return c; } @@ -62,7 +62,7 @@ public class Consumers{ * @param ticksToFill The number of ticks it shall take to fill the buffer. */ public ConsumePower powerBuffered(float powerCapacity, float ticksToFill){ - ConsumePower c = ConsumePower.consumePowerBuffered(powerCapacity, ticksToFill); + ConsumePower c = new ConsumePower(powerCapacity / ticksToFill, powerCapacity, true); add(c); return c; } diff --git a/tools/build.gradle b/tools/build.gradle index 5a7835980b..3f0ad3f87c 100644 --- a/tools/build.gradle +++ b/tools/build.gradle @@ -154,27 +154,6 @@ task scaleSprites4x(){ } } -task processBlocks(){ - def str = file("/home/anuke/Projects/Mindustry/core/src/io/anuke/mindustry/content/Blocks.java").text - def out = str - def mat = " consumes.power(" - - int i = 0 - while(str.indexOf(mat, i) != -1){ - i = str.indexOf(mat, i + 1) - if(i == -1) break - - def line = str.substring(i, str.indexOf("\n", i)) - def num = line.substring(line.indexOf("(") + 1, line.indexOf(")")) - float val = Float.parseFloat(num) * 10f; - boolean fmt = Math.abs((int)val - val) > 0.01f; - - out = out.replace(line, (line.replace(num, (fmt ? String.format("%.2f", val) : (int)val) + "f"))) - } - - println(out) -} - task scaleSprites(){ finalizedBy 'genSprites'