From 8dd4839f53fb5d329746ac281c304b6cd6be5463 Mon Sep 17 00:00:00 2001 From: Anuken Date: Tue, 4 Aug 2020 10:00:24 -0400 Subject: [PATCH] Anuken/Mindustry-Suggestions/issues/375 --- core/src/mindustry/content/Blocks.java | 9 +++- core/src/mindustry/world/Block.java | 3 +- .../world/blocks/production/SolidPump.java | 41 ++++++------------- 3 files changed, 22 insertions(+), 31 deletions(-) diff --git a/core/src/mindustry/content/Blocks.java b/core/src/mindustry/content/Blocks.java index 3af48566ec..0e0186a971 100644 --- a/core/src/mindustry/content/Blocks.java +++ b/core/src/mindustry/content/Blocks.java @@ -246,11 +246,13 @@ public class Blocks implements ContentList{ sand = new Floor("sand"){{ itemDrop = Items.sand; playerUnmineable = true; + attributes.set(Attribute.oil, 0.7f); }}; darksand = new Floor("darksand"){{ itemDrop = Items.sand; playerUnmineable = true; + attributes.set(Attribute.oil, 1.5f); }}; ((ShallowLiquid)darksandTaintedWater).set(Blocks.taintedWater, Blocks.darksand); @@ -267,7 +269,8 @@ public class Blocks implements ContentList{ salt = new Floor("salt"){{ variants = 0; - attributes.set(Attribute.water, -0.2f); + attributes.set(Attribute.water, -0.25f); + attributes.set(Attribute.oil, 0.3f); }}; snow = new Floor("snow"){{ @@ -355,7 +358,7 @@ public class Blocks implements ContentList{ shale = new Floor("shale"){{ variants = 3; - attributes.set(Attribute.oil, 0.15f); + attributes.set(Attribute.oil, 1f); }}; shaleRocks = new StaticWall("shalerocks"){{ @@ -1270,6 +1273,8 @@ public class Blocks implements ContentList{ size = 3; liquidCapacity = 30f; attribute = Attribute.oil; + baseEfficiency = 0f; + itemUseTime = 60f; consumes.item(Items.sand); consumes.power(3f); diff --git a/core/src/mindustry/world/Block.java b/core/src/mindustry/world/Block.java index 4a505b2ff0..122a71b1f3 100644 --- a/core/src/mindustry/world/Block.java +++ b/core/src/mindustry/world/Block.java @@ -265,7 +265,8 @@ public class Block extends UnlockableContent{ return width; } - public float sumAttribute(Attribute attr, int x, int y){ + public float sumAttribute(@Nullable Attribute attr, int x, int y){ + if(attr == null) return 0; Tile tile = world.tile(x, y); if(tile == null) return 0; return tile.getLinkedTilesAs(this, tempTiles) diff --git a/core/src/mindustry/world/blocks/production/SolidPump.java b/core/src/mindustry/world/blocks/production/SolidPump.java index abf531ba2a..511f317314 100644 --- a/core/src/mindustry/world/blocks/production/SolidPump.java +++ b/core/src/mindustry/world/blocks/production/SolidPump.java @@ -23,6 +23,7 @@ public class SolidPump extends Pump{ public Effect updateEffect = Fx.none; public float updateEffectChance = 0.02f; public float rotateSpeed = 1f; + public float baseEfficiency = 1f; /** Attribute that is checked when calculating output. */ public @Nullable Attribute attribute; @@ -36,7 +37,7 @@ public class SolidPump extends Pump{ @Override public void drawPlace(int x, int y, int rotation, boolean valid){ if(attribute != null){ - drawPlaceText(Core.bundle.formatFloat("bar.efficiency", Math.max(sumAttribute(attribute, x, y) + 1f, 0f) * 100 * percentSolid(x, y), 1), x, y, valid); + drawPlaceText(Core.bundle.formatFloat("bar.efficiency", Math.max(sumAttribute(attribute, x, y) / size / size + baseEfficiency, 0f) * 100 * percentSolid(x, y), 1), x, y, valid); } } @@ -56,22 +57,14 @@ public class SolidPump extends Pump{ stats.remove(BlockStat.output); stats.add(BlockStat.output, result, 60f * pumpAmount, true); if(attribute != null){ - stats.add(BlockStat.affinities, attribute); + stats.add(baseEfficiency > 0.0001f ? BlockStat.affinities : BlockStat.tiles, attribute); } } @Override public boolean canPlaceOn(Tile tile, Team team){ - if(isMultiblock()){ - for(Tile other : tile.getLinkedTilesAs(this, tempTiles)){ - if(canPump(other)){ - return true; - } - } - return false; - }else{ - return canPump(tile); - } + float sum = tile.getLinkedTilesAs(this, tempTiles).sumf(t -> canPump(t) ? baseEfficiency + (attribute != null ? t.floor().attributes.get(attribute) : 0f) : 0f); + return sum > 0.00001f; } @Override @@ -88,6 +81,7 @@ public class SolidPump extends Pump{ public float warmup; public float pumpTime; public float boost; + public float validTiles; public float lastPump; @Override @@ -108,20 +102,7 @@ public class SolidPump extends Pump{ @Override public void updateTile(){ - float fraction = 0f; - - if(isMultiblock()){ - for(Tile other : tile.getLinkedTiles(tempTiles)){ - if(canPump(other)){ - fraction += 1f / (size * size); - } - } - }else{ - if(canPump(tile)) fraction = 1f; - } - - fraction += boost + (attribute == null ? 0 : attribute.env()); - fraction = Math.max(fraction, 0); + float fraction = Math.max(validTiles + boost + (attribute == null ? 0 : attribute.env()), 0); if(cons.valid() && typeLiquid() < liquidCapacity - 0.001f){ float maxPump = Math.min(liquidCapacity - typeLiquid(), pumpAmount * delta() * fraction * efficiency()); @@ -144,8 +125,12 @@ public class SolidPump extends Pump{ public void onProximityUpdate(){ super.onProximityAdded(); - if(attribute != null){ - boost = sumAttribute(attribute, tile.x, tile.y); + boost = sumAttribute(attribute, tile.x, tile.y) / size / size; + validTiles = 0f; + for(Tile other : tile.getLinkedTiles(tempTiles)){ + if(canPump(other)){ + validTiles += baseEfficiency / (size * size); + } } }