diff --git a/core/src/io/anuke/mindustry/content/fx/BlockFx.java b/core/src/io/anuke/mindustry/content/fx/BlockFx.java index f84684ccbf..b902cd74c7 100644 --- a/core/src/io/anuke/mindustry/content/fx/BlockFx.java +++ b/core/src/io/anuke/mindustry/content/fx/BlockFx.java @@ -19,7 +19,7 @@ public class BlockFx extends FxList implements ContentList{ public static Effect reactorsmoke, nuclearsmoke, nuclearcloud, redgeneratespark, generatespark, fuelburn, plasticburn, pulverize, pulverizeRed, pulverizeRedder, pulverizeSmall, pulverizeMedium, producesmoke, smeltsmoke, formsmoke, blastsmoke, lava, dooropen, doorclose, dooropenlarge, doorcloselarge, purify, purifyoil, purifystone, generate, mine, mineBig, mineHuge, - smelt, teleportActivate, teleport, teleportOut, ripple, bubble, commandSend, healBlock, healBlockFull, healWaveMend, overdriveWave; + smelt, teleportActivate, teleport, teleportOut, ripple, bubble, commandSend, healBlock, healBlockFull, healWaveMend, overdriveWave, overdriveBlockFull; @Override public void load(){ @@ -312,5 +312,12 @@ public class BlockFx extends FxList implements ContentList{ Fill.square(e.x, e.y, e.rotation * tilesize); Draw.color(); }); + + overdriveBlockFull = new Effect(60, e -> { + Draw.color(e.color); + Draw.alpha(e.fslope() * 0.5f); + Fill.square(e.x, e.y, e.rotation * tilesize); + Draw.color(); + }); } } diff --git a/core/src/io/anuke/mindustry/entities/TileEntity.java b/core/src/io/anuke/mindustry/entities/TileEntity.java index 09a1cb354b..53e55dbc5b 100644 --- a/core/src/io/anuke/mindustry/entities/TileEntity.java +++ b/core/src/io/anuke/mindustry/entities/TileEntity.java @@ -40,9 +40,11 @@ public class TileEntity extends BaseEntity implements TargetTrait, HealthTrait{ private static final ObjectSet tmpTiles = new ObjectSet<>(); /**This value is only used for debugging.*/ public static int sleepingEntities = 0; + public Tile tile; public Timer timer; public float health; + public float timeScale = 1f, timeScaleDuration; public PowerModule power; public InventoryModule items; @@ -85,6 +87,11 @@ public class TileEntity extends BaseEntity implements TargetTrait, HealthTrait{ return this; } + /**Scaled delta.*/ + public float delta(){ + return Timers.delta() * timeScale; + } + /**Call when nothing is happening to the entity. This increments the internal sleep timer.*/ public void sleep(){ sleepTime += Timers.delta(); @@ -252,6 +259,11 @@ public class TileEntity extends BaseEntity implements TargetTrait, HealthTrait{ Effects.effect(Fx.smoke, x + Mathf.range(4), y + Mathf.range(4)); } + timeScaleDuration -= Timers.delta(); + if(timeScaleDuration <= 0f){ + timeScale = 1f; + } + if(health <= 0){ onDeath(); } 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 63cbb23482..d8073d5897 100644 --- a/core/src/io/anuke/mindustry/world/blocks/defense/OverdriveProjector.java +++ b/core/src/io/anuke/mindustry/world/blocks/defense/OverdriveProjector.java @@ -2,28 +2,35 @@ package io.anuke.mindustry.world.blocks.defense; import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.g2d.TextureRegion; -import io.anuke.mindustry.content.StatusEffects; +import com.badlogic.gdx.math.Vector2; +import com.badlogic.gdx.utils.IntSet; +import io.anuke.mindustry.content.fx.BlockFx; import io.anuke.mindustry.entities.TileEntity; -import io.anuke.mindustry.entities.Units; import io.anuke.mindustry.world.Block; import io.anuke.mindustry.world.Tile; +import io.anuke.ucore.core.Effects; import io.anuke.ucore.core.Graphics; import io.anuke.ucore.core.Timers; import io.anuke.ucore.graphics.Draw; +import io.anuke.ucore.graphics.Hue; import io.anuke.ucore.graphics.Lines; import io.anuke.ucore.util.Mathf; +import static io.anuke.mindustry.Vars.tilesize; +import static io.anuke.mindustry.Vars.world; + public class OverdriveProjector extends Block{ private static Color color = Color.valueOf("feb380"); private static Color phase = Color.valueOf("ffd59e"); + private static IntSet healed = new IntSet(); protected int timerUse = timers ++; - protected int timerApply = timers ++; protected TextureRegion topRegion; - protected float reload = 60f; - protected float range = 100f; - protected float phaseBoost = 30f; + protected float reload = 250f; + protected float range = 80f; + protected float speedBoost = 2f; + protected float speedBoostPhase = 0.5f; protected float useTime = 300f; public OverdriveProjector(String name){ @@ -44,28 +51,51 @@ public class OverdriveProjector extends Block{ @Override public void update(Tile tile){ OverdriveEntity entity = tile.entity(); - entity.heat = Mathf.lerpDelta(entity.heat, entity.cons.valid() ? 1f : 0f, 0.08f); + entity.charge += entity.heat * Timers.delta(); + entity.phaseHeat = Mathf.lerpDelta(entity.phaseHeat, (float)entity.items.get(consumes.item()) / itemCapacity, 0.1f); if(entity.timer.get(timerUse, useTime) && entity.items.total() > 0){ entity.items.remove(consumes.item(), 1); } - if(entity.heat > 0.5f && entity.timer.get(timerApply, 10)){ - float realRange = range + entity.phaseHeat * phaseBoost; + if(entity.charge >= reload){ + float realRange = range + entity.phaseHeat * 20f; + float realBoost = speedBoost + entity.phaseHeat*speedBoostPhase; - Units.getNearby(tile.getTeam(), tile.drawx(), tile.drawy(), realRange, unit -> unit.applyEffect(StatusEffects.overdrive, 1f + entity.phaseHeat)); + Effects.effect(BlockFx.overdriveWave, Hue.mix(color, phase, entity.phaseHeat), tile.drawx(), tile.drawy(), realRange); + entity.charge = 0f; + + Timers.run(10f, () -> { + int tileRange = (int)(realRange / tilesize); + healed.clear(); + + for(int x = -tileRange + tile.x; x <= tileRange + tile.x; x++){ + for(int y = -tileRange + tile.y; y <= tileRange + tile.y; y++){ + if(Vector2.dst(x, y, tile.x, tile.y) > realRange) continue; + + Tile other = world.tile(x, y); + + if(other == null) continue; + other = other.target(); + + if(other.getTeamID() == tile.getTeamID() && !healed.contains(other.packedPosition()) && other.entity != null){ + other.entity.timeScaleDuration = Math.max(other.entity.timeScaleDuration, reload + 1f); + other.entity.timeScale = Math.max(other.entity.timeScale, realBoost); + Effects.effect(BlockFx.overdriveBlockFull, Hue.mix(color, phase, entity.phaseHeat), other.drawx(), other.drawy(), other.block().size); + healed.add(other.packedPosition()); + } + } + } + }); } } @Override public void drawSelect(Tile tile){ - OverdriveEntity entity = tile.entity(); - float realRange = range + entity.phaseHeat * phaseBoost; - Draw.color(color); - Lines.poly(tile.drawx(), tile.drawy(), 300, realRange); + Lines.dashCircle(tile.drawx(), tile.drawy() - 1f, range); Draw.color(); } @@ -96,6 +126,7 @@ public class OverdriveProjector extends Block{ class OverdriveEntity extends TileEntity{ float heat; + float charge; float phaseHeat; } } \ No newline at end of file diff --git a/core/src/io/anuke/mindustry/world/blocks/defense/turrets/Turret.java b/core/src/io/anuke/mindustry/world/blocks/defense/turrets/Turret.java index 18ebd8ce48..6b85975397 100644 --- a/core/src/io/anuke/mindustry/world/blocks/defense/turrets/Turret.java +++ b/core/src/io/anuke/mindustry/world/blocks/defense/turrets/Turret.java @@ -213,7 +213,7 @@ public abstract class Turret extends Block{ } if(shouldTurn(tile)){ - entity.rotation = Angles.moveToward(entity.rotation, targetRot, rotatespeed * Timers.delta()); + entity.rotation = Angles.moveToward(entity.rotation, targetRot, rotatespeed * entity.delta()); } if(Angles.angleDist(entity.rotation, targetRot) < shootCone){ @@ -278,7 +278,7 @@ public abstract class Turret extends Block{ entity.reload = 0f; }else{ - entity.reload += Timers.delta() * peekAmmo(tile).reloadMultiplier; + entity.reload += tile.entity.delta() * peekAmmo(tile).reloadMultiplier; } } diff --git a/core/src/io/anuke/mindustry/world/blocks/distribution/Conveyor.java b/core/src/io/anuke/mindustry/world/blocks/distribution/Conveyor.java index 894b157143..bbf23b4459 100644 --- a/core/src/io/anuke/mindustry/world/blocks/distribution/Conveyor.java +++ b/core/src/io/anuke/mindustry/world/blocks/distribution/Conveyor.java @@ -204,7 +204,7 @@ public class Conveyor extends Block{ entity.carrying += unit.getMass(); if(entity.convey.size * itemSpace < 0.9f){ - unit.getVelocity().add((tx * speed + centerx) * Timers.delta(), (ty * speed + centery) * Timers.delta()); + unit.getVelocity().add((tx * speed + centerx) * entity.delta(), (ty * speed + centery) * entity.delta()); } } @@ -231,7 +231,7 @@ public class Conveyor extends Block{ if(entity.minCarry >= pos.y && entity.minCarry <= nextpos){ nextpos = entity.minCarry; } - float maxmove = Math.min(nextpos - pos.y, speed * Timers.delta()); + float maxmove = Math.min(nextpos - pos.y, speed * entity.delta()); if(maxmove > minmove){ pos.y += maxmove; diff --git a/core/src/io/anuke/mindustry/world/blocks/distribution/ItemBridge.java b/core/src/io/anuke/mindustry/world/blocks/distribution/ItemBridge.java index a6e65cc1d8..2994d5ea6f 100644 --- a/core/src/io/anuke/mindustry/world/blocks/distribution/ItemBridge.java +++ b/core/src/io/anuke/mindustry/world/blocks/distribution/ItemBridge.java @@ -152,8 +152,8 @@ public class ItemBridge extends Block{ public void update(Tile tile){ ItemBridgeEntity entity = tile.entity(); - entity.time += entity.cycleSpeed * Timers.delta(); - entity.time2 += (entity.cycleSpeed - 1f) * Timers.delta(); + entity.time += entity.cycleSpeed * entity.delta(); + entity.time2 += (entity.cycleSpeed - 1f) * entity.delta(); removals.clear(); diff --git a/core/src/io/anuke/mindustry/world/blocks/distribution/MassDriver.java b/core/src/io/anuke/mindustry/world/blocks/distribution/MassDriver.java index 37c0084ed3..75755546c2 100644 --- a/core/src/io/anuke/mindustry/world/blocks/distribution/MassDriver.java +++ b/core/src/io/anuke/mindustry/world/blocks/distribution/MassDriver.java @@ -146,7 +146,7 @@ public class MassDriver extends Block{ } if(entity.reload > 0f){ - entity.reload = Mathf.clamp(entity.reload - Timers.delta() / reloadTime); + entity.reload = Mathf.clamp(entity.reload - entity.delta() / reloadTime); } if(!entity.isRecieving){ diff --git a/core/src/io/anuke/mindustry/world/blocks/power/ItemGenerator.java b/core/src/io/anuke/mindustry/world/blocks/power/ItemGenerator.java index 0e5ba6d68a..0de68c738d 100644 --- a/core/src/io/anuke/mindustry/world/blocks/power/ItemGenerator.java +++ b/core/src/io/anuke/mindustry/world/blocks/power/ItemGenerator.java @@ -84,15 +84,15 @@ public abstract class ItemGenerator extends PowerGenerator{ public void update(Tile tile){ ItemGeneratorEntity entity = tile.entity(); - float maxPower = Math.min(powerCapacity - entity.power.amount, powerOutput * Timers.delta()) * entity.efficiency; + float maxPower = Math.min(powerCapacity - entity.power.amount, powerOutput * entity.delta()) * entity.efficiency; float mfract = maxPower / (powerOutput); if(entity.generateTime > 0f){ - entity.generateTime -= 1f / itemDuration * mfract; + entity.generateTime -= 1f / itemDuration * mfract * entity.delta(); entity.power.amount += maxPower; entity.generateTime = Mathf.clamp(entity.generateTime); - if(Mathf.chance(Timers.delta() * 0.06 * Mathf.clamp(entity.explosiveness - 0.25f))){ + if(Mathf.chance(entity.delta() * 0.06 * Mathf.clamp(entity.explosiveness - 0.25f))){ entity.damage(Mathf.random(8f)); Effects.effect(explodeEffect, tile.worldx() + Mathf.range(size * tilesize / 2f), tile.worldy() + Mathf.range(size * tilesize / 2f)); } diff --git a/core/src/io/anuke/mindustry/world/blocks/power/ItemLiquidGenerator.java b/core/src/io/anuke/mindustry/world/blocks/power/ItemLiquidGenerator.java index 07780884f7..5df81813da 100644 --- a/core/src/io/anuke/mindustry/world/blocks/power/ItemLiquidGenerator.java +++ b/core/src/io/anuke/mindustry/world/blocks/power/ItemLiquidGenerator.java @@ -6,7 +6,6 @@ import io.anuke.mindustry.type.Liquid; import io.anuke.mindustry.world.Tile; import io.anuke.mindustry.world.consumers.ConsumeLiquidFilter; import io.anuke.ucore.core.Effects; -import io.anuke.ucore.core.Timers; import io.anuke.ucore.graphics.Draw; import io.anuke.ucore.util.Mathf; @@ -44,26 +43,26 @@ public abstract class ItemLiquidGenerator extends ItemGenerator{ //liquid takes priority over solids if(liquid != null && entity.liquids.get(liquid) >= 0.001f && entity.cons.valid()){ float powerPerLiquid = getLiquidEfficiency(liquid) * this.powerPerLiquid; - float used = Math.min(entity.liquids.get(liquid), maxLiquidGenerate * Timers.delta()); + float used = Math.min(entity.liquids.get(liquid), maxLiquidGenerate * entity.delta()); used = Math.min(used, (powerCapacity - entity.power.amount) / powerPerLiquid); entity.liquids.remove(liquid, used); entity.power.amount += used * powerPerLiquid; - if(used > 0.001f && Mathf.chance(0.05 * Timers.delta())){ + if(used > 0.001f && Mathf.chance(0.05 * entity.delta())){ Effects.effect(generateEffect, tile.drawx() + Mathf.range(3f), tile.drawy() + Mathf.range(3f)); } }else if(entity.cons.valid()){ - float maxPower = Math.min(powerCapacity - entity.power.amount, powerOutput * Timers.delta()) * entity.efficiency; + float maxPower = Math.min(powerCapacity - entity.power.amount, powerOutput * entity.delta()) * entity.efficiency; float mfract = maxPower / (powerOutput); if(entity.generateTime > 0f){ - entity.generateTime -= 1f / itemDuration * mfract; + entity.generateTime -= 1f / itemDuration * mfract * entity.delta(); entity.power.amount += maxPower; entity.generateTime = Mathf.clamp(entity.generateTime); - if(Mathf.chance(Timers.delta() * 0.06 * Mathf.clamp(entity.explosiveness - 0.25f))){ + if(Mathf.chance(entity.delta() * 0.06 * Mathf.clamp(entity.explosiveness - 0.25f))){ entity.damage(Mathf.random(8f)); Effects.effect(explodeEffect, tile.worldx() + Mathf.range(size * tilesize / 2f), tile.worldy() + Mathf.range(size * tilesize / 2f)); } diff --git a/core/src/io/anuke/mindustry/world/blocks/power/LiquidGenerator.java b/core/src/io/anuke/mindustry/world/blocks/power/LiquidGenerator.java index b33f2c82d3..d1a9e312e8 100644 --- a/core/src/io/anuke/mindustry/world/blocks/power/LiquidGenerator.java +++ b/core/src/io/anuke/mindustry/world/blocks/power/LiquidGenerator.java @@ -8,7 +8,6 @@ import io.anuke.mindustry.world.blocks.power.ItemGenerator.ItemGeneratorEntity; import io.anuke.mindustry.world.consumers.ConsumeLiquidFilter; import io.anuke.ucore.core.Effects; import io.anuke.ucore.core.Effects.Effect; -import io.anuke.ucore.core.Timers; import io.anuke.ucore.graphics.Draw; import io.anuke.ucore.util.Mathf; @@ -51,13 +50,13 @@ public abstract class LiquidGenerator extends PowerGenerator{ if(entity.liquids.get(entity.liquids.current()) >= 0.001f){ float powerPerLiquid = getEfficiency(entity.liquids.current()) * this.powerPerLiquid; - float used = Math.min(entity.liquids.currentAmount(), maxLiquidGenerate * Timers.delta()); + float used = Math.min(entity.liquids.currentAmount(), maxLiquidGenerate * entity.delta()); used = Math.min(used, (powerCapacity - entity.power.amount) / powerPerLiquid); entity.liquids.remove(entity.liquids.current(), used); entity.power.amount += used * powerPerLiquid; - if(used > 0.001f && Mathf.chance(0.05 * Timers.delta())){ + if(used > 0.001f && Mathf.chance(0.05 * entity.delta())){ Effects.effect(generateEffect, tile.drawx() + Mathf.range(3f), tile.drawy() + Mathf.range(3f)); } } diff --git a/core/src/io/anuke/mindustry/world/blocks/power/NuclearReactor.java b/core/src/io/anuke/mindustry/world/blocks/power/NuclearReactor.java index a4a6894cdf..8c0e34c9ec 100644 --- a/core/src/io/anuke/mindustry/world/blocks/power/NuclearReactor.java +++ b/core/src/io/anuke/mindustry/world/blocks/power/NuclearReactor.java @@ -87,8 +87,8 @@ public class NuclearReactor extends PowerGenerator{ float fullness = (float) fuel / itemCapacity; if(fuel > 0){ - entity.heat += fullness * heating * Math.min(Timers.delta(), 4f); - entity.power.amount += powerMultiplier * fullness * Timers.delta(); + entity.heat += fullness * heating * Math.min(entity.delta(), 4f); + entity.power.amount += powerMultiplier * fullness * entity.delta(); entity.power.amount = Mathf.clamp(entity.power.amount, 0f, powerCapacity); if(entity.timer.get(timerFuel, fuelUseTime)){ entity.items.remove(consumes.item(), 1); @@ -100,12 +100,12 @@ public class NuclearReactor extends PowerGenerator{ if(liquid.temperature <= 0.5f){ //is coolant float pow = coolantPower * (liquid.heatCapacity + 0.5f / liquid.temperature); //heat depleted per unit of liquid - float maxUsed = Math.min(Math.min(entity.liquids.get(liquid), entity.heat / pow), maxLiquidUse * Timers.delta()); //max that can be cooled in terms of liquid + float maxUsed = Math.min(Math.min(entity.liquids.get(liquid), entity.heat / pow), maxLiquidUse * entity.delta()); //max that can be cooled in terms of liquid entity.heat -= maxUsed * pow; entity.liquids.remove(liquid, maxUsed); }else{ //is heater float heat = coolantPower * liquid.heatCapacity / 4f; //heat created per unit of liquid - float maxUsed = Math.min(Math.min(entity.liquids.get(liquid), (1f - entity.heat) / heat), maxLiquidUse * Timers.delta()); //max liquid used + float maxUsed = Math.min(Math.min(entity.liquids.get(liquid), (1f - entity.heat) / heat), maxLiquidUse * entity.delta()); //max liquid used entity.heat += maxUsed * heat; entity.liquids.remove(liquid, maxUsed); } @@ -113,7 +113,7 @@ public class NuclearReactor extends PowerGenerator{ if(entity.heat > smokeThreshold){ float smoke = 1.0f + (entity.heat - smokeThreshold) / (1f - smokeThreshold); //ranges from 1.0 to 2.0 - if(Mathf.chance(smoke / 20.0 * Timers.delta())){ + if(Mathf.chance(smoke / 20.0 * entity.delta())){ Effects.effect(BlockFx.reactorsmoke, tile.worldx() + Mathf.range(size * tilesize / 2f), tile.worldy() + Mathf.random(size * tilesize / 2f)); } 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 98e56b96c6..f07fe83ed7 100644 --- a/core/src/io/anuke/mindustry/world/blocks/production/Drill.java +++ b/core/src/io/anuke/mindustry/world/blocks/production/Drill.java @@ -175,7 +175,7 @@ public class Drill extends Block{ tryDump(tile); } - entity.drillTime += entity.warmup * Timers.delta(); + entity.drillTime += entity.warmup * entity.delta(); if(entity.items.total() < itemCapacity && entity.dominantItems > 0 && entity.cons.valid()){ @@ -186,7 +186,8 @@ public class Drill extends Block{ } entity.warmup = Mathf.lerpDelta(entity.warmup, speed, warmupSpeed); - entity.progress += Timers.delta() * entity.dominantItems * speed * entity.warmup; + entity.progress += entity.delta() + * entity.dominantItems * speed * entity.warmup; if(Mathf.chance(Timers.delta() * updateEffectChance * entity.warmup)) Effects.effect(updateEffect, entity.x + Mathf.range(size * 2f), entity.y + Mathf.range(size * 2f)); 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 63d34040d2..d333e26878 100644 --- a/core/src/io/anuke/mindustry/world/blocks/production/GenericCrafter.java +++ b/core/src/io/anuke/mindustry/world/blocks/production/GenericCrafter.java @@ -83,9 +83,9 @@ public class GenericCrafter extends Block{ if(entity.cons.valid() && tile.entity.items.get(output) < itemCapacity){ - entity.progress += 1f / craftTime * Timers.delta(); - entity.totalProgress += Timers.delta(); - entity.warmup = Mathf.lerp(entity.warmup, 1f, 0.02f); + entity.progress += 1f / craftTime * entity.delta(); + entity.totalProgress += entity.delta(); + entity.warmup = Mathf.lerpDelta(entity.warmup, 1f, 0.02f); if(Mathf.chance(Timers.delta() * updateEffectChance)) Effects.effect(updateEffect, entity.x + Mathf.range(size * 4f), entity.y + Mathf.range(size * 4)); 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 6f92f062b4..5d0b2a6c32 100644 --- a/core/src/io/anuke/mindustry/world/blocks/production/LiquidMixer.java +++ b/core/src/io/anuke/mindustry/world/blocks/production/LiquidMixer.java @@ -57,7 +57,7 @@ public class LiquidMixer extends LiquidBlock{ LiquidMixerEntity entity = tile.entity(); if(tile.entity.cons.valid()){ - float use = Math.min(consumes.get(ConsumeLiquid.class).used() * Timers.delta(), liquidCapacity - entity.liquids.get(outputLiquid)); + float use = Math.min(consumes.get(ConsumeLiquid.class).used() * entity.delta(), liquidCapacity - entity.liquids.get(outputLiquid)); 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 351e674938..12cb6161c4 100644 --- a/core/src/io/anuke/mindustry/world/blocks/production/PowerCrafter.java +++ b/core/src/io/anuke/mindustry/world/blocks/production/PowerCrafter.java @@ -7,7 +7,6 @@ import io.anuke.mindustry.world.Block; import io.anuke.mindustry.world.Tile; import io.anuke.mindustry.world.blocks.production.GenericCrafter.GenericCrafterEntity; import io.anuke.mindustry.world.meta.BlockStat; -import io.anuke.ucore.core.Timers; public class PowerCrafter extends Block{ protected final int timerDump = timers++; @@ -66,7 +65,7 @@ public class PowerCrafter extends Block{ if(entity.cons.valid()){ entity.progress += 1f / craftTime; - entity.totalProgress += Timers.delta(); + entity.totalProgress += entity.delta(); } if(entity.progress >= 1f){ 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 5808459bed..de5c8ea6fb 100644 --- a/core/src/io/anuke/mindustry/world/blocks/production/PowerSmelter.java +++ b/core/src/io/anuke/mindustry/world/blocks/production/PowerSmelter.java @@ -100,7 +100,7 @@ public class PowerSmelter extends PowerBlock{ //heat it up if there's enough power if(entity.cons.valid()){ - entity.heat += 1f / heatUpTime * Timers.delta(); + entity.heat += 1f / heatUpTime * entity.delta(); if(Mathf.chance(Timers.delta() * burnEffectChance)) Effects.effect(burnEffect, entity.x + Mathf.range(size * 4f), entity.y + Mathf.range(size * 4)); }else{ @@ -108,7 +108,7 @@ public class PowerSmelter extends PowerBlock{ } entity.heat = Mathf.clamp(entity.heat); - entity.time += entity.heat * Timers.delta(); + entity.time += entity.heat * entity.delta(); if(!entity.cons.valid()){ return; @@ -124,10 +124,12 @@ public class PowerSmelter extends PowerBlock{ if(entity.items.get(result) >= itemCapacity //output full || entity.heat <= minHeat //not burning - || !entity.timer.get(timerCraft, craftTime*baseSmeltSpeed)){ //not yet time + || entity.craftTime < craftTime*baseSmeltSpeed){ //not yet time return; } + entity.craftTime = 0f; + boolean consumeInputs = true; if(useFlux){ @@ -206,6 +208,7 @@ public class PowerSmelter extends PowerBlock{ class PowerSmelterEntity extends TileEntity{ public float heat; public float time; + public float craftTime; @Override public void write(DataOutputStream stream) throws IOException{ 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 2fe25dd59a..364464376e 100644 --- a/core/src/io/anuke/mindustry/world/blocks/production/Pump.java +++ b/core/src/io/anuke/mindustry/world/blocks/production/Pump.java @@ -9,7 +9,6 @@ import io.anuke.mindustry.world.blocks.LiquidBlock; import io.anuke.mindustry.world.meta.BlockGroup; import io.anuke.mindustry.world.meta.BlockStat; import io.anuke.mindustry.world.meta.StatUnit; -import io.anuke.ucore.core.Timers; import io.anuke.ucore.graphics.Draw; public class Pump extends LiquidBlock{ @@ -95,7 +94,7 @@ public class Pump extends LiquidBlock{ } if(tile.entity.cons.valid() && liquidDrop != null){ - float maxPump = Math.min(liquidCapacity - tile.entity.liquids.total(), tiles * pumpAmount * Timers.delta()); + float maxPump = Math.min(liquidCapacity - tile.entity.liquids.total(), tiles * pumpAmount * tile.entity.delta()); 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 8e6d88b942..3a1759860a 100644 --- a/core/src/io/anuke/mindustry/world/blocks/production/Separator.java +++ b/core/src/io/anuke/mindustry/world/blocks/production/Separator.java @@ -12,7 +12,6 @@ import io.anuke.mindustry.world.Tile; import io.anuke.mindustry.world.blocks.production.GenericCrafter.GenericCrafterEntity; import io.anuke.mindustry.world.meta.BlockStat; import io.anuke.mindustry.world.meta.values.ItemFilterValue; -import io.anuke.ucore.core.Timers; import io.anuke.ucore.graphics.Draw; import io.anuke.ucore.graphics.Lines; import io.anuke.ucore.util.Mathf; @@ -85,10 +84,10 @@ public class Separator extends Block{ public void update(Tile tile){ GenericCrafterEntity entity = tile.entity(); - entity.totalProgress += entity.warmup * Timers.delta(); + entity.totalProgress += entity.warmup * entity.delta(); if(entity.cons.valid()){ - entity.progress += 1f / filterTime; + entity.progress += 1f / filterTime*entity.delta(); 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/Smelter.java b/core/src/io/anuke/mindustry/world/blocks/production/Smelter.java index eaaa0e44ea..22d991109c 100644 --- a/core/src/io/anuke/mindustry/world/blocks/production/Smelter.java +++ b/core/src/io/anuke/mindustry/world/blocks/production/Smelter.java @@ -24,7 +24,6 @@ import static io.anuke.mindustry.Vars.*; public class Smelter extends Block{ protected final int timerDump = timers++; - protected final int timerCraft = timers++; protected Item result; @@ -99,10 +98,10 @@ public class Smelter extends Block{ //decrement burntime if(entity.burnTime > 0){ - entity.burnTime -= Timers.delta(); - entity.heat = Mathf.lerp(entity.heat, 1f, 0.02f); + entity.burnTime -= entity.delta(); + entity.heat = Mathf.lerpDelta(entity.heat, 1f, 0.02f); }else{ - entity.heat = Mathf.lerp(entity.heat, 0f, 0.02f); + entity.heat = Mathf.lerpDelta(entity.heat, 0f, 0.02f); } //make sure it has all the items @@ -118,12 +117,16 @@ public class Smelter extends Block{ } } + entity.craftTime += entity.delta(); + if(entity.items.get(result) >= itemCapacity //output full || entity.burnTime <= 0 //not burning - || !entity.timer.get(timerCraft, craftTime*baseSmeltSpeed)){ //not yet time + || entity.craftTime < craftTime*baseSmeltSpeed){ //not yet time return; } + entity.craftTime = 0f; + boolean consumeInputs = true; if(useFlux){ @@ -198,5 +201,6 @@ public class Smelter extends Block{ public class SmelterEntity extends TileEntity{ public float burnTime; public float heat; + public float craftTime; } } 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 69bea0e95d..8ac6745300 100644 --- a/core/src/io/anuke/mindustry/world/blocks/production/SolidPump.java +++ b/core/src/io/anuke/mindustry/world/blocks/production/SolidPump.java @@ -77,7 +77,7 @@ public class SolidPump extends Pump{ } if(tile.entity.cons.valid() && typeLiquid(tile) < liquidCapacity - 0.001f){ - float maxPump = Math.min(liquidCapacity - typeLiquid(tile), pumpAmount * Timers.delta() * fraction); + float maxPump = Math.min(liquidCapacity - typeLiquid(tile), pumpAmount * entity.delta() * fraction); tile.entity.liquids.add(result, maxPump); entity.warmup = Mathf.lerpDelta(entity.warmup, 1f, 0.02f); if(Mathf.chance(Timers.delta() * updateEffectChance)) 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 86b1bba1ab..b7d34b3deb 100644 --- a/core/src/io/anuke/mindustry/world/blocks/storage/CoreBlock.java +++ b/core/src/io/anuke/mindustry/world/blocks/storage/CoreBlock.java @@ -197,8 +197,8 @@ public class CoreBlock extends StorageBlock{ return; } entity.heat = Mathf.lerpDelta(entity.heat, 1f, 0.1f); - entity.time += Timers.delta(); - entity.progress += 1f / (entity.currentUnit instanceof Player ? state.mode.respawnTime : droneRespawnDuration) * Timers.delta(); + entity.time += entity.delta(); + entity.progress += 1f / (entity.currentUnit instanceof Player ? state.mode.respawnTime : droneRespawnDuration) * entity.delta(); //instant build for fast testing. if(debug){ diff --git a/core/src/io/anuke/mindustry/world/blocks/units/MechFactory.java b/core/src/io/anuke/mindustry/world/blocks/units/MechFactory.java index 4ff57d96b8..3eb8c7bc76 100644 --- a/core/src/io/anuke/mindustry/world/blocks/units/MechFactory.java +++ b/core/src/io/anuke/mindustry/world/blocks/units/MechFactory.java @@ -187,9 +187,9 @@ public class MechFactory extends Block{ if(entity.player != null){ entity.heat = Mathf.lerpDelta(entity.heat, 1f, 0.1f); - entity.progress += 1f / buildTime; + entity.progress += 1f / buildTime * entity.delta(); - entity.time += 0.5f; + entity.time += 0.5f * entity.delta(); if(entity.progress >= 1f){ Call.onMechFactoryDone(tile); diff --git a/core/src/io/anuke/mindustry/world/blocks/units/UnitPad.java b/core/src/io/anuke/mindustry/world/blocks/units/UnitPad.java index c9cfb04dc9..fb09bc82d7 100644 --- a/core/src/io/anuke/mindustry/world/blocks/units/UnitPad.java +++ b/core/src/io/anuke/mindustry/world/blocks/units/UnitPad.java @@ -147,10 +147,10 @@ public class UnitPad extends Block{ public void update(Tile tile){ UnitFactoryEntity entity = tile.entity(); - entity.time += Timers.delta() * entity.speedScl; + entity.time += entity.delta() * entity.speedScl; if(tile.isEnemyCheat()){ - entity.warmup += Timers.delta(); + entity.warmup += entity.delta(); } if(!tile.isEnemyCheat()){ @@ -158,7 +158,7 @@ public class UnitPad extends Block{ if(hasRequirements(entity.items, entity.buildTime / produceTime) && entity.cons.valid()){ - entity.buildTime += Timers.delta(); + entity.buildTime += entity.delta(); entity.speedScl = Mathf.lerpDelta(entity.speedScl, 1f, 0.05f); }else{ entity.speedScl = Mathf.lerpDelta(entity.speedScl, 0f, 0.05f); @@ -167,7 +167,7 @@ public class UnitPad extends Block{ }else if(entity.warmup > produceTime*gracePeriodMultiplier * Vars.state.difficulty.spawnerScaling){ float speedMultiplier = Math.min(0.1f + (entity.warmup - produceTime * gracePeriodMultiplier * Vars.state.difficulty.spawnerScaling) / speedupTime, maxSpeedup); //otherwise, it's an enemy, cheat by not requiring resources - entity.buildTime += Timers.delta() * speedMultiplier; + entity.buildTime += entity.delta() * speedMultiplier; entity.speedScl = Mathf.lerpDelta(entity.speedScl, 1f, 0.05f); }else{ entity.speedScl = Mathf.lerpDelta(entity.speedScl, 0f, 0.05f); diff --git a/core/src/io/anuke/mindustry/world/consumers/ConsumeLiquid.java b/core/src/io/anuke/mindustry/world/consumers/ConsumeLiquid.java index a7895fa6a8..0934cf73e5 100644 --- a/core/src/io/anuke/mindustry/world/consumers/ConsumeLiquid.java +++ b/core/src/io/anuke/mindustry/world/consumers/ConsumeLiquid.java @@ -6,7 +6,6 @@ import io.anuke.mindustry.world.Block; import io.anuke.mindustry.world.meta.BlockStat; import io.anuke.mindustry.world.meta.BlockStats; import io.anuke.mindustry.world.meta.StatUnit; -import io.anuke.ucore.core.Timers; import io.anuke.ucore.scene.ui.layout.Table; public class ConsumeLiquid extends Consume{ @@ -38,12 +37,12 @@ public class ConsumeLiquid extends Consume{ @Override public void update(Block block, TileEntity entity){ - entity.liquids.remove(liquid, Math.min(use(block), entity.liquids.get(liquid))); + entity.liquids.remove(liquid, Math.min(use(block, entity), entity.liquids.get(liquid))); } @Override public boolean valid(Block block, TileEntity entity){ - return entity != null && entity.liquids != null && entity.liquids.get(liquid) >= use(block); + return entity != null && entity.liquids != null && entity.liquids.get(liquid) >= use(block, entity); } @Override @@ -52,7 +51,7 @@ public class ConsumeLiquid extends Consume{ stats.add(BlockStat.inputLiquid, liquid); } - float use(Block block){ - return Math.min(use * Timers.delta(), block.liquidCapacity); + float use(Block block, TileEntity entity){ + return Math.min(use * entity.delta(), block.liquidCapacity); } } diff --git a/core/src/io/anuke/mindustry/world/consumers/ConsumeLiquidFilter.java b/core/src/io/anuke/mindustry/world/consumers/ConsumeLiquidFilter.java index 2bb7592c2c..19a5395522 100644 --- a/core/src/io/anuke/mindustry/world/consumers/ConsumeLiquidFilter.java +++ b/core/src/io/anuke/mindustry/world/consumers/ConsumeLiquidFilter.java @@ -8,10 +8,10 @@ import io.anuke.mindustry.world.meta.BlockStat; import io.anuke.mindustry.world.meta.BlockStats; import io.anuke.mindustry.world.meta.StatUnit; import io.anuke.mindustry.world.meta.values.LiquidFilterValue; -import io.anuke.ucore.core.Timers; import io.anuke.ucore.function.Predicate; import io.anuke.ucore.scene.ui.layout.Table; -import static io.anuke.mindustry.Vars.*; + +import static io.anuke.mindustry.Vars.content; public class ConsumeLiquidFilter extends Consume{ private final Predicate filter; @@ -52,12 +52,12 @@ public class ConsumeLiquidFilter extends Consume{ @Override public void update(Block block, TileEntity entity){ - entity.liquids.remove(entity.liquids.current(), use(block)); + entity.liquids.remove(entity.liquids.current(), use(block, entity)); } @Override public boolean valid(Block block, TileEntity entity){ - return entity.liquids != null && filter.test(entity.liquids.current()) && entity.liquids.currentAmount() >= use(block); + return entity.liquids != null && filter.test(entity.liquids.current()) && entity.liquids.currentAmount() >= use(block, entity); } @Override @@ -71,7 +71,7 @@ public class ConsumeLiquidFilter extends Consume{ } } - float use(Block block){ - return Math.min(use * Timers.delta(), block.liquidCapacity); + float use(Block block, TileEntity entity){ + return Math.min(use * entity.delta(), block.liquidCapacity); } } diff --git a/core/src/io/anuke/mindustry/world/consumers/ConsumePower.java b/core/src/io/anuke/mindustry/world/consumers/ConsumePower.java index 2af3170e0e..fba5626b78 100644 --- a/core/src/io/anuke/mindustry/world/consumers/ConsumePower.java +++ b/core/src/io/anuke/mindustry/world/consumers/ConsumePower.java @@ -5,7 +5,6 @@ import io.anuke.mindustry.world.Block; import io.anuke.mindustry.world.meta.BlockStat; import io.anuke.mindustry.world.meta.BlockStats; import io.anuke.mindustry.world.meta.StatUnit; -import io.anuke.ucore.core.Timers; import io.anuke.ucore.scene.ui.layout.Table; public class ConsumePower extends Consume{ @@ -28,13 +27,13 @@ public class ConsumePower extends Consume{ @Override public void update(Block block, TileEntity entity){ if(entity.power == null) return; - entity.power.amount -= Math.min(use(block), entity.power.amount); + entity.power.amount -= Math.min(use(block, entity), entity.power.amount); } @Override public boolean valid(Block block, TileEntity entity){ if(entity.power == null) return false; - return entity.power.amount >= use(block); + return entity.power.amount >= use(block, entity); } @Override @@ -42,7 +41,7 @@ public class ConsumePower extends Consume{ stats.add(BlockStat.powerUse, use * 60f, StatUnit.powerSecond); } - protected float use(Block block){ - return Math.min(use * Timers.delta(), block.powerCapacity); + protected float use(Block block, TileEntity entity){ + return Math.min(use * entity.delta(), block.powerCapacity); } }