Added coal purifier block
This commit is contained in:
@@ -402,7 +402,7 @@ public class Control extends ControlModule{
|
||||
|
||||
if(!GameState.is(State.paused)){
|
||||
Inputs.update();
|
||||
Timers.update(Gdx.graphics.getDeltaTime()*60f);
|
||||
Timers.update();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -35,6 +35,13 @@ public class EffectLoader{
|
||||
Draw.square(e.x, e.y, Vars.tilesize / 2f + e.ifract() * 3f);
|
||||
Draw.reset();
|
||||
});
|
||||
|
||||
Effects.create("purify", 10, e -> {
|
||||
Draw.color(Hue.mix(Color.ROYAL, Color.GRAY, e.ifract()));
|
||||
Draw.thickness(2f);
|
||||
Draw.spikes(e.x, e.y, e.ifract() * 4f, 2, 6);
|
||||
Draw.reset();
|
||||
});
|
||||
|
||||
Effects.create("spark", 10, e -> {
|
||||
Draw.thickness(1f);
|
||||
|
||||
@@ -108,7 +108,7 @@ public abstract class BulletType extends BaseBulletType<Bullet>{
|
||||
Draw.reset();
|
||||
}
|
||||
},
|
||||
plasmaflame = new BulletType(0.8f, 15){
|
||||
plasmaflame = new BulletType(0.8f, 17){
|
||||
{
|
||||
lifetime = 65f;
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ public class Player extends DestructibleEntity{
|
||||
float speed = this.speed;
|
||||
|
||||
if(Vars.debug)
|
||||
speed = 2f;
|
||||
speed *= 3f;
|
||||
|
||||
if(health < maxhealth && Timers.get(this, 50))
|
||||
health ++;
|
||||
@@ -76,10 +76,10 @@ public class Player extends DestructibleEntity{
|
||||
|
||||
vector.limit(speed);
|
||||
|
||||
move(vector.x*delta, vector.y*delta, 4);
|
||||
move(vector.x*Timers.delta(), vector.y*Timers.delta(), 4);
|
||||
|
||||
if(!shooting){
|
||||
direction.add(vector.scl(delta));
|
||||
direction.add(vector.scl(Timers.delta()));
|
||||
direction.limit(speed*6);
|
||||
}else{
|
||||
float angle = Angles.mouseAngle(x, y);
|
||||
|
||||
@@ -13,6 +13,7 @@ import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.blocks.Blocks;
|
||||
import io.anuke.mindustry.world.blocks.ProductionBlocks;
|
||||
import io.anuke.ucore.core.Effects;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
import io.anuke.ucore.entities.Entity;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
|
||||
@@ -67,7 +68,7 @@ public class TileEntity extends Entity{
|
||||
@Override
|
||||
public void update(){
|
||||
if(health != 0 && !tile.block().name().contains("block") &&
|
||||
Mathf.chance(0.009f*delta*(1f-(float)health/maxhealth))){
|
||||
Mathf.chance(0.009f*Timers.delta()*(1f-(float)health/maxhealth))){
|
||||
|
||||
Effects.effect("smoke", x+Mathf.range(4), y+Mathf.range(4));
|
||||
}
|
||||
@@ -87,6 +88,10 @@ public class TileEntity extends Entity{
|
||||
return items.get(item, 0) > 0;
|
||||
}
|
||||
|
||||
public boolean hasItem(Item item, int amount){
|
||||
return items.get(item, 0) >= amount;
|
||||
}
|
||||
|
||||
public void addItem(Item item, int amount){
|
||||
items.put(item, items.get(item, 0) + amount);
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ public class Enemy extends DestructibleEntity{
|
||||
Vector2 vec = Pathfind.find(this);
|
||||
vec.sub(x, y).setLength(speed);
|
||||
|
||||
move(vec.x*delta, vec.y*delta, Vars.tilesize-4);
|
||||
move(vec.x*Timers.delta(), vec.y*Timers.delta(), Vars.tilesize-4);
|
||||
|
||||
if(Timers.get(this, 15)){
|
||||
target = World.findTileTarget(x, y, null, range, false);
|
||||
|
||||
@@ -76,7 +76,7 @@ public class Input{
|
||||
Tile cursor = World.cursorTile();
|
||||
|
||||
//block breaking
|
||||
if(Inputs.buttonDown(Buttons.RIGHT) && World.cursorNear() && cursor.breakable()
|
||||
if(cursor != null && Inputs.buttonDown(Buttons.RIGHT) && World.cursorNear() && cursor.breakable()
|
||||
&& cursor.block() != ProductionBlocks.core){
|
||||
Tile tile = cursor;
|
||||
player.breaktime += Timers.delta();
|
||||
|
||||
@@ -27,8 +27,8 @@ public enum Recipe{
|
||||
sniperturret(defense, WeaponBlocks.sniperturret, stack(Item.iron, 30), stack(Item.steel, 20)),
|
||||
laserturret(defense, WeaponBlocks.laserturret, stack(Item.steel, 20), stack(Item.titanium, 20)),
|
||||
mortarturret(defense, WeaponBlocks.mortarturret, stack(Item.steel, 40), stack(Item.titanium, 30)),
|
||||
waveturret(defense, WeaponBlocks.teslaturret, stack(Item.steel, 20), stack(Item.titanium, 20), stack(Item.dirium, 20)),
|
||||
plasmaturret(defense, WeaponBlocks.plasmaturret, stack(Item.steel, 40), stack(Item.titanium, 30), stack(Item.dirium, 25)),
|
||||
teslaturret(defense, WeaponBlocks.teslaturret, stack(Item.steel, 20), stack(Item.titanium, 30), stack(Item.dirium, 30)),
|
||||
plasmaturret(defense, WeaponBlocks.plasmaturret, stack(Item.steel, 20), stack(Item.titanium, 20), stack(Item.dirium, 30)),
|
||||
|
||||
healturret(defense, WeaponBlocks.repairturret, stack(Item.iron, 50)),
|
||||
megahealturret(defense, WeaponBlocks.megarepairturret, stack(Item.iron, 30), stack(Item.steel, 50)),
|
||||
@@ -40,6 +40,7 @@ public enum Recipe{
|
||||
omnidrill(production, ProductionBlocks.omnidrill, stack(Item.steel, 50), stack(Item.titanium, 50)),
|
||||
smelter(production, ProductionBlocks.smelter, stack(Item.stone, 80), stack(Item.iron, 80)),
|
||||
crucible(production, ProductionBlocks.crucible, stack(Item.titanium, 80), stack(Item.steel, 80)),
|
||||
coalpurifier(production, ProductionBlocks.coalpurifier, stack(Item.steel, 20), stack(Item.iron, 20)),
|
||||
|
||||
conduit(distribution, ProductionBlocks.conduit, stack(Item.steel, 1)),
|
||||
pump(production, ProductionBlocks.pump, stack(Item.steel, 20));
|
||||
|
||||
@@ -62,7 +62,7 @@ public class Generator{
|
||||
floor = Blocks.coal;
|
||||
}
|
||||
|
||||
if(Noise.nnoise(x, y, 5, 1) > 0.2){
|
||||
if(Noise.nnoise(x, y, 9, 1) > 0.254){
|
||||
floor = Blocks.titanium;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import io.anuke.mindustry.Inventory;
|
||||
import io.anuke.mindustry.Renderer;
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.resource.Item;
|
||||
import io.anuke.mindustry.resource.Liquid;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.blocks.types.*;
|
||||
@@ -154,6 +155,20 @@ public class ProductionBlocks{
|
||||
}
|
||||
},
|
||||
|
||||
coalpurifier = new Purifier("coalpurifier"){
|
||||
{
|
||||
formalName = "coal purifier";
|
||||
input = Item.stone;
|
||||
inputLiquid = Liquid.water;
|
||||
output = Item.coal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String description(){
|
||||
return "Takes in stone + water, outputs coal.";
|
||||
}
|
||||
},
|
||||
|
||||
stonedrill = new Drill("stonedrill"){{
|
||||
resource = Blocks.stone;
|
||||
result = Item.stone;
|
||||
|
||||
@@ -141,7 +141,7 @@ public class WeaponBlocks{
|
||||
reload = 20f;
|
||||
bullet = BulletType.shell;
|
||||
ammo = Item.stone;
|
||||
health = 1100;
|
||||
health = 140;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -150,7 +150,7 @@ public class WeaponBlocks{
|
||||
Angles.translation(entity.rotation, 4);
|
||||
|
||||
new TeslaOrb(tile.worldx() + Angles.x(), tile.worldy() + Angles.y(),
|
||||
70, (int)(10*Vars.multiplier)).add();
|
||||
70, (int)(8*Vars.multiplier)).add();
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ import io.anuke.ucore.core.Draw;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
|
||||
public class Conduit extends Block{
|
||||
protected float capacity = 10f;
|
||||
protected float liquidCapacity = 10f;
|
||||
protected float flowfactor = 4f;
|
||||
|
||||
public Conduit(String name) {
|
||||
@@ -26,9 +26,9 @@ public class Conduit extends Block{
|
||||
ConduitEntity entity = tile.entity();
|
||||
|
||||
Draw.rect(name() + "bottom", tile.worldx(), tile.worldy(), tile.rotation * 90);
|
||||
if(entity.liquid != null && entity.amount > 0.01f){
|
||||
if(entity.liquid != null && entity.liquidAmount > 0.01f){
|
||||
Draw.color(entity.liquid.color);
|
||||
Draw.alpha(entity.amount / capacity);
|
||||
Draw.alpha(entity.liquidAmount / liquidCapacity);
|
||||
Draw.rect("conduitliquid", tile.worldx(), tile.worldy(), tile.rotation * 90);
|
||||
Draw.color();
|
||||
}
|
||||
@@ -45,7 +45,7 @@ public class Conduit extends Block{
|
||||
public void update(Tile tile){
|
||||
ConduitEntity entity = tile.entity();
|
||||
|
||||
if(entity.amount > 0.01f && Timers.get(entity, "flow", 3)){
|
||||
if(entity.liquidAmount > 0.01f && Timers.get(entity, "flow", 3)){
|
||||
tryMoveLiquid(tile, tile.getNearby()[tile.rotation]);
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ public class Conduit extends Block{
|
||||
public void tryDumpLiquid(Tile tile){
|
||||
ConduitEntity entity = tile.entity();
|
||||
|
||||
if(entity.amount > 0.01f){
|
||||
if(entity.liquidAmount > 0.01f){
|
||||
tryMoveLiquid(tile, tile.getNearby()[tile.dump]);
|
||||
tile.dump ++;
|
||||
tile.dump %= 4;
|
||||
@@ -66,47 +66,47 @@ public class Conduit extends Block{
|
||||
|
||||
Liquid liquid = entity.liquid;
|
||||
|
||||
if(next != null && next.block() instanceof Conduit && entity.amount > 0.01f){
|
||||
if(next != null && next.block() instanceof Conduit && entity.liquidAmount > 0.01f){
|
||||
Conduit other = (Conduit)next.block();
|
||||
ConduitEntity otherentity = next.entity();
|
||||
|
||||
float flow = Math.min(other.capacity - otherentity.amount - 0.001f, Math.min(entity.amount/flowfactor, entity.amount));
|
||||
float flow = Math.min(other.liquidCapacity - otherentity.liquidAmount - 0.001f, Math.min(entity.liquidAmount/flowfactor, entity.liquidAmount));
|
||||
|
||||
if(flow <= 0f || entity.amount < flow) return;
|
||||
if(flow <= 0f || entity.liquidAmount < flow) return;
|
||||
|
||||
if(other.accept(next, tile, liquid, flow)){
|
||||
if(other.acceptLiquid(next, tile, liquid, flow)){
|
||||
other.addLiquid(next, tile, liquid, flow);
|
||||
entity.amount -= flow;
|
||||
entity.liquidAmount -= flow;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean accept(Tile tile, Tile source, Liquid liquid, float amount){
|
||||
public boolean acceptLiquid(Tile tile, Tile source, Liquid liquid, float amount){
|
||||
ConduitEntity entity = tile.entity();
|
||||
|
||||
return entity.amount + amount < capacity && (entity.liquid == liquid || entity.amount <= 0.01f);
|
||||
return entity.liquidAmount + amount < liquidCapacity && (entity.liquid == liquid || entity.liquidAmount <= 0.01f);
|
||||
}
|
||||
|
||||
public void addLiquid(Tile tile, Tile source, Liquid liquid, float amount){
|
||||
ConduitEntity entity = tile.entity();
|
||||
entity.liquid = liquid;
|
||||
entity.amount += amount;
|
||||
entity.liquidAmount += amount;
|
||||
}
|
||||
|
||||
static class ConduitEntity extends TileEntity{
|
||||
Liquid liquid;
|
||||
float amount;
|
||||
float liquidAmount;
|
||||
|
||||
@Override
|
||||
public void write(DataOutputStream stream) throws IOException{
|
||||
stream.writeByte(liquid.ordinal());
|
||||
stream.writeByte((byte)(amount));
|
||||
stream.writeByte((byte)(liquidAmount));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(DataInputStream stream) throws IOException{
|
||||
liquid = Liquid.values()[stream.readByte()];
|
||||
amount = stream.readByte();
|
||||
liquidAmount = stream.readByte();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ public class Drill extends Block{
|
||||
Effects.effect("spark", tile.worldx(), tile.worldy());
|
||||
}
|
||||
|
||||
if(Timers.get(tile.hashCode() + "dump", 30)){
|
||||
if(Timers.get(tile.hashCode(), "dump", 30)){
|
||||
tryDump(tile);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ public class Pump extends Conduit{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean accept(Tile tile, Tile source, Liquid liquid, float amount){
|
||||
public boolean acceptLiquid(Tile tile, Tile source, Liquid liquid, float amount){
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -27,9 +27,9 @@ public class Pump extends Conduit{
|
||||
public void update(Tile tile){
|
||||
ConduitEntity entity = tile.entity();
|
||||
|
||||
if(Timers.get(tile, "pump", 8) && entity.amount < capacity){
|
||||
if(Timers.get(tile, "pump", 8) && entity.liquidAmount < liquidCapacity){
|
||||
entity.liquid = Liquid.water;
|
||||
entity.amount += pumpspeed;
|
||||
entity.liquidAmount += pumpspeed;
|
||||
}
|
||||
|
||||
if(Timers.get(tile, "dump", 1)){
|
||||
|
||||
77
core/src/io/anuke/mindustry/world/blocks/types/Purifier.java
Normal file
77
core/src/io/anuke/mindustry/world/blocks/types/Purifier.java
Normal file
@@ -0,0 +1,77 @@
|
||||
package io.anuke.mindustry.world.blocks.types;
|
||||
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
|
||||
import io.anuke.mindustry.Renderer;
|
||||
import io.anuke.mindustry.entities.TileEntity;
|
||||
import io.anuke.mindustry.resource.Item;
|
||||
import io.anuke.mindustry.resource.Liquid;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.ucore.core.Draw;
|
||||
import io.anuke.ucore.core.Effects;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
|
||||
public class Purifier extends Conduit{
|
||||
public Item input = null;
|
||||
public int inputAmount = 5;
|
||||
public Liquid inputLiquid = null;
|
||||
public float liquidAmount = 19.99f;
|
||||
public Item output = null;
|
||||
public int itemCapacity = 100;
|
||||
public int purifyTime = 90;
|
||||
|
||||
public Purifier(String name) {
|
||||
super(name);
|
||||
update = true;
|
||||
rotate = false;
|
||||
liquidCapacity = 20f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Tile tile){
|
||||
ConduitEntity entity = tile.entity();
|
||||
Draw.rect(name(), tile.worldx(), tile.worldy());
|
||||
|
||||
Draw.color(Color.ROYAL);
|
||||
Draw.alpha(entity.liquidAmount / liquidCapacity);
|
||||
Draw.rect("blank", tile.worldx(), tile.worldy(), 2, 2);
|
||||
Draw.color();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Tile tile){
|
||||
ConduitEntity entity = tile.entity();
|
||||
|
||||
if(Timers.get(tile, "purify", purifyTime) && entity.liquidAmount >= liquidAmount &&
|
||||
entity.hasItem(input, inputAmount)){
|
||||
|
||||
entity.removeItem(input, inputAmount);
|
||||
entity.liquidAmount -= liquidAmount;
|
||||
offloadNear(tile, output);
|
||||
Effects.effect("purify", tile.worldx(), tile.worldy());
|
||||
}
|
||||
|
||||
if(Timers.get(tile.hashCode(), "dump", 30)){
|
||||
tryDump(tile, -1, output);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawPixelOverlay(Tile tile){
|
||||
float fract = (float)tile.entity.items.get(input, 0) / itemCapacity;
|
||||
|
||||
Renderer.drawBar(Color.GREEN, tile.worldx(), tile.worldy() + 13, fract);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptLiquid(Tile tile, Tile source, Liquid liquid, float amount){
|
||||
return super.acceptLiquid(tile, source, liquid, amount) && liquid == inputLiquid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean accept(Item item, Tile tile, Tile source){
|
||||
TileEntity entity = tile.entity();
|
||||
return item == input && entity.items.get(item, 0) < itemCapacity;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user