Added block rubble, more liquid interaction
This commit is contained in:
@@ -8,6 +8,7 @@ import io.anuke.mindustry.content.StatusEffects;
|
||||
import io.anuke.mindustry.content.fx.EnvironmentFx;
|
||||
import io.anuke.mindustry.entities.SerializableEntity;
|
||||
import io.anuke.mindustry.entities.TileEntity;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.ucore.core.Effects;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
@@ -27,6 +28,7 @@ public class Fire extends TimedEntity implements SerializableEntity, Poolable{
|
||||
|
||||
private int loadedPosition = -1;
|
||||
private Tile tile;
|
||||
private Block block;
|
||||
private float baseFlammability = -1, puddleFlammability;
|
||||
|
||||
/**Start a fire on the tile. If there already is a file there, refreshes its lifetime..*/
|
||||
@@ -67,8 +69,9 @@ public class Fire extends TimedEntity implements SerializableEntity, Poolable{
|
||||
time += Timers.delta()*8;
|
||||
}
|
||||
|
||||
if (baseFlammability < 0){
|
||||
if (baseFlammability < 0 || block != tile.block()){
|
||||
baseFlammability = tile.block().getFlammability(tile);
|
||||
block = tile.block();
|
||||
}
|
||||
|
||||
if(damage) {
|
||||
|
||||
@@ -27,7 +27,7 @@ import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import static io.anuke.mindustry.Vars.groundItemGroup;
|
||||
import static io.anuke.mindustry.Vars.puddleGroup;
|
||||
import static io.anuke.mindustry.Vars.world;
|
||||
|
||||
public class Puddle extends Entity implements SerializableEntity, Poolable{
|
||||
@@ -60,6 +60,16 @@ public class Puddle extends Entity implements SerializableEntity, Poolable{
|
||||
}
|
||||
|
||||
private static void deposit(Tile tile, Tile source, Liquid liquid, float amount, int generation){
|
||||
if(tile.floor().liquid){
|
||||
reactPuddle(tile.floor().liquidDrop, liquid, amount, tile, tile.worldx(), tile.worldy());
|
||||
|
||||
if(generation == 0 && Timers.get(tile, "ripple", 50)){
|
||||
Effects.effect(BlockFx.ripple, tile.floor().liquidDrop.color,
|
||||
(tile.worldx() + source.worldx())/2f, (tile.worldy() + source.worldy())/2f);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
Puddle p = map.get(tile.packedPosition());
|
||||
if(p == null){
|
||||
Puddle puddle = Pools.obtain(Puddle.class);
|
||||
@@ -76,28 +86,29 @@ public class Puddle extends Entity implements SerializableEntity, Poolable{
|
||||
Effects.effect(BlockFx.ripple, p.liquid.color, (tile.worldx() + source.worldx())/2f, (tile.worldy() + source.worldy())/2f);
|
||||
}
|
||||
}else{
|
||||
reactPuddle(p, liquid, amount);
|
||||
p.amount -= reactPuddle(p.liquid, liquid, amount, p.tile, p.x, p.y);
|
||||
}
|
||||
}
|
||||
|
||||
private static void reactPuddle(Puddle p, Liquid liquid, float amount){
|
||||
if((p.liquid.flammability > 0.3f && liquid.temperature > 0.7f) ||
|
||||
(liquid.flammability > 0.3f && p.liquid.temperature > 0.7f)){ //flammable liquid + hot liquid
|
||||
Fire.create(p.tile);
|
||||
private static float reactPuddle(Liquid pliquid, Liquid liquid, float amount, Tile tile, float x, float y){
|
||||
if((pliquid.flammability > 0.3f && liquid.temperature > 0.7f) ||
|
||||
(liquid.flammability > 0.3f && pliquid.temperature > 0.7f)){ //flammable liquid + hot liquid
|
||||
Fire.create(tile);
|
||||
if(Mathf.chance(0.006 * amount)){
|
||||
new Fireball(p.x, p.y, p.liquid.flameColor, Mathf.random(360f)).add();
|
||||
new Fireball(x, y, pliquid.flameColor, Mathf.random(360f)).add();
|
||||
}
|
||||
}else if(p.liquid.temperature > 0.7f && liquid.temperature < 0.55f){ //cold liquid poured onto hot puddle
|
||||
}else if(pliquid.temperature > 0.7f && liquid.temperature < 0.55f){ //cold liquid poured onto hot puddle
|
||||
if(Mathf.chance(0.5f * amount)){
|
||||
Effects.effect(EnvironmentFx.steam, p.x, p.y);
|
||||
Effects.effect(EnvironmentFx.steam, x, y);
|
||||
}
|
||||
p.amount -= 0.1f * amount;
|
||||
}else if(liquid.temperature > 0.7f && p.liquid.temperature < 0.55f){ //hot liquid poured onto cold puddle
|
||||
return - 0.1f * amount;
|
||||
}else if(liquid.temperature > 0.7f && pliquid.temperature < 0.55f){ //hot liquid poured onto cold puddle
|
||||
if(Mathf.chance(0.8f * amount)){
|
||||
Effects.effect(EnvironmentFx.steam, p.x, p.y);
|
||||
Effects.effect(EnvironmentFx.steam, x, y);
|
||||
}
|
||||
p.amount -= 0.4f * amount;
|
||||
return - 0.4f * amount;
|
||||
}
|
||||
return 0f;
|
||||
}
|
||||
|
||||
/**Deserialization use only!*/
|
||||
@@ -209,6 +220,6 @@ public class Puddle extends Entity implements SerializableEntity, Poolable{
|
||||
|
||||
@Override
|
||||
public Puddle add() {
|
||||
return add(groundItemGroup);
|
||||
return add(puddleGroup);
|
||||
}
|
||||
}
|
||||
|
||||
35
core/src/io/anuke/mindustry/entities/effect/Rubble.java
Normal file
35
core/src/io/anuke/mindustry/entities/effect/Rubble.java
Normal file
@@ -0,0 +1,35 @@
|
||||
package io.anuke.mindustry.entities.effect;
|
||||
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import io.anuke.ucore.entities.TimedEntity;
|
||||
import io.anuke.ucore.graphics.Draw;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
|
||||
import static io.anuke.mindustry.Vars.groundEffectGroup;
|
||||
|
||||
public class Rubble extends TimedEntity{
|
||||
private static final Color color = Color.valueOf("52504e");
|
||||
private int size;
|
||||
|
||||
public static void create(float x, float y, int size){
|
||||
Rubble rubble = new Rubble();
|
||||
rubble.size = size;
|
||||
rubble.set(x + Mathf.range(1), y + Mathf.range(1)).add();
|
||||
}
|
||||
|
||||
private Rubble(){
|
||||
lifetime = 7000f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(){
|
||||
Draw.color(color.r, color.g, color.b, 1f-Mathf.curve(fin(), 0.98f));
|
||||
Draw.rect("rubble-" + size + "-" + Mathf.randomSeed(id, 0, 1), x, y, Mathf.randomSeed(id, 0, 4) * 90);
|
||||
Draw.color();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Rubble add() {
|
||||
return add(groundEffectGroup);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user