From 034fab480d8b16c46091546fc006a8900c97eccc Mon Sep 17 00:00:00 2001 From: Timmeey86 Date: Sat, 1 Dec 2018 18:32:17 +0100 Subject: [PATCH] Most direct consumers now operate slower when not supplied with full power --- core/src/io/anuke/mindustry/world/Block.java | 8 ++++++++ .../mindustry/world/blocks/defense/MendProjector.java | 2 +- .../world/blocks/defense/OverdriveProjector.java | 2 +- .../mindustry/world/blocks/distribution/LiquidBridge.java | 6 +++++- .../io/anuke/mindustry/world/blocks/production/Drill.java | 3 +++ .../anuke/mindustry/world/blocks/production/Fracker.java | 2 +- .../mindustry/world/blocks/production/GenericCrafter.java | 2 +- .../mindustry/world/blocks/production/Incinerator.java | 3 ++- .../mindustry/world/blocks/production/LiquidMixer.java | 3 +++ .../mindustry/world/blocks/production/PowerCrafter.java | 2 +- .../mindustry/world/blocks/production/PowerSmelter.java | 2 +- .../io/anuke/mindustry/world/blocks/production/Pump.java | 3 +++ .../mindustry/world/blocks/production/Separator.java | 2 +- .../mindustry/world/blocks/production/SolidPump.java | 2 +- .../anuke/mindustry/world/blocks/units/UnitFactory.java | 2 +- 15 files changed, 33 insertions(+), 11 deletions(-) diff --git a/core/src/io/anuke/mindustry/world/Block.java b/core/src/io/anuke/mindustry/world/Block.java index 4394277321..fe7376d91c 100644 --- a/core/src/io/anuke/mindustry/world/Block.java +++ b/core/src/io/anuke/mindustry/world/Block.java @@ -186,6 +186,14 @@ public class Block extends BaseBlock { return out; } + protected float getProgressIncrease(TileEntity entity, float baseTime){ + float progressIncrease = 1f / baseTime * entity.delta(); + if(hasPower){ + progressIncrease *= entity.power.satisfaction; // Reduced increase in case of low power + } + return progressIncrease; + } + public boolean isLayer(Tile tile){ return true; } diff --git a/core/src/io/anuke/mindustry/world/blocks/defense/MendProjector.java b/core/src/io/anuke/mindustry/world/blocks/defense/MendProjector.java index 997c821de9..9b6ea039a7 100644 --- a/core/src/io/anuke/mindustry/world/blocks/defense/MendProjector.java +++ b/core/src/io/anuke/mindustry/world/blocks/defense/MendProjector.java @@ -84,7 +84,7 @@ public class MendProjector extends Block{ other = other.target(); if(other.getTeamID() == tile.getTeamID() && !healed.contains(other.packedPosition()) && other.entity != null && other.entity.health < other.entity.maxHealth()){ - other.entity.healBy(other.entity.maxHealth() * (healPercent + entity.phaseHeat*phaseBoost)/100f); + other.entity.healBy(other.entity.maxHealth() * (healPercent + entity.phaseHeat*phaseBoost)/100f * entity.power.satisfaction); Effects.effect(BlockFx.healBlockFull, Hue.mix(color, phase, entity.phaseHeat), other.drawx(), other.drawy(), other.block().size); healed.add(other.packedPosition()); } diff --git a/core/src/io/anuke/mindustry/world/blocks/defense/OverdriveProjector.java b/core/src/io/anuke/mindustry/world/blocks/defense/OverdriveProjector.java index 615a6fa5a8..80acda8888 100644 --- a/core/src/io/anuke/mindustry/world/blocks/defense/OverdriveProjector.java +++ b/core/src/io/anuke/mindustry/world/blocks/defense/OverdriveProjector.java @@ -68,7 +68,7 @@ public class OverdriveProjector extends Block{ if(entity.charge >= reload){ float realRange = range + entity.phaseHeat * phaseRangeBoost; - float realBoost = speedBoost + entity.phaseHeat*speedBoostPhase; + float realBoost = (speedBoost + entity.phaseHeat*speedBoostPhase) * entity.power.satisfaction; Effects.effect(BlockFx.overdriveWave, Hue.mix(color, phase, entity.phaseHeat), tile.drawx(), tile.drawy(), realRange); entity.charge = 0f; diff --git a/core/src/io/anuke/mindustry/world/blocks/distribution/LiquidBridge.java b/core/src/io/anuke/mindustry/world/blocks/distribution/LiquidBridge.java index 97a495cc54..3a0124fbc9 100644 --- a/core/src/io/anuke/mindustry/world/blocks/distribution/LiquidBridge.java +++ b/core/src/io/anuke/mindustry/world/blocks/distribution/LiquidBridge.java @@ -31,7 +31,11 @@ public class LiquidBridge extends ItemBridge{ tryDumpLiquid(tile, entity.liquids.current()); }else{ if(entity.cons.valid()){ - entity.uptime = Mathf.lerpDelta(entity.uptime, 1f, 0.04f); + float alpha = 0.04f; + if(hasPower){ + alpha *= entity.power.satisfaction; // Exceed boot time unless power is at max. + } + entity.uptime = Mathf.lerpDelta(entity.uptime, 1f, alpha); }else{ entity.uptime = Mathf.lerpDelta(entity.uptime, 0f, 0.02f); } 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 212a71168b..ccd016f292 100644 --- a/core/src/io/anuke/mindustry/world/blocks/production/Drill.java +++ b/core/src/io/anuke/mindustry/world/blocks/production/Drill.java @@ -188,6 +188,9 @@ public class Drill extends Block{ if(entity.consumed(ConsumeLiquid.class) && !liquidRequired){ speed = liquidBoostIntensity; } + if(hasPower){ + speed *= entity.power.satisfaction; // Drill slower when not at full power + } entity.warmup = Mathf.lerpDelta(entity.warmup, speed, warmupSpeed); entity.progress += entity.delta() diff --git a/core/src/io/anuke/mindustry/world/blocks/production/Fracker.java b/core/src/io/anuke/mindustry/world/blocks/production/Fracker.java index 4c8fd24934..0c809a732e 100644 --- a/core/src/io/anuke/mindustry/world/blocks/production/Fracker.java +++ b/core/src/io/anuke/mindustry/world/blocks/production/Fracker.java @@ -64,7 +64,7 @@ public class Fracker extends SolidPump{ if(entity.cons.valid() && entity.accumulator < itemUseTime){ super.update(tile); - entity.accumulator += entity.delta(); + entity.accumulator += entity.delta() * entity.power.satisfaction; }else{ tryDumpLiquid(tile, result); } 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 a0e08537f3..7f7a3c69d7 100644 --- a/core/src/io/anuke/mindustry/world/blocks/production/GenericCrafter.java +++ b/core/src/io/anuke/mindustry/world/blocks/production/GenericCrafter.java @@ -83,7 +83,7 @@ public class GenericCrafter extends Block{ if(entity.cons.valid() && tile.entity.items.get(output) < itemCapacity){ - entity.progress += 1f / craftTime * entity.delta(); + entity.progress += getProgressIncrease(entity, craftTime); entity.totalProgress += entity.delta(); entity.warmup = Mathf.lerpDelta(entity.warmup, 1f, 0.02f); diff --git a/core/src/io/anuke/mindustry/world/blocks/production/Incinerator.java b/core/src/io/anuke/mindustry/world/blocks/production/Incinerator.java index 5fa8d18eff..e3fd63ad9e 100644 --- a/core/src/io/anuke/mindustry/world/blocks/production/Incinerator.java +++ b/core/src/io/anuke/mindustry/world/blocks/production/Incinerator.java @@ -26,7 +26,8 @@ public class Incinerator extends Block{ update = true; solid = true; - consumes.powerDirect(0.05f); + // Incinerator has no speed which could be adjusted, so it will only operate fully powered for now + consumes.powerDirect(0.05f, 1.0f); } @Override diff --git a/core/src/io/anuke/mindustry/world/blocks/production/LiquidMixer.java b/core/src/io/anuke/mindustry/world/blocks/production/LiquidMixer.java index 01e96fb5c3..4d00df4f3e 100644 --- a/core/src/io/anuke/mindustry/world/blocks/production/LiquidMixer.java +++ b/core/src/io/anuke/mindustry/world/blocks/production/LiquidMixer.java @@ -60,6 +60,9 @@ public class LiquidMixer extends LiquidBlock{ if(tile.entity.cons.valid()){ float use = Math.min(consumes.get(ConsumeLiquid.class).used() * entity.delta(), liquidCapacity - entity.liquids.get(outputLiquid)); + if(hasPower){ + use *= entity.power.satisfaction; // Produce less liquid if power is not maxed + } entity.accumulator += use; entity.liquids.add(outputLiquid, use); for(int i = 0; i < (int) (entity.accumulator / liquidPerItem); i++){ diff --git a/core/src/io/anuke/mindustry/world/blocks/production/PowerCrafter.java b/core/src/io/anuke/mindustry/world/blocks/production/PowerCrafter.java index 15fb12218b..4f3889eca5 100644 --- a/core/src/io/anuke/mindustry/world/blocks/production/PowerCrafter.java +++ b/core/src/io/anuke/mindustry/world/blocks/production/PowerCrafter.java @@ -65,7 +65,7 @@ public class PowerCrafter extends Block{ GenericCrafterEntity entity = tile.entity(); if(entity.cons.valid()){ - entity.progress += 1f / craftTime * entity.delta(); + entity.progress += getProgressIncrease(entity, craftTime); entity.totalProgress += entity.delta(); } diff --git a/core/src/io/anuke/mindustry/world/blocks/production/PowerSmelter.java b/core/src/io/anuke/mindustry/world/blocks/production/PowerSmelter.java index a1e587315a..dd9daed408 100644 --- a/core/src/io/anuke/mindustry/world/blocks/production/PowerSmelter.java +++ b/core/src/io/anuke/mindustry/world/blocks/production/PowerSmelter.java @@ -122,7 +122,7 @@ public class PowerSmelter extends PowerBlock{ } } - entity.craftTime += entity.delta(); + entity.craftTime += entity.delta() * entity.power.satisfaction; if(entity.items.get(result) >= itemCapacity //output full || entity.heat <= minHeat //not burning diff --git a/core/src/io/anuke/mindustry/world/blocks/production/Pump.java b/core/src/io/anuke/mindustry/world/blocks/production/Pump.java index 939587fa60..188fa00cea 100644 --- a/core/src/io/anuke/mindustry/world/blocks/production/Pump.java +++ b/core/src/io/anuke/mindustry/world/blocks/production/Pump.java @@ -95,6 +95,9 @@ public class Pump extends LiquidBlock{ if(tile.entity.cons.valid() && liquidDrop != null){ float maxPump = Math.min(liquidCapacity - tile.entity.liquids.total(), tiles * pumpAmount * tile.entity.delta()); + if(hasPower){ + maxPump *= tile.entity.power.satisfaction; // Produce slower if not at full power + } tile.entity.liquids.add(liquidDrop, maxPump); } diff --git a/core/src/io/anuke/mindustry/world/blocks/production/Separator.java b/core/src/io/anuke/mindustry/world/blocks/production/Separator.java index 50ab3fa2cb..514236578b 100644 --- a/core/src/io/anuke/mindustry/world/blocks/production/Separator.java +++ b/core/src/io/anuke/mindustry/world/blocks/production/Separator.java @@ -87,7 +87,7 @@ public class Separator extends Block{ entity.totalProgress += entity.warmup * entity.delta(); if(entity.cons.valid()){ - entity.progress += 1f / filterTime*entity.delta(); + entity.progress += getProgressIncrease(entity, filterTime); entity.warmup = Mathf.lerpDelta(entity.warmup, 1f, 0.02f); }else{ entity.warmup = Mathf.lerpDelta(entity.warmup, 0f, 0.02f); diff --git a/core/src/io/anuke/mindustry/world/blocks/production/SolidPump.java b/core/src/io/anuke/mindustry/world/blocks/production/SolidPump.java index 46a30bca31..a0c2b860a6 100644 --- a/core/src/io/anuke/mindustry/world/blocks/production/SolidPump.java +++ b/core/src/io/anuke/mindustry/world/blocks/production/SolidPump.java @@ -76,7 +76,7 @@ public class SolidPump extends Pump{ } if(tile.entity.cons.valid() && typeLiquid(tile) < liquidCapacity - 0.001f){ - float maxPump = Math.min(liquidCapacity - typeLiquid(tile), pumpAmount * entity.delta() * fraction); + float maxPump = Math.min(liquidCapacity - typeLiquid(tile), pumpAmount * entity.delta() * fraction * entity.power.satisfaction); tile.entity.liquids.add(result, maxPump); entity.warmup = Mathf.lerpDelta(entity.warmup, 1f, 0.02f); if(Mathf.chance(entity.delta() * updateEffectChance)) 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 d7856bf1b3..d08ec4294f 100644 --- a/core/src/io/anuke/mindustry/world/blocks/units/UnitFactory.java +++ b/core/src/io/anuke/mindustry/world/blocks/units/UnitFactory.java @@ -159,7 +159,7 @@ public class UnitFactory extends Block{ if(hasRequirements(entity.items, entity.buildTime / produceTime) && entity.cons.valid()){ - entity.buildTime += entity.delta(); + entity.buildTime += entity.delta() * entity.power.satisfaction; entity.speedScl = Mathf.lerpDelta(entity.speedScl, 1f, 0.05f); }else{ entity.speedScl = Mathf.lerpDelta(entity.speedScl, 0f, 0.05f);