From 12ccc10e83fedde8398bb662cb6c96df8873eed2 Mon Sep 17 00:00:00 2001 From: Timmeey86 Date: Wed, 28 Nov 2018 23:56:11 +0100 Subject: [PATCH] Restored SolarGenerator and adapted to new power system. --- .../mindustry/content/blocks/PowerBlocks.java | 25 +++++------------ .../maps/generation/FortressGenerator.java | 4 +-- .../world/blocks/power/SolarGenerator.java | 27 +++++++++++++++++++ 3 files changed, 35 insertions(+), 21 deletions(-) create mode 100644 core/src/io/anuke/mindustry/world/blocks/power/SolarGenerator.java diff --git a/core/src/io/anuke/mindustry/content/blocks/PowerBlocks.java b/core/src/io/anuke/mindustry/content/blocks/PowerBlocks.java index cf59a636d1..c2f2e24596 100644 --- a/core/src/io/anuke/mindustry/content/blocks/PowerBlocks.java +++ b/core/src/io/anuke/mindustry/content/blocks/PowerBlocks.java @@ -42,26 +42,13 @@ public class PowerBlocks extends BlockList implements ContentList{ itemDuration = 220f; }}; - // TODO: Maybe reintroduce a class for the initial production efficiency - solarPanel = new PowerGenerator("solar-panel"){ - { - powerProduction = 0.0045f; - } - @Override - public void update(Tile tile){ - tile.entity().productionEfficiency = 1.0f; - } - }; + solarPanel = new SolarGenerator("solar-panel"){{ + powerProduction = 0.0045f; + }}; - largeSolarPanel = new PowerGenerator("solar-panel-large"){ - { - powerProduction = 0.055f; - } - @Override - public void update(Tile tile){ - tile.entity().productionEfficiency = 1.0f; - } - }; + largeSolarPanel = new PowerGenerator("solar-panel-large"){{ + powerProduction = 0.055f; + }}; thoriumReactor = new NuclearReactor("thorium-reactor"){{ size = 3; diff --git a/core/src/io/anuke/mindustry/maps/generation/FortressGenerator.java b/core/src/io/anuke/mindustry/maps/generation/FortressGenerator.java index 7cde4bc33c..f2ea2cb06a 100644 --- a/core/src/io/anuke/mindustry/maps/generation/FortressGenerator.java +++ b/core/src/io/anuke/mindustry/maps/generation/FortressGenerator.java @@ -25,6 +25,7 @@ import io.anuke.mindustry.world.blocks.defense.turrets.PowerTurret; import io.anuke.mindustry.world.blocks.defense.turrets.Turret; import io.anuke.mindustry.world.blocks.power.NuclearReactor; import io.anuke.mindustry.world.blocks.power.PowerGenerator; +import io.anuke.mindustry.world.blocks.power.SolarGenerator; import io.anuke.mindustry.world.blocks.storage.CoreBlock; import io.anuke.mindustry.world.blocks.storage.StorageBlock; import io.anuke.mindustry.world.blocks.units.UnitFactory; @@ -114,8 +115,7 @@ public class FortressGenerator{ seeder.get(PowerBlocks.solarPanel, tile -> tile.block() == PowerBlocks.largeSolarPanel && gen.random.chance(0.3)), //coal gens - // TODO Verify - This used to be solar panel - seeder.get(PowerBlocks.combustionGenerator, tile -> tile.block() instanceof PowerGenerator && gen.random.chance(0.2)), + seeder.get(PowerBlocks.combustionGenerator, tile -> tile.block() instanceof SolarGenerator && gen.random.chance(0.2)), //water extractors seeder.get(ProductionBlocks.waterExtractor, tile -> tile.block() instanceof NuclearReactor && gen.random.chance(0.5)), diff --git a/core/src/io/anuke/mindustry/world/blocks/power/SolarGenerator.java b/core/src/io/anuke/mindustry/world/blocks/power/SolarGenerator.java new file mode 100644 index 0000000000..ebbc88b35f --- /dev/null +++ b/core/src/io/anuke/mindustry/world/blocks/power/SolarGenerator.java @@ -0,0 +1,27 @@ +package io.anuke.mindustry.world.blocks.power; + +import io.anuke.mindustry.entities.TileEntity; +import io.anuke.mindustry.world.BarType; +import io.anuke.mindustry.world.Tile; +import io.anuke.mindustry.world.meta.BlockBar; +import io.anuke.mindustry.world.meta.BlockStat; +import io.anuke.mindustry.world.meta.StatUnit; +import io.anuke.ucore.core.Timers; +import io.anuke.ucore.util.EnumSet; + +public class SolarGenerator extends PowerGenerator{ + + public SolarGenerator(String name){ + super(name); + // Remove the BlockFlag.producer flag to make this a lower priority target than other generators. + flags = EnumSet.of(); + } + + @Override + public TileEntity newEntity(){ + return new PowerGenerator.GeneratorEntity(){{ + productionEfficiency = 1.0f; + }}; + } + +}