Added incinerator

This commit is contained in:
Anuken
2018-04-08 12:23:39 -04:00
parent 6db1175c95
commit 21fe0f9246
7 changed files with 224 additions and 126 deletions

View File

@@ -67,6 +67,7 @@ public class Recipes {
new Recipe(crafting, CraftingBlocks.pulverizer, stack(Items.steel, 10), stack(Items.iron, 10)),
new Recipe(crafting, CraftingBlocks.stoneFormer, stack(Items.steel, 10), stack(Items.iron, 10)),
new Recipe(crafting, CraftingBlocks.melter, stack(Items.steel, 30), stack(Items.titanium, 15)),
new Recipe(crafting, CraftingBlocks.incinerator, stack(Items.steel, 60), stack(Items.iron, 60)),
new Recipe(crafting, CraftingBlocks.weaponFactory, stack(Items.steel, 60), stack(Items.iron, 60)).setDesktop(),
//new Recipe(production, ProductionBlocks.stonedrill, stack(Item.stone, 12)),

View File

@@ -193,5 +193,9 @@ public class CraftingBlocks {
weaponFactory = new WeaponFactory("weaponfactory") {{
size = 2;
health = 250;
}},
incinerator = new Incinerator("incinerator") {{
health = 90;
}};
}

View File

@@ -0,0 +1,86 @@
package io.anuke.mindustry.world.blocks.types.production;
import com.badlogic.gdx.graphics.Color;
import io.anuke.mindustry.content.fx.BlockFx;
import io.anuke.mindustry.entities.TileEntity;
import io.anuke.mindustry.resource.Item;
import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.Tile;
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.graphics.Fill;
import io.anuke.ucore.util.Mathf;
public class Incinerator extends Block {
protected float powerUse = 0.07f;
protected Effect effect = BlockFx.fuelburn;
protected Color flameColor = Color.valueOf("ffad9d");
public Incinerator(String name) {
super(name);
hasPower = true;
hasInventory = false;
update = true;
solid = true;
}
@Override
public void update(Tile tile) {
IncineratorEntity entity = tile.entity();
float used = Math.min(powerCapacity, powerUse * Timers.delta());
if(entity.power.amount >= used){
entity.power.amount -= used;
entity.heat = Mathf.lerpDelta(entity.heat, 1f, 0.04f);
}else{
entity.heat = Mathf.lerpDelta(entity.heat, 0f, 0.02f);
}
}
@Override
public void draw(Tile tile) {
super.draw(tile);
IncineratorEntity entity = tile.entity();
if(entity.heat > 0f){
float g = 0.3f;
float r = 0.06f;
float cr = Mathf.random(0.05f);
Draw.alpha(((1f-g) + Mathf.absin(Timers.time(), 8f, g) + Mathf.random(r) - r) * entity.heat);
Draw.tint(flameColor);
Fill.circle(tile.drawx(), tile.drawy(), 2f);
Draw.color(1f, 1f, 1f, entity.heat);
Fill.circle(tile.drawx(), tile.drawy(), 1f);
Draw.color();
}
}
@Override
public void handleItem(Item item, Tile tile, Tile source) {
if(Mathf.chance(0.3)){
Effects.effect(effect, tile.drawx(), tile.drawy());
}
}
@Override
public boolean acceptItem(Item item, Tile tile, Tile source) {
IncineratorEntity entity = tile.entity();
return entity.heat > 0.5f;
}
@Override
public TileEntity getEntity() {
return new IncineratorEntity();
}
public static class IncineratorEntity extends TileEntity{
public float heat;
}
}