Groundwater pump animation / water recolor

This commit is contained in:
Anuken 2018-03-29 23:38:16 -04:00
parent e78579581f
commit 532eeb7ab0
12 changed files with 293 additions and 264 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 313 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 207 B

After

Width:  |  Height:  |  Size: 192 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 256 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 338 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 484 B

After

Width:  |  Height:  |  Size: 298 B

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 99 KiB

After

Width:  |  Height:  |  Size: 98 KiB

View File

@ -1,7 +1,7 @@
#Autogenerated file. Do not modify.
#Thu Mar 29 22:50:34 EDT 2018
#Thu Mar 29 23:33:54 EDT 2018
version=release
androidBuildCode=727
androidBuildCode=729
name=Mindustry
code=3.4
build=custom build

View File

@ -8,7 +8,7 @@ public class Liquids {
public static final Liquid
none = new Liquid("none", Color.CLEAR),
water = new Liquid("water", Color.ROYAL) {
water = new Liquid("water", Color.valueOf("486acd")) {
{
heatCapacity = 0.4f;
}
@ -26,7 +26,7 @@ public class Liquids {
viscosity = 0.8f;
}
},
oil = new Liquid("oil", Color.valueOf("292929")) {
oil = new Liquid("oil", Color.valueOf("313131")) {
{
viscosity = 0.7f;
flammability = 0.6f;

View File

@ -71,6 +71,7 @@ public class ProductionBlocks {
pumpAmount = 0.1f;
size = 2;
liquidCapacity = 30f;
rotateSpeed = 1.4f;
}},
oilextractor = new Fracker("oilextractor") {{

View File

@ -113,7 +113,7 @@ public class Drill extends Block{
float powerUsed = Math.min(powerCapacity, powerUse * Timers.delta());
float liquidUsed = Math.min(liquidCapacity, liquidUse * Timers.delta());
if(entity.inventory.totalItems() < itemCapacity &&
if(entity.inventory.totalItems() < itemCapacity && toAdd.size > 0 &&
(!hasPower || entity.power.amount >= powerUsed) &&
(!liquidRequired || entity.liquid.amount >= liquidUsed)){

View File

@ -1,5 +1,6 @@
package io.anuke.mindustry.world.blocks.types.production;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.utils.Array;
import io.anuke.mindustry.content.Liquids;
import io.anuke.mindustry.entities.TileEntity;
@ -9,6 +10,7 @@ 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.util.Mathf;
/**Pump that makes liquid from solids and takes in power. Only works on solid floor blocks.*/
@ -18,6 +20,7 @@ public class SolidPump extends Pump {
protected float powerUse = 0.1f;
protected Effect updateEffect = Fx.none;
protected float updateEffectChance = 0.02f;
protected float rotateSpeed = 1f;
protected final Array<Tile> drawTiles = new Array<>();
@ -27,6 +30,24 @@ public class SolidPump extends Pump {
liquidRegion = name + "-liquid";
}
@Override
public void draw(Tile tile) {
SolidPumpEntity entity = tile.entity();
Draw.rect(name, tile.drawx(), tile.drawy());
Draw.color(tile.entity.liquid.liquid.color);
Draw.alpha(tile.entity.liquid.amount / liquidCapacity);
Draw.rect(liquidRegion, tile.drawx(), tile.drawy());
Draw.color();
Draw.rect(name + "-rotator", tile.drawx(), tile.drawy(), entity.pumpTime * rotateSpeed);
Draw.rect(name + "-top", tile.drawx(), tile.drawy());
}
@Override
public TextureRegion[] getIcon() {
return new TextureRegion[]{Draw.region(name), Draw.region(name + "-rotator"), Draw.region(name + "-top")};
}
@Override
public void update(Tile tile){
SolidPumpEntity entity = tile.entity();
@ -45,7 +66,7 @@ public class SolidPump extends Pump {
if(isValid(tile)) fraction = 1f;
}
if(tile.entity.power.amount >= used){
if(tile.entity.power.amount >= used && tile.entity.liquid.amount < liquidCapacity - 0.001f){
float maxPump = Math.min(liquidCapacity - tile.entity.liquid.amount, pumpAmount * Timers.delta() * fraction);
tile.entity.liquid.liquid = result;
tile.entity.liquid.amount += maxPump;