Refactoring of generators, added solar panel, power drills

This commit is contained in:
Anuken 2018-03-05 22:12:33 -05:00
parent a25b6a9952
commit 45a3be7642
22 changed files with 468 additions and 333 deletions

View File

Before

Width:  |  Height:  |  Size: 266 B

After

Width:  |  Height:  |  Size: 266 B

View File

Before

Width:  |  Height:  |  Size: 274 B

After

Width:  |  Height:  |  Size: 274 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 427 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 459 B

After

Width:  |  Height:  |  Size: 405 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 198 B

View File

Before

Width:  |  Height:  |  Size: 260 B

After

Width:  |  Height:  |  Size: 260 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 261 B

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 89 KiB

After

Width:  |  Height:  |  Size: 87 KiB

View File

@ -1,7 +1,7 @@
#Autogenerated file. Do not modify.
#Mon Mar 05 16:14:27 EST 2018
#Mon Mar 05 21:35:42 EST 2018
version=release
androidBuildCode=395
androidBuildCode=399
name=Mindustry
code=3.4
build=custom build

View File

@ -9,7 +9,7 @@ import io.anuke.mindustry.world.blocks.types.defense.Turret;
import io.anuke.mindustry.world.blocks.types.distribution.Conveyor;
import io.anuke.mindustry.world.blocks.types.distribution.Router;
import io.anuke.mindustry.world.blocks.types.production.Drill;
import io.anuke.mindustry.world.blocks.types.production.Generator;
import io.anuke.mindustry.world.blocks.types.generation.Generator;
import io.anuke.mindustry.world.blocks.types.production.Smelter;
import io.anuke.ucore.util.Bundles;

View File

