Somewhat more dangerous neoplasm

This commit is contained in:
Anuken 2022-06-22 03:25:35 -04:00
parent 8ed878b1b3
commit 76735b01f7
5 changed files with 72 additions and 9 deletions

View File

@ -48,9 +48,10 @@ public class Liquids{
heatCapacity = 0.4f;
temperature = 0.54f;
viscosity = 0.85f;
flammability = 0.1f;
flammability = 0f;
capPuddles = false;
hidden = true;
spreadTarget = Liquids.water;
colorFrom = Color.valueOf("f98f4a");
colorTo = Color.valueOf("9e172c");

View File

@ -124,7 +124,7 @@ public class Puddles{
}
return -0.4f * amount;
}
return 0f;
return dest.react(liquid, amount, tile, x, y);
}
/**

View File

@ -1289,14 +1289,16 @@ public class LExecutor{
if(b instanceof OverlayFloor o && tile.overlay() != o) tile.setOverlayNet(o);
}
case floor -> {
if(b instanceof Floor f && tile.floor() != f) tile.setFloorNet(f);
if(b instanceof Floor f && tile.floor() != f && !f.isOverlay()) tile.setFloorNet(f);
}
case block -> {
Team t = exec.team(team);
if(t == null) t = Team.derelict;
if(!b.isFloor()){
Team t = exec.team(team);
if(t == null) t = Team.derelict;
if(tile.block() != b || tile.team() != t){
tile.setNet(b, t, Mathf.clamp(exec.numi(rotation), 0, 3));
if(tile.block() != b || tile.team() != t){
tile.setNet(b, t, Mathf.clamp(exec.numi(rotation), 0, 3));
}
}
}
//building case not allowed

View File

@ -3,16 +3,23 @@ package mindustry.type;
import arc.graphics.*;
import arc.graphics.g2d.*;
import arc.math.*;
import arc.math.geom.*;
import arc.util.*;
import mindustry.entities.*;
import mindustry.gen.*;
import mindustry.graphics.*;
import mindustry.world.*;
import static mindustry.entities.Puddles.*;
/** Liquid that draws cells in its puddle. */
public class CellLiquid extends Liquid{
public Color colorFrom = Color.white.cpy(), colorTo = Color.white.cpy();
public int cells = 8;
public @Nullable Liquid spreadTarget;
public float maxSpread = 0.5f, spreadConversion = 0.5f, spreadDamage = 0.1f;
public CellLiquid(String name, Color color){
super(name, color);
}
@ -21,11 +28,58 @@ public class CellLiquid extends Liquid{
super(name);
}
@Override
public void update(Puddle puddle){
if(spreadTarget != null){
float scaling = Mathf.pow(Mathf.clamp(puddle.amount / maxLiquid), 2f);
for(var point : Geometry.d4c){
Tile tile = puddle.tile.nearby(point);
if(tile != null && tile.build != null && tile.build.liquids != null && tile.build.liquids.get(spreadTarget) > 0){
float amount = Math.min(tile.build.liquids.get(spreadTarget), maxSpread * Time.delta * scaling);
tile.build.liquids.remove(spreadTarget, amount);
Puddles.deposit(tile, this, amount * spreadConversion);
}
}
//damage thing it is on
if(spreadDamage > 0 && puddle.tile.build != null && puddle.tile.build.liquids != null && puddle.tile.build.liquids.get(spreadTarget) > 0){
puddle.tile.build.damage(spreadDamage * Time.delta * scaling);
}
//spread to nearby puddles
for(var point : Geometry.d4){
Tile tile = puddle.tile.nearby(point);
if(tile != null){
var other = Puddles.get(tile);
if(other != null && other.liquid == spreadTarget){
//TODO looks somewhat buggy when outputs are occurring
float amount = Math.min(other.amount, Math.max(maxSpread * Time.delta * scaling, other.amount * 0.25f * scaling));
other.amount -= amount;
puddle.amount += amount;
if(other.amount <= maxLiquid / 3f){
other.remove();
Puddles.deposit(tile, puddle.tile, this, Math.max(amount, maxLiquid / 3f));
}
}
}
}
}
}
@Override
public float react(Liquid other, float amount, Tile tile, float x, float y){
if(other == spreadTarget){
return amount;
}
return 0f;
}
@Override
public void drawPuddle(Puddle puddle){
super.drawPuddle(puddle);
Draw.z(Layer.debris - 0.5f);
float baseLayer = puddle.tile != null && puddle.tile.build != null ? Layer.blockOver : Layer.debris - 0.5f;
int id = puddle.id;
float amount = puddle.amount, x = puddle.x, y = puddle.y;
@ -35,7 +89,7 @@ public class CellLiquid extends Liquid{
rand.setSeed(id);
for(int i = 0; i < cells; i++){
Draw.z(Layer.debris - 0.5f + i/1000f + (id % 100) / 10000f);
Draw.z(baseLayer + i/1000f + (id % 100) / 10000f);
Tmp.v1.trns(rand.random(360f), rand.random(length));
float vx = x + Tmp.v1.x, vy = y + Tmp.v1.y;

View File

@ -10,6 +10,7 @@ import mindustry.entities.*;
import mindustry.gen.*;
import mindustry.graphics.*;
import mindustry.logic.*;
import mindustry.world.*;
import mindustry.world.meta.*;
import static mindustry.entities.Puddles.*;
@ -145,6 +146,11 @@ public class Liquid extends UnlockableContent implements Senseable{
}
//TODO proper API for this (do not use yet!)
public float react(Liquid other, float amount, Tile tile, float x, float y){
return 0f;
}
@Override
public void setStats(){
stats.addPercent(Stat.explosiveness, explosiveness);