@ -48,9 +48,10 @@ public class Recipes {
new Recipe(weapon, WeaponBlocks.fornaxcannon, stack(Item.steel, 70), stack(Item.titanium, 50), stack(Item.dirium, 55)),
new Recipe(crafting, ProductionBlocks.smelter, stack(Item.stone, 40), stack(Item.iron, 40)),
new Recipe(crafting, ProductionBlocks.crucible, stack(Item.titanium, 50), stack(Item.steel, 50)),
new Recipe(crafting, ProductionBlocks.coalpurifier, stack(Item.steel, 10), stack(Item.iron, 10)),
new Recipe(crafting, ProductionBlocks.titaniumpurifier, stack(Item.steel, 30), stack(Item.iron, 30)),
new Recipe(crafting, ProductionBlocks.alloysmelter, stack(Item.titanium, 50), stack(Item.steel, 50)),
new Recipe(crafting, ProductionBlocks.coalextractor, stack(Item.steel, 10), stack(Item.iron, 10)),
new Recipe(crafting, ProductionBlocks.titaniumextractor, stack(Item.steel, 30), stack(Item.iron, 30)),
new Recipe(crafting, ProductionBlocks.uraniumextractor, stack(Item.steel, 30), stack(Item.iron, 30)),
new Recipe(crafting, ProductionBlocks.oilrefinery, stack(Item.steel, 15), stack(Item.iron, 15)),
new Recipe(crafting, ProductionBlocks.stoneformer, stack(Item.steel, 10), stack(Item.iron, 10)),
new Recipe(crafting, ProductionBlocks.lavasmelter, stack(Item.steel, 30), stack(Item.titanium, 15)),
@ -69,9 +70,9 @@ public class Recipes {
new Recipe(power, ProductionBlocks.coalgenerator, stack(Item.iron, 30), stack(Item.stone, 20)),
new Recipe(power, ProductionBlocks.thermalgenerator, stack(Item.steel, 30), stack(Item.iron, 30)),
new Recipe(power, ProductionBlocks.combustiongenerator, stack(Item.iron, 30), stack(Item.stone, 20)),
new Recipe(power, ProductionBlocks.solarpanel, stack(Item.iron, 30), stack(Item.silicon, 20)),
new Recipe(power, ProductionBlocks.rtgenerator, stack(Item.titanium, 20), stack(Item.steel, 20)),
new Recipe(power, ProductionBlocks.nuclearReactor, stack(Item.titanium, 40), stack(Item.dirium, 40), stack(Item.steel, 50)),
//new Recipe(power, DistributionBlocks.powerbooster, stack(Item.steel, 8), stack(Item.iron, 8)),
new Recipe(power, DistributionBlocks.powerlaser, stack(Item.steel, 3), stack(Item.iron, 3)),
new Recipe(power, DistributionBlocks.powerlasercorner, stack(Item.steel, 4), stack(Item.iron, 4)),
new Recipe(power, DistributionBlocks.powerlaserrouter, stack(Item.steel, 5), stack(Item.iron, 5)),

View File

@ -5,6 +5,8 @@ import io.anuke.mindustry.resource.Item;
import io.anuke.mindustry.resource.ItemStack;
import io.anuke.mindustry.resource.Liquid;
import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.blocks.types.generation.*;
import io.anuke.mindustry.world.blocks.types.generation.SolarGenerator;
import io.anuke.mindustry.world.blocks.types.storage.CoreBlock;
import io.anuke.mindustry.world.blocks.types.production.*;
@ -30,7 +32,7 @@ public class ProductionBlocks{
}
},
crucible = new Smelter("crucible"){
alloysmelter = new Smelter("alloysmelter"){
{
health = 90;
inputs = new Item[]{Item.titanium, Item.steel};
@ -41,7 +43,7 @@ public class ProductionBlocks{
}
},
coalpurifier = new LiquidCrafter("coalpurifier"){
coalextractor = new LiquidCrafter("coalextractor"){
{
input = Item.stone;
inputAmount = 5;
@ -53,7 +55,7 @@ public class ProductionBlocks{
}
},
titaniumpurifier = new LiquidCrafter("titaniumpurifier"){
titaniumextractor = new LiquidCrafter("titaniumextractor"){
{
input = Item.iron;
inputAmount = 6;
@ -65,6 +67,19 @@ public class ProductionBlocks{
health = 70;
}
},
uraniumextractor = new LiquidCrafter("uraniumextractor"){
{
input = Item.iron;
inputAmount = 6;
inputLiquid = Liquid.water;
liquidAmount = 40f;
liquidCapacity = 41f;
purifyTime = 60;
output = Item.uranium;
health = 70;
}
},
oilrefinery = new LiquidCrafter("oilrefinery"){
{
@ -168,9 +183,27 @@ public class ProductionBlocks{
}
},
omnidrill = new Omnidrill("omnidrill"){
laserdrill = new PowerDrill("laserdrill"){
{
time = 4;
size = 2;
powerUse = 0.08f;
}
},
plasmadrill = new PowerDrill("plasmadrill"){
{
time = 4;
size = 3;
powerUse = 0.16f;
}
},
nucleardrill = new PowerDrill("nucleardrill"){
{
time = 4;
size = 4;
powerUse = 0.32f;
}
},
@ -223,6 +256,9 @@ public class ProductionBlocks{
powerOutput = 0.03f;
itemDuration = 240f;
}
},
solarpanel = new SolarGenerator("solarpanel"){
},
nuclearReactor = new NuclearReactor("nuclearreactor"){
{

View File

@ -5,7 +5,7 @@ import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.Array;
import io.anuke.mindustry.world.Tile;
import io.anuke.mindustry.world.blocks.types.PowerAcceptor;
import io.anuke.mindustry.world.blocks.types.production.Generator;
import io.anuke.mindustry.world.blocks.types.generation.Generator;
import io.anuke.ucore.core.Timers;
import io.anuke.ucore.graphics.Draw;
import io.anuke.ucore.graphics.Lines;

View File

@ -3,7 +3,7 @@ package io.anuke.mindustry.world.blocks.types.distribution;
import com.badlogic.gdx.graphics.Color;
import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.Tile;
import io.anuke.mindustry.world.blocks.types.production.Generator;
import io.anuke.mindustry.world.blocks.types.generation.Generator;
public class PowerLaser extends Generator{
public Color color = Color.valueOf("e54135");

View File

@ -1,4 +1,4 @@
package io.anuke.mindustry.world.blocks.types.production;
package io.anuke.mindustry.world.blocks.types.generation;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.math.GridPoint2;

View File

@ -1,4 +1,4 @@
package io.anuke.mindustry.world.blocks.types.production;
package io.anuke.mindustry.world.blocks.types.generation;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.utils.Array;

View File

@ -1,4 +1,4 @@
package io.anuke.mindustry.world.blocks.types.production;
package io.anuke.mindustry.world.blocks.types.generation;
import com.badlogic.gdx.utils.Array;
import io.anuke.mindustry.entities.TileEntity;

View File

@ -1,4 +1,4 @@
package io.anuke.mindustry.world.blocks.types.production;
package io.anuke.mindustry.world.blocks.types.generation;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.utils.Array;

View File

@ -0,0 +1,21 @@
package io.anuke.mindustry.world.blocks.types.generation;
import io.anuke.mindustry.world.Tile;
import io.anuke.ucore.core.Timers;
public class SolarGenerator extends Generator {
/**power generated per frame*/
protected float generation = 0.005f;
public SolarGenerator(String name){
super(name);
}
@Override
public void update(Tile tile){
addPower(tile, generation * Timers.delta());
distributeLaserPower(tile);
}
}

View File

@ -1,10 +0,0 @@
package io.anuke.mindustry.world.blocks.types.production;
import io.anuke.mindustry.world.Block;
public class LiquidDrill extends Block {
public LiquidDrill(String name) {
super(name);
}
}

View File

@ -0,0 +1,80 @@
package io.anuke.mindustry.world.blocks.types.production;
import io.anuke.mindustry.entities.TileEntity;
import io.anuke.mindustry.world.Tile;
import io.anuke.mindustry.world.blocks.types.PowerAcceptor;
import io.anuke.mindustry.world.blocks.types.PowerBlock.PowerEntity;
import io.anuke.ucore.core.Effects;
import io.anuke.ucore.core.Timers;
public class PowerDrill extends Drill implements PowerAcceptor {
public float powerCapacity = 10f;
/**power use per frame.*/
public float powerUse = 0.08f;
public PowerDrill(String name){
super(name);
}
@Override
public void update(Tile tile){
PowerEntity entity = tile.entity();
int mines = 0;
float used = Math.min(entity.power * Timers.delta(), powerCapacity-0.1f);
if(entity.power >= used){
entity.power -= used;
}
if(isMultiblock()){
for(Tile other : tile.getLinkedTiles(tempTiles)){
if(isValid(other)){
mines ++;
}
}
}else{
if(isValid(tile)) mines = 1;
}
if(mines > 0 && entity.power > powerUse && entity.timer.get(timerDrill, 60 * time)
&& tile.entity.getItem(result) < capacity){
for(int i = 0; i < mines; i ++) offloadNear(tile, result);
Effects.effect(drillEffect, tile.drawx(), tile.drawy());
}
if(entity.timer.get(timerDump, 30)){
tryDump(tile);
}
}
@Override
public boolean acceptsPower(Tile tile){
PowerEntity entity = tile.entity();
return entity.power + 0.001f <= powerCapacity;
}
@Override
public float addPower(Tile tile, float amount){
PowerEntity entity = tile.entity();
float canAccept = Math.min(powerCapacity - entity.power, amount);
entity.power += canAccept;
return canAccept;
}
@Override
public void setPower(Tile tile, float power){
PowerEntity entity = tile.entity();
entity.power = power;
}
@Override
public TileEntity getEntity() {
return new PowerEntity();
}
}